Skip to content

Commit b1a4cb4

Browse files
committed
Update test
1 parent 121c54a commit b1a4cb4

5 files changed

+95
-20
lines changed

Diff for: tests/baselines/reference/excessPropertyCheckWithMultipleDiscriminants.errors.txt

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tests/cases/compiler/excessPropertyCheckWithMultipleDiscriminants.ts(41,5): erro
44
Object literal may only specify known properties, and 'p3' does not exist in type '{ p1: "left"; p2: boolean; }'.
55
tests/cases/compiler/excessPropertyCheckWithMultipleDiscriminants.ts(49,5): error TS2322: Type '{ p1: "left"; p2: boolean; p3: number; p4: string; }' is not assignable to type 'DisjointDiscriminants'.
66
Object literal may only specify known properties, and 'p3' does not exist in type '{ p1: "left"; p2: boolean; }'.
7-
tests/cases/compiler/excessPropertyCheckWithMultipleDiscriminants.ts(57,5): error TS2322: Type '{ p1: "right"; p2: false; p3: number; p4: string; }' is not assignable to type 'DisjointDiscriminants'.
7+
tests/cases/compiler/excessPropertyCheckWithMultipleDiscriminants.ts(65,5): error TS2322: Type '{ p1: "right"; p2: false; p3: number; p4: string; }' is not assignable to type 'DisjointDiscriminants'.
88
Object literal may only specify known properties, and 'p3' does not exist in type '{ p1: "right"; p2: false; p4: string; }'.
99

1010

@@ -59,8 +59,8 @@ tests/cases/compiler/excessPropertyCheckWithMultipleDiscriminants.ts(57,5): erro
5959
p4: "hello"
6060
};
6161

62-
// This has no excess error because variant one and three are both applicable.
63-
const b: DisjointDiscriminants = {
62+
// This has excess error because variant three is the only applicable case.
63+
const b1: DisjointDiscriminants = {
6464
p1: 'left',
6565
p2: true,
6666
p3: 42,
@@ -70,6 +70,14 @@ tests/cases/compiler/excessPropertyCheckWithMultipleDiscriminants.ts(57,5): erro
7070
p4: "hello"
7171
};
7272

73+
// This has no excess error because variant one and three are both applicable.
74+
const b2: DisjointDiscriminants = {
75+
p1: 'left',
76+
p2: true as const,
77+
p3: 42,
78+
p4: "hello"
79+
};
80+
7381
// This has excess error because variant two is the only applicable case
7482
const c: DisjointDiscriminants = {
7583
p1: 'right',

Diff for: tests/baselines/reference/excessPropertyCheckWithMultipleDiscriminants.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,22 @@ const a: DisjointDiscriminants = {
4343
p4: "hello"
4444
};
4545

46-
// This has no excess error because variant one and three are both applicable.
47-
const b: DisjointDiscriminants = {
46+
// This has excess error because variant three is the only applicable case.
47+
const b1: DisjointDiscriminants = {
4848
p1: 'left',
4949
p2: true,
5050
p3: 42,
5151
p4: "hello"
5252
};
5353

54+
// This has no excess error because variant one and three are both applicable.
55+
const b2: DisjointDiscriminants = {
56+
p1: 'left',
57+
p2: true as const,
58+
p3: 42,
59+
p4: "hello"
60+
};
61+
5462
// This has excess error because variant two is the only applicable case
5563
const c: DisjointDiscriminants = {
5664
p1: 'right',
@@ -75,8 +83,15 @@ var a = {
7583
p3: 42,
7684
p4: "hello"
7785
};
86+
// This has excess error because variant three is the only applicable case.
87+
var b1 = {
88+
p1: 'left',
89+
p2: true,
90+
p3: 42,
91+
p4: "hello"
92+
};
7893
// This has no excess error because variant one and three are both applicable.
79-
var b = {
94+
var b2 = {
8095
p1: 'left',
8196
p2: true,
8297
p3: 42,

Diff for: tests/baselines/reference/excessPropertyCheckWithMultipleDiscriminants.symbols

+29-9
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ const a: DisjointDiscriminants = {
103103

104104
};
105105

106-
// This has no excess error because variant one and three are both applicable.
107-
const b: DisjointDiscriminants = {
108-
>b : Symbol(b, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 45, 5))
106+
// This has excess error because variant three is the only applicable case.
107+
const b1: DisjointDiscriminants = {
108+
>b1 : Symbol(b1, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 45, 5))
109109
>DisjointDiscriminants : Symbol(DisjointDiscriminants, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 31, 1))
110110

111111
p1: 'left',
112-
>p1 : Symbol(p1, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 45, 34))
112+
>p1 : Symbol(p1, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 45, 35))
113113

114114
p2: true,
115115
>p2 : Symbol(p2, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 46, 15))
@@ -122,22 +122,42 @@ const b: DisjointDiscriminants = {
122122

123123
};
124124

125+
// This has no excess error because variant one and three are both applicable.
126+
const b2: DisjointDiscriminants = {
127+
>b2 : Symbol(b2, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 53, 5))
128+
>DisjointDiscriminants : Symbol(DisjointDiscriminants, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 31, 1))
129+
130+
p1: 'left',
131+
>p1 : Symbol(p1, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 53, 35))
132+
133+
p2: true as const,
134+
>p2 : Symbol(p2, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 54, 15))
135+
>const : Symbol(const)
136+
137+
p3: 42,
138+
>p3 : Symbol(p3, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 55, 22))
139+
140+
p4: "hello"
141+
>p4 : Symbol(p4, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 56, 11))
142+
143+
};
144+
125145
// This has excess error because variant two is the only applicable case
126146
const c: DisjointDiscriminants = {
127-
>c : Symbol(c, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 53, 5))
147+
>c : Symbol(c, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 61, 5))
128148
>DisjointDiscriminants : Symbol(DisjointDiscriminants, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 31, 1))
129149

130150
p1: 'right',
131-
>p1 : Symbol(p1, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 53, 34))
151+
>p1 : Symbol(p1, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 61, 34))
132152

133153
p2: false,
134-
>p2 : Symbol(p2, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 54, 16))
154+
>p2 : Symbol(p2, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 62, 16))
135155

136156
p3: 42,
137-
>p3 : Symbol(p3, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 55, 14))
157+
>p3 : Symbol(p3, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 63, 14))
138158

139159
p4: "hello"
140-
>p4 : Symbol(p4, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 56, 11))
160+
>p4 : Symbol(p4, Decl(excessPropertyCheckWithMultipleDiscriminants.ts, 64, 11))
141161

142162
};
143163

Diff for: tests/baselines/reference/excessPropertyCheckWithMultipleDiscriminants.types

+27-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ const a: DisjointDiscriminants = {
9393

9494
};
9595

96-
// This has no excess error because variant one and three are both applicable.
97-
const b: DisjointDiscriminants = {
98-
>b : DisjointDiscriminants
96+
// This has excess error because variant three is the only applicable case.
97+
const b1: DisjointDiscriminants = {
98+
>b1 : DisjointDiscriminants
9999
>{ p1: 'left', p2: true, p3: 42, p4: "hello"} : { p1: "left"; p2: boolean; p3: number; p4: string; }
100100

101101
p1: 'left',
@@ -116,6 +116,30 @@ const b: DisjointDiscriminants = {
116116

117117
};
118118

119+
// This has no excess error because variant one and three are both applicable.
120+
const b2: DisjointDiscriminants = {
121+
>b2 : DisjointDiscriminants
122+
>{ p1: 'left', p2: true as const, p3: 42, p4: "hello"} : { p1: "left"; p2: true; p3: number; p4: string; }
123+
124+
p1: 'left',
125+
>p1 : "left"
126+
>'left' : "left"
127+
128+
p2: true as const,
129+
>p2 : true
130+
>true as const : true
131+
>true : true
132+
133+
p3: 42,
134+
>p3 : number
135+
>42 : 42
136+
137+
p4: "hello"
138+
>p4 : string
139+
>"hello" : "hello"
140+
141+
};
142+
119143
// This has excess error because variant two is the only applicable case
120144
const c: DisjointDiscriminants = {
121145
>c : DisjointDiscriminants

Diff for: tests/cases/compiler/excessPropertyCheckWithMultipleDiscriminants.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,22 @@ const a: DisjointDiscriminants = {
4242
p4: "hello"
4343
};
4444

45-
// This has no excess error because variant one and three are both applicable.
46-
const b: DisjointDiscriminants = {
45+
// This has excess error because variant three is the only applicable case.
46+
const b1: DisjointDiscriminants = {
4747
p1: 'left',
4848
p2: true,
4949
p3: 42,
5050
p4: "hello"
5151
};
5252

53+
// This has no excess error because variant one and three are both applicable.
54+
const b2: DisjointDiscriminants = {
55+
p1: 'left',
56+
p2: true as const,
57+
p3: 42,
58+
p4: "hello"
59+
};
60+
5361
// This has excess error because variant two is the only applicable case
5462
const c: DisjointDiscriminants = {
5563
p1: 'right',

0 commit comments

Comments
 (0)