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: " ",
|
||||
base: 0,
|
||||
},
|
||||
decoratorsBeforeExport:
|
||||
opts.decoratorsBeforeExport === undefined
|
||||
? true
|
||||
: opts.decoratorsBeforeExport,
|
||||
decoratorsBeforeExport: !!opts.decoratorsBeforeExport,
|
||||
};
|
||||
|
||||
if (format.minified) {
|
||||
|
||||
@ -32,15 +32,15 @@ class Foo {
|
||||
|
||||
}
|
||||
|
||||
@foo
|
||||
export default class Foo {
|
||||
export default @foo
|
||||
class Foo {
|
||||
bar() {
|
||||
class Baz {}
|
||||
}
|
||||
|
||||
}
|
||||
@foo
|
||||
export class Foo {
|
||||
export @foo
|
||||
class Foo {
|
||||
bar() {
|
||||
class Baz {}
|
||||
}
|
||||
|
||||
@ -263,8 +263,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
this.raise(
|
||||
this.state.start,
|
||||
"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.",
|
||||
"Please use `export @dec class` instead.",
|
||||
);
|
||||
}
|
||||
} else if (!this.canHaveLeadingDecorator()) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"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 (legacy) {
|
||||
throw new Error(
|
||||
@ -26,8 +26,6 @@ export default declare((api, options) => {
|
||||
if (typeof decoratorsBeforeExport !== "boolean") {
|
||||
throw new Error("'decoratorsBeforeExport' must be a boolean.");
|
||||
}
|
||||
} else if (!legacy) {
|
||||
decoratorsBeforeExport = true;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -47,8 +47,8 @@ describe("'decoratorsBeforeExport' option", function() {
|
||||
const AFTER = "export @dec class Foo {}";
|
||||
|
||||
// These are skipped
|
||||
run(BEFORE, undefined, false);
|
||||
run(AFTER, undefined, true);
|
||||
run(BEFORE, undefined, true);
|
||||
run(AFTER, undefined, false);
|
||||
run(BEFORE, true, false);
|
||||
run(AFTER, true, true);
|
||||
run(BEFORE, false, true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user