diff --git a/tests/baselines/reference/errorMessagesIntersectionTypes03.errors.txt b/tests/baselines/reference/errorMessagesIntersectionTypes03.errors.txt new file mode 100644 index 00000000000..87b2020a421 --- /dev/null +++ b/tests/baselines/reference/errorMessagesIntersectionTypes03.errors.txt @@ -0,0 +1,52 @@ +tests/cases/compiler/errorMessagesIntersectionTypes03.ts(17,5): error TS2322: Type 'A & B' is not assignable to type 'T'. + Type 'B' is not assignable to type 'T'. +tests/cases/compiler/errorMessagesIntersectionTypes03.ts(18,5): error TS2322: Type 'A & B' is not assignable to type 'U'. + Type 'B' is not assignable to type 'U'. +tests/cases/compiler/errorMessagesIntersectionTypes03.ts(19,5): error TS2322: Type 'A & B' is not assignable to type 'V'. + Type 'B' is not assignable to type 'V'. +tests/cases/compiler/errorMessagesIntersectionTypes03.ts(22,5): error TS2322: Type 'T & B' is not assignable to type 'U'. + Type 'B' is not assignable to type 'U'. +tests/cases/compiler/errorMessagesIntersectionTypes03.ts(23,5): error TS2322: Type 'T & B' is not assignable to type 'V'. + Type 'B' is not assignable to type 'V'. + + +==== tests/cases/compiler/errorMessagesIntersectionTypes03.ts (5 errors) ==== + interface A { + a; + } + + interface B { + b; + } + + function f(): void { + let t: T; + let u: U; + let v: V; + + let a_and_b: A & B; + let t_and_b: T & B; + + t = a_and_b; + ~ +!!! error TS2322: Type 'A & B' is not assignable to type 'T'. +!!! error TS2322: Type 'B' is not assignable to type 'T'. + u = a_and_b; + ~ +!!! error TS2322: Type 'A & B' is not assignable to type 'U'. +!!! error TS2322: Type 'B' is not assignable to type 'U'. + v = a_and_b; + ~ +!!! error TS2322: Type 'A & B' is not assignable to type 'V'. +!!! error TS2322: Type 'B' is not assignable to type 'V'. + + t = t_and_b; + u = t_and_b; + ~ +!!! error TS2322: Type 'T & B' is not assignable to type 'U'. +!!! error TS2322: Type 'B' is not assignable to type 'U'. + v = t_and_b; + ~ +!!! error TS2322: Type 'T & B' is not assignable to type 'V'. +!!! error TS2322: Type 'B' is not assignable to type 'V'. + } \ No newline at end of file diff --git a/tests/baselines/reference/errorMessagesIntersectionTypes03.js b/tests/baselines/reference/errorMessagesIntersectionTypes03.js new file mode 100644 index 00000000000..278b81a329a --- /dev/null +++ b/tests/baselines/reference/errorMessagesIntersectionTypes03.js @@ -0,0 +1,40 @@ +//// [errorMessagesIntersectionTypes03.ts] +interface A { + a; +} + +interface B { + b; +} + +function f(): void { + let t: T; + let u: U; + let v: V; + + let a_and_b: A & B; + let t_and_b: T & B; + + t = a_and_b; + u = a_and_b; + v = a_and_b; + + t = t_and_b; + u = t_and_b; + v = t_and_b; +} + +//// [errorMessagesIntersectionTypes03.js] +function f() { + var t; + var u; + var v; + var a_and_b; + var t_and_b; + t = a_and_b; + u = a_and_b; + v = a_and_b; + t = t_and_b; + u = t_and_b; + v = t_and_b; +} diff --git a/tests/baselines/reference/errorMessagesIntersectionTypes04.errors.txt b/tests/baselines/reference/errorMessagesIntersectionTypes04.errors.txt new file mode 100644 index 00000000000..c413c3b2219 --- /dev/null +++ b/tests/baselines/reference/errorMessagesIntersectionTypes04.errors.txt @@ -0,0 +1,45 @@ +tests/cases/compiler/errorMessagesIntersectionTypes04.ts(17,5): error TS2322: Type 'A & B' is not assignable to type 'number'. + Type 'B' is not assignable to type 'number'. +tests/cases/compiler/errorMessagesIntersectionTypes04.ts(18,5): error TS2322: Type 'A & B' is not assignable to type 'boolean'. + Type 'B' is not assignable to type 'boolean'. +tests/cases/compiler/errorMessagesIntersectionTypes04.ts(19,5): error TS2322: Type 'A & B' is not assignable to type 'string'. + Type 'B' is not assignable to type 'string'. +tests/cases/compiler/errorMessagesIntersectionTypes04.ts(21,5): error TS2322: Type 'number & boolean' is not assignable to type 'string'. + Type 'boolean' is not assignable to type 'string'. + + +==== tests/cases/compiler/errorMessagesIntersectionTypes04.ts (4 errors) ==== + interface A { + a; + } + + interface B { + b; + } + + function f(): void { + let num: number; + let bool: boolean; + let str: string; + + let a_and_b: A & B; + let num_and_bool: number & boolean; + + num = a_and_b; + ~~~ +!!! error TS2322: Type 'A & B' is not assignable to type 'number'. +!!! error TS2322: Type 'B' is not assignable to type 'number'. + bool = a_and_b; + ~~~~ +!!! error TS2322: Type 'A & B' is not assignable to type 'boolean'. +!!! error TS2322: Type 'B' is not assignable to type 'boolean'. + str = a_and_b; + ~~~ +!!! error TS2322: Type 'A & B' is not assignable to type 'string'. +!!! error TS2322: Type 'B' is not assignable to type 'string'. + + str = num_and_bool; + ~~~ +!!! error TS2322: Type 'number & boolean' is not assignable to type 'string'. +!!! error TS2322: Type 'boolean' is not assignable to type 'string'. + } \ No newline at end of file diff --git a/tests/baselines/reference/errorMessagesIntersectionTypes04.js b/tests/baselines/reference/errorMessagesIntersectionTypes04.js new file mode 100644 index 00000000000..f663e1a7907 --- /dev/null +++ b/tests/baselines/reference/errorMessagesIntersectionTypes04.js @@ -0,0 +1,36 @@ +//// [errorMessagesIntersectionTypes04.ts] +interface A { + a; +} + +interface B { + b; +} + +function f(): void { + let num: number; + let bool: boolean; + let str: string; + + let a_and_b: A & B; + let num_and_bool: number & boolean; + + num = a_and_b; + bool = a_and_b; + str = a_and_b; + + str = num_and_bool; +} + +//// [errorMessagesIntersectionTypes04.js] +function f() { + var num; + var bool; + var str; + var a_and_b; + var num_and_bool; + num = a_and_b; + bool = a_and_b; + str = a_and_b; + str = num_and_bool; +}