Fix: Use parseExprAtom() for TS module id string (#684)
This commit is contained in:
parent
d685b3999c
commit
d0c7d7a8c7
@ -911,7 +911,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
node.global = true;
|
node.global = true;
|
||||||
node.id = this.parseIdentifier();
|
node.id = this.parseIdentifier();
|
||||||
} else if (this.match(tt.string)) {
|
} else if (this.match(tt.string)) {
|
||||||
node.id = this.parseLiteral(this.state.value, "StringLiteral");
|
node.id = this.parseExprAtom();
|
||||||
} else {
|
} else {
|
||||||
this.unexpected();
|
this.unexpected();
|
||||||
}
|
}
|
||||||
|
|||||||
4
test/fixtures/typescript/estree-compat/options.json
vendored
Normal file
4
test/fixtures/typescript/estree-compat/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"sourceType": "module",
|
||||||
|
"plugins": ["typescript", "estree"]
|
||||||
|
}
|
||||||
1
test/fixtures/typescript/estree-compat/shorthand-ambient-module/actual.js
vendored
Normal file
1
test/fixtures/typescript/estree-compat/shorthand-ambient-module/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
declare module "hot-new-module";
|
||||||
66
test/fixtures/typescript/estree-compat/shorthand-ambient-module/expected.json
vendored
Normal file
66
test/fixtures/typescript/estree-compat/shorthand-ambient-module/expected.json
vendored
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 32,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 32
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 32,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 32
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "TSModuleDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 32,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 32
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Literal",
|
||||||
|
"start": 15,
|
||||||
|
"end": 31,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 31
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"value": "hot-new-module",
|
||||||
|
"raw": "\"hot-new-module\""
|
||||||
|
},
|
||||||
|
"declare": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user