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

Commit

Permalink
Breaking: Support unique symbol (fixes #426)
Browse files Browse the repository at this point in the history
  • Loading branch information
azz committed Jan 27, 2018
1 parent e94ede3 commit 189b3ef
Show file tree
Hide file tree
Showing 7 changed files with 478 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/ast-node-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ module.exports = {
TSSymbolKeyword: "TSSymbolKeyword",
TSTypeAnnotation: "TSTypeAnnotation",
TSTypeLiteral: "TSTypeLiteral",
TSTypeOperator: "TSTypeOperator",
TSTypeParameter: "TSTypeParameter",
TSTypeParameterDeclaration: "TSTypeParameterDeclaration",
TSTypeParameterInstantiation: "TSTypeParameterInstantiation",
Expand Down
8 changes: 8 additions & 0 deletions lib/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,14 @@ module.exports = function convert(config) {
});
break;

case SyntaxKind.TypeOperator:
Object.assign(result, {
type: AST_NODE_TYPES.TSTypeOperator,
operator: nodeUtils.getTextForTokenKind(node.operator),
typeAnnotation: convertChild(node.type)
});
break;

// Binary Operations

case SyntaxKind.BinaryExpression:
Expand Down
2 changes: 2 additions & 0 deletions lib/node-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ TOKEN_TO_TEXT[SyntaxKind.BarEqualsToken] = "|=";
TOKEN_TO_TEXT[SyntaxKind.CaretEqualsToken] = "^=";
TOKEN_TO_TEXT[SyntaxKind.AtToken] = "@";
TOKEN_TO_TEXT[SyntaxKind.InKeyword] = "in";
TOKEN_TO_TEXT[SyntaxKind.UniqueKeyword] = "unique";
TOKEN_TO_TEXT[SyntaxKind.KeyOfKeyword] = "keyof";

/**
* Find the first matching child based on the given sourceFile and predicate function.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"npm-license": "0.3.3",
"shelljs": "0.7.8",
"shelljs-nodecli": "0.1.1",
"typescript": "~2.6.1"
"typescript": "2.7.0-insiders.20180108"
},
"keywords": [
"ast",
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/typescript/basics/keyof-operator.src.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type x = keyof foo;
1 change: 1 addition & 0 deletions tests/fixtures/typescript/basics/unique-symbol.src.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type A = unique symbol;
Loading

0 comments on commit 189b3ef

Please sign in to comment.