diff --git a/packages/babel-helper-create-class-features-plugin/src/index.ts b/packages/babel-helper-create-class-features-plugin/src/index.ts index 25105ca085a0..1f874cde0bd2 100644 --- a/packages/babel-helper-create-class-features-plugin/src/index.ts +++ b/packages/babel-helper-create-class-features-plugin/src/index.ts @@ -38,7 +38,7 @@ interface Options { name: string; feature: number; loose?: boolean; - inherits?: () => Options; + inherits?: (api: any, options: any) => any; // same as PluginObject.manipulateOptions manipulateOptions: (options: unknown, parserOpts: ParserOptions) => void; // TODO(flow->ts): change to babel api @@ -52,6 +52,7 @@ export function createClassFeaturePlugin({ manipulateOptions, // TODO(Babel 8): Remove the default value api = { assumption: () => void 0 }, + inherits, }: Options) { const setPublicClassFields = api.assumption("setPublicClassFields"); const privateFieldsAsProperties = api.assumption("privateFieldsAsProperties"); @@ -86,6 +87,7 @@ export function createClassFeaturePlugin({ return { name, manipulateOptions, + inherits, pre() { enableFeature(this.file, feature, loose); diff --git a/packages/babel-plugin-proposal-decorators/src/index.ts b/packages/babel-plugin-proposal-decorators/src/index.ts index 6d9fcf633ba3..f98c07c6f2b7 100644 --- a/packages/babel-plugin-proposal-decorators/src/index.ts +++ b/packages/babel-plugin-proposal-decorators/src/index.ts @@ -26,18 +26,17 @@ export default declare((api, options) => { } else if (version === "2021-12") { return transformer2021_12(api, options); } else { - const plugin = createClassFeaturePlugin({ + return createClassFeaturePlugin({ name: "proposal-decorators", api, feature: FEATURES.decorators, + inherits: syntaxDecorators, // loose: options.loose, Not supported manipulateOptions({ generatorOpts }) { generatorOpts.decoratorsBeforeExport = decoratorsBeforeExport; }, }); - plugin.inherits = syntaxDecorators; - return plugin; } });