File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -4420,12 +4420,19 @@ namespace ts {
44204420 let container = getThisContainer(node, /*includeArrowFunctions*/ false);
44214421 let parent = container && container.parent;
44224422 if (parent && (isClassLike(parent) || parent.kind === SyntaxKind.InterfaceDeclaration)) {
4423- if (!(container.flags & NodeFlags.Static)) {
4423+ if (!(container.flags & NodeFlags.Static) && !isConstructorParameter(node, container) ) {
44244424 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType;
44254425 }
44264426 }
44274427 error(node, Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface);
44284428 return unknownType;
4429+
4430+ function isConstructorParameter(node: TypeNode, container: Node) {
4431+ if (container.kind === SyntaxKind.Constructor) {
4432+ let ctor = (<ConstructorDeclaration>container);
4433+ return !ctor.body.statements.some(st => st === node.parent);
4434+ }
4435+ }
44294436 }
44304437
44314438 function getTypeFromThisTypeNode(node: TypeNode): Type {
You can’t perform that action at this time.
0 commit comments