refactor: disable resolveType by default

This commit is contained in:
三咲智子 Kevin Deng 2024-01-21 17:29:26 +08:00
parent 830fa7dff8
commit e9c7e2c2a0
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
4 changed files with 7 additions and 5 deletions

View File

@ -44,7 +44,7 @@ export default declare<VueJSXPluginOptions, BabelCore.PluginObj<State>>(
(api, opt, dirname) => {
const { types } = api;
let resolveType: BabelCore.PluginObj<BabelCore.PluginPass> | undefined;
if (opt.resolveType !== false) {
if (opt.resolveType) {
if (typeof opt.resolveType === 'boolean') opt.resolveType = {};
resolveType = ResolveType(api, opt.resolveType, dirname);
}

View File

@ -25,7 +25,8 @@ export interface VueJSXPluginOptions {
/** Replace the function used when compiling JSX expressions */
pragma?: string;
/**
* enabled by default
* (**Experimental**) Infer component metadata from types (e.g. `props`, `emits`, `name`)
* @default false
*/
resolveType?: Options | boolean;
}

View File

@ -188,8 +188,6 @@ const A = defineComponent({
}) {
return () => _createVNode("span", null, [slots.default()]);
}
}, {
name: "A"
});
const _a2 = 2;
a = _a2;

View File

@ -12,7 +12,10 @@ describe('resolve type', () => {
const App = defineComponent((props: Props) => <div />)
`,
{
plugins: [[typescript, { isTSX: true }], VueJsx],
plugins: [
[typescript, { isTSX: true }],
[VueJsx, { resolveType: true }],
],
}
);
expect(result!.code).toMatchSnapshot();