Skip to content

Commit

Permalink
Add missing visitor of template literal type (#40738)
Browse files Browse the repository at this point in the history
* Add missing visitor of template literal type

* make linter happy
  • Loading branch information
Kingwl authored Sep 24, 2020
1 parent 3b9eb1e commit fc03982
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/compiler/factory/nodeTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ namespace ts {
return node.kind === SyntaxKind.ImportType;
}

export function isTemplateLiteralTypeSpan(node: Node): node is TemplateLiteralTypeSpan {
return node.kind === SyntaxKind.TemplateLiteralTypeSpan;
}

// Binding patterns

export function isObjectBindingPattern(node: Node): node is ObjectBindingPattern {
Expand Down
10 changes: 10 additions & 0 deletions src/compiler/visitorPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,16 @@ namespace ts {
return factory.updateLiteralTypeNode(<LiteralTypeNode>node,
nodeVisitor((<LiteralTypeNode>node).literal, visitor, isExpression));

case SyntaxKind.TemplateLiteralType:
return factory.updateTemplateLiteralType(<TemplateLiteralTypeNode>node,
nodeVisitor((<TemplateLiteralTypeNode>node).head, visitor, isTemplateHead),
nodesVisitor((<TemplateLiteralTypeNode>node).templateSpans, visitor, isTemplateLiteralTypeSpan));

case SyntaxKind.TemplateLiteralTypeSpan:
return factory.updateTemplateLiteralTypeSpan(<TemplateLiteralTypeSpan>node,
nodeVisitor((<TemplateLiteralTypeSpan>node).type, visitor, isTypeNode),
nodeVisitor((<TemplateLiteralTypeSpan>node).literal, visitor, isTemplateMiddleOrTemplateTail));

// Binding patterns
case SyntaxKind.ObjectBindingPattern:
return factory.updateObjectBindingPattern(<ObjectBindingPattern>node,
Expand Down
1 change: 1 addition & 0 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4368,6 +4368,7 @@ declare namespace ts {
function isMappedTypeNode(node: Node): node is MappedTypeNode;
function isLiteralTypeNode(node: Node): node is LiteralTypeNode;
function isImportTypeNode(node: Node): node is ImportTypeNode;
function isTemplateLiteralTypeSpan(node: Node): node is TemplateLiteralTypeSpan;
function isObjectBindingPattern(node: Node): node is ObjectBindingPattern;
function isArrayBindingPattern(node: Node): node is ArrayBindingPattern;
function isBindingElement(node: Node): node is BindingElement;
Expand Down
1 change: 1 addition & 0 deletions tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4368,6 +4368,7 @@ declare namespace ts {
function isMappedTypeNode(node: Node): node is MappedTypeNode;
function isLiteralTypeNode(node: Node): node is LiteralTypeNode;
function isImportTypeNode(node: Node): node is ImportTypeNode;
function isTemplateLiteralTypeSpan(node: Node): node is TemplateLiteralTypeSpan;
function isObjectBindingPattern(node: Node): node is ObjectBindingPattern;
function isArrayBindingPattern(node: Node): node is ArrayBindingPattern;
function isBindingElement(node: Node): node is BindingElement;
Expand Down

0 comments on commit fc03982

Please sign in to comment.