Open simplefeel opened 3 years ago
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
ObjectProperty
but , the plugin code traverse ObjectMethod|ClassMethod
howover, if target is esnext it will work ,because this node ast is ObjectMethod
esnext
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
I have a .tsx file
it will compile first by typescript , tsconfig.json is
after ts compile with es5
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 isObjectMethod
after ts compile with exnext
above is work
I think maybe is babel/parser transform ast result not some with different stage code