diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f1a49611698..e112a33b9ac 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -34454,7 +34454,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function getDecoratorArgumentCount(node: Decorator, signature: Signature) { return compilerOptions.experimentalDecorators ? getLegacyDecoratorArgumentCount(node, signature) : - 2; + // Allow the runtime to oversupply arguments to an ES decorator as long as there's at least one parameter. + Math.min(Math.max(getParameterCount(signature), 1), 2); } /** diff --git a/tests/baselines/reference/esDecorators-arguments.errors.txt b/tests/baselines/reference/esDecorators-arguments.errors.txt index fba580b6681..fe42eb5acd0 100644 --- a/tests/baselines/reference/esDecorators-arguments.errors.txt +++ b/tests/baselines/reference/esDecorators-arguments.errors.txt @@ -1,22 +1,17 @@ esDecorators-arguments.ts(1,2): error TS1238: Unable to resolve signature of class decorator when called as an expression. The runtime will invoke the decorator with 2 arguments, but the decorator expects 0. -esDecorators-arguments.ts(2,2): error TS1238: Unable to resolve signature of class decorator when called as an expression. - The runtime will invoke the decorator with 2 arguments, but the decorator expects 1. esDecorators-arguments.ts(4,1): error TS1238: Unable to resolve signature of class decorator when called as an expression. The runtime will invoke the decorator with 2 arguments, but the decorator expects 3. esDecorators-arguments.ts(5,1): error TS1238: Unable to resolve signature of class decorator when called as an expression. The runtime will invoke the decorator with 2 arguments, but the decorator expects at least 3. -==== esDecorators-arguments.ts (4 errors) ==== +==== esDecorators-arguments.ts (3 errors) ==== @(() => {}) ~~~~~~~~~~ !!! error TS1238: Unable to resolve signature of class decorator when called as an expression. !!! error TS1238: The runtime will invoke the decorator with 2 arguments, but the decorator expects 0. @((a: any) => {}) - ~~~~~~~~~~~~~~~~ -!!! error TS1238: Unable to resolve signature of class decorator when called as an expression. -!!! error TS1238: The runtime will invoke the decorator with 2 arguments, but the decorator expects 1. @((a: any, b: any) => {}) @((a: any, b: any, c: any) => {}) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/tscWatch/programUpdates/updates-diagnostics-and-emit-for-decorators.js b/tests/baselines/reference/tscWatch/programUpdates/updates-diagnostics-and-emit-for-decorators.js index 7104586c6a2..8b2f049ee9b 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/updates-diagnostics-and-emit-for-decorators.js +++ b/tests/baselines/reference/tscWatch/programUpdates/updates-diagnostics-and-emit-for-decorators.js @@ -39,13 +39,7 @@ Output:: error TS2318: Cannot find global type 'ClassDecoratorContext'. -a.ts:2:2 - error TS1238: Unable to resolve signature of class decorator when called as an expression. - The runtime will invoke the decorator with 2 arguments, but the decorator expects 1. - -2 @((_) => {}) -   ~~~~~~~~~~~ - -[12:00:20 AM] Found 2 errors. Watching for file changes. +[12:00:20 AM] Found 1 error. Watching for file changes.