* Only prohibit 'export type' when flow is enabled * Fix lint
This commit is contained in:
parent
dcef4012a0
commit
6c4acecf00
@ -896,9 +896,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
|
||||
isExportDefaultSpecifier(): boolean {
|
||||
if (this.match(tt.name)) {
|
||||
return this.state.value !== "type"
|
||||
&& this.state.value !== "async"
|
||||
&& this.state.value !== "interface";
|
||||
return this.state.value !== "async";
|
||||
}
|
||||
|
||||
if (!this.match(tt._default)) {
|
||||
|
||||
@ -1061,6 +1061,17 @@ export default (superClass: Class<Parser>): Class<Parser> => class extends super
|
||||
|| super.shouldParseExportDeclaration();
|
||||
}
|
||||
|
||||
isExportDefaultSpecifier(): boolean {
|
||||
if (
|
||||
this.match(tt.name) &&
|
||||
(this.state.value === "type" || this.state.value === "interface")
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.isExportDefaultSpecifier();
|
||||
}
|
||||
|
||||
parseConditional(expr: N.Expression, noIn: ?boolean, startPos: number, startLoc: Position, refNeedsArrowPos?: Pos): N.Expression {
|
||||
// only do the expensive clone if there is a question mark
|
||||
// and if we come from inside parens
|
||||
|
||||
1
test/fixtures/experimental/export-extensions/default-type-with-flow/actual.js
vendored
Normal file
1
test/fixtures/experimental/export-extensions/default-type-with-flow/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
export type from 'test';
|
||||
5
test/fixtures/experimental/export-extensions/default-type-with-flow/options.json
vendored
Normal file
5
test/fixtures/experimental/export-extensions/default-type-with-flow/options.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"plugins": ["exportExtensions", "flow"],
|
||||
"sourceType": "module",
|
||||
"throws": "Unexpected token, expected = (1:17)"
|
||||
}
|
||||
1
test/fixtures/experimental/export-extensions/default-type-without-flow/actual.js
vendored
Normal file
1
test/fixtures/experimental/export-extensions/default-type-without-flow/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
export type from 'test';
|
||||
103
test/fixtures/experimental/export-extensions/default-type-without-flow/expected.json
vendored
Normal file
103
test/fixtures/experimental/export-extensions/default-type-without-flow/expected.json
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 24
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 24
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"body": [
|
||||
{
|
||||
"type": "ExportNamedDeclaration",
|
||||
"start": 0,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 24
|
||||
}
|
||||
},
|
||||
"specifiers": [
|
||||
{
|
||||
"type": "ExportDefaultSpecifier",
|
||||
"start": 7,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"exported": {
|
||||
"type": "Identifier",
|
||||
"start": 7,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "type"
|
||||
},
|
||||
"name": "type"
|
||||
}
|
||||
}
|
||||
],
|
||||
"source": {
|
||||
"type": "StringLiteral",
|
||||
"start": 17,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "test",
|
||||
"raw": "'test'"
|
||||
},
|
||||
"value": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user