TypeScript/tests/cases/compiler/substitutionTypeNoMergeOfAssignableType.ts
Wesley Wigham 7a3e68fc5c
Only return the substitute in substitution instantiation when assignability fails (rather than subtype) (#31027)
* Only return the substitute in substitution instantiation when assignability fails (rather than subtype)

* Add test from issue
2019-04-19 16:02:11 -07:00

25 lines
526 B
TypeScript

interface Entry {
comment?: string;
}
interface Entity {
fields: {[key: string]: Entry};
}
type Fields<E extends Entity> = {
[P in keyof E["fields"]]: E["fields"][P]
};
type Nodes<T = any> = {
[P in keyof T]: T[P] extends Entity
? Fields<T[P]>
: T[P]
};
function makeEntityStore<T extends Record<string, Entity>>(config: T): Nodes<T> {
return {} as Nodes<T>
}
const myTest = makeEntityStore({ test: { fields: { id: {} } } });
myTest.test