@@ -8519,17 +8519,10 @@ module ts {
85198519 }
85208520
85218521 function checkDecoratorSignature(node: Decorator, exprType: Type, expectedAnnotationType: Type, parentType?: Type, expectedDecoratorType?: Type, message?: DiagnosticMessage) {
8522+ // first validate that we are using the correct decorator signature for the declaration
85228523 if (checkTypeAssignableTo(exprType, expectedAnnotationType, node) && expectedDecoratorType) {
8523- let signature = getSingleCallSignature(expectedDecoratorType);
8524- if (!signature) {
8525- // if we couldn't get the signature of the decorator function type, it is likely because we are using an out-of-date lib.d.ts
8526- // and we have already reported an error in initializeTypeChecker.
8527- return;
8528- }
8529-
8530- let instantiatedSignature = getSignatureInstantiation(signature, [parentType]);
8531- let instantiatedSignatureType = getOrCreateTypeFromSignature(instantiatedSignature);
8532- checkTypeAssignableTo(exprType, instantiatedSignatureType, node, message);
8524+ // next validate that we are not changing the static type in the decorator to a type that is not assignable.
8525+ checkTypeAssignableTo(exprType, instantiateSingleCallFunctionType(expectedDecoratorType, [parentType]), node, message);
85338526 }
85348527 }
85358528
@@ -11317,17 +11310,17 @@ module ts {
1131711310 return undefined;
1131811311 }
1131911312
11320- function getAnnotationTypeForDecoratorType(type : Type, typeArgument : Type): Type {
11321- if (type === unknownType) {
11313+ function instantiateSingleCallFunctionType(functionType : Type, typeArguments : Type[] ): Type {
11314+ if (functionType === unknownType) {
1132211315 return unknownType;
1132311316 }
1132411317
11325- let signature = getSingleCallSignature(type );
11318+ let signature = getSingleCallSignature(functionType );
1132611319 if (!signature) {
1132711320 return unknownType;
1132811321 }
1132911322
11330- let instantiatedSignature = getSignatureInstantiation(signature, [typeArgument] );
11323+ let instantiatedSignature = getSignatureInstantiation(signature, typeArguments );
1133111324 return getOrCreateTypeFromSignature(instantiatedSignature);
1133211325 }
1133311326
@@ -11381,9 +11374,9 @@ module ts {
1138111374 globalRegExpType = getGlobalType("RegExp");
1138211375 globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1);
1138311376 globalClassDecoratorType = getGlobalType("ClassDecorator");
11384- globalClassAnnotationType = getAnnotationTypeForDecoratorType (globalClassDecoratorType, globalFunctionType);
11377+ globalClassAnnotationType = instantiateSingleCallFunctionType (globalClassDecoratorType, [ globalFunctionType] );
1138511378 globalPropertyDecoratorType = getGlobalType("PropertyDecorator");
11386- globalPropertyAnnotationType = getAnnotationTypeForDecoratorType (globalPropertyDecoratorType, anyType);
11379+ globalPropertyAnnotationType = instantiateSingleCallFunctionType (globalPropertyDecoratorType, [ anyType] );
1138711380 globalParameterDecoratorType = getGlobalType("ParameterDecorator");
1138811381
1138911382 // If we're in ES6 mode, load the TemplateStringsArray.
0 commit comments