Skip to content

vue-tsc error at line 27 of nuxt-icon.vue, while activated noUncheckedIndexedAccess in tsconfig #55

@tsukuha

Description

@tsukuha

Describe the bug
I found a bug about type error.
vue-tsc error at line 27 of nuxt-icon.vue, while activated noUncheckedIndexedAccess in tsconfig.

To Reproduce

It occurs vue-tsc error on building nuxt-icons.

  • nuxt.config.ts
export default defineNuxtConfig({
  ssr: false,
  typescript: {
    typeCheck: true,
  },
  app: {
    head: {
      charset: 'utf-8',
      title: '',
    },
  },
  modules: ['nuxt-icons'],
  vue: {
    compilerOptions: {
      whitespace: 'preserve',
    },
  },
  telemetry: false,
  devtools: {
    enabled: true
  },
})
  • tsconfig.json
{
  "extends": "./.nuxt/tsconfig.json",
  "compilerOptions": {
    "noUncheckedIndexedAccess": true
  }
}
  • package.json
{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "author": "",
  "scripts": {
    "build": "nuxt build",
    "dev": "rm -rf /tmp/nitro && HOST=0.0.0.0 PORT=8080 nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare",
  },
  "dependencies": {
    "nuxt": "^3.8.2",
    "nuxt-icons": "^3.2.1",
    "sass": "^1.69.5",
    "vue": "^3.3.10",
  },
  "devDependencies": {
    "@nuxt/devtools": "latest",
    "typescript": "^5.4.3",
    "vue-tsc": "^1.8.27"
  },
  "optionalDependencies": {
    "@rollup/rollup-linux-arm64-gnu": "^4.9.1",
    "@rollup/rollup-linux-x64-gnu": "^4.9.1"
  }
}

Expected behavior

// nuxt-icons/dist/runtime 27 line
const rawIcon = await iconsImport[`/assets/icons/${props.name}.svg`]()

Maybe, It needs to fix.

const iconsImportFunc = iconsImport[`/assets/icons/${props.name}.svg`]
if (iconsImportFunc === undefined) {
  return
}
const rawIcon = await iconsImportFunc()

Screenshots
スクリーンショット 2024-04-08 16 46 38

Desktop (please complete the following information):

  • OS: Apple M2 13.5
  • Browser: Chrome
  • Version: 122.0.6261.112(Official Build) (arm64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions