diff --git a/src/runtime/components/nuxt-icon.vue b/src/runtime/components/nuxt-icon.vue index 7d80b5a..1fbb7e7 100644 --- a/src/runtime/components/nuxt-icon.vue +++ b/src/runtime/components/nuxt-icon.vue @@ -24,7 +24,14 @@ async function getIcon () { as: 'raw', eager: false }) - const rawIcon = await iconsImport[`/assets/icons/${props.name}.svg`]() + const rawIconImport = iconsImport[`/assets/icons/${props.name}.svg`] + if (!rawIconImport) { + console.error( + `[nuxt-icons] Icon '${props.name}' doesn't exist in 'assets/icons'` + ) + return + } + const rawIcon = await rawIconImport() if (rawIcon.includes('stroke')) { hasStroke = true } icon.value = rawIcon } catch { diff --git a/tsconfig.json b/tsconfig.json index 9dd826f..d3a68d1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,3 +1,6 @@ { - "extends": "./playground/.nuxt/tsconfig.json" + "extends": "./playground/.nuxt/tsconfig.json", + "compilerOptions": { + "noUncheckedIndexedAccess": true + } }