fix: register inserted class declaration (#10302)
* Decorators legacy: register inserted declaration For compatibility with the Typescript plugin Fixes #10264 * Register declaration but also keep replaceWithMultiple
This commit is contained in:
parent
5fb4d84a33
commit
ba2c0f7adf
@ -237,7 +237,7 @@ export default {
|
||||
|
||||
const replacement = decoratedClassToExpression(decl);
|
||||
if (replacement) {
|
||||
path.replaceWithMultiple([
|
||||
const [varDeclPath] = path.replaceWithMultiple([
|
||||
replacement,
|
||||
t.exportNamedDeclaration(null, [
|
||||
t.exportSpecifier(
|
||||
@ -246,6 +246,10 @@ export default {
|
||||
),
|
||||
]),
|
||||
]);
|
||||
|
||||
if (!decl.node.id) {
|
||||
path.scope.registerDeclaration(varDeclPath);
|
||||
}
|
||||
}
|
||||
},
|
||||
ClassDeclaration(path) {
|
||||
|
||||
4
packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/10264/input.mjs
vendored
Normal file
4
packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/10264/input.mjs
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
function myDecorator(decoratee) {}
|
||||
|
||||
@myDecorator
|
||||
export default class {}
|
||||
6
packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/10264/options.json
vendored
Normal file
6
packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/10264/options.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
"transform-typescript",
|
||||
[ "proposal-decorators", { "legacy": true } ]
|
||||
]
|
||||
}
|
||||
7
packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/10264/output.mjs
vendored
Normal file
7
packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/10264/output.mjs
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
var _class2;
|
||||
|
||||
function myDecorator(decoratee) {}
|
||||
|
||||
let _class = myDecorator(_class2 = class {}) || _class2;
|
||||
|
||||
export { _class as default };
|
||||
Loading…
x
Reference in New Issue
Block a user