Skip to content

Commit 7582b1b

Browse files
authored
fix(45799): skip checking arguments used as a key in object literals (microsoft#45814)
1 parent b1f39a7 commit 7582b1b

6 files changed

+226
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12581,7 +12581,7 @@ namespace ts {
1258112581
if (!node) return false;
1258212582
switch (node.kind) {
1258312583
case SyntaxKind.Identifier:
12584-
return (node as Identifier).escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node as Identifier) === argumentsSymbol;
12584+
return (node as Identifier).escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node as Identifier) === argumentsSymbol;
1258512585

1258612586
case SyntaxKind.PropertyDeclaration:
1258712587
case SyntaxKind.MethodDeclaration:
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/a.js(16,9): error TS18004: No value exists in scope for the shorthand property 'arguments'. Either declare one or provide an initializer.
2+
3+
4+
==== /a.js (1 errors) ====
5+
const a = () => {
6+
return {
7+
arguments: [],
8+
};
9+
};
10+
11+
const b = () => {
12+
const c = {
13+
arguments: [],
14+
}
15+
return c;
16+
};
17+
18+
const c = () => {
19+
return {
20+
arguments,
21+
~~~~~~~~~
22+
!!! error TS18004: No value exists in scope for the shorthand property 'arguments'. Either declare one or provide an initializer.
23+
};
24+
}
25+
26+
const d = () => {
27+
const arguments = undefined;
28+
return {
29+
arguments,
30+
};
31+
}
32+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//// [a.js]
2+
const a = () => {
3+
return {
4+
arguments: [],
5+
};
6+
};
7+
8+
const b = () => {
9+
const c = {
10+
arguments: [],
11+
}
12+
return c;
13+
};
14+
15+
const c = () => {
16+
return {
17+
arguments,
18+
};
19+
}
20+
21+
const d = () => {
22+
const arguments = undefined;
23+
return {
24+
arguments,
25+
};
26+
}
27+
28+
29+
//// [a.js]
30+
const a = () => {
31+
return {
32+
arguments: [],
33+
};
34+
};
35+
const b = () => {
36+
const c = {
37+
arguments: [],
38+
};
39+
return c;
40+
};
41+
const c = () => {
42+
return {
43+
arguments,
44+
};
45+
};
46+
const d = () => {
47+
const arguments = undefined;
48+
return {
49+
arguments,
50+
};
51+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
=== /a.js ===
2+
const a = () => {
3+
>a : Symbol(a, Decl(a.js, 0, 5))
4+
5+
return {
6+
arguments: [],
7+
>arguments : Symbol(arguments, Decl(a.js, 1, 12))
8+
9+
};
10+
};
11+
12+
const b = () => {
13+
>b : Symbol(b, Decl(a.js, 6, 5))
14+
15+
const c = {
16+
>c : Symbol(c, Decl(a.js, 7, 9))
17+
18+
arguments: [],
19+
>arguments : Symbol(arguments, Decl(a.js, 7, 15))
20+
}
21+
return c;
22+
>c : Symbol(c, Decl(a.js, 7, 9))
23+
24+
};
25+
26+
const c = () => {
27+
>c : Symbol(c, Decl(a.js, 13, 5))
28+
29+
return {
30+
arguments,
31+
>arguments : Symbol(arguments, Decl(a.js, 14, 12))
32+
33+
};
34+
}
35+
36+
const d = () => {
37+
>d : Symbol(d, Decl(a.js, 19, 5))
38+
39+
const arguments = undefined;
40+
>arguments : Symbol(arguments, Decl(a.js, 20, 9))
41+
>undefined : Symbol(undefined)
42+
43+
return {
44+
arguments,
45+
>arguments : Symbol(arguments, Decl(a.js, 21, 12))
46+
47+
};
48+
}
49+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
=== /a.js ===
2+
const a = () => {
3+
>a : () => { arguments: any[]; }
4+
>() => { return { arguments: [], };} : () => { arguments: any[]; }
5+
6+
return {
7+
>{ arguments: [], } : { arguments: undefined[]; }
8+
9+
arguments: [],
10+
>arguments : undefined[]
11+
>[] : undefined[]
12+
13+
};
14+
};
15+
16+
const b = () => {
17+
>b : () => { arguments: any[]; }
18+
>() => { const c = { arguments: [], } return c;} : () => { arguments: any[]; }
19+
20+
const c = {
21+
>c : { arguments: any[]; }
22+
>{ arguments: [], } : { arguments: undefined[]; }
23+
24+
arguments: [],
25+
>arguments : undefined[]
26+
>[] : undefined[]
27+
}
28+
return c;
29+
>c : { arguments: any[]; }
30+
31+
};
32+
33+
const c = () => {
34+
>c : () => { arguments: any; }
35+
>() => { return { arguments, };} : () => { arguments: any; }
36+
37+
return {
38+
>{ arguments, } : { arguments: any; }
39+
40+
arguments,
41+
>arguments : any
42+
43+
};
44+
}
45+
46+
const d = () => {
47+
>d : () => { arguments: any; }
48+
>() => { const arguments = undefined; return { arguments, };} : () => { arguments: any; }
49+
50+
const arguments = undefined;
51+
>arguments : any
52+
>undefined : undefined
53+
54+
return {
55+
>{ arguments, } : { arguments: any; }
56+
57+
arguments,
58+
>arguments : any
59+
60+
};
61+
}
62+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// @checkJs: true
2+
// @allowJs: true
3+
// @target: es6
4+
// @outDir: ./out
5+
// @filename: /a.js
6+
7+
const a = () => {
8+
return {
9+
arguments: [],
10+
};
11+
};
12+
13+
const b = () => {
14+
const c = {
15+
arguments: [],
16+
}
17+
return c;
18+
};
19+
20+
const c = () => {
21+
return {
22+
arguments,
23+
};
24+
}
25+
26+
const d = () => {
27+
const arguments = undefined;
28+
return {
29+
arguments,
30+
};
31+
}

0 commit comments

Comments
 (0)