Regression: TypeScript no longer infers primitive types as widened types in conditional types. #29825
Labels
Working as Intended
The behavior described is the intended behavior; this is not a bug
TypeScript Version: 3.1.0-dev.20180918 <= affected version <= 3.4.0-dev.20190208
Search Terms:
Issues, PRs + Google: infer[ence] literal type
Searched the changelog of TS 3.1 to find out whether this might be an intended change.
Code
Obs:
infer V
rather than<V>
works across all versions in the above example.Expected behavior:
In the above example V should be inferred to a primitive type (e.g. number in the given example but also applies to other primitive types)
Actual behavior:
Starting with [email protected], TypeScript infers the value in the above type to a literal type. The last working package is [email protected] (including 2.x and 3.x)
Playground Link:
https://www.typescriptlang.org/play/#src=class%20Test%3CT%3E%20%7B%0D%0A%20%20makePromise%3CV%3E(value%3A%20T%20extends%20Promise%3CV%3E%20%3F%20V%20%3A%20never)%3A%20Promise%3CV%3E%20%7B%0D%0A%20%20%20%20return%20Promise.resolve(value)%3B%0D%0A%20%20%7D%0D%0A%7D%0D%0A%0D%0Aconst%20test%20%3D%20new%20Test%3CPromise%3Cnumber%3E%3E()%3B%0D%0Atest.makePromise(5)%0D%0A
Related Issues:
none found
The text was updated successfully, but these errors were encountered: