type Foo<BooleanParameter extends boolean> = { boolean_parameter: BooleanParameter } & (BooleanParameter extends true ? { first_parameter: number } : { second_parameter: string })
const bar = <BooleanParameter extends boolean>(foo: Foo<BooleanParameter>) => {
if (foo.boolean_parameter) {
//foo.first_parameter Property 'first_parameter' does not exist on type 'Foo<BooleanParameter>'.
} else {
//foo.second_parameter Property 'second_parameter' does not exist on type 'Foo<BooleanParameter>'.
}
}
What is the reason behind the inability to access first_parameter
and second_parameter
when boolean_parameter
is generic?