Skip to content

Commit 0662d17

Browse files
committedDec 21, 2020
fix: should not throw when root property not found
1 parent 622e53b commit 0662d17

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
 

‎transformations/__tests__/root-prop-to-use-test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@ defineInlineTest(
2020
`Vue.createApp({}).use(router);`,
2121
'Can recognize Vue.createApp'
2222
)
23+
24+
defineInlineTest(
25+
transform,
26+
{
27+
rootPropName: 'router',
28+
},
29+
`createApp({});`,
30+
`createApp({});`
31+
)

‎transformations/root-prop-to-use.ts

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ export const transformAST: ASTTransformation<Params> = (
4242
// @ts-ignore
4343
(p) => p.key && p.key.name === rootPropName
4444
)
45+
46+
if (propertyIndex === -1) {
47+
return createAppCall
48+
}
49+
4550
// @ts-ignore
4651
const [{ value: pluginInstance }] = rootProps.properties.splice(
4752
propertyIndex,

0 commit comments

Comments
 (0)
Please sign in to comment.