mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 12:32:42 -05:00
Fixed intersections of primitive unions with exactOptionalPropertyTypes when mixing undefinedType with missingType (#58186)
This commit is contained in:
committed by
GitHub
parent
cde45aa21c
commit
f374ec5fbe
@@ -17835,10 +17835,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
|
||||
// Check that the given type has a match in every union. A given type is matched by
|
||||
// an identical type, and a literal type is additionally matched by its corresponding
|
||||
// primitive type.
|
||||
// primitive type, and missingType is matched by undefinedType (and vice versa).
|
||||
function eachUnionContains(unionTypes: UnionType[], type: Type) {
|
||||
for (const u of unionTypes) {
|
||||
if (!containsType(u.types, type)) {
|
||||
if (type === missingType) {
|
||||
return containsType(u.types, undefinedType);
|
||||
}
|
||||
if (type === undefinedType) {
|
||||
return containsType(u.types, missingType);
|
||||
}
|
||||
const primitive = type.flags & TypeFlags.StringLiteral ? stringType :
|
||||
type.flags & (TypeFlags.Enum | TypeFlags.NumberLiteral) ? numberType :
|
||||
type.flags & TypeFlags.BigIntLiteral ? bigintType :
|
||||
@@ -17918,6 +17924,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
for (const t of u.types) {
|
||||
if (insertType(checked, t)) {
|
||||
if (eachUnionContains(unionTypes, t)) {
|
||||
// undefinedType/missingType should always come sorted first so we leverage that here
|
||||
if (t === undefinedType && result.length && result[0] === missingType) {
|
||||
continue;
|
||||
}
|
||||
if (t === missingType && result.length && result[0] === undefinedType) {
|
||||
result[0] = missingType;
|
||||
continue;
|
||||
}
|
||||
insertType(result, t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
//// [tests/cases/compiler/intersectionsAndOptionalProperties2.ts] ////
|
||||
|
||||
=== intersectionsAndOptionalProperties2.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/58174
|
||||
|
||||
type A_Primitive = {
|
||||
>A_Primitive : Symbol(A_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 0, 0))
|
||||
|
||||
disabled?: boolean;
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20))
|
||||
|
||||
};
|
||||
|
||||
type B_Primitive = {
|
||||
>B_Primitive : Symbol(B_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 4, 2))
|
||||
|
||||
disabled?: boolean | undefined;
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 6, 20))
|
||||
|
||||
};
|
||||
|
||||
type C_Primitive = {
|
||||
>C_Primitive : Symbol(C_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 8, 2))
|
||||
|
||||
disabled?: boolean;
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 10, 20))
|
||||
|
||||
};
|
||||
|
||||
declare const ab_primitive: A_Primitive & B_Primitive;
|
||||
>ab_primitive : Symbol(ab_primitive, Decl(intersectionsAndOptionalProperties2.ts, 14, 13))
|
||||
>A_Primitive : Symbol(A_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 0, 0))
|
||||
>B_Primitive : Symbol(B_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 4, 2))
|
||||
|
||||
declare const ac_primitive: A_Primitive & C_Primitive;
|
||||
>ac_primitive : Symbol(ac_primitive, Decl(intersectionsAndOptionalProperties2.ts, 15, 13))
|
||||
>A_Primitive : Symbol(A_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 0, 0))
|
||||
>C_Primitive : Symbol(C_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 8, 2))
|
||||
|
||||
const ab_disabled_read = ab_primitive.disabled;
|
||||
>ab_disabled_read : Symbol(ab_disabled_read, Decl(intersectionsAndOptionalProperties2.ts, 17, 5))
|
||||
>ab_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 6, 20))
|
||||
>ab_primitive : Symbol(ab_primitive, Decl(intersectionsAndOptionalProperties2.ts, 14, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 6, 20))
|
||||
|
||||
const ac_disabled_read = ac_primitive.disabled;
|
||||
>ac_disabled_read : Symbol(ac_disabled_read, Decl(intersectionsAndOptionalProperties2.ts, 18, 5))
|
||||
>ac_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 10, 20))
|
||||
>ac_primitive : Symbol(ac_primitive, Decl(intersectionsAndOptionalProperties2.ts, 15, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 10, 20))
|
||||
|
||||
ab_primitive.disabled = undefined;
|
||||
>ab_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 6, 20))
|
||||
>ab_primitive : Symbol(ab_primitive, Decl(intersectionsAndOptionalProperties2.ts, 14, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 6, 20))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
ac_primitive.disabled = undefined;
|
||||
>ac_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 10, 20))
|
||||
>ac_primitive : Symbol(ac_primitive, Decl(intersectionsAndOptionalProperties2.ts, 15, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 10, 20))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
type Foo = {
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties2.ts, 21, 34))
|
||||
|
||||
prop: boolean;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 23, 12))
|
||||
|
||||
};
|
||||
|
||||
type A_Obj = {
|
||||
>A_Obj : Symbol(A_Obj, Decl(intersectionsAndOptionalProperties2.ts, 25, 2))
|
||||
|
||||
prop?: Foo;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14))
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties2.ts, 21, 34))
|
||||
|
||||
};
|
||||
|
||||
type B_Obj = {
|
||||
>B_Obj : Symbol(B_Obj, Decl(intersectionsAndOptionalProperties2.ts, 29, 2))
|
||||
|
||||
prop?: Foo | undefined;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 31, 14))
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties2.ts, 21, 34))
|
||||
|
||||
};
|
||||
|
||||
type C_Obj = {
|
||||
>C_Obj : Symbol(C_Obj, Decl(intersectionsAndOptionalProperties2.ts, 33, 2))
|
||||
|
||||
prop?: Foo;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 35, 14))
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties2.ts, 21, 34))
|
||||
|
||||
};
|
||||
|
||||
declare const ab_obj: A_Obj & B_Obj;
|
||||
>ab_obj : Symbol(ab_obj, Decl(intersectionsAndOptionalProperties2.ts, 39, 13))
|
||||
>A_Obj : Symbol(A_Obj, Decl(intersectionsAndOptionalProperties2.ts, 25, 2))
|
||||
>B_Obj : Symbol(B_Obj, Decl(intersectionsAndOptionalProperties2.ts, 29, 2))
|
||||
|
||||
declare const ac_obj: A_Obj & C_Obj;
|
||||
>ac_obj : Symbol(ac_obj, Decl(intersectionsAndOptionalProperties2.ts, 40, 13))
|
||||
>A_Obj : Symbol(A_Obj, Decl(intersectionsAndOptionalProperties2.ts, 25, 2))
|
||||
>C_Obj : Symbol(C_Obj, Decl(intersectionsAndOptionalProperties2.ts, 33, 2))
|
||||
|
||||
const ab_prop_read = ab_obj.prop;
|
||||
>ab_prop_read : Symbol(ab_prop_read, Decl(intersectionsAndOptionalProperties2.ts, 42, 5))
|
||||
>ab_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 31, 14))
|
||||
>ab_obj : Symbol(ab_obj, Decl(intersectionsAndOptionalProperties2.ts, 39, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 31, 14))
|
||||
|
||||
const ac_prop_read = ac_obj.prop;
|
||||
>ac_prop_read : Symbol(ac_prop_read, Decl(intersectionsAndOptionalProperties2.ts, 43, 5))
|
||||
>ac_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 35, 14))
|
||||
>ac_obj : Symbol(ac_obj, Decl(intersectionsAndOptionalProperties2.ts, 40, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 35, 14))
|
||||
|
||||
ab_obj.prop = undefined;
|
||||
>ab_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 31, 14))
|
||||
>ab_obj : Symbol(ab_obj, Decl(intersectionsAndOptionalProperties2.ts, 39, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 31, 14))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
ac_obj.prop = undefined;
|
||||
>ac_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 35, 14))
|
||||
>ac_obj : Symbol(ac_obj, Decl(intersectionsAndOptionalProperties2.ts, 40, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 35, 14))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
//// [tests/cases/compiler/intersectionsAndOptionalProperties2.ts] ////
|
||||
|
||||
=== intersectionsAndOptionalProperties2.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/58174
|
||||
|
||||
type A_Primitive = {
|
||||
>A_Primitive : A_Primitive
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
disabled?: boolean;
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type B_Primitive = {
|
||||
>B_Primitive : B_Primitive
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
disabled?: boolean | undefined;
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type C_Primitive = {
|
||||
>C_Primitive : C_Primitive
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
disabled?: boolean;
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
declare const ab_primitive: A_Primitive & B_Primitive;
|
||||
>ab_primitive : A_Primitive & B_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
declare const ac_primitive: A_Primitive & C_Primitive;
|
||||
>ac_primitive : A_Primitive & C_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
const ab_disabled_read = ab_primitive.disabled;
|
||||
>ab_disabled_read : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ab_primitive.disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ab_primitive : A_Primitive & B_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
const ac_disabled_read = ac_primitive.disabled;
|
||||
>ac_disabled_read : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ac_primitive.disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ac_primitive : A_Primitive & C_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
ab_primitive.disabled = undefined;
|
||||
>ab_primitive.disabled = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ab_primitive.disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ab_primitive : A_Primitive & B_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
ac_primitive.disabled = undefined;
|
||||
>ac_primitive.disabled = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ac_primitive.disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ac_primitive : A_Primitive & C_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
type Foo = {
|
||||
>Foo : Foo
|
||||
> : ^^^
|
||||
|
||||
prop: boolean;
|
||||
>prop : boolean
|
||||
> : ^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type A_Obj = {
|
||||
>A_Obj : A_Obj
|
||||
> : ^^^^^
|
||||
|
||||
prop?: Foo;
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type B_Obj = {
|
||||
>B_Obj : B_Obj
|
||||
> : ^^^^^
|
||||
|
||||
prop?: Foo | undefined;
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type C_Obj = {
|
||||
>C_Obj : C_Obj
|
||||
> : ^^^^^
|
||||
|
||||
prop?: Foo;
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
declare const ab_obj: A_Obj & B_Obj;
|
||||
>ab_obj : A_Obj & B_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
|
||||
declare const ac_obj: A_Obj & C_Obj;
|
||||
>ac_obj : A_Obj & C_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
|
||||
const ab_prop_read = ab_obj.prop;
|
||||
>ab_prop_read : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ab_obj.prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ab_obj : A_Obj & B_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
const ac_prop_read = ac_obj.prop;
|
||||
>ac_prop_read : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ac_obj.prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ac_obj : A_Obj & C_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
ab_obj.prop = undefined;
|
||||
>ab_obj.prop = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ab_obj.prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ab_obj : A_Obj & B_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
ac_obj.prop = undefined;
|
||||
>ac_obj.prop = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ac_obj.prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ac_obj : A_Obj & C_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
intersectionsAndOptionalProperties2.ts(21,1): error TS2412: Type 'undefined' is not assignable to type 'boolean' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
|
||||
intersectionsAndOptionalProperties2.ts(22,1): error TS2412: Type 'undefined' is not assignable to type 'boolean' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
|
||||
intersectionsAndOptionalProperties2.ts(46,1): error TS2412: Type 'undefined' is not assignable to type 'Foo' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
|
||||
intersectionsAndOptionalProperties2.ts(47,1): error TS2412: Type 'undefined' is not assignable to type 'Foo' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
|
||||
|
||||
|
||||
==== intersectionsAndOptionalProperties2.ts (4 errors) ====
|
||||
// https://github.com/microsoft/TypeScript/issues/58174
|
||||
|
||||
type A_Primitive = {
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
type B_Primitive = {
|
||||
disabled?: boolean | undefined;
|
||||
};
|
||||
|
||||
type C_Primitive = {
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
declare const ab_primitive: A_Primitive & B_Primitive;
|
||||
declare const ac_primitive: A_Primitive & C_Primitive;
|
||||
|
||||
const ab_disabled_read = ab_primitive.disabled;
|
||||
const ac_disabled_read = ac_primitive.disabled;
|
||||
|
||||
ab_primitive.disabled = undefined;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2412: Type 'undefined' is not assignable to type 'boolean' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
|
||||
ac_primitive.disabled = undefined;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2412: Type 'undefined' is not assignable to type 'boolean' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
|
||||
|
||||
type Foo = {
|
||||
prop: boolean;
|
||||
};
|
||||
|
||||
type A_Obj = {
|
||||
prop?: Foo;
|
||||
};
|
||||
|
||||
type B_Obj = {
|
||||
prop?: Foo | undefined;
|
||||
};
|
||||
|
||||
type C_Obj = {
|
||||
prop?: Foo;
|
||||
};
|
||||
|
||||
declare const ab_obj: A_Obj & B_Obj;
|
||||
declare const ac_obj: A_Obj & C_Obj;
|
||||
|
||||
const ab_prop_read = ab_obj.prop;
|
||||
const ac_prop_read = ac_obj.prop;
|
||||
|
||||
ab_obj.prop = undefined;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2412: Type 'undefined' is not assignable to type 'Foo' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
|
||||
ac_obj.prop = undefined;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2412: Type 'undefined' is not assignable to type 'Foo' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
//// [tests/cases/compiler/intersectionsAndOptionalProperties2.ts] ////
|
||||
|
||||
=== intersectionsAndOptionalProperties2.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/58174
|
||||
|
||||
type A_Primitive = {
|
||||
>A_Primitive : Symbol(A_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 0, 0))
|
||||
|
||||
disabled?: boolean;
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20))
|
||||
|
||||
};
|
||||
|
||||
type B_Primitive = {
|
||||
>B_Primitive : Symbol(B_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 4, 2))
|
||||
|
||||
disabled?: boolean | undefined;
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 6, 20))
|
||||
|
||||
};
|
||||
|
||||
type C_Primitive = {
|
||||
>C_Primitive : Symbol(C_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 8, 2))
|
||||
|
||||
disabled?: boolean;
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 10, 20))
|
||||
|
||||
};
|
||||
|
||||
declare const ab_primitive: A_Primitive & B_Primitive;
|
||||
>ab_primitive : Symbol(ab_primitive, Decl(intersectionsAndOptionalProperties2.ts, 14, 13))
|
||||
>A_Primitive : Symbol(A_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 0, 0))
|
||||
>B_Primitive : Symbol(B_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 4, 2))
|
||||
|
||||
declare const ac_primitive: A_Primitive & C_Primitive;
|
||||
>ac_primitive : Symbol(ac_primitive, Decl(intersectionsAndOptionalProperties2.ts, 15, 13))
|
||||
>A_Primitive : Symbol(A_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 0, 0))
|
||||
>C_Primitive : Symbol(C_Primitive, Decl(intersectionsAndOptionalProperties2.ts, 8, 2))
|
||||
|
||||
const ab_disabled_read = ab_primitive.disabled;
|
||||
>ab_disabled_read : Symbol(ab_disabled_read, Decl(intersectionsAndOptionalProperties2.ts, 17, 5))
|
||||
>ab_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 6, 20))
|
||||
>ab_primitive : Symbol(ab_primitive, Decl(intersectionsAndOptionalProperties2.ts, 14, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 6, 20))
|
||||
|
||||
const ac_disabled_read = ac_primitive.disabled;
|
||||
>ac_disabled_read : Symbol(ac_disabled_read, Decl(intersectionsAndOptionalProperties2.ts, 18, 5))
|
||||
>ac_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 10, 20))
|
||||
>ac_primitive : Symbol(ac_primitive, Decl(intersectionsAndOptionalProperties2.ts, 15, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 10, 20))
|
||||
|
||||
ab_primitive.disabled = undefined;
|
||||
>ab_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 6, 20))
|
||||
>ab_primitive : Symbol(ab_primitive, Decl(intersectionsAndOptionalProperties2.ts, 14, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 6, 20))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
ac_primitive.disabled = undefined;
|
||||
>ac_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 10, 20))
|
||||
>ac_primitive : Symbol(ac_primitive, Decl(intersectionsAndOptionalProperties2.ts, 15, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties2.ts, 2, 20), Decl(intersectionsAndOptionalProperties2.ts, 10, 20))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
type Foo = {
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties2.ts, 21, 34))
|
||||
|
||||
prop: boolean;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 23, 12))
|
||||
|
||||
};
|
||||
|
||||
type A_Obj = {
|
||||
>A_Obj : Symbol(A_Obj, Decl(intersectionsAndOptionalProperties2.ts, 25, 2))
|
||||
|
||||
prop?: Foo;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14))
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties2.ts, 21, 34))
|
||||
|
||||
};
|
||||
|
||||
type B_Obj = {
|
||||
>B_Obj : Symbol(B_Obj, Decl(intersectionsAndOptionalProperties2.ts, 29, 2))
|
||||
|
||||
prop?: Foo | undefined;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 31, 14))
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties2.ts, 21, 34))
|
||||
|
||||
};
|
||||
|
||||
type C_Obj = {
|
||||
>C_Obj : Symbol(C_Obj, Decl(intersectionsAndOptionalProperties2.ts, 33, 2))
|
||||
|
||||
prop?: Foo;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 35, 14))
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties2.ts, 21, 34))
|
||||
|
||||
};
|
||||
|
||||
declare const ab_obj: A_Obj & B_Obj;
|
||||
>ab_obj : Symbol(ab_obj, Decl(intersectionsAndOptionalProperties2.ts, 39, 13))
|
||||
>A_Obj : Symbol(A_Obj, Decl(intersectionsAndOptionalProperties2.ts, 25, 2))
|
||||
>B_Obj : Symbol(B_Obj, Decl(intersectionsAndOptionalProperties2.ts, 29, 2))
|
||||
|
||||
declare const ac_obj: A_Obj & C_Obj;
|
||||
>ac_obj : Symbol(ac_obj, Decl(intersectionsAndOptionalProperties2.ts, 40, 13))
|
||||
>A_Obj : Symbol(A_Obj, Decl(intersectionsAndOptionalProperties2.ts, 25, 2))
|
||||
>C_Obj : Symbol(C_Obj, Decl(intersectionsAndOptionalProperties2.ts, 33, 2))
|
||||
|
||||
const ab_prop_read = ab_obj.prop;
|
||||
>ab_prop_read : Symbol(ab_prop_read, Decl(intersectionsAndOptionalProperties2.ts, 42, 5))
|
||||
>ab_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 31, 14))
|
||||
>ab_obj : Symbol(ab_obj, Decl(intersectionsAndOptionalProperties2.ts, 39, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 31, 14))
|
||||
|
||||
const ac_prop_read = ac_obj.prop;
|
||||
>ac_prop_read : Symbol(ac_prop_read, Decl(intersectionsAndOptionalProperties2.ts, 43, 5))
|
||||
>ac_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 35, 14))
|
||||
>ac_obj : Symbol(ac_obj, Decl(intersectionsAndOptionalProperties2.ts, 40, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 35, 14))
|
||||
|
||||
ab_obj.prop = undefined;
|
||||
>ab_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 31, 14))
|
||||
>ab_obj : Symbol(ab_obj, Decl(intersectionsAndOptionalProperties2.ts, 39, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 31, 14))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
ac_obj.prop = undefined;
|
||||
>ac_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 35, 14))
|
||||
>ac_obj : Symbol(ac_obj, Decl(intersectionsAndOptionalProperties2.ts, 40, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties2.ts, 27, 14), Decl(intersectionsAndOptionalProperties2.ts, 35, 14))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
//// [tests/cases/compiler/intersectionsAndOptionalProperties2.ts] ////
|
||||
|
||||
=== intersectionsAndOptionalProperties2.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/58174
|
||||
|
||||
type A_Primitive = {
|
||||
>A_Primitive : A_Primitive
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
disabled?: boolean;
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type B_Primitive = {
|
||||
>B_Primitive : B_Primitive
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
disabled?: boolean | undefined;
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type C_Primitive = {
|
||||
>C_Primitive : C_Primitive
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
disabled?: boolean;
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
declare const ab_primitive: A_Primitive & B_Primitive;
|
||||
>ab_primitive : A_Primitive & B_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
declare const ac_primitive: A_Primitive & C_Primitive;
|
||||
>ac_primitive : A_Primitive & C_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
const ab_disabled_read = ab_primitive.disabled;
|
||||
>ab_disabled_read : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ab_primitive.disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ab_primitive : A_Primitive & B_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
const ac_disabled_read = ac_primitive.disabled;
|
||||
>ac_disabled_read : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ac_primitive.disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ac_primitive : A_Primitive & C_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
ab_primitive.disabled = undefined;
|
||||
>ab_primitive.disabled = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ab_primitive.disabled : boolean
|
||||
> : ^^^^^^^
|
||||
>ab_primitive : A_Primitive & B_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean
|
||||
> : ^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
ac_primitive.disabled = undefined;
|
||||
>ac_primitive.disabled = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ac_primitive.disabled : boolean
|
||||
> : ^^^^^^^
|
||||
>ac_primitive : A_Primitive & C_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean
|
||||
> : ^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
type Foo = {
|
||||
>Foo : Foo
|
||||
> : ^^^
|
||||
|
||||
prop: boolean;
|
||||
>prop : boolean
|
||||
> : ^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type A_Obj = {
|
||||
>A_Obj : A_Obj
|
||||
> : ^^^^^
|
||||
|
||||
prop?: Foo;
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type B_Obj = {
|
||||
>B_Obj : B_Obj
|
||||
> : ^^^^^
|
||||
|
||||
prop?: Foo | undefined;
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type C_Obj = {
|
||||
>C_Obj : C_Obj
|
||||
> : ^^^^^
|
||||
|
||||
prop?: Foo;
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
declare const ab_obj: A_Obj & B_Obj;
|
||||
>ab_obj : A_Obj & B_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
|
||||
declare const ac_obj: A_Obj & C_Obj;
|
||||
>ac_obj : A_Obj & C_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
|
||||
const ab_prop_read = ab_obj.prop;
|
||||
>ab_prop_read : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ab_obj.prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ab_obj : A_Obj & B_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
const ac_prop_read = ac_obj.prop;
|
||||
>ac_prop_read : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ac_obj.prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ac_obj : A_Obj & C_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
ab_obj.prop = undefined;
|
||||
>ab_obj.prop = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ab_obj.prop : Foo
|
||||
> : ^^^
|
||||
>ab_obj : A_Obj & B_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo
|
||||
> : ^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
ac_obj.prop = undefined;
|
||||
>ac_obj.prop = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ac_obj.prop : Foo
|
||||
> : ^^^
|
||||
>ac_obj : A_Obj & C_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo
|
||||
> : ^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
//// [tests/cases/compiler/intersectionsAndOptionalProperties3.ts] ////
|
||||
|
||||
=== intersectionsAndOptionalProperties3.ts ===
|
||||
type A_Primitive = {
|
||||
>A_Primitive : Symbol(A_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 0, 0))
|
||||
|
||||
disabled?: boolean | undefined;
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20))
|
||||
|
||||
};
|
||||
|
||||
type B_Primitive = {
|
||||
>B_Primitive : Symbol(B_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 2, 2))
|
||||
|
||||
disabled?: boolean;
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 4, 20))
|
||||
|
||||
};
|
||||
|
||||
type C_Primitive = {
|
||||
>C_Primitive : Symbol(C_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 6, 2))
|
||||
|
||||
disabled?: boolean | undefined;
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 8, 20))
|
||||
|
||||
};
|
||||
|
||||
declare const ab_primitive: A_Primitive & B_Primitive;
|
||||
>ab_primitive : Symbol(ab_primitive, Decl(intersectionsAndOptionalProperties3.ts, 12, 13))
|
||||
>A_Primitive : Symbol(A_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 0, 0))
|
||||
>B_Primitive : Symbol(B_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 2, 2))
|
||||
|
||||
declare const ac_primitive: A_Primitive & C_Primitive;
|
||||
>ac_primitive : Symbol(ac_primitive, Decl(intersectionsAndOptionalProperties3.ts, 13, 13))
|
||||
>A_Primitive : Symbol(A_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 0, 0))
|
||||
>C_Primitive : Symbol(C_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 6, 2))
|
||||
|
||||
const ab_disabled_read = ab_primitive.disabled;
|
||||
>ab_disabled_read : Symbol(ab_disabled_read, Decl(intersectionsAndOptionalProperties3.ts, 15, 5))
|
||||
>ab_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 4, 20))
|
||||
>ab_primitive : Symbol(ab_primitive, Decl(intersectionsAndOptionalProperties3.ts, 12, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 4, 20))
|
||||
|
||||
const ac_disabled_read = ac_primitive.disabled;
|
||||
>ac_disabled_read : Symbol(ac_disabled_read, Decl(intersectionsAndOptionalProperties3.ts, 16, 5))
|
||||
>ac_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 8, 20))
|
||||
>ac_primitive : Symbol(ac_primitive, Decl(intersectionsAndOptionalProperties3.ts, 13, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 8, 20))
|
||||
|
||||
ab_primitive.disabled = undefined;
|
||||
>ab_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 4, 20))
|
||||
>ab_primitive : Symbol(ab_primitive, Decl(intersectionsAndOptionalProperties3.ts, 12, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 4, 20))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
ac_primitive.disabled = undefined;
|
||||
>ac_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 8, 20))
|
||||
>ac_primitive : Symbol(ac_primitive, Decl(intersectionsAndOptionalProperties3.ts, 13, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 8, 20))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
type Foo = {
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties3.ts, 19, 34))
|
||||
|
||||
prop: boolean;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 21, 12))
|
||||
|
||||
};
|
||||
|
||||
type A_Obj = {
|
||||
>A_Obj : Symbol(A_Obj, Decl(intersectionsAndOptionalProperties3.ts, 23, 2))
|
||||
|
||||
prop?: Foo | undefined;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14))
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties3.ts, 19, 34))
|
||||
|
||||
};
|
||||
|
||||
type B_Obj = {
|
||||
>B_Obj : Symbol(B_Obj, Decl(intersectionsAndOptionalProperties3.ts, 27, 2))
|
||||
|
||||
prop?: Foo;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 29, 14))
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties3.ts, 19, 34))
|
||||
|
||||
};
|
||||
|
||||
type C_Obj = {
|
||||
>C_Obj : Symbol(C_Obj, Decl(intersectionsAndOptionalProperties3.ts, 31, 2))
|
||||
|
||||
prop?: Foo | undefined;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 33, 14))
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties3.ts, 19, 34))
|
||||
|
||||
};
|
||||
|
||||
declare const ab_obj: A_Obj & B_Obj;
|
||||
>ab_obj : Symbol(ab_obj, Decl(intersectionsAndOptionalProperties3.ts, 37, 13))
|
||||
>A_Obj : Symbol(A_Obj, Decl(intersectionsAndOptionalProperties3.ts, 23, 2))
|
||||
>B_Obj : Symbol(B_Obj, Decl(intersectionsAndOptionalProperties3.ts, 27, 2))
|
||||
|
||||
declare const ac_obj: A_Obj & C_Obj;
|
||||
>ac_obj : Symbol(ac_obj, Decl(intersectionsAndOptionalProperties3.ts, 38, 13))
|
||||
>A_Obj : Symbol(A_Obj, Decl(intersectionsAndOptionalProperties3.ts, 23, 2))
|
||||
>C_Obj : Symbol(C_Obj, Decl(intersectionsAndOptionalProperties3.ts, 31, 2))
|
||||
|
||||
const ab_prop_read = ab_obj.prop;
|
||||
>ab_prop_read : Symbol(ab_prop_read, Decl(intersectionsAndOptionalProperties3.ts, 40, 5))
|
||||
>ab_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 29, 14))
|
||||
>ab_obj : Symbol(ab_obj, Decl(intersectionsAndOptionalProperties3.ts, 37, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 29, 14))
|
||||
|
||||
const ac_prop_read = ac_obj.prop;
|
||||
>ac_prop_read : Symbol(ac_prop_read, Decl(intersectionsAndOptionalProperties3.ts, 41, 5))
|
||||
>ac_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 33, 14))
|
||||
>ac_obj : Symbol(ac_obj, Decl(intersectionsAndOptionalProperties3.ts, 38, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 33, 14))
|
||||
|
||||
ab_obj.prop = undefined;
|
||||
>ab_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 29, 14))
|
||||
>ab_obj : Symbol(ab_obj, Decl(intersectionsAndOptionalProperties3.ts, 37, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 29, 14))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
ac_obj.prop = undefined;
|
||||
>ac_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 33, 14))
|
||||
>ac_obj : Symbol(ac_obj, Decl(intersectionsAndOptionalProperties3.ts, 38, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 33, 14))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
//// [tests/cases/compiler/intersectionsAndOptionalProperties3.ts] ////
|
||||
|
||||
=== intersectionsAndOptionalProperties3.ts ===
|
||||
type A_Primitive = {
|
||||
>A_Primitive : A_Primitive
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
disabled?: boolean | undefined;
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type B_Primitive = {
|
||||
>B_Primitive : B_Primitive
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
disabled?: boolean;
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type C_Primitive = {
|
||||
>C_Primitive : C_Primitive
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
disabled?: boolean | undefined;
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
declare const ab_primitive: A_Primitive & B_Primitive;
|
||||
>ab_primitive : A_Primitive & B_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
declare const ac_primitive: A_Primitive & C_Primitive;
|
||||
>ac_primitive : A_Primitive & C_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
const ab_disabled_read = ab_primitive.disabled;
|
||||
>ab_disabled_read : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ab_primitive.disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ab_primitive : A_Primitive & B_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
const ac_disabled_read = ac_primitive.disabled;
|
||||
>ac_disabled_read : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ac_primitive.disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ac_primitive : A_Primitive & C_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
ab_primitive.disabled = undefined;
|
||||
>ab_primitive.disabled = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ab_primitive.disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ab_primitive : A_Primitive & B_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
ac_primitive.disabled = undefined;
|
||||
>ac_primitive.disabled = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ac_primitive.disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ac_primitive : A_Primitive & C_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
type Foo = {
|
||||
>Foo : Foo
|
||||
> : ^^^
|
||||
|
||||
prop: boolean;
|
||||
>prop : boolean
|
||||
> : ^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type A_Obj = {
|
||||
>A_Obj : A_Obj
|
||||
> : ^^^^^
|
||||
|
||||
prop?: Foo | undefined;
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type B_Obj = {
|
||||
>B_Obj : B_Obj
|
||||
> : ^^^^^
|
||||
|
||||
prop?: Foo;
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type C_Obj = {
|
||||
>C_Obj : C_Obj
|
||||
> : ^^^^^
|
||||
|
||||
prop?: Foo | undefined;
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
declare const ab_obj: A_Obj & B_Obj;
|
||||
>ab_obj : A_Obj & B_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
|
||||
declare const ac_obj: A_Obj & C_Obj;
|
||||
>ac_obj : A_Obj & C_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
|
||||
const ab_prop_read = ab_obj.prop;
|
||||
>ab_prop_read : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ab_obj.prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ab_obj : A_Obj & B_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
const ac_prop_read = ac_obj.prop;
|
||||
>ac_prop_read : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ac_obj.prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ac_obj : A_Obj & C_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
ab_obj.prop = undefined;
|
||||
>ab_obj.prop = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ab_obj.prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ab_obj : A_Obj & B_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
ac_obj.prop = undefined;
|
||||
>ac_obj.prop = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ac_obj.prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ac_obj : A_Obj & C_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
intersectionsAndOptionalProperties3.ts(19,1): error TS2412: Type 'undefined' is not assignable to type 'boolean' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
|
||||
intersectionsAndOptionalProperties3.ts(44,1): error TS2412: Type 'undefined' is not assignable to type 'Foo' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
|
||||
|
||||
|
||||
==== intersectionsAndOptionalProperties3.ts (2 errors) ====
|
||||
type A_Primitive = {
|
||||
disabled?: boolean | undefined;
|
||||
};
|
||||
|
||||
type B_Primitive = {
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
type C_Primitive = {
|
||||
disabled?: boolean | undefined;
|
||||
};
|
||||
|
||||
declare const ab_primitive: A_Primitive & B_Primitive;
|
||||
declare const ac_primitive: A_Primitive & C_Primitive;
|
||||
|
||||
const ab_disabled_read = ab_primitive.disabled;
|
||||
const ac_disabled_read = ac_primitive.disabled;
|
||||
|
||||
ab_primitive.disabled = undefined;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2412: Type 'undefined' is not assignable to type 'boolean' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
|
||||
ac_primitive.disabled = undefined;
|
||||
|
||||
type Foo = {
|
||||
prop: boolean;
|
||||
};
|
||||
|
||||
type A_Obj = {
|
||||
prop?: Foo | undefined;
|
||||
};
|
||||
|
||||
type B_Obj = {
|
||||
prop?: Foo;
|
||||
};
|
||||
|
||||
type C_Obj = {
|
||||
prop?: Foo | undefined;
|
||||
};
|
||||
|
||||
declare const ab_obj: A_Obj & B_Obj;
|
||||
declare const ac_obj: A_Obj & C_Obj;
|
||||
|
||||
const ab_prop_read = ab_obj.prop;
|
||||
const ac_prop_read = ac_obj.prop;
|
||||
|
||||
ab_obj.prop = undefined;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2412: Type 'undefined' is not assignable to type 'Foo' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
|
||||
ac_obj.prop = undefined;
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
//// [tests/cases/compiler/intersectionsAndOptionalProperties3.ts] ////
|
||||
|
||||
=== intersectionsAndOptionalProperties3.ts ===
|
||||
type A_Primitive = {
|
||||
>A_Primitive : Symbol(A_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 0, 0))
|
||||
|
||||
disabled?: boolean | undefined;
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20))
|
||||
|
||||
};
|
||||
|
||||
type B_Primitive = {
|
||||
>B_Primitive : Symbol(B_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 2, 2))
|
||||
|
||||
disabled?: boolean;
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 4, 20))
|
||||
|
||||
};
|
||||
|
||||
type C_Primitive = {
|
||||
>C_Primitive : Symbol(C_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 6, 2))
|
||||
|
||||
disabled?: boolean | undefined;
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 8, 20))
|
||||
|
||||
};
|
||||
|
||||
declare const ab_primitive: A_Primitive & B_Primitive;
|
||||
>ab_primitive : Symbol(ab_primitive, Decl(intersectionsAndOptionalProperties3.ts, 12, 13))
|
||||
>A_Primitive : Symbol(A_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 0, 0))
|
||||
>B_Primitive : Symbol(B_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 2, 2))
|
||||
|
||||
declare const ac_primitive: A_Primitive & C_Primitive;
|
||||
>ac_primitive : Symbol(ac_primitive, Decl(intersectionsAndOptionalProperties3.ts, 13, 13))
|
||||
>A_Primitive : Symbol(A_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 0, 0))
|
||||
>C_Primitive : Symbol(C_Primitive, Decl(intersectionsAndOptionalProperties3.ts, 6, 2))
|
||||
|
||||
const ab_disabled_read = ab_primitive.disabled;
|
||||
>ab_disabled_read : Symbol(ab_disabled_read, Decl(intersectionsAndOptionalProperties3.ts, 15, 5))
|
||||
>ab_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 4, 20))
|
||||
>ab_primitive : Symbol(ab_primitive, Decl(intersectionsAndOptionalProperties3.ts, 12, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 4, 20))
|
||||
|
||||
const ac_disabled_read = ac_primitive.disabled;
|
||||
>ac_disabled_read : Symbol(ac_disabled_read, Decl(intersectionsAndOptionalProperties3.ts, 16, 5))
|
||||
>ac_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 8, 20))
|
||||
>ac_primitive : Symbol(ac_primitive, Decl(intersectionsAndOptionalProperties3.ts, 13, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 8, 20))
|
||||
|
||||
ab_primitive.disabled = undefined;
|
||||
>ab_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 4, 20))
|
||||
>ab_primitive : Symbol(ab_primitive, Decl(intersectionsAndOptionalProperties3.ts, 12, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 4, 20))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
ac_primitive.disabled = undefined;
|
||||
>ac_primitive.disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 8, 20))
|
||||
>ac_primitive : Symbol(ac_primitive, Decl(intersectionsAndOptionalProperties3.ts, 13, 13))
|
||||
>disabled : Symbol(disabled, Decl(intersectionsAndOptionalProperties3.ts, 0, 20), Decl(intersectionsAndOptionalProperties3.ts, 8, 20))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
type Foo = {
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties3.ts, 19, 34))
|
||||
|
||||
prop: boolean;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 21, 12))
|
||||
|
||||
};
|
||||
|
||||
type A_Obj = {
|
||||
>A_Obj : Symbol(A_Obj, Decl(intersectionsAndOptionalProperties3.ts, 23, 2))
|
||||
|
||||
prop?: Foo | undefined;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14))
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties3.ts, 19, 34))
|
||||
|
||||
};
|
||||
|
||||
type B_Obj = {
|
||||
>B_Obj : Symbol(B_Obj, Decl(intersectionsAndOptionalProperties3.ts, 27, 2))
|
||||
|
||||
prop?: Foo;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 29, 14))
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties3.ts, 19, 34))
|
||||
|
||||
};
|
||||
|
||||
type C_Obj = {
|
||||
>C_Obj : Symbol(C_Obj, Decl(intersectionsAndOptionalProperties3.ts, 31, 2))
|
||||
|
||||
prop?: Foo | undefined;
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 33, 14))
|
||||
>Foo : Symbol(Foo, Decl(intersectionsAndOptionalProperties3.ts, 19, 34))
|
||||
|
||||
};
|
||||
|
||||
declare const ab_obj: A_Obj & B_Obj;
|
||||
>ab_obj : Symbol(ab_obj, Decl(intersectionsAndOptionalProperties3.ts, 37, 13))
|
||||
>A_Obj : Symbol(A_Obj, Decl(intersectionsAndOptionalProperties3.ts, 23, 2))
|
||||
>B_Obj : Symbol(B_Obj, Decl(intersectionsAndOptionalProperties3.ts, 27, 2))
|
||||
|
||||
declare const ac_obj: A_Obj & C_Obj;
|
||||
>ac_obj : Symbol(ac_obj, Decl(intersectionsAndOptionalProperties3.ts, 38, 13))
|
||||
>A_Obj : Symbol(A_Obj, Decl(intersectionsAndOptionalProperties3.ts, 23, 2))
|
||||
>C_Obj : Symbol(C_Obj, Decl(intersectionsAndOptionalProperties3.ts, 31, 2))
|
||||
|
||||
const ab_prop_read = ab_obj.prop;
|
||||
>ab_prop_read : Symbol(ab_prop_read, Decl(intersectionsAndOptionalProperties3.ts, 40, 5))
|
||||
>ab_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 29, 14))
|
||||
>ab_obj : Symbol(ab_obj, Decl(intersectionsAndOptionalProperties3.ts, 37, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 29, 14))
|
||||
|
||||
const ac_prop_read = ac_obj.prop;
|
||||
>ac_prop_read : Symbol(ac_prop_read, Decl(intersectionsAndOptionalProperties3.ts, 41, 5))
|
||||
>ac_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 33, 14))
|
||||
>ac_obj : Symbol(ac_obj, Decl(intersectionsAndOptionalProperties3.ts, 38, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 33, 14))
|
||||
|
||||
ab_obj.prop = undefined;
|
||||
>ab_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 29, 14))
|
||||
>ab_obj : Symbol(ab_obj, Decl(intersectionsAndOptionalProperties3.ts, 37, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 29, 14))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
ac_obj.prop = undefined;
|
||||
>ac_obj.prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 33, 14))
|
||||
>ac_obj : Symbol(ac_obj, Decl(intersectionsAndOptionalProperties3.ts, 38, 13))
|
||||
>prop : Symbol(prop, Decl(intersectionsAndOptionalProperties3.ts, 25, 14), Decl(intersectionsAndOptionalProperties3.ts, 33, 14))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
//// [tests/cases/compiler/intersectionsAndOptionalProperties3.ts] ////
|
||||
|
||||
=== intersectionsAndOptionalProperties3.ts ===
|
||||
type A_Primitive = {
|
||||
>A_Primitive : A_Primitive
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
disabled?: boolean | undefined;
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type B_Primitive = {
|
||||
>B_Primitive : B_Primitive
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
disabled?: boolean;
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type C_Primitive = {
|
||||
>C_Primitive : C_Primitive
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
disabled?: boolean | undefined;
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
declare const ab_primitive: A_Primitive & B_Primitive;
|
||||
>ab_primitive : A_Primitive & B_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
declare const ac_primitive: A_Primitive & C_Primitive;
|
||||
>ac_primitive : A_Primitive & C_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
const ab_disabled_read = ab_primitive.disabled;
|
||||
>ab_disabled_read : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ab_primitive.disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ab_primitive : A_Primitive & B_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
const ac_disabled_read = ac_primitive.disabled;
|
||||
>ac_disabled_read : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ac_primitive.disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ac_primitive : A_Primitive & C_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
ab_primitive.disabled = undefined;
|
||||
>ab_primitive.disabled = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ab_primitive.disabled : boolean
|
||||
> : ^^^^^^^
|
||||
>ab_primitive : A_Primitive & B_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean
|
||||
> : ^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
ac_primitive.disabled = undefined;
|
||||
>ac_primitive.disabled = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ac_primitive.disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>ac_primitive : A_Primitive & C_Primitive
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>disabled : boolean | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
type Foo = {
|
||||
>Foo : Foo
|
||||
> : ^^^
|
||||
|
||||
prop: boolean;
|
||||
>prop : boolean
|
||||
> : ^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type A_Obj = {
|
||||
>A_Obj : A_Obj
|
||||
> : ^^^^^
|
||||
|
||||
prop?: Foo | undefined;
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type B_Obj = {
|
||||
>B_Obj : B_Obj
|
||||
> : ^^^^^
|
||||
|
||||
prop?: Foo;
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
type C_Obj = {
|
||||
>C_Obj : C_Obj
|
||||
> : ^^^^^
|
||||
|
||||
prop?: Foo | undefined;
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
|
||||
declare const ab_obj: A_Obj & B_Obj;
|
||||
>ab_obj : A_Obj & B_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
|
||||
declare const ac_obj: A_Obj & C_Obj;
|
||||
>ac_obj : A_Obj & C_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
|
||||
const ab_prop_read = ab_obj.prop;
|
||||
>ab_prop_read : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ab_obj.prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ab_obj : A_Obj & B_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
const ac_prop_read = ac_obj.prop;
|
||||
>ac_prop_read : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ac_obj.prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ac_obj : A_Obj & C_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
ab_obj.prop = undefined;
|
||||
>ab_obj.prop = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ab_obj.prop : Foo
|
||||
> : ^^^
|
||||
>ab_obj : A_Obj & B_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo
|
||||
> : ^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
ac_obj.prop = undefined;
|
||||
>ac_obj.prop = undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
>ac_obj.prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>ac_obj : A_Obj & C_Obj
|
||||
> : ^^^^^^^^^^^^^
|
||||
>prop : Foo | undefined
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
51
tests/cases/compiler/intersectionsAndOptionalProperties2.ts
Normal file
51
tests/cases/compiler/intersectionsAndOptionalProperties2.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
// @strict: true
|
||||
// @exactOptionalPropertyTypes: true, false
|
||||
// @noEmit: true
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/58174
|
||||
|
||||
type A_Primitive = {
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
type B_Primitive = {
|
||||
disabled?: boolean | undefined;
|
||||
};
|
||||
|
||||
type C_Primitive = {
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
declare const ab_primitive: A_Primitive & B_Primitive;
|
||||
declare const ac_primitive: A_Primitive & C_Primitive;
|
||||
|
||||
const ab_disabled_read = ab_primitive.disabled;
|
||||
const ac_disabled_read = ac_primitive.disabled;
|
||||
|
||||
ab_primitive.disabled = undefined;
|
||||
ac_primitive.disabled = undefined;
|
||||
|
||||
type Foo = {
|
||||
prop: boolean;
|
||||
};
|
||||
|
||||
type A_Obj = {
|
||||
prop?: Foo;
|
||||
};
|
||||
|
||||
type B_Obj = {
|
||||
prop?: Foo | undefined;
|
||||
};
|
||||
|
||||
type C_Obj = {
|
||||
prop?: Foo;
|
||||
};
|
||||
|
||||
declare const ab_obj: A_Obj & B_Obj;
|
||||
declare const ac_obj: A_Obj & C_Obj;
|
||||
|
||||
const ab_prop_read = ab_obj.prop;
|
||||
const ac_prop_read = ac_obj.prop;
|
||||
|
||||
ab_obj.prop = undefined;
|
||||
ac_obj.prop = undefined;
|
||||
49
tests/cases/compiler/intersectionsAndOptionalProperties3.ts
Normal file
49
tests/cases/compiler/intersectionsAndOptionalProperties3.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
// @strict: true
|
||||
// @exactOptionalPropertyTypes: true, false
|
||||
// @noEmit: true
|
||||
|
||||
type A_Primitive = {
|
||||
disabled?: boolean | undefined;
|
||||
};
|
||||
|
||||
type B_Primitive = {
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
type C_Primitive = {
|
||||
disabled?: boolean | undefined;
|
||||
};
|
||||
|
||||
declare const ab_primitive: A_Primitive & B_Primitive;
|
||||
declare const ac_primitive: A_Primitive & C_Primitive;
|
||||
|
||||
const ab_disabled_read = ab_primitive.disabled;
|
||||
const ac_disabled_read = ac_primitive.disabled;
|
||||
|
||||
ab_primitive.disabled = undefined;
|
||||
ac_primitive.disabled = undefined;
|
||||
|
||||
type Foo = {
|
||||
prop: boolean;
|
||||
};
|
||||
|
||||
type A_Obj = {
|
||||
prop?: Foo | undefined;
|
||||
};
|
||||
|
||||
type B_Obj = {
|
||||
prop?: Foo;
|
||||
};
|
||||
|
||||
type C_Obj = {
|
||||
prop?: Foo | undefined;
|
||||
};
|
||||
|
||||
declare const ab_obj: A_Obj & B_Obj;
|
||||
declare const ac_obj: A_Obj & C_Obj;
|
||||
|
||||
const ab_prop_read = ab_obj.prop;
|
||||
const ac_prop_read = ac_obj.prop;
|
||||
|
||||
ab_obj.prop = undefined;
|
||||
ac_obj.prop = undefined;
|
||||
Reference in New Issue
Block a user