mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2024-11-10 09:39:14 +08:00
refactor: disable resolveType by default
This commit is contained in:
parent
830fa7dff8
commit
e9c7e2c2a0
@ -44,7 +44,7 @@ export default declare<VueJSXPluginOptions, BabelCore.PluginObj<State>>(
|
|||||||
(api, opt, dirname) => {
|
(api, opt, dirname) => {
|
||||||
const { types } = api;
|
const { types } = api;
|
||||||
let resolveType: BabelCore.PluginObj<BabelCore.PluginPass> | undefined;
|
let resolveType: BabelCore.PluginObj<BabelCore.PluginPass> | undefined;
|
||||||
if (opt.resolveType !== false) {
|
if (opt.resolveType) {
|
||||||
if (typeof opt.resolveType === 'boolean') opt.resolveType = {};
|
if (typeof opt.resolveType === 'boolean') opt.resolveType = {};
|
||||||
resolveType = ResolveType(api, opt.resolveType, dirname);
|
resolveType = ResolveType(api, opt.resolveType, dirname);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,8 @@ export interface VueJSXPluginOptions {
|
|||||||
/** Replace the function used when compiling JSX expressions */
|
/** Replace the function used when compiling JSX expressions */
|
||||||
pragma?: string;
|
pragma?: string;
|
||||||
/**
|
/**
|
||||||
* enabled by default
|
* (**Experimental**) Infer component metadata from types (e.g. `props`, `emits`, `name`)
|
||||||
|
* @default false
|
||||||
*/
|
*/
|
||||||
resolveType?: Options | boolean;
|
resolveType?: Options | boolean;
|
||||||
}
|
}
|
||||||
|
@ -188,8 +188,6 @@ const A = defineComponent({
|
|||||||
}) {
|
}) {
|
||||||
return () => _createVNode("span", null, [slots.default()]);
|
return () => _createVNode("span", null, [slots.default()]);
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
name: "A"
|
|
||||||
});
|
});
|
||||||
const _a2 = 2;
|
const _a2 = 2;
|
||||||
a = _a2;
|
a = _a2;
|
||||||
|
@ -12,7 +12,10 @@ describe('resolve type', () => {
|
|||||||
const App = defineComponent((props: Props) => <div />)
|
const App = defineComponent((props: Props) => <div />)
|
||||||
`,
|
`,
|
||||||
{
|
{
|
||||||
plugins: [[typescript, { isTSX: true }], VueJsx],
|
plugins: [
|
||||||
|
[typescript, { isTSX: true }],
|
||||||
|
[VueJsx, { resolveType: true }],
|
||||||
|
],
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
expect(result!.code).toMatchSnapshot();
|
expect(result!.code).toMatchSnapshot();
|
||||||
|
Loading…
Reference in New Issue
Block a user