diff --git a/tests/baselines/reference/objectLiteralsAgainstUnionsOfArrays01.errors.txt b/tests/baselines/reference/objectLiteralsAgainstUnionsOfArrays01.errors.txt new file mode 100644 index 00000000000..bba6e3906e0 --- /dev/null +++ b/tests/baselines/reference/objectLiteralsAgainstUnionsOfArrays01.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/objectLiteralsAgainstUnionsOfArrays01.ts(9,5): error TS2322: Type '{ bar: { prop: number; }; }[]' is not assignable to type 'Foo[]'. + Type '{ bar: { prop: number; }; }' is not assignable to type 'Foo'. + Types of property 'bar' are incompatible. + Type '{ prop: number; }' is not assignable to type 'Bar | Bar[]'. + Type '{ prop: number; }' is not assignable to type 'Bar[]'. + Property 'length' is missing in type '{ prop: number; }'. + + +==== tests/cases/compiler/objectLiteralsAgainstUnionsOfArrays01.ts (1 errors) ==== + interface Foo { + bar: Bar | Bar[]; + } + + interface Bar { + prop: string; + } + + let x: Foo[] = [ + ~ +!!! error TS2322: Type '{ bar: { prop: number; }; }[]' is not assignable to type 'Foo[]'. +!!! error TS2322: Type '{ bar: { prop: number; }; }' is not assignable to type 'Foo'. +!!! error TS2322: Types of property 'bar' are incompatible. +!!! error TS2322: Type '{ prop: number; }' is not assignable to type 'Bar | Bar[]'. +!!! error TS2322: Type '{ prop: number; }' is not assignable to type 'Bar[]'. +!!! error TS2322: Property 'length' is missing in type '{ prop: number; }'. + { bar: { prop: 100 } } + ] + \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralsAgainstUnionsOfArrays01.js b/tests/baselines/reference/objectLiteralsAgainstUnionsOfArrays01.js new file mode 100644 index 00000000000..d7fbddd5cce --- /dev/null +++ b/tests/baselines/reference/objectLiteralsAgainstUnionsOfArrays01.js @@ -0,0 +1,18 @@ +//// [objectLiteralsAgainstUnionsOfArrays01.ts] +interface Foo { + bar: Bar | Bar[]; +} + +interface Bar { + prop: string; +} + +let x: Foo[] = [ + { bar: { prop: 100 } } +] + + +//// [objectLiteralsAgainstUnionsOfArrays01.js] +var x = [ + { bar: { prop: 100 } } +]; diff --git a/tests/baselines/reference/objectLiteralsAgainstUnionsOfArrays01.symbols b/tests/baselines/reference/objectLiteralsAgainstUnionsOfArrays01.symbols new file mode 100644 index 00000000000..248824334f0 --- /dev/null +++ b/tests/baselines/reference/objectLiteralsAgainstUnionsOfArrays01.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/objectLiteralsAgainstUnionsOfArrays01.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(objectLiteralsAgainstUnionsOfArrays01.ts, 0, 0)) + + bar: Bar | Bar[]; +>bar : Symbol(Foo.bar, Decl(objectLiteralsAgainstUnionsOfArrays01.ts, 0, 15)) +>Bar : Symbol(Bar, Decl(objectLiteralsAgainstUnionsOfArrays01.ts, 2, 1)) +>Bar : Symbol(Bar, Decl(objectLiteralsAgainstUnionsOfArrays01.ts, 2, 1)) +} + +interface Bar { +>Bar : Symbol(Bar, Decl(objectLiteralsAgainstUnionsOfArrays01.ts, 2, 1)) + + prop: string; +>prop : Symbol(Bar.prop, Decl(objectLiteralsAgainstUnionsOfArrays01.ts, 4, 15)) +} + +let x: Foo[] = [ +>x : Symbol(x, Decl(objectLiteralsAgainstUnionsOfArrays01.ts, 8, 3)) +>Foo : Symbol(Foo, Decl(objectLiteralsAgainstUnionsOfArrays01.ts, 0, 0)) + + { bar: { prop: 100 } } +>bar : Symbol(bar, Decl(objectLiteralsAgainstUnionsOfArrays01.ts, 9, 3)) +>prop : Symbol(prop, Decl(objectLiteralsAgainstUnionsOfArrays01.ts, 9, 10)) + +] + diff --git a/tests/baselines/reference/objectLiteralsAgainstUnionsOfArrays01.types b/tests/baselines/reference/objectLiteralsAgainstUnionsOfArrays01.types new file mode 100644 index 00000000000..6c841fdd3f2 --- /dev/null +++ b/tests/baselines/reference/objectLiteralsAgainstUnionsOfArrays01.types @@ -0,0 +1,31 @@ +=== tests/cases/compiler/objectLiteralsAgainstUnionsOfArrays01.ts === +interface Foo { +>Foo : Foo + + bar: Bar | Bar[]; +>bar : Bar | Bar[] +>Bar : Bar +>Bar : Bar +} + +interface Bar { +>Bar : Bar + + prop: string; +>prop : string +} + +let x: Foo[] = [ +>x : Foo[] +>Foo : Foo +>[ { bar: { prop: 100 } }] : { bar: { prop: number; }; }[] + + { bar: { prop: 100 } } +>{ bar: { prop: 100 } } : { bar: { prop: number; }; } +>bar : { prop: number; } +>{ prop: 100 } : { prop: number; } +>prop : number +>100 : 100 + +] +