diff --git a/src/plugins/typescript.js b/src/plugins/typescript.js index 3839a92009..1360b04be4 100644 --- a/src/plugins/typescript.js +++ b/src/plugins/typescript.js @@ -911,7 +911,7 @@ export default (superClass: Class): Class => node.global = true; node.id = this.parseIdentifier(); } else if (this.match(tt.string)) { - node.id = this.parseLiteral(this.state.value, "StringLiteral"); + node.id = this.parseExprAtom(); } else { this.unexpected(); } diff --git a/test/fixtures/typescript/estree-compat/options.json b/test/fixtures/typescript/estree-compat/options.json new file mode 100644 index 0000000000..511e4947cc --- /dev/null +++ b/test/fixtures/typescript/estree-compat/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "plugins": ["typescript", "estree"] +} diff --git a/test/fixtures/typescript/estree-compat/shorthand-ambient-module/actual.js b/test/fixtures/typescript/estree-compat/shorthand-ambient-module/actual.js new file mode 100644 index 0000000000..422ee35552 --- /dev/null +++ b/test/fixtures/typescript/estree-compat/shorthand-ambient-module/actual.js @@ -0,0 +1 @@ +declare module "hot-new-module"; \ No newline at end of file diff --git a/test/fixtures/typescript/estree-compat/shorthand-ambient-module/expected.json b/test/fixtures/typescript/estree-compat/shorthand-ambient-module/expected.json new file mode 100644 index 0000000000..659fe3a957 --- /dev/null +++ b/test/fixtures/typescript/estree-compat/shorthand-ambient-module/expected.json @@ -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 + } + ] + } +} \ No newline at end of file