diff --git a/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.errors.txt b/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.errors.txt new file mode 100644 index 00000000000..63683c87610 --- /dev/null +++ b/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.errors.txt @@ -0,0 +1,99 @@ +tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts(25,1): error TS2322: Type 'A' is not assignable to type 'A | B | C'. + Type 'A' is not assignable to type 'C'. + Property 'cProp' is missing in type 'A'. +tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts(26,1): error TS2322: Type 'B' is not assignable to type 'A | B | C'. + Type 'B' is not assignable to type 'C'. + Property 'cProp' is missing in type 'B'. +tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts(27,1): error TS2322: Type 'C' is not assignable to type 'A | B | C'. + Type 'C' is not assignable to type 'C'. + Type 'Foo' is not assignable to type 'Kwah'. + Property 'kwah' is missing in type 'Foo'. +tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts(48,1): error TS2322: Type 'X' is not assignable to type 'X | Y | Z'. + Type 'X' is not assignable to type 'Z'. + Property 'zProp' is missing in type 'X'. +tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts(49,1): error TS2322: Type 'Y' is not assignable to type 'X | Y | Z'. + Type 'Y' is not assignable to type 'Z'. + Property 'zProp' is missing in type 'Y'. +tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts(50,1): error TS2322: Type 'Z' is not assignable to type 'X | Y | Z'. + Type 'Z' is not assignable to type 'Z'. + Types of property 'zProp' are incompatible. + Type 'Foo' is not assignable to type 'Kwah'. + + +==== tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts (6 errors) ==== + interface Foo { foo: any } + interface Bar { bar: any } + interface Baz { baz: any } + interface Kwah { kwah: any } + + //////// + + interface A { + aProp: T; + } + + interface B { + bProp: T; + } + + interface C { + cProp: T; + } + + declare const a: A; + declare const b: B; + declare const c: C; + declare let thingOfInterfaces: A | B | C; + + thingOfInterfaces = a; + ~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'A' is not assignable to type 'A | B | C'. +!!! error TS2322: Type 'A' is not assignable to type 'C'. +!!! error TS2322: Property 'cProp' is missing in type 'A'. + thingOfInterfaces = b; + ~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'B' is not assignable to type 'A | B | C'. +!!! error TS2322: Type 'B' is not assignable to type 'C'. +!!! error TS2322: Property 'cProp' is missing in type 'B'. + thingOfInterfaces = c; + ~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'C' is not assignable to type 'A | B | C'. +!!! error TS2322: Type 'C' is not assignable to type 'C'. +!!! error TS2322: Type 'Foo' is not assignable to type 'Kwah'. +!!! error TS2322: Property 'kwah' is missing in type 'Foo'. + + //////// + + type X = { + xProp: T; + } + + type Y = { + yProp: T; + } + + type Z = { + zProp: T; + } + + declare const x: X; + declare const y: Y; + declare const z: Z; + declare let thingOfTypeAliases: X | Y | Z; + + thingOfTypeAliases = x; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'X' is not assignable to type 'X | Y | Z'. +!!! error TS2322: Type 'X' is not assignable to type 'Z'. +!!! error TS2322: Property 'zProp' is missing in type 'X'. + thingOfTypeAliases = y; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'Y' is not assignable to type 'X | Y | Z'. +!!! error TS2322: Type 'Y' is not assignable to type 'Z'. +!!! error TS2322: Property 'zProp' is missing in type 'Y'. + thingOfTypeAliases = z; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'Z' is not assignable to type 'X | Y | Z'. +!!! error TS2322: Type 'Z' is not assignable to type 'Z'. +!!! error TS2322: Types of property 'zProp' are incompatible. +!!! error TS2322: Type 'Foo' is not assignable to type 'Kwah'. \ No newline at end of file diff --git a/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.js b/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.js new file mode 100644 index 00000000000..defd59035a5 --- /dev/null +++ b/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.js @@ -0,0 +1,59 @@ +//// [unionTypeErrorMessageTypeRefs01.ts] +interface Foo { foo: any } +interface Bar { bar: any } +interface Baz { baz: any } +interface Kwah { kwah: any } + +//////// + +interface A { + aProp: T; +} + +interface B { + bProp: T; +} + +interface C { + cProp: T; +} + +declare const a: A; +declare const b: B; +declare const c: C; +declare let thingOfInterfaces: A | B | C; + +thingOfInterfaces = a; +thingOfInterfaces = b; +thingOfInterfaces = c; + +//////// + +type X = { + xProp: T; +} + +type Y = { + yProp: T; +} + +type Z = { + zProp: T; +} + +declare const x: X; +declare const y: Y; +declare const z: Z; +declare let thingOfTypeAliases: X | Y | Z; + +thingOfTypeAliases = x; +thingOfTypeAliases = y; +thingOfTypeAliases = z; + +//// [unionTypeErrorMessageTypeRefs01.js] +thingOfInterfaces = a; +thingOfInterfaces = b; +thingOfInterfaces = c; +thingOfTypeAliases = x; +thingOfTypeAliases = y; +thingOfTypeAliases = z; diff --git a/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.symbols b/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.symbols new file mode 100644 index 00000000000..1788d27a7dc --- /dev/null +++ b/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.symbols @@ -0,0 +1,147 @@ +=== tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts === +interface Foo { foo: any } +>Foo : Symbol(Foo, Decl(unionTypeErrorMessageTypeRefs01.ts, 0, 0)) +>foo : Symbol(Foo.foo, Decl(unionTypeErrorMessageTypeRefs01.ts, 0, 15)) + +interface Bar { bar: any } +>Bar : Symbol(Bar, Decl(unionTypeErrorMessageTypeRefs01.ts, 0, 26)) +>bar : Symbol(Bar.bar, Decl(unionTypeErrorMessageTypeRefs01.ts, 1, 15)) + +interface Baz { baz: any } +>Baz : Symbol(Baz, Decl(unionTypeErrorMessageTypeRefs01.ts, 1, 26)) +>baz : Symbol(Baz.baz, Decl(unionTypeErrorMessageTypeRefs01.ts, 2, 15)) + +interface Kwah { kwah: any } +>Kwah : Symbol(Kwah, Decl(unionTypeErrorMessageTypeRefs01.ts, 2, 26)) +>kwah : Symbol(Kwah.kwah, Decl(unionTypeErrorMessageTypeRefs01.ts, 3, 16)) + +//////// + +interface A { +>A : Symbol(A, Decl(unionTypeErrorMessageTypeRefs01.ts, 3, 28)) +>T : Symbol(T, Decl(unionTypeErrorMessageTypeRefs01.ts, 7, 12)) + + aProp: T; +>aProp : Symbol(A.aProp, Decl(unionTypeErrorMessageTypeRefs01.ts, 7, 16)) +>T : Symbol(T, Decl(unionTypeErrorMessageTypeRefs01.ts, 7, 12)) +} + +interface B { +>B : Symbol(B, Decl(unionTypeErrorMessageTypeRefs01.ts, 9, 1)) +>T : Symbol(T, Decl(unionTypeErrorMessageTypeRefs01.ts, 11, 12)) + + bProp: T; +>bProp : Symbol(B.bProp, Decl(unionTypeErrorMessageTypeRefs01.ts, 11, 16)) +>T : Symbol(T, Decl(unionTypeErrorMessageTypeRefs01.ts, 11, 12)) +} + +interface C { +>C : Symbol(C, Decl(unionTypeErrorMessageTypeRefs01.ts, 13, 1)) +>T : Symbol(T, Decl(unionTypeErrorMessageTypeRefs01.ts, 15, 12)) + + cProp: T; +>cProp : Symbol(C.cProp, Decl(unionTypeErrorMessageTypeRefs01.ts, 15, 16)) +>T : Symbol(T, Decl(unionTypeErrorMessageTypeRefs01.ts, 15, 12)) +} + +declare const a: A; +>a : Symbol(a, Decl(unionTypeErrorMessageTypeRefs01.ts, 19, 13)) +>A : Symbol(A, Decl(unionTypeErrorMessageTypeRefs01.ts, 3, 28)) +>Foo : Symbol(Foo, Decl(unionTypeErrorMessageTypeRefs01.ts, 0, 0)) + +declare const b: B; +>b : Symbol(b, Decl(unionTypeErrorMessageTypeRefs01.ts, 20, 13)) +>B : Symbol(B, Decl(unionTypeErrorMessageTypeRefs01.ts, 9, 1)) +>Foo : Symbol(Foo, Decl(unionTypeErrorMessageTypeRefs01.ts, 0, 0)) + +declare const c: C; +>c : Symbol(c, Decl(unionTypeErrorMessageTypeRefs01.ts, 21, 13)) +>C : Symbol(C, Decl(unionTypeErrorMessageTypeRefs01.ts, 13, 1)) +>Foo : Symbol(Foo, Decl(unionTypeErrorMessageTypeRefs01.ts, 0, 0)) + +declare let thingOfInterfaces: A | B | C; +>thingOfInterfaces : Symbol(thingOfInterfaces, Decl(unionTypeErrorMessageTypeRefs01.ts, 22, 11)) +>A : Symbol(A, Decl(unionTypeErrorMessageTypeRefs01.ts, 3, 28)) +>Bar : Symbol(Bar, Decl(unionTypeErrorMessageTypeRefs01.ts, 0, 26)) +>B : Symbol(B, Decl(unionTypeErrorMessageTypeRefs01.ts, 9, 1)) +>Baz : Symbol(Baz, Decl(unionTypeErrorMessageTypeRefs01.ts, 1, 26)) +>C : Symbol(C, Decl(unionTypeErrorMessageTypeRefs01.ts, 13, 1)) +>Kwah : Symbol(Kwah, Decl(unionTypeErrorMessageTypeRefs01.ts, 2, 26)) + +thingOfInterfaces = a; +>thingOfInterfaces : Symbol(thingOfInterfaces, Decl(unionTypeErrorMessageTypeRefs01.ts, 22, 11)) +>a : Symbol(a, Decl(unionTypeErrorMessageTypeRefs01.ts, 19, 13)) + +thingOfInterfaces = b; +>thingOfInterfaces : Symbol(thingOfInterfaces, Decl(unionTypeErrorMessageTypeRefs01.ts, 22, 11)) +>b : Symbol(b, Decl(unionTypeErrorMessageTypeRefs01.ts, 20, 13)) + +thingOfInterfaces = c; +>thingOfInterfaces : Symbol(thingOfInterfaces, Decl(unionTypeErrorMessageTypeRefs01.ts, 22, 11)) +>c : Symbol(c, Decl(unionTypeErrorMessageTypeRefs01.ts, 21, 13)) + +//////// + +type X = { +>X : Symbol(X, Decl(unionTypeErrorMessageTypeRefs01.ts, 26, 22)) +>T : Symbol(T, Decl(unionTypeErrorMessageTypeRefs01.ts, 30, 7)) + + xProp: T; +>xProp : Symbol(xProp, Decl(unionTypeErrorMessageTypeRefs01.ts, 30, 13)) +>T : Symbol(T, Decl(unionTypeErrorMessageTypeRefs01.ts, 30, 7)) +} + +type Y = { +>Y : Symbol(Y, Decl(unionTypeErrorMessageTypeRefs01.ts, 32, 1)) +>T : Symbol(T, Decl(unionTypeErrorMessageTypeRefs01.ts, 34, 7)) + + yProp: T; +>yProp : Symbol(yProp, Decl(unionTypeErrorMessageTypeRefs01.ts, 34, 13)) +>T : Symbol(T, Decl(unionTypeErrorMessageTypeRefs01.ts, 34, 7)) +} + +type Z = { +>Z : Symbol(Z, Decl(unionTypeErrorMessageTypeRefs01.ts, 36, 1)) +>T : Symbol(T, Decl(unionTypeErrorMessageTypeRefs01.ts, 38, 7)) + + zProp: T; +>zProp : Symbol(zProp, Decl(unionTypeErrorMessageTypeRefs01.ts, 38, 13)) +>T : Symbol(T, Decl(unionTypeErrorMessageTypeRefs01.ts, 38, 7)) +} + +declare const x: X; +>x : Symbol(x, Decl(unionTypeErrorMessageTypeRefs01.ts, 42, 13)) +>X : Symbol(X, Decl(unionTypeErrorMessageTypeRefs01.ts, 26, 22)) +>Foo : Symbol(Foo, Decl(unionTypeErrorMessageTypeRefs01.ts, 0, 0)) + +declare const y: Y; +>y : Symbol(y, Decl(unionTypeErrorMessageTypeRefs01.ts, 43, 13)) +>Y : Symbol(Y, Decl(unionTypeErrorMessageTypeRefs01.ts, 32, 1)) +>Foo : Symbol(Foo, Decl(unionTypeErrorMessageTypeRefs01.ts, 0, 0)) + +declare const z: Z; +>z : Symbol(z, Decl(unionTypeErrorMessageTypeRefs01.ts, 44, 13)) +>Z : Symbol(Z, Decl(unionTypeErrorMessageTypeRefs01.ts, 36, 1)) +>Foo : Symbol(Foo, Decl(unionTypeErrorMessageTypeRefs01.ts, 0, 0)) + +declare let thingOfTypeAliases: X | Y | Z; +>thingOfTypeAliases : Symbol(thingOfTypeAliases, Decl(unionTypeErrorMessageTypeRefs01.ts, 45, 11)) +>X : Symbol(X, Decl(unionTypeErrorMessageTypeRefs01.ts, 26, 22)) +>Bar : Symbol(Bar, Decl(unionTypeErrorMessageTypeRefs01.ts, 0, 26)) +>Y : Symbol(Y, Decl(unionTypeErrorMessageTypeRefs01.ts, 32, 1)) +>Baz : Symbol(Baz, Decl(unionTypeErrorMessageTypeRefs01.ts, 1, 26)) +>Z : Symbol(Z, Decl(unionTypeErrorMessageTypeRefs01.ts, 36, 1)) +>Kwah : Symbol(Kwah, Decl(unionTypeErrorMessageTypeRefs01.ts, 2, 26)) + +thingOfTypeAliases = x; +>thingOfTypeAliases : Symbol(thingOfTypeAliases, Decl(unionTypeErrorMessageTypeRefs01.ts, 45, 11)) +>x : Symbol(x, Decl(unionTypeErrorMessageTypeRefs01.ts, 42, 13)) + +thingOfTypeAliases = y; +>thingOfTypeAliases : Symbol(thingOfTypeAliases, Decl(unionTypeErrorMessageTypeRefs01.ts, 45, 11)) +>y : Symbol(y, Decl(unionTypeErrorMessageTypeRefs01.ts, 43, 13)) + +thingOfTypeAliases = z; +>thingOfTypeAliases : Symbol(thingOfTypeAliases, Decl(unionTypeErrorMessageTypeRefs01.ts, 45, 11)) +>z : Symbol(z, Decl(unionTypeErrorMessageTypeRefs01.ts, 44, 13)) + diff --git a/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.types b/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.types new file mode 100644 index 00000000000..7010519b559 --- /dev/null +++ b/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.types @@ -0,0 +1,153 @@ +=== tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts === +interface Foo { foo: any } +>Foo : Foo +>foo : any + +interface Bar { bar: any } +>Bar : Bar +>bar : any + +interface Baz { baz: any } +>Baz : Baz +>baz : any + +interface Kwah { kwah: any } +>Kwah : Kwah +>kwah : any + +//////// + +interface A { +>A : A +>T : T + + aProp: T; +>aProp : T +>T : T +} + +interface B { +>B : B +>T : T + + bProp: T; +>bProp : T +>T : T +} + +interface C { +>C : C +>T : T + + cProp: T; +>cProp : T +>T : T +} + +declare const a: A; +>a : A +>A : A +>Foo : Foo + +declare const b: B; +>b : B +>B : B +>Foo : Foo + +declare const c: C; +>c : C +>C : C +>Foo : Foo + +declare let thingOfInterfaces: A | B | C; +>thingOfInterfaces : A | B | C +>A : A +>Bar : Bar +>B : B +>Baz : Baz +>C : C +>Kwah : Kwah + +thingOfInterfaces = a; +>thingOfInterfaces = a : A +>thingOfInterfaces : A | B | C +>a : A + +thingOfInterfaces = b; +>thingOfInterfaces = b : B +>thingOfInterfaces : A | B | C +>b : B + +thingOfInterfaces = c; +>thingOfInterfaces = c : C +>thingOfInterfaces : A | B | C +>c : C + +//////// + +type X = { +>X : X +>T : T + + xProp: T; +>xProp : T +>T : T +} + +type Y = { +>Y : Y +>T : T + + yProp: T; +>yProp : T +>T : T +} + +type Z = { +>Z : Z +>T : T + + zProp: T; +>zProp : T +>T : T +} + +declare const x: X; +>x : X +>X : X +>Foo : Foo + +declare const y: Y; +>y : Y +>Y : Y +>Foo : Foo + +declare const z: Z; +>z : Z +>Z : Z +>Foo : Foo + +declare let thingOfTypeAliases: X | Y | Z; +>thingOfTypeAliases : X | Y | Z +>X : X +>Bar : Bar +>Y : Y +>Baz : Baz +>Z : Z +>Kwah : Kwah + +thingOfTypeAliases = x; +>thingOfTypeAliases = x : X +>thingOfTypeAliases : X | Y | Z +>x : X + +thingOfTypeAliases = y; +>thingOfTypeAliases = y : Y +>thingOfTypeAliases : X | Y | Z +>y : Y + +thingOfTypeAliases = z; +>thingOfTypeAliases = z : Z +>thingOfTypeAliases : X | Y | Z +>z : Z +