mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
fix(47004): ignore arguments name in PropertyAssignment (#47054)
This commit is contained in:
@@ -12737,6 +12737,9 @@ namespace ts {
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
return traverse((node as PropertyAccessExpression | ElementAccessExpression).expression);
|
||||
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
return traverse((node as PropertyAssignment).initializer);
|
||||
|
||||
default:
|
||||
return !nodeStartsNewLexicalEnvironment(node) && !isPartOfTypeNode(node) && !!forEachChild(node, traverse);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
tests/cases/compiler/a.js(9,7): error TS2554: Expected 0-1 arguments, but got 3.
|
||||
|
||||
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
const foo = {
|
||||
f1: (params) => { }
|
||||
}
|
||||
|
||||
function f2(x) {
|
||||
foo.f1({ x, arguments: [] });
|
||||
}
|
||||
|
||||
f2(1, 2, 3);
|
||||
~~~~
|
||||
!!! error TS2554: Expected 0-1 arguments, but got 3.
|
||||
|
||||
27
tests/baselines/reference/argumentsPropertyNameInJsMode1.js
Normal file
27
tests/baselines/reference/argumentsPropertyNameInJsMode1.js
Normal file
@@ -0,0 +1,27 @@
|
||||
//// [a.js]
|
||||
const foo = {
|
||||
f1: (params) => { }
|
||||
}
|
||||
|
||||
function f2(x) {
|
||||
foo.f1({ x, arguments: [] });
|
||||
}
|
||||
|
||||
f2(1, 2, 3);
|
||||
|
||||
|
||||
//// [a.js]
|
||||
var foo = {
|
||||
f1: function (params) { }
|
||||
};
|
||||
function f2(x) {
|
||||
foo.f1({ x: x, arguments: [] });
|
||||
}
|
||||
f2(1, 2, 3);
|
||||
|
||||
|
||||
//// [a.d.ts]
|
||||
declare function f2(x: any): void;
|
||||
declare namespace foo {
|
||||
function f1(params: any): void;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/compiler/a.js ===
|
||||
const foo = {
|
||||
>foo : Symbol(foo, Decl(a.js, 0, 5))
|
||||
|
||||
f1: (params) => { }
|
||||
>f1 : Symbol(f1, Decl(a.js, 0, 13))
|
||||
>params : Symbol(params, Decl(a.js, 1, 8))
|
||||
}
|
||||
|
||||
function f2(x) {
|
||||
>f2 : Symbol(f2, Decl(a.js, 2, 1))
|
||||
>x : Symbol(x, Decl(a.js, 4, 12))
|
||||
|
||||
foo.f1({ x, arguments: [] });
|
||||
>foo.f1 : Symbol(f1, Decl(a.js, 0, 13))
|
||||
>foo : Symbol(foo, Decl(a.js, 0, 5))
|
||||
>f1 : Symbol(f1, Decl(a.js, 0, 13))
|
||||
>x : Symbol(x, Decl(a.js, 5, 10))
|
||||
>arguments : Symbol(arguments, Decl(a.js, 5, 13))
|
||||
}
|
||||
|
||||
f2(1, 2, 3);
|
||||
>f2 : Symbol(f2, Decl(a.js, 2, 1))
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
=== tests/cases/compiler/a.js ===
|
||||
const foo = {
|
||||
>foo : { f1: (params: any) => void; }
|
||||
>{ f1: (params) => { }} : { f1: (params: any) => void; }
|
||||
|
||||
f1: (params) => { }
|
||||
>f1 : (params: any) => void
|
||||
>(params) => { } : (params: any) => void
|
||||
>params : any
|
||||
}
|
||||
|
||||
function f2(x) {
|
||||
>f2 : (x: any) => void
|
||||
>x : any
|
||||
|
||||
foo.f1({ x, arguments: [] });
|
||||
>foo.f1({ x, arguments: [] }) : void
|
||||
>foo.f1 : (params: any) => void
|
||||
>foo : { f1: (params: any) => void; }
|
||||
>f1 : (params: any) => void
|
||||
>{ x, arguments: [] } : { x: any; arguments: undefined[]; }
|
||||
>x : any
|
||||
>arguments : undefined[]
|
||||
>[] : undefined[]
|
||||
}
|
||||
|
||||
f2(1, 2, 3);
|
||||
>f2(1, 2, 3) : void
|
||||
>f2 : (x: any) => void
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
17
tests/baselines/reference/argumentsPropertyNameInJsMode2.js
Normal file
17
tests/baselines/reference/argumentsPropertyNameInJsMode2.js
Normal file
@@ -0,0 +1,17 @@
|
||||
//// [a.js]
|
||||
function f(x) {
|
||||
arguments;
|
||||
}
|
||||
|
||||
f(1, 2, 3);
|
||||
|
||||
|
||||
//// [a.js]
|
||||
function f(x) {
|
||||
arguments;
|
||||
}
|
||||
f(1, 2, 3);
|
||||
|
||||
|
||||
//// [a.d.ts]
|
||||
declare function f(x: any, ...args: any[]): void;
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/a.js ===
|
||||
function f(x) {
|
||||
>f : Symbol(f, Decl(a.js, 0, 0))
|
||||
>x : Symbol(x, Decl(a.js, 0, 11))
|
||||
|
||||
arguments;
|
||||
>arguments : Symbol(arguments)
|
||||
}
|
||||
|
||||
f(1, 2, 3);
|
||||
>f : Symbol(f, Decl(a.js, 0, 0))
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/a.js ===
|
||||
function f(x) {
|
||||
>f : (x: any, ...args: any[]) => void
|
||||
>x : any
|
||||
|
||||
arguments;
|
||||
>arguments : IArguments
|
||||
}
|
||||
|
||||
f(1, 2, 3);
|
||||
>f(1, 2, 3) : void
|
||||
>f : (x: any, ...args: any[]) => void
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
[
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/a.js",
|
||||
"position": 50,
|
||||
"name": "1"
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "function",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 50,
|
||||
"length": 2
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "function",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "f2",
|
||||
"kind": "functionName"
|
||||
},
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "void",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/a.js",
|
||||
"position": 94,
|
||||
"name": "2"
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "function",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 94,
|
||||
"length": 2
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "function",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "f2",
|
||||
"kind": "functionName"
|
||||
},
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "void",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": []
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,206 @@
|
||||
[
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/a.js",
|
||||
"position": 9,
|
||||
"name": "1"
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "function",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 9,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "function",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "f",
|
||||
"kind": "functionName"
|
||||
},
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ",",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "...",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "args",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": "[",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "void",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/a.js",
|
||||
"position": 33,
|
||||
"name": "2"
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "function",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 33,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "function",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "f",
|
||||
"kind": "functionName"
|
||||
},
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ",",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "...",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "args",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": "[",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "void",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": []
|
||||
}
|
||||
}
|
||||
]
|
||||
15
tests/cases/compiler/argumentsPropertyNameInJsMode1.ts
Normal file
15
tests/cases/compiler/argumentsPropertyNameInJsMode1.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @declaration: true
|
||||
// @outDir: ./out
|
||||
// @filename: a.js
|
||||
|
||||
const foo = {
|
||||
f1: (params) => { }
|
||||
}
|
||||
|
||||
function f2(x) {
|
||||
foo.f1({ x, arguments: [] });
|
||||
}
|
||||
|
||||
f2(1, 2, 3);
|
||||
11
tests/cases/compiler/argumentsPropertyNameInJsMode2.ts
Normal file
11
tests/cases/compiler/argumentsPropertyNameInJsMode2.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @declaration: true
|
||||
// @outDir: ./out
|
||||
// @filename: a.js
|
||||
|
||||
function f(x) {
|
||||
arguments;
|
||||
}
|
||||
|
||||
f(1, 2, 3);
|
||||
@@ -0,0 +1,16 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
|
||||
////const foo = {
|
||||
//// f1: (params) => { }
|
||||
////}
|
||||
////
|
||||
////function /*1*/f2(x) {
|
||||
//// foo.f1({ x, arguments: [] });
|
||||
////}
|
||||
////
|
||||
/////*2*/f2('');
|
||||
|
||||
verify.baselineQuickInfo();
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
|
||||
////function /*1*/f(x) {
|
||||
//// arguments;
|
||||
////}
|
||||
////
|
||||
/////*2*/f('');
|
||||
|
||||
verify.baselineQuickInfo();
|
||||
Reference in New Issue
Block a user