TypeScript/tests/cases/compiler/indexedAccessTypeConstraints.ts
Anders Hejlsberg 3357aae2d8 Update tests
2017-11-16 10:58:12 -08:00

37 lines
631 B
TypeScript

// @strict: true
// Repro from #14557
interface IData<T> {
content: T;
}
type Data<T> = {
get: <K extends keyof T>(prop: K) => T[K];
};
class Parent<M> {
constructor(private data: Data<M>) {}
getData(): Data<M> {
return this.data;
}
}
export class Foo<C> extends Parent<IData<C>> {
getContent(): C {
return this.getData().get('content');
}
}
export class Bar<C, T extends IData<C>> extends Parent<T> {
getContent(): C {
return this.getData().get('content');
}
}
// Repro from #14557
function foo<C, T extends { content: C }>(x: C, y: T['content']) {
x = y;
}