Closed
Description
TypeScript Version: 3.0.0-dev.20180607
Search Terms:
conditional inference empty infer extends mapped
Code
type Combine<C, Prop extends string> = {
[Key in keyof C]: (
C[Key] extends { [X in Prop]: infer Just } ? Just :
C[Key] extends { [X in Prop]?: infer Maybe } ? (Maybe | undefined) :
undefined
)
}
type Test = {
x: {
test?: boolean,
},
y: {
test?: boolean,
},
}
type Combined = Combine<Test, 'test'>
let combined: Combined
// Type '{}' is not assignable to type 'boolean'.
let flag: boolean = combined.x
Expected behavior:
Should compile, as the type of combined.x
should be boolean.
Actual behavior:
In 2.9+, fails with "Type '{}' is not assignable to type 'boolean'."
In 2.8.1, compiles without error.
Playground Link:
Related Issues: