Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit eb32fed

Browse files
authored
Fix: Convert type guards (fixes #282) (#283)
1 parent b7220fd commit eb32fed

File tree

4 files changed

+639
-0
lines changed

4 files changed

+639
-0
lines changed

lib/ast-node-types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ module.exports = {
122122
TSQuestionToken: "TSQuestionToken",
123123
TSStringKeyword: "TSStringKeyword",
124124
TSTypeLiteral: "TSTypeLiteral",
125+
TSTypePredicate: "TSTypePredicate",
125126
TSTypeReference: "TSTypeReference",
126127
TSUnionType: "TSUnionType",
127128
TSVoidKeyword: "TSVoidKeyword",

lib/convert.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,14 @@ module.exports = function convert(config) {
17331733

17341734
}
17351735

1736+
case SyntaxKind.FirstTypeNode:
1737+
Object.assign(result, {
1738+
type: AST_NODE_TYPES.TSTypePredicate,
1739+
parameterName: convertChild(node.parameterName),
1740+
typeAnnotation: convertTypeAnnotation(node.type)
1741+
});
1742+
break;
1743+
17361744
default:
17371745
deeplyCopy();
17381746
}

0 commit comments

Comments
 (0)