Skip to content

Commit

Permalink
fix: TypeParameterDeclaration#getStructure() should trim leading in…
Browse files Browse the repository at this point in the history
…dentation on contraint and default.
  • Loading branch information
dsherret committed Apr 28, 2019
1 parent 616c4cc commit ec971ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/compiler/ast/type/TypeParameterDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ export class TypeParameterDeclaration extends TypeParameterDeclarationBase<ts.Ty

return callBaseGetStructure<TypeParameterDeclarationSpecificStructure>(TypeParameterDeclarationBase.prototype, this, {
kind: StructureKind.TypeParameter,
constraint: constraintNode != null ? constraintNode.getText() : undefined,
default: defaultNode ? defaultNode.getText() : undefined
constraint: constraintNode != null ? constraintNode.getText({ trimLeadingIndentation: true }) : undefined,
default: defaultNode ? defaultNode.getText({ trimLeadingIndentation: true }) : undefined
});
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/tests/compiler/ast/type/typeParameterDeclarationTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,14 @@ describe(nameof(TypeParameterDeclaration), () => {
default: "number"
});
});

it("should trim leading indentation on the contraint and default", () => {
doTest("class C<T extends {\n } = {\n }> {}", {
kind: StructureKind.TypeParameter,
name: "T",
constraint: "{\n}",
default: "{\n}"
});
});
});
});

0 comments on commit ec971ce

Please sign in to comment.