Open
Description
I have a .tsx file
import Vue, { VNode } from 'vue'
export default Vue.extend({
data() {
return {}
},
methods: {
handleClick() {
alert('hello,world')
}
},
render(): VNode {
return (
<button onClick={this.handleClick} className="button_bg">
Click
</button>
)
}
})
it will compile first by typescript , tsconfig.json is
"compilerOptions": {
"target": "es5"
}
after ts compile with es5
exports.default = vue_1.default.extend({
data: function () {
return {};
},
methods: {
handleClick: function () {
alert('hello,world');
}
},
render: function () {
return (<button onClick={this.handleClick} className="button_bg">
Click
</button>);
}
});
when target is es5 , it will have problem , after bable will compile is ObjectProperty
but , the plugin code traverse ObjectMethod|ClassMethod
howover, if target is esnext
it will work ,because this node ast is ObjectMethod
after ts compile with exnext
exports.default = vue_1.default.extend({
data() {
return {};
},
methods: {
handleClick() {
alert('hello,world');
}
},
render() {
return (<button onClick={this.handleClick} className="button_bg">
Click
</button>);
}
});
"compilerOptions": {
"target": "esnext"
}
above is work
I think maybe is babel/parser transform ast result not some with different stage code
Metadata
Metadata
Assignees
Labels
No labels