Skip to content

Flow’s parser does not understand export from attributes (the with { type: "json" } syntax). #9346

@sangafabrice

Description

@sangafabrice

Flow version: 0.295.0

Expected behavior

According to MDN:

export from supports all features that import supports — for example, import attributes.

So the following should be valid:

/** @file export.js */
export { default } from "./htmlhint.json" with { type: "json" };
/** @file index.js */
import ruleset from "./export.js";

console.log(ruleset);

Running:

node index.js

should output the contents of htmlhint.json as an object:

{ "tagname-lowercase": true }

And processing with Flow should succeed:

npx flow-remove-types --out-file ./export.out.js ./export.js --all

Expected result:

./export.js
 ↳ ./export.out.js

Actual behavior

Flow fails to parse the with { type: "json" } attribute on export from:

./export.js
 ↳ Syntax Error: ';' expected (2:42)
export { default } from "./htmlhint.json" with { type: "json" };
                                          ^
   1: export { default } from "./htmlhint.json" with { type: "json" };

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions