Adjust TSParameterProperty handling to work with transform-parameters (#8695)
This commit is contained in:
parent
6059637f09
commit
402bd1cc42
@ -151,10 +151,6 @@ export default declare((api, { jsxPragma = "React" }) => {
|
|||||||
// Rest handled by Function visitor
|
// Rest handled by Function visitor
|
||||||
},
|
},
|
||||||
|
|
||||||
TSParameterProperty(path) {
|
|
||||||
path.replaceWith(path.node.parameter);
|
|
||||||
},
|
|
||||||
|
|
||||||
ClassProperty(path) {
|
ClassProperty(path) {
|
||||||
const { node } = path;
|
const { node } = path;
|
||||||
|
|
||||||
@ -208,6 +204,13 @@ export default declare((api, { jsxPragma = "React" }) => {
|
|||||||
if (p0 && t.isIdentifier(p0) && p0.name === "this") {
|
if (p0 && t.isIdentifier(p0) && p0.name === "this") {
|
||||||
node.params.shift();
|
node.params.shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We replace `TSParameterProperty` here so that transforms that
|
||||||
|
// rely on a `Function` visitor to deal with arguments, like
|
||||||
|
// `transform-parameters`, work properly.
|
||||||
|
node.params = node.params.map(p => {
|
||||||
|
return p.type === "TSParameterProperty" ? p.parameter : p;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
TSModuleDeclaration(path) {
|
TSModuleDeclaration(path) {
|
||||||
|
|||||||
@ -0,0 +1,3 @@
|
|||||||
|
export default class Example {
|
||||||
|
constructor(public arg1 = null) { }
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["transform-typescript", "transform-parameters"]
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
export default class Example {
|
||||||
|
constructor() {
|
||||||
|
let arg1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
||||||
|
this.arg1 = arg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user