Require decoratorsBeforeExport option for decorators (#8465)
* Require decoratorsBeforeExport option for syntax-decorators * Also babylon * Enable test
This commit is contained in:
@@ -17,7 +17,14 @@ export default declare((api, options) => {
|
||||
}
|
||||
|
||||
const { decoratorsBeforeExport } = options;
|
||||
if (decoratorsBeforeExport !== undefined) {
|
||||
if (decoratorsBeforeExport === undefined) {
|
||||
if (!legacy) {
|
||||
throw new Error(
|
||||
"The '@babel/plugin-syntax-decorators' plugin requires a" +
|
||||
" 'decoratorsBeforeExport' option, whose value must be a boolean.",
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (legacy) {
|
||||
throw new Error(
|
||||
"'decoratorsBeforeExport' can't be used with legacy decorators.",
|
||||
|
||||
@@ -37,6 +37,10 @@ describe("'decoratorsBeforeExport' option", function() {
|
||||
expect(makeParser("", { decoratorsBeforeExport: "before" })).toThrow();
|
||||
});
|
||||
|
||||
test.skip("is required", function() {
|
||||
expect(makeParser("", { legacy: false })).toThrow(/decoratorsBeforeExport/);
|
||||
});
|
||||
|
||||
test("is incompatible with legacy", function() {
|
||||
expect(
|
||||
makeParser("", { decoratorsBeforeExport: false, legacy: true }),
|
||||
@@ -47,8 +51,6 @@ describe("'decoratorsBeforeExport' option", function() {
|
||||
const AFTER = "export @dec class Foo {}";
|
||||
|
||||
// These are skipped
|
||||
run(BEFORE, undefined, true);
|
||||
run(AFTER, undefined, false);
|
||||
run(BEFORE, true, false);
|
||||
run(AFTER, true, true);
|
||||
run(BEFORE, false, true);
|
||||
|
||||
Reference in New Issue
Block a user