microsoft / microsoft/TypeScript
Conditional type doesn't narrow primitive types
Aperta
@weswigham ci sta già lavorando.
Dal 8/1/2019.
In Discussion
Suggestion
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
TypeScript Version: 3.1.0-dev.201xxxxx
Search Terms:
Code
type OnlyNumber<T extends number> = T
type ToNumber<T extends number | string> =
T extends string ? undefined : OnlyNumber<T>
Expected behavior:
No errors
Actual behavior:
Error:
index.ts:37:47 - error TS2344: Type 'T' does not satisfy the constraint 'number'.
Type 'string | number' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
37 T extends string ? undefined : OnlyNumber<T>
Related Issues:
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.