Change decoratorsBeforeExport default to false (#8113)

This commit is contained in:
Nicolò Ribaudo 2018-06-04 21:12:01 +02:00 committed by GitHub
parent b445b79734
commit 6349118bed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 16 deletions

View File

@ -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) {

View File

@ -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 {}
} }

View File

@ -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()) {

View File

@ -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)"
} }

View File

@ -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 {

View File

@ -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);