Closed
Description
TypeScript Version: 2.7.0-dev.20171026
Minimal example:
interface Observable<T> {peek(): T}
declare function obs<T>(val: T): Observable<T>
const t: Observable<'A'> = obs('A')
Expected behavior:
Compilation without errors.
Actual behavior:
src/test.ts(3,7): error TS2322: Type 'Observable<string>' is not assignable to type 'Observable<"A">'.
Type 'string' is not assignable to type '"A"'.
This error goes away if the interface has no methods or function signature:
interface Observable<T> {}
Alternately, you can redundantly specify the type of the argument to obs()
:
const t: Observable<'A'> = obs('A' as 'A')