fix(45799): skip checking arguments used as a key in object literals (#45814)
This commit is contained in:
parent
b1f39a705e
commit
7582b1bbae
|
@ -12581,7 +12581,7 @@ namespace ts {
|
|||
if (!node) return false;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
return (node as Identifier).escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node as Identifier) === argumentsSymbol;
|
||||
return (node as Identifier).escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node as Identifier) === argumentsSymbol;
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/a.js(16,9): error TS18004: No value exists in scope for the shorthand property 'arguments'. Either declare one or provide an initializer.
|
||||
|
||||
|
||||
==== /a.js (1 errors) ====
|
||||
const a = () => {
|
||||
return {
|
||||
arguments: [],
|
||||
};
|
||||
};
|
||||
|
||||
const b = () => {
|
||||
const c = {
|
||||
arguments: [],
|
||||
}
|
||||
return c;
|
||||
};
|
||||
|
||||
const c = () => {
|
||||
return {
|
||||
arguments,
|
||||
~~~~~~~~~
|
||||
!!! error TS18004: No value exists in scope for the shorthand property 'arguments'. Either declare one or provide an initializer.
|
||||
};
|
||||
}
|
||||
|
||||
const d = () => {
|
||||
const arguments = undefined;
|
||||
return {
|
||||
arguments,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
//// [a.js]
|
||||
const a = () => {
|
||||
return {
|
||||
arguments: [],
|
||||
};
|
||||
};
|
||||
|
||||
const b = () => {
|
||||
const c = {
|
||||
arguments: [],
|
||||
}
|
||||
return c;
|
||||
};
|
||||
|
||||
const c = () => {
|
||||
return {
|
||||
arguments,
|
||||
};
|
||||
}
|
||||
|
||||
const d = () => {
|
||||
const arguments = undefined;
|
||||
return {
|
||||
arguments,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
//// [a.js]
|
||||
const a = () => {
|
||||
return {
|
||||
arguments: [],
|
||||
};
|
||||
};
|
||||
const b = () => {
|
||||
const c = {
|
||||
arguments: [],
|
||||
};
|
||||
return c;
|
||||
};
|
||||
const c = () => {
|
||||
return {
|
||||
arguments,
|
||||
};
|
||||
};
|
||||
const d = () => {
|
||||
const arguments = undefined;
|
||||
return {
|
||||
arguments,
|
||||
};
|
||||
};
|
|
@ -0,0 +1,49 @@
|
|||
=== /a.js ===
|
||||
const a = () => {
|
||||
>a : Symbol(a, Decl(a.js, 0, 5))
|
||||
|
||||
return {
|
||||
arguments: [],
|
||||
>arguments : Symbol(arguments, Decl(a.js, 1, 12))
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
const b = () => {
|
||||
>b : Symbol(b, Decl(a.js, 6, 5))
|
||||
|
||||
const c = {
|
||||
>c : Symbol(c, Decl(a.js, 7, 9))
|
||||
|
||||
arguments: [],
|
||||
>arguments : Symbol(arguments, Decl(a.js, 7, 15))
|
||||
}
|
||||
return c;
|
||||
>c : Symbol(c, Decl(a.js, 7, 9))
|
||||
|
||||
};
|
||||
|
||||
const c = () => {
|
||||
>c : Symbol(c, Decl(a.js, 13, 5))
|
||||
|
||||
return {
|
||||
arguments,
|
||||
>arguments : Symbol(arguments, Decl(a.js, 14, 12))
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
const d = () => {
|
||||
>d : Symbol(d, Decl(a.js, 19, 5))
|
||||
|
||||
const arguments = undefined;
|
||||
>arguments : Symbol(arguments, Decl(a.js, 20, 9))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
return {
|
||||
arguments,
|
||||
>arguments : Symbol(arguments, Decl(a.js, 21, 12))
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
=== /a.js ===
|
||||
const a = () => {
|
||||
>a : () => { arguments: any[]; }
|
||||
>() => { return { arguments: [], };} : () => { arguments: any[]; }
|
||||
|
||||
return {
|
||||
>{ arguments: [], } : { arguments: undefined[]; }
|
||||
|
||||
arguments: [],
|
||||
>arguments : undefined[]
|
||||
>[] : undefined[]
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
const b = () => {
|
||||
>b : () => { arguments: any[]; }
|
||||
>() => { const c = { arguments: [], } return c;} : () => { arguments: any[]; }
|
||||
|
||||
const c = {
|
||||
>c : { arguments: any[]; }
|
||||
>{ arguments: [], } : { arguments: undefined[]; }
|
||||
|
||||
arguments: [],
|
||||
>arguments : undefined[]
|
||||
>[] : undefined[]
|
||||
}
|
||||
return c;
|
||||
>c : { arguments: any[]; }
|
||||
|
||||
};
|
||||
|
||||
const c = () => {
|
||||
>c : () => { arguments: any; }
|
||||
>() => { return { arguments, };} : () => { arguments: any; }
|
||||
|
||||
return {
|
||||
>{ arguments, } : { arguments: any; }
|
||||
|
||||
arguments,
|
||||
>arguments : any
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
const d = () => {
|
||||
>d : () => { arguments: any; }
|
||||
>() => { const arguments = undefined; return { arguments, };} : () => { arguments: any; }
|
||||
|
||||
const arguments = undefined;
|
||||
>arguments : any
|
||||
>undefined : undefined
|
||||
|
||||
return {
|
||||
>{ arguments, } : { arguments: any; }
|
||||
|
||||
arguments,
|
||||
>arguments : any
|
||||
|
||||
};
|
||||
}
|
||||
|
31
tests/cases/compiler/argumentsReferenceInObjectLiteral_Js.ts
Normal file
31
tests/cases/compiler/argumentsReferenceInObjectLiteral_Js.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
// @checkJs: true
|
||||
// @allowJs: true
|
||||
// @target: es6
|
||||
// @outDir: ./out
|
||||
// @filename: /a.js
|
||||
|
||||
const a = () => {
|
||||
return {
|
||||
arguments: [],
|
||||
};
|
||||
};
|
||||
|
||||
const b = () => {
|
||||
const c = {
|
||||
arguments: [],
|
||||
}
|
||||
return c;
|
||||
};
|
||||
|
||||
const c = () => {
|
||||
return {
|
||||
arguments,
|
||||
};
|
||||
}
|
||||
|
||||
const d = () => {
|
||||
const arguments = undefined;
|
||||
return {
|
||||
arguments,
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue