google / google/closure-compiler

Parse error for quoted export/import names

Open
#3,961 1 comment 0 reactions 0 assignees View on GitHub
help wanted P3
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

```mjs
// e.mjs
const a = 'print me';
export { a as "dove" };
```
```mjs
// i.mjs
import { "dove" as b } from './e.mjs';
console.log(b);
```
`"dove"` is the quoted name, and this code works (`i.mjs` prints `print me`).

Spec reference:
[`ModuleExportName`](https://tc39.es/ecma262/multipage/ecmascript-language-scripts-and-modules.html#prod-ModuleExportName) can be [`StringLiteral`](https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#prod-StringLiteral).

However, compiler can't parse that:
```console
e.mjs:3:14: ERROR - [JSC_PARSE_ERROR] Parse error. 'identifier' expected
3| export { a as "dove" };
^
```
```console
i.mjs:2:9: ERROR - [JSC_PARSE_ERROR] Parse error. '}' expected
2| import { "dove" as b } from './e.mjs';
^
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.