mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 14:13:54 -06:00
Merge pull request #5937 from Microsoft/missingSemicolonInModuleSpecifier
parse module specifier as string
This commit is contained in:
commit
0348fd4d4b
@ -5310,16 +5310,17 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseModuleSpecifier(): Expression {
|
||||
// We allow arbitrary expressions here, even though the grammar only allows string
|
||||
// literals. We check to ensure that it is only a string literal later in the grammar
|
||||
// walker.
|
||||
const result = parseExpression();
|
||||
// Ensure the string being required is in our 'identifier' table. This will ensure
|
||||
// that features like 'find refs' will look inside this file when search for its name.
|
||||
if (result.kind === SyntaxKind.StringLiteral) {
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
const result = parseLiteralNode();
|
||||
internIdentifier((<LiteralExpression>result).text);
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
// We allow arbitrary expressions here, even though the grammar only allows string
|
||||
// literals. We check to ensure that it is only a string literal later in the grammar
|
||||
// check pass.
|
||||
return parseExpression();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function parseNamespaceImport(): NamespaceImport {
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
//// [tests/cases/compiler/missingSemicolonInModuleSpecifier.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
|
||||
export const x = 1;
|
||||
|
||||
//// [b.ts]
|
||||
import {x} from "./a"
|
||||
(function() { return 1; }())
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
(function () { return 1; }());
|
||||
@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
|
||||
export const x = 1;
|
||||
>x : Symbol(x, Decl(a.ts, 1, 12))
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
import {x} from "./a"
|
||||
>x : Symbol(x, Decl(b.ts, 0, 8))
|
||||
|
||||
(function() { return 1; }())
|
||||
@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
|
||||
export const x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
import {x} from "./a"
|
||||
>x : number
|
||||
|
||||
(function() { return 1; }())
|
||||
>(function() { return 1; }()) : number
|
||||
>function() { return 1; }() : number
|
||||
>function() { return 1; } : () => number
|
||||
>1 : number
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
// @module: commonjs
|
||||
|
||||
// @filename: a.ts
|
||||
export const x = 1;
|
||||
|
||||
// @filename: b.ts
|
||||
import {x} from "./a"
|
||||
(function() { return 1; }())
|
||||
Loading…
x
Reference in New Issue
Block a user