Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tsukuha opened this issue Apr 8, 2024 · 0 comments · May be fixed by #57
Open
Labels
bug Something isn't working

Comments

@tsukuha
Copy link

tsukuha commented Apr 8, 2024

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)
@tsukuha tsukuha added the bug Something isn't working label Apr 8, 2024
@tsukuha tsukuha linked a pull request Jun 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant