diff --git a/packages/babel-plugin-jsx/src/index.ts b/packages/babel-plugin-jsx/src/index.ts index d165d16..9038353 100644 --- a/packages/babel-plugin-jsx/src/index.ts +++ b/packages/babel-plugin-jsx/src/index.ts @@ -44,7 +44,7 @@ export default declare>( (api, opt, dirname) => { const { types } = api; let resolveType: BabelCore.PluginObj | undefined; - if (opt.resolveType !== false) { + if (opt.resolveType) { if (typeof opt.resolveType === 'boolean') opt.resolveType = {}; resolveType = ResolveType(api, opt.resolveType, dirname); } diff --git a/packages/babel-plugin-jsx/src/interface.ts b/packages/babel-plugin-jsx/src/interface.ts index 4700e5b..e2aa08e 100644 --- a/packages/babel-plugin-jsx/src/interface.ts +++ b/packages/babel-plugin-jsx/src/interface.ts @@ -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; } diff --git a/packages/babel-plugin-jsx/test/__snapshots__/snapshot.test.ts.snap b/packages/babel-plugin-jsx/test/__snapshots__/snapshot.test.ts.snap index dac48f8..732fc0f 100644 --- a/packages/babel-plugin-jsx/test/__snapshots__/snapshot.test.ts.snap +++ b/packages/babel-plugin-jsx/test/__snapshots__/snapshot.test.ts.snap @@ -188,8 +188,6 @@ const A = defineComponent({ }) { return () => _createVNode("span", null, [slots.default()]); } -}, { - name: "A" }); const _a2 = 2; a = _a2; diff --git a/packages/babel-plugin-jsx/test/resolve-type.test.tsx b/packages/babel-plugin-jsx/test/resolve-type.test.tsx index 83926d4..15cba50 100644 --- a/packages/babel-plugin-jsx/test/resolve-type.test.tsx +++ b/packages/babel-plugin-jsx/test/resolve-type.test.tsx @@ -12,7 +12,10 @@ describe('resolve type', () => { const App = defineComponent((props: Props) =>
) `, { - plugins: [[typescript, { isTSX: true }], VueJsx], + plugins: [ + [typescript, { isTSX: true }], + [VueJsx, { resolveType: true }], + ], } ); expect(result!.code).toMatchSnapshot();