Closed

Description
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
class Test<T> {
makePromise<V>(value: T extends Promise<V> ? V : never): Promise<V> {
return Promise.resolve(value);
}
}
const test = new Test<Promise<number>>();
test.makePromise(5) // throws a compile-time error starting with [email protected]
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)
Related Issues:
none found