@@ -102,10 +102,10 @@ module ts {
102
102
let anyArrayType: Type;
103
103
let globalTypedPropertyDescriptorType: ObjectType;
104
104
let globalClassDecoratorType: ObjectType;
105
- let globalClassAnnotationType : ObjectType;
105
+ let globalClassDecoratorErasedType : ObjectType;
106
106
let globalParameterDecoratorType: ObjectType;
107
- let globalPropertyAnnotationType: ObjectType;
108
107
let globalPropertyDecoratorType: ObjectType;
108
+ let globalPropertyDecoratorErasedType: ObjectType;
109
109
110
110
let tupleTypes: Map<TupleType> = {};
111
111
let unionTypes: Map<UnionType> = {};
@@ -8518,11 +8518,11 @@ module ts {
8518
8518
}
8519
8519
}
8520
8520
8521
- function checkDecoratorSignature(node: Decorator, exprType: Type, expectedAnnotationType : Type, parentType?: Type, expectedDecoratorType ?: Type, message?: DiagnosticMessage) {
8521
+ function checkDecoratorSignature(node: Decorator, exprType: Type, expectedErasedDecoratorType : Type, parentType?: Type, expectedGenericDecoratorType ?: Type, message?: DiagnosticMessage) {
8522
8522
// first validate that we are using the correct decorator signature for the declaration
8523
- if (checkTypeAssignableTo(exprType, expectedAnnotationType , node) && expectedDecoratorType ) {
8523
+ if (checkTypeAssignableTo(exprType, expectedErasedDecoratorType , node) && parentType && expectedGenericDecoratorType && message ) {
8524
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);
8525
+ checkTypeAssignableTo(exprType, instantiateSingleCallFunctionType(expectedGenericDecoratorType , [parentType]), node, message);
8526
8526
}
8527
8527
}
8528
8528
@@ -8535,15 +8535,15 @@ module ts {
8535
8535
case SyntaxKind.ClassDeclaration:
8536
8536
let classSymbol = getSymbolOfNode(node.parent);
8537
8537
let classType = getTypeOfSymbol(classSymbol);
8538
- checkDecoratorSignature(node, exprType, globalClassAnnotationType , classType, globalClassDecoratorType, Diagnostics.A_decorator_may_not_change_the_type_of_a_class);
8538
+ checkDecoratorSignature(node, exprType, globalClassDecoratorErasedType , classType, globalClassDecoratorType, Diagnostics.A_decorator_may_not_change_the_type_of_a_class);
8539
8539
break;
8540
8540
8541
8541
case SyntaxKind.PropertyDeclaration:
8542
8542
case SyntaxKind.MethodDeclaration:
8543
8543
case SyntaxKind.GetAccessor:
8544
8544
case SyntaxKind.SetAccessor:
8545
8545
let propertyType = getTypeOfNode(node.parent);
8546
- checkDecoratorSignature(node, exprType, globalPropertyAnnotationType , propertyType, globalPropertyDecoratorType, Diagnostics.A_decorator_may_not_change_the_type_of_a_member);
8546
+ checkDecoratorSignature(node, exprType, globalPropertyDecoratorErasedType , propertyType, globalPropertyDecoratorType, Diagnostics.A_decorator_may_not_change_the_type_of_a_member);
8547
8547
break;
8548
8548
8549
8549
case SyntaxKind.Parameter:
@@ -11374,9 +11374,9 @@ module ts {
11374
11374
globalRegExpType = getGlobalType("RegExp");
11375
11375
globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1);
11376
11376
globalClassDecoratorType = getGlobalType("ClassDecorator");
11377
- globalClassAnnotationType = instantiateSingleCallFunctionType(globalClassDecoratorType, [globalFunctionType]);
11377
+ globalClassDecoratorErasedType = instantiateSingleCallFunctionType(globalClassDecoratorType, [globalFunctionType]);
11378
11378
globalPropertyDecoratorType = getGlobalType("PropertyDecorator");
11379
- globalPropertyAnnotationType = instantiateSingleCallFunctionType(globalPropertyDecoratorType, [anyType]);
11379
+ globalPropertyDecoratorErasedType = instantiateSingleCallFunctionType(globalPropertyDecoratorType, [anyType]);
11380
11380
globalParameterDecoratorType = getGlobalType("ParameterDecorator");
11381
11381
11382
11382
// If we're in ES6 mode, load the TemplateStringsArray.
0 commit comments