mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 12:32:08 -06:00
Allow target-only ES decorators (#57768)
This commit is contained in:
parent
1c5706092e
commit
d64646b3fd
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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) => {})
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@ -39,13 +39,7 @@ Output::
|
||||
|
||||
[91merror[0m[90m TS2318: [0mCannot find global type 'ClassDecoratorContext'.
|
||||
|
||||
[96ma.ts[0m:[93m2[0m:[93m2[0m - [91merror[0m[90m TS1238: [0mUnable 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.
|
||||
|
||||
[7m2[0m @((_) => {})
|
||||
[7m [0m [91m ~~~~~~~~~~~[0m
|
||||
|
||||
[[90m12:00:20 AM[0m] Found 2 errors. Watching for file changes.
|
||||
[[90m12:00:20 AM[0m] Found 1 error. Watching for file changes.
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user