-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Description
TypeScript Version: Version 3.1.0-dev.20180823
Search Terms: Different types with same name
Code
export type Constructor<T> = new (...args: any[]) => T
export type MappedResult<T> =
T extends Boolean ? boolean :
T extends Number ? number :
T extends String ? string :
T
interface X {
decode<C extends Constructor<any>>(ctor: C): MappedResult<C extends Constructor<infer T> ? T : never>
}
class Y implements X {
decode<C extends Constructor<any>>(ctor: C): MappedResult<C extends Constructor<infer T> ? T : never> {
throw new Error()
}
}
Expected behavior: It should compile without any error. Everything is in the same namespace, so it should be the same type.
Actual behavior: The quoted error below is emitted.
$ tsc tsc-test.ts
tsc-test.ts:14:5 - error TS2416: Property 'decode' in type 'Y' is not assignable to the same property in base type 'X'.
Type '<C extends import("tsc-test").Constructor<any>>(ctor: C) => import("tsc-test").MappedResult<C extends import("tsc-test").Constructor<infer T> ? T : never>' is not assignable to type '<C extends import("tsc-test").Constructor<any>>(ctor: C) => import("tsc-test").MappedResult<C extends import("tsc-test").Constructor<infer T> ? T : never>'. Two different types with this name exist, but they are unrelated.
Type 'import("tsc-test").MappedResult<C extends import("tsc-test").Constructor<infer T> ? T : never>' is not assignable to type 'import("tsc-test").MappedResult<C extends import("tsc-test").Constructor<infer T> ? T : never>'. Two different types with this name exist, but they are unrelated.
14 decode<C extends Constructor<any>>(ctor: C): MappedResult<C extends Constructor<infer T> ? T : never> {
~~~~~~
Playground Link: Here
Related Issues: None I can find
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript