Skip to content

Commit 7017fa2

Browse files
authored
Update utilities.ts
1 parent eee4c61 commit 7017fa2

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

‎src/compiler/utilities.ts‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,22 +1118,25 @@ namespace ts {
11181118

11191119
case SyntaxKind.PropertyDeclaration:
11201120
// property declarations are valid if their parent is a class declaration.
1121-
return node.parent.kind === SyntaxKind.ClassDeclaration;
1121+
return (node.parent && node.parent.kind === SyntaxKind.ClassDeclaration)
1122+
|| (node.original && node.original.parent.kind === SyntaxKind.ClassDeclaration);
11221123

11231124
case SyntaxKind.GetAccessor:
11241125
case SyntaxKind.SetAccessor:
11251126
case SyntaxKind.MethodDeclaration:
11261127
// if this method has a body and its parent is a class declaration, this is a valid target.
11271128
return (<FunctionLikeDeclaration>node).body !== undefined
1128-
&& node.parent.kind === SyntaxKind.ClassDeclaration;
1129+
&& ((node.parent && node.parent.kind === SyntaxKind.ClassDeclaration)
1130+
|| (node.original && node.original.parent.kind === SyntaxKind.ClassDeclaration));
11291131

11301132
case SyntaxKind.Parameter:
11311133
// if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target;
1132-
return (<FunctionLikeDeclaration>node.parent).body !== undefined
1133-
&& (node.parent.kind === SyntaxKind.Constructor
1134-
|| node.parent.kind === SyntaxKind.MethodDeclaration
1135-
|| node.parent.kind === SyntaxKind.SetAccessor)
1136-
&& node.parent.parent.kind === SyntaxKind.ClassDeclaration;
1134+
const parent = node.parent || (node.original && node.original.parent);
1135+
return parent && (<FunctionLikeDeclaration>parent).body !== undefined
1136+
&& (parent.kind === SyntaxKind.Constructor
1137+
|| parent.kind === SyntaxKind.MethodDeclaration
1138+
|| parent.kind === SyntaxKind.SetAccessor)
1139+
&& parent.parent.kind === SyntaxKind.ClassDeclaration;
11371140
}
11381141

11391142
return false;

0 commit comments

Comments
 (0)