From b3690da549fb2255754c00e9531927910bb3b781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 6 Oct 2025 00:00:12 +0200 Subject: [PATCH] Consistently resolve to the `errorType` on `arguments` with error --- src/compiler/checker.ts | 2 +- ...itializerOrStaticInitializationBlock.types | 64 +++++++++---------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cbdbd55660bcd..48bc0da113816 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -30975,7 +30975,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { checkIdentifierCalculateNodeCheckFlags(node, symbol); if (symbol === argumentsSymbol) { - if (isInPropertyInitializerOrClassStaticBlock(node)) { + if (isInPropertyInitializerOrClassStaticBlock(node, /*ignoreArrowFunctions*/ true)) { return errorType; } return getTypeOfSymbol(symbol); diff --git a/tests/baselines/reference/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.types b/tests/baselines/reference/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.types index daf115ded7c38..99c13629e5b7c 100644 --- a/tests/baselines/reference/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.types +++ b/tests/baselines/reference/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.types @@ -116,12 +116,12 @@ function D() { > : ^^^^^^^^ a = () => arguments // should error ->a : () => IArguments -> : ^^^^^^^^^^^^^^^^ ->() => arguments : () => IArguments -> : ^^^^^^^^^^^^^^^^ ->arguments : IArguments -> : ^^^^^^^^^^ +>a : () => any +> : ^^^^^^^^^ +>() => arguments : () => any +> : ^^^^^^^^^ +>arguments : any +> : ^^^ } } @@ -142,18 +142,18 @@ function D1() { > : ^^^^^^^^^^ arguments; // should error ->arguments : IArguments -> : ^^^^^^^^^^ +>arguments : any +> : ^^^ const b = () => { ->b : () => IArguments -> : ^^^^^^^^^^^^^^^^ ->() => { return arguments; // should error } : () => IArguments -> : ^^^^^^^^^^^^^^^^ +>b : () => any +> : ^^^^^^^^^ +>() => { return arguments; // should error } : () => any +> : ^^^^^^^^^ return arguments; // should error ->arguments : IArguments -> : ^^^^^^^^^^ +>arguments : any +> : ^^^ } function f() { @@ -286,16 +286,16 @@ function D5() { > : ^^^^^^^^ a = (() => { return arguments; })() // should error ->a : IArguments -> : ^^^^^^^^^^ ->(() => { return arguments; })() : IArguments -> : ^^^^^^^^^^ ->(() => { return arguments; }) : () => IArguments -> : ^^^^^^^^^^^^^^^^ ->() => { return arguments; } : () => IArguments -> : ^^^^^^^^^^^^^^^^ ->arguments : IArguments -> : ^^^^^^^^^^ +>a : any +> : ^^^ +>(() => { return arguments; })() : any +> : ^^^ +>(() => { return arguments; }) : () => any +> : ^^^^^^^^^ +>() => { return arguments; } : () => any +> : ^^^^^^^^^ +>arguments : any +> : ^^^ } } @@ -310,14 +310,14 @@ function D6() { > : ^^^^^^^^ a = (x = arguments) => {} // should error ->a : (x?: IArguments) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^ ->(x = arguments) => {} : (x?: IArguments) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^ ->x : IArguments -> : ^^^^^^^^^^ ->arguments : IArguments -> : ^^^^^^^^^^ +>a : (x?: any) => void +> : ^ ^^^^^^^^^^^^^^^ +>(x = arguments) => {} : (x?: any) => void +> : ^ ^^^^^^^^^^^^^^^ +>x : any +> : ^^^ +>arguments : any +> : ^^^ } }