Bug Report
π Search Terms
- union type
- missing properties
π Version & Regression Information
Typescript version: v4.9.0-dev.20220921
β― Playground Link
Playground link with relevant code
π» Code
type A = {
propA: number;
propB: number;
propC: number;
propD: number;
}
type B = {
propA: number;
propB: string;
propC: undefined;
}
type C = A | B;
let test: C;
type TPropA = typeof test.propA; // -> type TPropA = number;
type TPropB = typeof test.propB; // -> type TPropB = string | number;
type TPropC = typeof test.propC; // -> type TPropC = number | undefined;
// TS2551: Property 'propD' does not exist on type 'C'.
type TPropD = typeof test.propD; // -> expected: type TPropD = number | undefined;
π Actual behavior
When defining union types of interfaces, properties will be missing on the resulting type if they are missing on one of the original types.
π Expected behavior
The resulting type should contain the said property, either as an optional or as a union with undefined (-> see TPropC)
Bug Report
π Search Terms
π Version & Regression Information
Typescript version: v4.9.0-dev.20220921
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
When defining union types of interfaces, properties will be missing on the resulting type if they are missing on one of the original types.
π Expected behavior
The resulting type should contain the said property, either as an optional or as a union with undefined (-> see TPropC)