Closed
Description
TypeScript Version: 3.2.0-dev.20180927
Code
export interface DocumentRef<T extends string> {
id: number;
type: T;
}
export type PartialDocument<R extends DocumentRef<R['type']> = R> = {
[P in keyof R]?: R[P];
} & DocumentRef<R['type']>;
Expected behavior:
const test: PartialDocument = {id: 1, type: 1} // Error: Type 'number' is not assignable to type 'string'
Actual behavior:
const test: PartialDocument = {id: 1, type: 1} // No error, type of test.type is always 'unknown'