Skip to content

Instantly share code, notes, and snippets.

@nabeix
Last active October 16, 2017 10:08
Show Gist options
  • Save nabeix/7a0fdce6c560be0e7ab1408a7f7fb94c to your computer and use it in GitHub Desktop.
Save nabeix/7a0fdce6c560be0e7ab1408a7f7fb94c to your computer and use it in GitHub Desktop.
TypeScript Generics ignore extend types
abstract class A<T1, T2> {
}
class B extends A<string, number> {
}
interface AClassStatic<T1, T2, T3 extends A<T1, T2>> {
new (): T3
}
function getFromAClass<T1, T2, T3 extends A<T1, T2>>(aClass: AClassStatic<T1, T2, T3>): { t1: T1, t2: T2 } {
return <any>{}; // dummy
}
const param = getFromAClass(B); // expect: {t1: string, t2: number}, actual: {t1: {}, t2: {}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment