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

Fix: Do not mislabel JSXMemberExpression as JSXIdentifier (fixes #257) #258

Merged
merged 1 commit into from
May 21, 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: 1 addition & 0 deletions lib/ast-node-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ module.exports = {
TSNumberKeyword: "TSNumberKeyword",
TSParameterProperty: "TSParameterProperty",
TSPropertySignature: "TSPropertySignature",
TSQualifiedName: "TSQualifiedName",
TSQuestionToken: "TSQuestionToken",
TSStringKeyword: "TSStringKeyword",
TSTypeLiteral: "TSTypeLiteral",
Expand Down
14 changes: 3 additions & 11 deletions lib/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -1634,18 +1634,10 @@ module.exports = function convert(config) {
break;

case SyntaxKind.FirstNode: {
const jsxMemberExpressionObject = convertChild(node.left);
jsxMemberExpressionObject.type = AST_NODE_TYPES.JSXIdentifier;
delete jsxMemberExpressionObject.value;

const jsxMemberExpressionProperty = convertChild(node.right);
jsxMemberExpressionProperty.type = AST_NODE_TYPES.JSXIdentifier;
delete jsxMemberExpressionObject.value;

Object.assign(result, {
type: AST_NODE_TYPES.JSXMemberExpression,
object: jsxMemberExpressionObject,
property: jsxMemberExpressionProperty
type: AST_NODE_TYPES.TSQualifiedName,
left: convertChild(node.left),
right: convertChild(node.right)
});

break;
Expand Down
362 changes: 362 additions & 0 deletions tests/fixtures/typescript/basics/var-with-dotted-type.result.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,362 @@
module.exports = {
"type": "Program",
"range": [
0,
15
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"body": [
{
"type": "VariableDeclaration",
"range": [
0,
15
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"declarations": [
{
"type": "VariableDeclarator",
"range": [
4,
14
],
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 14
}
},
"id": {
"type": "Identifier",
"range": [
4,
7
],
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 7
}
},
"name": "foo",
"typeAnnotation": {
"type": "TypeAnnotation",
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
}
},
"range": [
9,
14
],
"typeAnnotation": {
"type": "TSTypeReference",
"range": [
9,
14
],
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
}
},
"typeName": {
"type": "TSQualifiedName",
"range": [
9,
14
],
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
}
},
"left": {
"type": "TSQualifiedName",
"range": [
9,
12
],
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
}
},
"left": {
"type": "Identifier",
"range": [
9,
10
],
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
},
"name": "A"
},
"right": {
"type": "Identifier",
"range": [
11,
12
],
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
}
},
"name": "B"
}
},
"right": {
"type": "Identifier",
"range": [
13,
14
],
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 14
}
},
"name": "C"
}
}
}
}
},
"init": null
}
],
"kind": "var"
}
],
"sourceType": "script",
"tokens": [
{
"type": "Keyword",
"value": "var",
"range": [
0,
3
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
}
},
{
"type": "Identifier",
"value": "foo",
"range": [
4,
7
],
"loc": {
"start": {
"line": 1,
"column": 4
},
"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": "A",
"range": [
9,
10
],
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
}
},
{
"type": "Punctuator",
"value": ".",
"range": [
10,
11
],
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
}
}
},
{
"type": "Identifier",
"value": "B",
"range": [
11,
12
],
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
}
}
},
{
"type": "Punctuator",
"value": ".",
"range": [
12,
13
],
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 13
}
}
},
{
"type": "Identifier",
"value": "C",
"range": [
13,
14
],
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 14
}
}
},
{
"type": "Punctuator",
"value": ";",
"range": [
14,
15
],
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
}
}
}
]
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var foo: A.B.C;