Skip to content

Commit c282771

Browse files
authored
fix(47004): ignore arguments name in PropertyAssignment (microsoft#47054)
1 parent 93bdfd2 commit c282771

14 files changed

+542
-0
lines changed

src/compiler/checker.ts

+3
Original file line numberDiff line numberDiff line change
@@ -12737,6 +12737,9 @@ namespace ts {
1273712737
case SyntaxKind.ElementAccessExpression:
1273812738
return traverse((node as PropertyAccessExpression | ElementAccessExpression).expression);
1273912739

12740+
case SyntaxKind.PropertyAssignment:
12741+
return traverse((node as PropertyAssignment).initializer);
12742+
1274012743
default:
1274112744
return !nodeStartsNewLexicalEnvironment(node) && !isPartOfTypeNode(node) && !!forEachChild(node, traverse);
1274212745
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
tests/cases/compiler/a.js(9,7): error TS2554: Expected 0-1 arguments, but got 3.
2+
3+
4+
==== tests/cases/compiler/a.js (1 errors) ====
5+
const foo = {
6+
f1: (params) => { }
7+
}
8+
9+
function f2(x) {
10+
foo.f1({ x, arguments: [] });
11+
}
12+
13+
f2(1, 2, 3);
14+
~~~~
15+
!!! error TS2554: Expected 0-1 arguments, but got 3.
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//// [a.js]
2+
const foo = {
3+
f1: (params) => { }
4+
}
5+
6+
function f2(x) {
7+
foo.f1({ x, arguments: [] });
8+
}
9+
10+
f2(1, 2, 3);
11+
12+
13+
//// [a.js]
14+
var foo = {
15+
f1: function (params) { }
16+
};
17+
function f2(x) {
18+
foo.f1({ x: x, arguments: [] });
19+
}
20+
f2(1, 2, 3);
21+
22+
23+
//// [a.d.ts]
24+
declare function f2(x: any): void;
25+
declare namespace foo {
26+
function f1(params: any): void;
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
=== tests/cases/compiler/a.js ===
2+
const foo = {
3+
>foo : Symbol(foo, Decl(a.js, 0, 5))
4+
5+
f1: (params) => { }
6+
>f1 : Symbol(f1, Decl(a.js, 0, 13))
7+
>params : Symbol(params, Decl(a.js, 1, 8))
8+
}
9+
10+
function f2(x) {
11+
>f2 : Symbol(f2, Decl(a.js, 2, 1))
12+
>x : Symbol(x, Decl(a.js, 4, 12))
13+
14+
foo.f1({ x, arguments: [] });
15+
>foo.f1 : Symbol(f1, Decl(a.js, 0, 13))
16+
>foo : Symbol(foo, Decl(a.js, 0, 5))
17+
>f1 : Symbol(f1, Decl(a.js, 0, 13))
18+
>x : Symbol(x, Decl(a.js, 5, 10))
19+
>arguments : Symbol(arguments, Decl(a.js, 5, 13))
20+
}
21+
22+
f2(1, 2, 3);
23+
>f2 : Symbol(f2, Decl(a.js, 2, 1))
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
=== tests/cases/compiler/a.js ===
2+
const foo = {
3+
>foo : { f1: (params: any) => void; }
4+
>{ f1: (params) => { }} : { f1: (params: any) => void; }
5+
6+
f1: (params) => { }
7+
>f1 : (params: any) => void
8+
>(params) => { } : (params: any) => void
9+
>params : any
10+
}
11+
12+
function f2(x) {
13+
>f2 : (x: any) => void
14+
>x : any
15+
16+
foo.f1({ x, arguments: [] });
17+
>foo.f1({ x, arguments: [] }) : void
18+
>foo.f1 : (params: any) => void
19+
>foo : { f1: (params: any) => void; }
20+
>f1 : (params: any) => void
21+
>{ x, arguments: [] } : { x: any; arguments: undefined[]; }
22+
>x : any
23+
>arguments : undefined[]
24+
>[] : undefined[]
25+
}
26+
27+
f2(1, 2, 3);
28+
>f2(1, 2, 3) : void
29+
>f2 : (x: any) => void
30+
>1 : 1
31+
>2 : 2
32+
>3 : 3
33+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//// [a.js]
2+
function f(x) {
3+
arguments;
4+
}
5+
6+
f(1, 2, 3);
7+
8+
9+
//// [a.js]
10+
function f(x) {
11+
arguments;
12+
}
13+
f(1, 2, 3);
14+
15+
16+
//// [a.d.ts]
17+
declare function f(x: any, ...args: any[]): void;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== tests/cases/compiler/a.js ===
2+
function f(x) {
3+
>f : Symbol(f, Decl(a.js, 0, 0))
4+
>x : Symbol(x, Decl(a.js, 0, 11))
5+
6+
arguments;
7+
>arguments : Symbol(arguments)
8+
}
9+
10+
f(1, 2, 3);
11+
>f : Symbol(f, Decl(a.js, 0, 0))
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/compiler/a.js ===
2+
function f(x) {
3+
>f : (x: any, ...args: any[]) => void
4+
>x : any
5+
6+
arguments;
7+
>arguments : IArguments
8+
}
9+
10+
f(1, 2, 3);
11+
>f(1, 2, 3) : void
12+
>f : (x: any, ...args: any[]) => void
13+
>1 : 1
14+
>2 : 2
15+
>3 : 3
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
[
2+
{
3+
"marker": {
4+
"fileName": "/tests/cases/fourslash/a.js",
5+
"position": 50,
6+
"name": "1"
7+
},
8+
"quickInfo": {
9+
"kind": "function",
10+
"kindModifiers": "",
11+
"textSpan": {
12+
"start": 50,
13+
"length": 2
14+
},
15+
"displayParts": [
16+
{
17+
"text": "function",
18+
"kind": "keyword"
19+
},
20+
{
21+
"text": " ",
22+
"kind": "space"
23+
},
24+
{
25+
"text": "f2",
26+
"kind": "functionName"
27+
},
28+
{
29+
"text": "(",
30+
"kind": "punctuation"
31+
},
32+
{
33+
"text": "x",
34+
"kind": "parameterName"
35+
},
36+
{
37+
"text": ":",
38+
"kind": "punctuation"
39+
},
40+
{
41+
"text": " ",
42+
"kind": "space"
43+
},
44+
{
45+
"text": "any",
46+
"kind": "keyword"
47+
},
48+
{
49+
"text": ")",
50+
"kind": "punctuation"
51+
},
52+
{
53+
"text": ":",
54+
"kind": "punctuation"
55+
},
56+
{
57+
"text": " ",
58+
"kind": "space"
59+
},
60+
{
61+
"text": "void",
62+
"kind": "keyword"
63+
}
64+
],
65+
"documentation": []
66+
}
67+
},
68+
{
69+
"marker": {
70+
"fileName": "/tests/cases/fourslash/a.js",
71+
"position": 94,
72+
"name": "2"
73+
},
74+
"quickInfo": {
75+
"kind": "function",
76+
"kindModifiers": "",
77+
"textSpan": {
78+
"start": 94,
79+
"length": 2
80+
},
81+
"displayParts": [
82+
{
83+
"text": "function",
84+
"kind": "keyword"
85+
},
86+
{
87+
"text": " ",
88+
"kind": "space"
89+
},
90+
{
91+
"text": "f2",
92+
"kind": "functionName"
93+
},
94+
{
95+
"text": "(",
96+
"kind": "punctuation"
97+
},
98+
{
99+
"text": "x",
100+
"kind": "parameterName"
101+
},
102+
{
103+
"text": ":",
104+
"kind": "punctuation"
105+
},
106+
{
107+
"text": " ",
108+
"kind": "space"
109+
},
110+
{
111+
"text": "any",
112+
"kind": "keyword"
113+
},
114+
{
115+
"text": ")",
116+
"kind": "punctuation"
117+
},
118+
{
119+
"text": ":",
120+
"kind": "punctuation"
121+
},
122+
{
123+
"text": " ",
124+
"kind": "space"
125+
},
126+
{
127+
"text": "void",
128+
"kind": "keyword"
129+
}
130+
],
131+
"documentation": []
132+
}
133+
}
134+
]

0 commit comments

Comments
 (0)