Skip to content

Commit 70bd582

Browse files
committed
Changed emit for decorators
1 parent 695c50b commit 70bd582

3 files changed

Lines changed: 222 additions & 192 deletions

File tree

src/compiler/checker.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11368,35 +11368,11 @@ module ts {
1136811368

1136911369

1137011370
// GRAMMAR CHECKING
11371-
function isValidDecoratorTarget(node: Node): boolean {
11372-
switch (node.kind) {
11373-
case SyntaxKind.ClassDeclaration:
11374-
// classes are valid targets
11375-
return true;
11376-
11377-
case SyntaxKind.PropertyDeclaration:
11378-
// property declarations are valid if their parent is a class declaration.
11379-
return node.parent.kind === SyntaxKind.ClassDeclaration;
11380-
11381-
case SyntaxKind.Parameter:
11382-
// if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target;
11383-
return (<FunctionLikeDeclaration>node.parent).body && node.parent.parent.kind === SyntaxKind.ClassDeclaration;
11384-
11385-
case SyntaxKind.GetAccessor:
11386-
case SyntaxKind.SetAccessor:
11387-
case SyntaxKind.MethodDeclaration:
11388-
// if this method has a body and its parent is a class declaration, this is a valid target.
11389-
return (<FunctionLikeDeclaration>node).body && node.parent.kind === SyntaxKind.ClassDeclaration;
11390-
}
11391-
11392-
return false;
11393-
}
11394-
1139511371
function checkGrammarDecorators(node: Node): boolean {
1139611372
if (!node.decorators) {
1139711373
return false;
1139811374
}
11399-
if (!isValidDecoratorTarget(node)) {
11375+
if (!nodeCanBeDecorated(node)) {
1140011376
return grammarErrorOnNode(node, Diagnostics.Decorators_are_not_valid_here);
1140111377
}
1140211378
else if (languageVersion < ScriptTarget.ES5) {

0 commit comments

Comments
 (0)