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

nuxt/icon breaks nuxt's plugin system types #214

Closed
OrlS15 opened this issue Jul 23, 2024 · 0 comments
Closed

nuxt/icon breaks nuxt's plugin system types #214

OrlS15 opened this issue Jul 23, 2024 · 0 comments
Labels
bug Something isn't working upstream

Comments

@OrlS15
Copy link

OrlS15 commented Jul 23, 2024

If you create a plugin and provide some functions, these functions are not typed if nuxt/icon is installed.

// ~/plugins/test.ts
export default defineNuxtPlugin(async () => {
 return {
   provide: {
     aaa: () => 'WEWE',
   },
 };
});
// ~/app.vue
<script setup lang="ts">
useNuxtApp().$aaa(); // $aaa is unknown
</script>

<template></template>

In ~/.nuxt/types/plugins.d.ts NuxtAppInjections is any (because one of the unions is any):

type NuxtAppInjections = 
  InjectionType<typeof import("../../node_modules/.pnpm/nuxt@3.12.4_@parcel+watcher@2.4.1_@types+node@20.14.11_ioredis@5.4.1_magicast@0.3.4_rollup@4._lljhbfrgkudpe6zumtjkp3yzvi/node_modules/nuxt/dist/app/plugins/navigation-repaint.client").default> &
  InjectionType<typeof import("../../node_modules/.pnpm/nuxt@3.12.4_@parcel+watcher@2.4.1_@types+node@20.14.11_ioredis@5.4.1_magicast@0.3.4_rollup@4._lljhbfrgkudpe6zumtjkp3yzvi/node_modules/nuxt/dist/app/plugins/check-outdated-build.client").default> &
  InjectionType<typeof import("../../node_modules/.pnpm/nuxt@3.12.4_@parcel+watcher@2.4.1_@types+node@20.14.11_ioredis@5.4.1_magicast@0.3.4_rollup@4._lljhbfrgkudpe6zumtjkp3yzvi/node_modules/nuxt/dist/app/plugins/revive-payload.server").default> &
  InjectionType<typeof import("../../node_modules/.pnpm/nuxt@3.12.4_@parcel+watcher@2.4.1_@types+node@20.14.11_ioredis@5.4.1_magicast@0.3.4_rollup@4._lljhbfrgkudpe6zumtjkp3yzvi/node_modules/nuxt/dist/app/plugins/revive-payload.client").default> &
  InjectionType<typeof import("../../node_modules/.pnpm/nuxt@3.12.4_@parcel+watcher@2.4.1_@types+node@20.14.11_ioredis@5.4.1_magicast@0.3.4_rollup@4._lljhbfrgkudpe6zumtjkp3yzvi/node_modules/nuxt/dist/app/plugins/chunk-reload.client").default> &
  InjectionType<typeof import("../../node_modules/.pnpm/nuxt@3.12.4_@parcel+watcher@2.4.1_@types+node@20.14.11_ioredis@5.4.1_magicast@0.3.4_rollup@4._lljhbfrgkudpe6zumtjkp3yzvi/node_modules/nuxt/dist/head/runtime/plugins/unhead").default> &
  InjectionType<typeof import("../../node_modules/.pnpm/nuxt@3.12.4_@parcel+watcher@2.4.1_@types+node@20.14.11_ioredis@5.4.1_magicast@0.3.4_rollup@4._lljhbfrgkudpe6zumtjkp3yzvi/node_modules/nuxt/dist/app/plugins/router").default> &
  InjectionType<typeof import("../../node_modules/.pnpm/@nuxt+devtools@1.3.9_rollup@4.19.0_vite@5.3.4_@types+node@20.14.11_terser@5.31.3_/node_modules/@nuxt/devtools/dist/runtime/plugins/devtools.server").default> &
  InjectionType<typeof import("../../node_modules/.pnpm/@nuxt+devtools@1.3.9_rollup@4.19.0_vite@5.3.4_@types+node@20.14.11_terser@5.31.3_/node_modules/@nuxt/devtools/dist/runtime/plugins/devtools.client").default> &
  // this one below is any
  InjectionType<typeof import("../../node_modules/.pnpm/@nuxt+icon@1.3.0_magicast@0.3.4_rollup@4.19.0_vite@5.3.4_@types+node@20.14.11_terser@5.31.3__vue@3.4.33/node_modules/@nuxt/icon/dist/runtime/plugin").default /* <-- 'default' is any */> &
  InjectionType<typeof import("../../node_modules/.pnpm/nuxt@3.12.4_@parcel+watcher@2.4.1_@types+node@20.14.11_ioredis@5.4.1_magicast@0.3.4_rollup@4._lljhbfrgkudpe6zumtjkp3yzvi/node_modules/nuxt/dist/app/plugins/dev-server-logs").default> &
  InjectionType<typeof import("../../node_modules/.pnpm/nuxt@3.12.4_@parcel+watcher@2.4.1_@types+node@20.14.11_ioredis@5.4.1_magicast@0.3.4_rollup@4._lljhbfrgkudpe6zumtjkp3yzvi/node_modules/nuxt/dist/app/plugins/check-if-layout-used").default> &
  InjectionType<typeof import("../../plugins/test").default>

The file node_modules/@nuxt/icon/dist/runtime/plugin.d.ts is empty.

Reproduction:
https://stackblitz.com/edit/github-upzndu?file=plugins%2Ftest.ts,app.vue (stackblitz's types don't work in .vue files, test it in local)

@antfu antfu added bug Something isn't working upstream labels Jul 23, 2024
@antfu antfu closed this as completed in 6515a80 Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

No branches or pull requests

2 participants