Change decoratorsBeforeExport default to false (#8113)
This commit is contained in:
parent
b445b79734
commit
6349118bed
@ -52,10 +52,7 @@ function normalizeOptions(code, opts): Format {
|
|||||||
style: " ",
|
style: " ",
|
||||||
base: 0,
|
base: 0,
|
||||||
},
|
},
|
||||||
decoratorsBeforeExport:
|
decoratorsBeforeExport: !!opts.decoratorsBeforeExport,
|
||||||
opts.decoratorsBeforeExport === undefined
|
|
||||||
? true
|
|
||||||
: opts.decoratorsBeforeExport,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (format.minified) {
|
if (format.minified) {
|
||||||
|
|||||||
@ -32,15 +32,15 @@ class Foo {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@foo
|
export default @foo
|
||||||
export default class Foo {
|
class Foo {
|
||||||
bar() {
|
bar() {
|
||||||
class Baz {}
|
class Baz {}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@foo
|
export @foo
|
||||||
export class Foo {
|
class Foo {
|
||||||
bar() {
|
bar() {
|
||||||
class Baz {}
|
class Baz {}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -263,8 +263,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
this.raise(
|
this.raise(
|
||||||
this.state.start,
|
this.state.start,
|
||||||
"Using the export keyword between a decorator and a class is not allowed. " +
|
"Using the export keyword between a decorator and a class is not allowed. " +
|
||||||
"Please use `export @dec class` instead, or set the " +
|
"Please use `export @dec class` instead.",
|
||||||
"'decoratorsBeforeExport' option to true.",
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (!this.canHaveLeadingDecorator()) {
|
} else if (!this.canHaveLeadingDecorator()) {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
"throws": "Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead, or set the 'decoratorsBeforeExport' option to true. (2:0)"
|
"throws": "Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead. (2:0)"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export default declare((api, options) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let { decoratorsBeforeExport } = options;
|
const { decoratorsBeforeExport } = options;
|
||||||
if (decoratorsBeforeExport !== undefined) {
|
if (decoratorsBeforeExport !== undefined) {
|
||||||
if (legacy) {
|
if (legacy) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -26,8 +26,6 @@ export default declare((api, options) => {
|
|||||||
if (typeof decoratorsBeforeExport !== "boolean") {
|
if (typeof decoratorsBeforeExport !== "boolean") {
|
||||||
throw new Error("'decoratorsBeforeExport' must be a boolean.");
|
throw new Error("'decoratorsBeforeExport' must be a boolean.");
|
||||||
}
|
}
|
||||||
} else if (!legacy) {
|
|
||||||
decoratorsBeforeExport = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -47,8 +47,8 @@ describe("'decoratorsBeforeExport' option", function() {
|
|||||||
const AFTER = "export @dec class Foo {}";
|
const AFTER = "export @dec class Foo {}";
|
||||||
|
|
||||||
// These are skipped
|
// These are skipped
|
||||||
run(BEFORE, undefined, false);
|
run(BEFORE, undefined, true);
|
||||||
run(AFTER, undefined, true);
|
run(AFTER, undefined, false);
|
||||||
run(BEFORE, true, false);
|
run(BEFORE, true, false);
|
||||||
run(AFTER, true, true);
|
run(AFTER, true, true);
|
||||||
run(BEFORE, false, true);
|
run(BEFORE, false, true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user