Skip to content

Commit

Permalink
refactor: disable resolveType by default
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Jan 21, 2024
1 parent 830fa7d commit e9c7e2c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/babel-plugin-jsx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/babel-plugin-jsx/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ const A = defineComponent({
}) {
return () => _createVNode("span", null, [slots.default()]);
}
}, {
name: "A"
});
const _a2 = 2;
a = _a2;
Expand Down
5 changes: 4 additions & 1 deletion packages/babel-plugin-jsx/test/resolve-type.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e9c7e2c

Please sign in to comment.