microsoft / microsoft/TypeScript

PropertyDecorator factory with generic type is not so intelligent

Aperta
#31,917 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@rbuckton ci sta già lavorando.

Dal 26/6/2019.

Needs Investigation
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

TypeScript Version: 3.5.1

Search Terms:

Code

export const Reactive = <T, K extends keyof T>(
  setter?: (this: T, value?: T[K]) => boolean | void,
) => (target: T, propertyKey: K) => {
  // do something
};

class Test {
  @Reactive(function(name) {
    // error
  })
  name: string
}

Expected behavior:
Automatically detect this should be type of Test, and name should be type of string

Actual behavior:
Argument of type '"name"' is not assignable to parameter of type 'never'.

Playground Link:
Playground Link

Related Issues:

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.