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

Breaking: Updates to AST node types of some TSNodes (fixes #386) #388

Merged
merged 3 commits into from
Dec 11, 2017
Merged
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,3 @@ Issues and pull requests will be triaged and responded to as quickly as possible
## License

TypeScript ESLint Parser is licensed under a permissive BSD 2-clause license.

10 changes: 4 additions & 6 deletions lib/ast-node-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ module.exports = {
ThisExpression: "ThisExpression",
ThrowStatement: "ThrowStatement",
TryStatement: "TryStatement",

/**
* TS-prefixed nodes
*/
Expand Down Expand Up @@ -140,17 +139,16 @@ module.exports = {
TSStaticKeyword: "TSStaticKeyword",
TSStringKeyword: "TSStringKeyword",
TSSymbolKeyword: "TSSymbolKeyword",
TSTypeAnnotation: "TSTypeAnnotation",
TSTypeLiteral: "TSTypeLiteral",
TSTypeParameter: "TSTypeParameter",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this will conflict with TypeParameters that were already being copied over :(

Example with mapped types:

var x: { [A in keyof B]?: any };

Ref: prettier/prettier#1393

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your patience on this @existentialism, I have a fix for that in prettier and have opened a PR here: prettier/prettier#3455

TSTypeParameterDeclaration: "TSTypeParameterDeclaration",
TSTypeParameterInstantiation: "TSTypeParameterInstantiation",
TSTypePredicate: "TSTypePredicate",
TSTypeReference: "TSTypeReference",
TSUnionType: "TSUnionType",
TSUndefinedKeyword: "TSUndefinedKeyword",
TSVoidKeyword: "TSVoidKeyword",

TypeAnnotation: "TypeAnnotation",
TypeParameter: "TypeParameter",
TypeParameterDeclaration: "TypeParameterDeclaration",
TypeParameterInstantiation: "TypeParameterInstantiation",
UnaryExpression: "UnaryExpression",
UpdateExpression: "UpdateExpression",
VariableDeclaration: "VariableDeclaration",
Expand Down
8 changes: 4 additions & 4 deletions lib/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module.exports = function convert(config) {
const annotationStartCol = child.getFullStart() - 1;
const loc = nodeUtils.getLocFor(annotationStartCol, child.end, ast);
return {
type: AST_NODE_TYPES.TypeAnnotation,
type: AST_NODE_TYPES.TSTypeAnnotation,
loc,
range: [annotationStartCol, child.end],
typeAnnotation: annotation
Expand Down Expand Up @@ -122,7 +122,7 @@ module.exports = function convert(config) {
}
}
return {
type: AST_NODE_TYPES.TypeParameterInstantiation,
type: AST_NODE_TYPES.TSTypeParameterInstantiation,
range: [
start,
end
Expand Down Expand Up @@ -167,7 +167,7 @@ module.exports = function convert(config) {
const greaterThanToken = nodeUtils.findNextToken(lastTypeParameter, ast);

return {
type: AST_NODE_TYPES.TypeParameterDeclaration,
type: AST_NODE_TYPES.TSTypeParameterDeclaration,
range: [
firstTypeParameter.pos - 1,
greaterThanToken.end
Expand All @@ -185,7 +185,7 @@ module.exports = function convert(config) {
: typeParameter.default;

return {
type: AST_NODE_TYPES.TypeParameter,
type: AST_NODE_TYPES.TSTypeParameter,
range: [
typeParameter.getStart(),
typeParameter.getEnd()
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"license": "BSD-2-Clause",
"devDependencies": {
"babel-code-frame": "6.26.0",
"babylon": "7.0.0-beta.24",
"dedent": "^0.7.0",
"eslint": "4.10.0",
"babylon": "7.0.0-beta.34",
"dedent": "0.7.0",
"eslint": "4.13.0",
"eslint-config-eslint": "4.0.0",
"eslint-plugin-node": "5.2.1",
"eslint-release": "0.10.3",
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/__snapshots__/tsx.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Object {
53,
61,
],
"type": "TypeAnnotation",
"type": "TSTypeAnnotation",
"typeAnnotation": Object {
"loc": Object {
"end": Object {
Expand Down Expand Up @@ -526,7 +526,7 @@ Object {
98,
105,
],
"type": "TypeAnnotation",
"type": "TSTypeAnnotation",
"typeAnnotation": Object {
"loc": Object {
"end": Object {
Expand Down
Loading