Skip to content

Commit 6ba7d35

Browse files
authored
Consistently resolve to the errorType on arguments with error (#62549)
1 parent d0d675a commit 6ba7d35

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30975,7 +30975,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3097530975
checkIdentifierCalculateNodeCheckFlags(node, symbol);
3097630976

3097730977
if (symbol === argumentsSymbol) {
30978-
if (isInPropertyInitializerOrClassStaticBlock(node)) {
30978+
if (isInPropertyInitializerOrClassStaticBlock(node, /*ignoreArrowFunctions*/ true)) {
3097930979
return errorType;
3098030980
}
3098130981
return getTypeOfSymbol(symbol);

tests/baselines/reference/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.types

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ function D() {
116116
> : ^^^^^^^^
117117

118118
a = () => arguments // should error
119-
>a : () => IArguments
120-
> : ^^^^^^^^^^^^^^^^
121-
>() => arguments : () => IArguments
122-
> : ^^^^^^^^^^^^^^^^
123-
>arguments : IArguments
124-
> : ^^^^^^^^^^
119+
>a : () => any
120+
> : ^^^^^^^^^
121+
>() => arguments : () => any
122+
> : ^^^^^^^^^
123+
>arguments : any
124+
> : ^^^
125125
}
126126
}
127127

@@ -142,18 +142,18 @@ function D1() {
142142
> : ^^^^^^^^^^
143143

144144
arguments; // should error
145-
>arguments : IArguments
146-
> : ^^^^^^^^^^
145+
>arguments : any
146+
> : ^^^
147147

148148
const b = () => {
149-
>b : () => IArguments
150-
> : ^^^^^^^^^^^^^^^^
151-
>() => { return arguments; // should error } : () => IArguments
152-
> : ^^^^^^^^^^^^^^^^
149+
>b : () => any
150+
> : ^^^^^^^^^
151+
>() => { return arguments; // should error } : () => any
152+
> : ^^^^^^^^^
153153

154154
return arguments; // should error
155-
>arguments : IArguments
156-
> : ^^^^^^^^^^
155+
>arguments : any
156+
> : ^^^
157157
}
158158

159159
function f() {
@@ -286,16 +286,16 @@ function D5() {
286286
> : ^^^^^^^^
287287

288288
a = (() => { return arguments; })() // should error
289-
>a : IArguments
290-
> : ^^^^^^^^^^
291-
>(() => { return arguments; })() : IArguments
292-
> : ^^^^^^^^^^
293-
>(() => { return arguments; }) : () => IArguments
294-
> : ^^^^^^^^^^^^^^^^
295-
>() => { return arguments; } : () => IArguments
296-
> : ^^^^^^^^^^^^^^^^
297-
>arguments : IArguments
298-
> : ^^^^^^^^^^
289+
>a : any
290+
> : ^^^
291+
>(() => { return arguments; })() : any
292+
> : ^^^
293+
>(() => { return arguments; }) : () => any
294+
> : ^^^^^^^^^
295+
>() => { return arguments; } : () => any
296+
> : ^^^^^^^^^
297+
>arguments : any
298+
> : ^^^
299299
}
300300
}
301301

@@ -310,14 +310,14 @@ function D6() {
310310
> : ^^^^^^^^
311311

312312
a = (x = arguments) => {} // should error
313-
>a : (x?: IArguments) => void
314-
> : ^ ^^^^^^^^^^^^^^^^^^^^^^
315-
>(x = arguments) => {} : (x?: IArguments) => void
316-
> : ^ ^^^^^^^^^^^^^^^^^^^^^^
317-
>x : IArguments
318-
> : ^^^^^^^^^^
319-
>arguments : IArguments
320-
> : ^^^^^^^^^^
313+
>a : (x?: any) => void
314+
> : ^ ^^^^^^^^^^^^^^^
315+
>(x = arguments) => {} : (x?: any) => void
316+
> : ^ ^^^^^^^^^^^^^^^
317+
>x : any
318+
> : ^^^
319+
>arguments : any
320+
> : ^^^
321321
}
322322
}
323323

0 commit comments

Comments
 (0)