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

Update: added handler for AsExpression TS node.kind #22

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
npm-debug.log
_test.js

.idea
3 changes: 3 additions & 0 deletions lib/ast-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,9 @@ module.exports = function(ast, extra) {
case SyntaxKind.ParenthesizedExpression:
return convert(node.expression, parent);

case SyntaxKind.AsExpression:
return convert(node.expression, parent);

default:
console.log(node.kind);
result = null;
Expand Down
174 changes: 174 additions & 0 deletions tests/fixtures/ecma-features/typeHints/as-expression.result.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
module.exports = {
"type": "Program",
"range": [0, 51],
"loc": {
"start": {"line": 1, "column": 0},
"end": {"line": 1, "column": 51}
},
"body": [{
"type": "ExpressionStatement",
"range": [0, 7],
"loc": {
"start": {"line": 1, "column": 0},
"end": {"line": 1, "column": 7}
},
"expression": {
"type": "Identifier",
"range": [0, 1],
"loc": {
"start": {"line": 1, "column": 0},
"end": {"line": 1, "column": 1}
},
"name": "a"
}
}, {
"type": "ExpressionStatement",
"range": [7, 51],
"loc": {
"start": {"line": 1, "column": 7},
"end": {"line": 1, "column": 51}
},
"expression": {
"type": "MemberExpression",
"range": [7, 50],
"loc": {
"start": {"line": 1, "column": 7},
"end": {"line": 1, "column": 50}
},
"object": {
"type": "Identifier",
"range": [8, 12],
"loc": {
"start": {"line": 1, "column": 8},
"end": {"line": 1, "column": 12}
},
"name": "node"
},
"property": {
"type": "Identifier",
"range": [37, 50],
"loc": {
"start": {"line": 1, "column": 37},
"end": {"line": 1, "column": 50}
},
"name": "operatorToken"
},
"computed": false
}
}],
"sourceType": "script",
"tokens": [{
"type": "Identifier",
"value": "a",
"range": [0, 1],
"loc": {
"start": {"line": 1, "column": 0},
"end": {"line": 1, "column": 1}
}
}, {
"type": "Identifier",
"value": "as",
"range": [2, 4],
"loc": {
"start": {"line": 1, "column": 2},
"end": {"line": 1, "column": 4}
}
}, {
"type": "Identifier",
"value": "b",
"range": [5, 6],
"loc": {
"start": {"line": 1, "column": 5},
"end": {"line": 1, "column": 6}
}
}, {
"type": "Punctuator",
"value": ";",
"range": [6, 7],
"loc": {
"start": {"line": 1, "column": 6},
"end": {"line": 1, "column": 7}
}
}, {
"type": "Punctuator",
"value": "(",
"range": [7, 8],
"loc": {
"start": {"line": 1, "column": 7},
"end": {"line": 1, "column": 8}
}
}, {
"type": "Identifier",
"value": "node",
"range": [8, 12],
"loc": {
"start": {"line": 1, "column": 8},
"end": {"line": 1, "column": 12}
}
}, {
"type": "Identifier",
"value": "as",
"range": [13, 15],
"loc": {
"start": {"line": 1, "column": 13},
"end": {"line": 1, "column": 15}
}
}, {
"type": "Identifier",
"value": "ts",
"range": [16, 18],
"loc": {
"start": {"line": 1, "column": 16},
"end": {"line": 1, "column": 18}
}
}, {
"type": "Punctuator",
"value": ".",
"range": [18, 19],
"loc": {
"start": {"line": 1, "column": 18},
"end": {"line": 1, "column": 19}
}
}, {
"type": "Identifier",
"value": "BinaryExpression",
"range": [19, 35],
"loc": {
"start": {"line": 1, "column": 19},
"end": {"line": 1, "column": 35}
}
}, {
"type": "Punctuator",
"value": ")",
"range": [35, 36],
"loc": {
"start": {"line": 1, "column": 35},
"end": {"line": 1, "column": 36}
}
}, {
"type": "Punctuator",
"value": ".",
"range": [36, 37],
"loc": {
"start": {"line": 1, "column": 36},
"end": {"line": 1, "column": 37}
}
}, {
"type": "Identifier",
"value": "operatorToken",
"range": [37, 50],
"loc": {
"start": {"line": 1, "column": 37},
"end": {"line": 1, "column": 50}
}
}, {
"type": "Punctuator",
"value": ";",
"range": [50, 51],
"loc": {
"start": {"line": 1, "column": 50},
"end": {"line": 1, "column": 51}
}
}]
}
;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a as b;(node as ts.BinaryExpression).operatorToken;