Skip to content

Commit

Permalink
[[FEAT]] Add support for "export * as ns from"
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike committed Mar 1, 2021
1 parent a9bdc93 commit c46f464
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
11 changes: 11 additions & 0 deletions src/jshint.js
Expand Up @@ -5631,7 +5631,18 @@ var JSHINT = (function() {

if (state.tokens.next.value === "*") {
// ExportDeclaration :: export * FromClause
// ExportDeclaration :: export * as IdentifierName FromClause
advance("*");

if (state.tokens.next.value === "as") {
if (!state.inES11()) {
warning("W119", state.tokens.curr, "export * as ns from", "11");
}
advance("as");
identifier(context, true);
state.funct["(scope)"].setExported(null, state.tokens.curr);
}

advance("from");
advance("(string)");
return this;
Expand Down
3 changes: 2 additions & 1 deletion src/options.js
Expand Up @@ -1051,7 +1051,8 @@ exports.val = {
* - `10` - To enable language features introduced by [ECMAScript
* 10](https://www.ecma-international.org/ecma-262/10.0/index.html).
* Notable additions: optional catch bindings.
* - `11` - To enable language features introduced by ECMAScript 11.
* - `11` - To enable language features introduced by ECMAScript 11. Notable
* additions: "export * as ns from 'module'".
*/
esversion: 5
};
Expand Down
10 changes: 0 additions & 10 deletions tests/test262/expectations.txt
Expand Up @@ -1382,14 +1382,6 @@ test/language/comments/multi-line-asi-line-separator.js(default)
test/language/comments/multi-line-asi-line-separator.js(strict mode)
test/language/comments/multi-line-asi-paragraph-separator.js(default)
test/language/comments/multi-line-asi-paragraph-separator.js(strict mode)
test/language/module-code/eval-rqstd-once.js(default)
test/language/module-code/eval-rqstd-once.js(strict mode)
test/language/module-code/eval-rqstd-order.js(default)
test/language/module-code/eval-rqstd-order.js(strict mode)
test/language/module-code/eval-self-once.js(default)
test/language/module-code/eval-self-once.js(strict mode)
test/language/module-code/instn-once.js(default)
test/language/module-code/instn-once.js(strict mode)
test/language/module-code/privatename-valid-no-earlyerr.js(default)
test/language/module-code/privatename-valid-no-earlyerr.js(strict mode)
test/annexB/language/comments/single-line-html-close-unicode-separators.js(default)
Expand Down Expand Up @@ -8998,8 +8990,6 @@ test/language/identifiers/start-unicode-9.0.0-escaped.js(default)
test/language/identifiers/start-unicode-9.0.0-escaped.js(strict mode)
test/language/identifiers/start-unicode-9.0.0.js(default)
test/language/identifiers/start-unicode-9.0.0.js(strict mode)
test/language/module-code/export-star-as-dflt.js(default)
test/language/module-code/export-star-as-dflt.js(strict mode)
test/language/statementList/block-array-literal-with-item.js(default)
test/language/statementList/block-array-literal.js(default)
test/language/statementList/block-arrow-function-assignment-expr.js(default)
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/core.js
Expand Up @@ -1107,6 +1107,33 @@ exports.testES6ModuleDuplicateExport = function (test) {
test.done();
};

exports.testExportStar = function (test) {
TestRun(test, "rejects earlier language editions")
.addError(1, 8, "'export * as ns from' is only available in ES11 (use 'esversion: 11').")
.test([
"export * as x from '.';"
], { esversion: 10, module: true });

TestRun(test, "minimal esversion")
.test([
"export * as x from '.';"
], { esversion: 11, module: true });

TestRun(test, "tolerates any IdentifierName")
.test([
"export * as if from '.';"
], { esversion: 11, module: true });

TestRun(test, "detects duplicate bindings")
.addError(2, 13, "Duplicate exported binding: 'x'.")
.test([
"export * as x from '.';",
"export * as x from '.';"
], { esversion: 11, module: true });

test.done();
};

exports.testES6ModulesNamedExportsAffectUnused = function (test) {
// Named Exports should count as used
var src1 = [
Expand Down

0 comments on commit c46f464

Please sign in to comment.