Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (legacy) {
return {
name: "proposal-decorators",
inherits: syntaxDecorators,
manipulateOptions({ generatorOpts }) {
generatorOpts.decoratorsBeforeExport = decoratorsBeforeExport;
},
visitor: legacyVisitor,
};
}
return createClassFeaturePlugin({
name: "proposal-decorators",
feature: FEATURES.decorators,
// loose: options.loose, Not supported
manipulateOptions({ generatorOpts, parserOpts }) {
parserOpts.plugins.push(["decorators", { decoratorsBeforeExport }]);
generatorOpts.decoratorsBeforeExport = decoratorsBeforeExport;
},
});
});
export default declare((api, options) => {
api.assertVersion(7);
return createClassFeaturePlugin({
name: "proposal-class-properties",
feature: FEATURES.fields,
loose: options.loose,
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("classProperties", "classPrivateProperties");
},
});
});
export default declare((api, options) => {
api.assertVersion(7);
return createClassFeaturePlugin({
name: "proposal-private-methods",
feature: FEATURES.privateMethods,
loose: options.loose,
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("classPrivateMethods");
},
});
});
const assigns = parameterProperties.map(p => {
let id;
if (t.isIdentifier(p)) {
id = p;
} else if (t.isAssignmentPattern(p) && t.isIdentifier(p.left)) {
id = p.left;
} else {
throw path.buildCodeFrameError(
"Parameter properties can not be destructuring patterns.",
);
}
return template.statement.ast`this.${id} = ${id}`;
});
injectInitialization(classPath, path, assigns);
}
},
};