Closed Tsuyoshi84 closed 6 months ago
Nuxt: 3.9.1 icon: 0.6.8
A type error occurs when the TypeScript compiler option noUncheckedIndexedAccess is enabled.
When the option is enabled, TypeScript considers that the type of the following computed, iconName, is string | undefined
iconName
string | undefined
https://github.com/nuxt-modules/icon/blob/0aa6fd707a455ea8c416f73e1b4ef7295e12647e/src/runtime/Icon.vue#L62-L67
And because of that, the following code becomes invalid because nuxtApp.vueApp.component() takes a string value, not string | undefined:
nuxtApp.vueApp.component()
string
https://github.com/nuxt-modules/icon/blob/0aa6fd707a455ea8c416f73e1b4ef7295e12647e/src/runtime/Icon.vue#L71
You can reproduce the error by running "npm run typecheck" in the following environment: https://stackblitz.com/edit/nuxt-icon-playground-q1bjwm?file=nuxt.config.ts
Environment
Nuxt: 3.9.1 icon: 0.6.8
Bug Description
A type error occurs when the TypeScript compiler option noUncheckedIndexedAccess is enabled.
When the option is enabled, TypeScript considers that the type of the following computed,
iconName
, isstring | undefined
https://github.com/nuxt-modules/icon/blob/0aa6fd707a455ea8c416f73e1b4ef7295e12647e/src/runtime/Icon.vue#L62-L67
And because of that, the following code becomes invalid because
nuxtApp.vueApp.component()
takes astring
value, notstring | undefined
:https://github.com/nuxt-modules/icon/blob/0aa6fd707a455ea8c416f73e1b4ef7295e12647e/src/runtime/Icon.vue#L71
Reproduction
You can reproduce the error by running "npm run typecheck" in the following environment: https://stackblitz.com/edit/nuxt-icon-playground-q1bjwm?file=nuxt.config.ts