Skip to content

Commit 6e022bd

Browse files
committed
Accept new baselines
1 parent e7bb562 commit 6e022bd

File tree

4 files changed

+192
-7
lines changed

4 files changed

+192
-7
lines changed

tests/baselines/reference/objectLiteralExcessProperties.errors.txt

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
tests/cases/compiler/objectLiteralExcessProperties.ts(9,18): error TS2322: Type '{ forword: string; }' is not assignable to type 'Book'.
22
Object literal may only specify known properties, but 'forword' does not exist in type 'Book'. Did you mean to write 'foreword'?
33
tests/cases/compiler/objectLiteralExcessProperties.ts(11,27): error TS2322: Type '{ foreward: string; }' is not assignable to type 'string | Book'.
4-
Object literal may only specify known properties, and 'foreward' does not exist in type 'string | Book'.
4+
Object literal may only specify known properties, but 'foreward' does not exist in type 'Book'. Did you mean to write 'foreword'?
55
tests/cases/compiler/objectLiteralExcessProperties.ts(13,53): error TS2322: Type '({ foreword: string; } | { forwards: string; })[]' is not assignable to type 'Book | Book[]'.
66
Type '({ foreword: string; } | { forwards: string; })[]' is not assignable to type 'Book[]'.
77
Type '{ foreword: string; } | { forwards: string; }' is not assignable to type 'Book'.
@@ -13,17 +13,27 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(17,26): error TS2322: Type
1313
Object literal may only specify known properties, but 'foreward' does not exist in type 'Book & Cover'. Did you mean to write 'foreword'?
1414
tests/cases/compiler/objectLiteralExcessProperties.ts(19,57): error TS2322: Type '{ foreword: string; color: string; price: number; }' is not assignable to type 'Book & Cover'.
1515
Object literal may only specify known properties, and 'price' does not exist in type 'Book & Cover'.
16-
tests/cases/compiler/objectLiteralExcessProperties.ts(21,43): error TS2322: Type '{ foreword: string; price: number; }' is not assignable to type 'Book & number'.
17-
Object literal may only specify known properties, and 'price' does not exist in type 'Book & number'.
16+
tests/cases/compiler/objectLiteralExcessProperties.ts(21,5): error TS2322: Type '{ foreword: string; price: number; }' is not assignable to type 'Book & number'.
17+
Type '{ foreword: string; price: number; }' is not assignable to type 'number'.
1818
tests/cases/compiler/objectLiteralExcessProperties.ts(23,29): error TS2322: Type '{ couleur: string; }' is not assignable to type 'Cover | Cover[]'.
1919
Object literal may only specify known properties, and 'couleur' does not exist in type 'Cover | Cover[]'.
2020
tests/cases/compiler/objectLiteralExcessProperties.ts(25,27): error TS2322: Type '{ forewarned: string; }' is not assignable to type 'Book | Book[]'.
2121
Object literal may only specify known properties, and 'forewarned' does not exist in type 'Book | Book[]'.
2222
tests/cases/compiler/objectLiteralExcessProperties.ts(33,27): error TS2322: Type '{ colour: string; }' is not assignable to type 'Cover'.
2323
Object literal may only specify known properties, but 'colour' does not exist in type 'Cover'. Did you mean to write 'color'?
24+
tests/cases/compiler/objectLiteralExcessProperties.ts(37,25): error TS2304: Cannot find name 'IFoo'.
25+
tests/cases/compiler/objectLiteralExcessProperties.ts(39,11): error TS2322: Type '{ name: string; }' is not assignable to type 'T'.
26+
tests/cases/compiler/objectLiteralExcessProperties.ts(41,11): error TS2322: Type '{ name: string; prop: boolean; }' is not assignable to type 'T & { prop: boolean; }'.
27+
Type '{ name: string; prop: boolean; }' is not assignable to type 'T'.
28+
tests/cases/compiler/objectLiteralExcessProperties.ts(43,43): error TS2322: Type '{ name: string; prop: boolean; }' is not assignable to type 'T | { prop: boolean; }'.
29+
Object literal may only specify known properties, and 'name' does not exist in type '{ prop: boolean; }'.
30+
tests/cases/compiler/objectLiteralExcessProperties.ts(45,76): error TS2322: Type '{ name: string; prop: boolean; }' is not assignable to type '{ name: string; } | (T & { prop: boolean; })'.
31+
Object literal may only specify known properties, and 'prop' does not exist in type '{ name: string; }'.
32+
tests/cases/compiler/objectLiteralExcessProperties.ts(49,44): error TS2322: Type '{ z: string; }' is not assignable to type 'object & { x: string; }'.
33+
Object literal may only specify known properties, and 'z' does not exist in type 'object & { x: string; }'.
2434

2535

26-
==== tests/cases/compiler/objectLiteralExcessProperties.ts (10 errors) ====
36+
==== tests/cases/compiler/objectLiteralExcessProperties.ts (16 errors) ====
2737
interface Book {
2838
foreword: string;
2939
}
@@ -40,7 +50,7 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(33,27): error TS2322: Type
4050
var b2: Book | string = { foreward: "nope" };
4151
~~~~~~~~~~~~~~~~
4252
!!! error TS2322: Type '{ foreward: string; }' is not assignable to type 'string | Book'.
43-
!!! error TS2322: Object literal may only specify known properties, and 'foreward' does not exist in type 'string | Book'.
53+
!!! error TS2322: Object literal may only specify known properties, but 'foreward' does not exist in type 'Book'. Did you mean to write 'foreword'?
4454

4555
var b3: Book | (Book[]) = [{ foreword: "hello" }, { forwards: "back" }];
4656
~~~~~~~~~~~~~~~~
@@ -66,9 +76,9 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(33,27): error TS2322: Type
6676
!!! error TS2322: Object literal may only specify known properties, and 'price' does not exist in type 'Book & Cover'.
6777

6878
var b7: Book & number = { foreword: "hi", price: 10.99 };
69-
~~~~~~~~~~~~
79+
~~
7080
!!! error TS2322: Type '{ foreword: string; price: number; }' is not assignable to type 'Book & number'.
71-
!!! error TS2322: Object literal may only specify known properties, and 'price' does not exist in type 'Book & number'.
81+
!!! error TS2322: Type '{ foreword: string; price: number; }' is not assignable to type 'number'.
7282

7383
var b8: Cover | Cover[] = { couleur : "non" };
7484
~~~~~~~~~~~~~~~
@@ -91,4 +101,37 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(33,27): error TS2322: Type
91101
!!! error TS2322: Type '{ colour: string; }' is not assignable to type 'Cover'.
92102
!!! error TS2322: Object literal may only specify known properties, but 'colour' does not exist in type 'Cover'. Did you mean to write 'color'?
93103
!!! related TS6501 tests/cases/compiler/objectLiteralExcessProperties.ts:28:5: The expected type comes from this index signature.
104+
105+
// Repros inspired by #28752
106+
107+
function test<T extends IFoo>() {
108+
~~~~
109+
!!! error TS2304: Cannot find name 'IFoo'.
110+
// No excess property checks on generic types
111+
const obj1: T = { name: "test" };
112+
~~~~
113+
!!! error TS2322: Type '{ name: string; }' is not assignable to type 'T'.
114+
// No excess property checks on intersections involving generics
115+
const obj2: T & { prop: boolean } = { name: "test", prop: true };
116+
~~~~
117+
!!! error TS2322: Type '{ name: string; prop: boolean; }' is not assignable to type 'T & { prop: boolean; }'.
118+
!!! error TS2322: Type '{ name: string; prop: boolean; }' is not assignable to type 'T'.
119+
// Excess property checks only on non-generic parts of unions
120+
const obj3: T | { prop: boolean } = { name: "test", prop: true };
121+
~~~~~~~~~~~~
122+
!!! error TS2322: Type '{ name: string; prop: boolean; }' is not assignable to type 'T | { prop: boolean; }'.
123+
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ prop: boolean; }'.
124+
// Excess property checks only on non-generic parts of unions
125+
const obj4: T & { prop: boolean } | { name: string } = { name: "test", prop: true };
126+
~~~~~~~~~~
127+
!!! error TS2322: Type '{ name: string; prop: boolean; }' is not assignable to type '{ name: string; } | (T & { prop: boolean; })'.
128+
!!! error TS2322: Object literal may only specify known properties, and 'prop' does not exist in type '{ name: string; }'.
129+
// No excess property checks when union includes 'object' type
130+
const obj5: object | { x: string } = { z: 'abc' }
131+
// The 'object' type has no effect on intersections
132+
const obj6: object & { x: string } = { z: 'abc' }
133+
~~~~~~~~
134+
!!! error TS2322: Type '{ z: string; }' is not assignable to type 'object & { x: string; }'.
135+
!!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type 'object & { x: string; }'.
136+
}
94137

tests/baselines/reference/objectLiteralExcessProperties.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ interface Indexed {
3232
var b10: Indexed = { 0: { }, '1': { } }; // ok
3333

3434
var b11: Indexed = { 0: { colour: "blue" } }; // nested object literal still errors
35+
36+
// Repros inspired by #28752
37+
38+
function test<T extends IFoo>() {
39+
// No excess property checks on generic types
40+
const obj1: T = { name: "test" };
41+
// No excess property checks on intersections involving generics
42+
const obj2: T & { prop: boolean } = { name: "test", prop: true };
43+
// Excess property checks only on non-generic parts of unions
44+
const obj3: T | { prop: boolean } = { name: "test", prop: true };
45+
// Excess property checks only on non-generic parts of unions
46+
const obj4: T & { prop: boolean } | { name: string } = { name: "test", prop: true };
47+
// No excess property checks when union includes 'object' type
48+
const obj5: object | { x: string } = { z: 'abc' }
49+
// The 'object' type has no effect on intersections
50+
const obj6: object & { x: string } = { z: 'abc' }
51+
}
3552

3653

3754
//// [objectLiteralExcessProperties.js]
@@ -46,3 +63,18 @@ var b8 = { couleur: "non" };
4663
var b9 = { forewarned: "still no" };
4764
var b10 = { 0: {}, '1': {} }; // ok
4865
var b11 = { 0: { colour: "blue" } }; // nested object literal still errors
66+
// Repros inspired by #28752
67+
function test() {
68+
// No excess property checks on generic types
69+
var obj1 = { name: "test" };
70+
// No excess property checks on intersections involving generics
71+
var obj2 = { name: "test", prop: true };
72+
// Excess property checks only on non-generic parts of unions
73+
var obj3 = { name: "test", prop: true };
74+
// Excess property checks only on non-generic parts of unions
75+
var obj4 = { name: "test", prop: true };
76+
// No excess property checks when union includes 'object' type
77+
var obj5 = { z: 'abc' };
78+
// The 'object' type has no effect on intersections
79+
var obj6 = { z: 'abc' };
80+
}

tests/baselines/reference/objectLiteralExcessProperties.symbols

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,53 @@ var b11: Indexed = { 0: { colour: "blue" } }; // nested object literal still err
9090
>0 : Symbol(0, Decl(objectLiteralExcessProperties.ts, 32, 20))
9191
>colour : Symbol(colour, Decl(objectLiteralExcessProperties.ts, 32, 25))
9292

93+
// Repros inspired by #28752
94+
95+
function test<T extends IFoo>() {
96+
>test : Symbol(test, Decl(objectLiteralExcessProperties.ts, 32, 45))
97+
>T : Symbol(T, Decl(objectLiteralExcessProperties.ts, 36, 14))
98+
99+
// No excess property checks on generic types
100+
const obj1: T = { name: "test" };
101+
>obj1 : Symbol(obj1, Decl(objectLiteralExcessProperties.ts, 38, 9))
102+
>T : Symbol(T, Decl(objectLiteralExcessProperties.ts, 36, 14))
103+
>name : Symbol(name, Decl(objectLiteralExcessProperties.ts, 38, 21))
104+
105+
// No excess property checks on intersections involving generics
106+
const obj2: T & { prop: boolean } = { name: "test", prop: true };
107+
>obj2 : Symbol(obj2, Decl(objectLiteralExcessProperties.ts, 40, 9))
108+
>T : Symbol(T, Decl(objectLiteralExcessProperties.ts, 36, 14))
109+
>prop : Symbol(prop, Decl(objectLiteralExcessProperties.ts, 40, 21))
110+
>name : Symbol(name, Decl(objectLiteralExcessProperties.ts, 40, 41))
111+
>prop : Symbol(prop, Decl(objectLiteralExcessProperties.ts, 40, 55))
112+
113+
// Excess property checks only on non-generic parts of unions
114+
const obj3: T | { prop: boolean } = { name: "test", prop: true };
115+
>obj3 : Symbol(obj3, Decl(objectLiteralExcessProperties.ts, 42, 9))
116+
>T : Symbol(T, Decl(objectLiteralExcessProperties.ts, 36, 14))
117+
>prop : Symbol(prop, Decl(objectLiteralExcessProperties.ts, 42, 21))
118+
>name : Symbol(name, Decl(objectLiteralExcessProperties.ts, 42, 41))
119+
>prop : Symbol(prop, Decl(objectLiteralExcessProperties.ts, 42, 55))
120+
121+
// Excess property checks only on non-generic parts of unions
122+
const obj4: T & { prop: boolean } | { name: string } = { name: "test", prop: true };
123+
>obj4 : Symbol(obj4, Decl(objectLiteralExcessProperties.ts, 44, 9))
124+
>T : Symbol(T, Decl(objectLiteralExcessProperties.ts, 36, 14))
125+
>prop : Symbol(prop, Decl(objectLiteralExcessProperties.ts, 44, 21))
126+
>name : Symbol(name, Decl(objectLiteralExcessProperties.ts, 44, 41))
127+
>name : Symbol(name, Decl(objectLiteralExcessProperties.ts, 44, 60))
128+
>prop : Symbol(prop, Decl(objectLiteralExcessProperties.ts, 44, 74))
129+
130+
// No excess property checks when union includes 'object' type
131+
const obj5: object | { x: string } = { z: 'abc' }
132+
>obj5 : Symbol(obj5, Decl(objectLiteralExcessProperties.ts, 46, 9))
133+
>x : Symbol(x, Decl(objectLiteralExcessProperties.ts, 46, 26))
134+
>z : Symbol(z, Decl(objectLiteralExcessProperties.ts, 46, 42))
135+
136+
// The 'object' type has no effect on intersections
137+
const obj6: object & { x: string } = { z: 'abc' }
138+
>obj6 : Symbol(obj6, Decl(objectLiteralExcessProperties.ts, 48, 9))
139+
>x : Symbol(x, Decl(objectLiteralExcessProperties.ts, 48, 26))
140+
>z : Symbol(z, Decl(objectLiteralExcessProperties.ts, 48, 42))
141+
}
142+

tests/baselines/reference/objectLiteralExcessProperties.types

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,63 @@ var b11: Indexed = { 0: { colour: "blue" } }; // nested object literal still err
9898
>colour : string
9999
>"blue" : "blue"
100100

101+
// Repros inspired by #28752
102+
103+
function test<T extends IFoo>() {
104+
>test : <T extends any>() => void
105+
106+
// No excess property checks on generic types
107+
const obj1: T = { name: "test" };
108+
>obj1 : T
109+
>{ name: "test" } : { name: string; }
110+
>name : string
111+
>"test" : "test"
112+
113+
// No excess property checks on intersections involving generics
114+
const obj2: T & { prop: boolean } = { name: "test", prop: true };
115+
>obj2 : T & { prop: boolean; }
116+
>prop : boolean
117+
>{ name: "test", prop: true } : { name: string; prop: boolean; }
118+
>name : string
119+
>"test" : "test"
120+
>prop : boolean
121+
>true : true
122+
123+
// Excess property checks only on non-generic parts of unions
124+
const obj3: T | { prop: boolean } = { name: "test", prop: true };
125+
>obj3 : T | { prop: boolean; }
126+
>prop : boolean
127+
>{ name: "test", prop: true } : { name: string; prop: boolean; }
128+
>name : string
129+
>"test" : "test"
130+
>prop : boolean
131+
>true : true
132+
133+
// Excess property checks only on non-generic parts of unions
134+
const obj4: T & { prop: boolean } | { name: string } = { name: "test", prop: true };
135+
>obj4 : { name: string; } | (T & { prop: boolean; })
136+
>prop : boolean
137+
>name : string
138+
>{ name: "test", prop: true } : { name: string; prop: boolean; }
139+
>name : string
140+
>"test" : "test"
141+
>prop : boolean
142+
>true : true
143+
144+
// No excess property checks when union includes 'object' type
145+
const obj5: object | { x: string } = { z: 'abc' }
146+
>obj5 : object | { x: string; }
147+
>x : string
148+
>{ z: 'abc' } : { z: string; }
149+
>z : string
150+
>'abc' : "abc"
151+
152+
// The 'object' type has no effect on intersections
153+
const obj6: object & { x: string } = { z: 'abc' }
154+
>obj6 : object & { x: string; }
155+
>x : string
156+
>{ z: 'abc' } : { z: string; }
157+
>z : string
158+
>'abc' : "abc"
159+
}
160+

0 commit comments

Comments
 (0)