fix(vite, webpack): handle auto keys for composables without args (#7651)

This commit is contained in:
Daniel Roe 2022-09-19 15:45:28 +01:00 committed by GitHub
parent f536bf5548
commit 42cf48e45d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,7 +45,7 @@ export const composableKeysPlugin = createUnplugin((options: ComposableKeysOptio
switch (name) { switch (name) {
case 'useState': case 'useState':
if (node.arguments.length >= 2 || stringTypes.includes(node.arguments[0].type)) { return } if (node.arguments.length >= 2 || stringTypes.includes(node.arguments[0]?.type)) { return }
break break
case 'useFetch': case 'useFetch':
@ -55,7 +55,7 @@ export const composableKeysPlugin = createUnplugin((options: ComposableKeysOptio
case 'useAsyncData': case 'useAsyncData':
case 'useLazyAsyncData': case 'useLazyAsyncData':
if (node.arguments.length >= 3 || stringTypes.includes(node.arguments[0].type) || stringTypes.includes(node.arguments[node.arguments.length - 1].type)) { return } if (node.arguments.length >= 3 || stringTypes.includes(node.arguments[0]?.type) || stringTypes.includes(node.arguments[node.arguments.length - 1]?.type)) { return }
break break
} }