N
Nuxt9mo ago
codeman1o1

State incorrectly typed as any

Hi! I'm pretty new to Nuxt modules, but I am making some progress. For my module I want to have a state which tracks the auth state. I wrote this in src/runtime/composables/states.ts:
import { useState } from "#imports"

export const useAuth = () => useState<boolean | null>("auth", () => null)
import { useState } from "#imports"

export const useAuth = () => useState<boolean | null>("auth", () => null)
The state works fine - as in the value is updated correctly - but it is typed as any instead of Ref<boolean | null>. How would I fix this?
7 Replies
manniL
manniL9mo ago
Can you provide a reproduction? It should be typed correctly like that
codeman1o1
codeman1o1OP9mo ago
Hi, I have made a simple reproduction, using nuxi init as the base for both module and website. https://github.com/codeman1o1/nuxt-module-mre
GitHub
GitHub - codeman1o1/nuxt-module-mre
Contribute to codeman1o1/nuxt-module-mre development by creating an account on GitHub.
codeman1o1
codeman1o1OP9mo ago
The module/my-module-1.0.0.tgz is locally built using npm run prepack && npm pack Hi @manniL / TheAlexLichter (sorry for the ping), Have you been able to look into this? It seems like a really strange bug that is not present in the playground, but only in production. Does this maybe have to do with the build process?
manniL
manniL9mo ago
not yet ☺️
danielroe
danielroe9mo ago
Might be to do with how the declaration files are rendered by the builder - there is a bug tracking it.
codeman1o1
codeman1o1OP9mo ago
Thanks for your response, I would like to stay updated on any progress made on this. Is #233 the issue you mentioned by any chance?
GitHub
Type definitions are incorrect when importing useAsyncData from #im...
Environment Operating System: Darwin Node Version: v20.9.0 Nuxt Version: 3.10.3 CLI Version: 3.10.1 Nitro Version: 2.9.1 Package Manager: [email protected] Builder: - User Config: - Runtime Modules: - B...
danielroe
danielroe9mo ago
It might be related, but https://github.com/nuxt/module-builder/issues/215 is the one I meant.
GitHub
Plugin injections are unknown · Issue #215 · nuxt/module-builder
Environment Operating System: Darwin Node Version: v20.9.0 Nuxt Version: 3.8.2 CLI Version: 3.10.0 Nitro Version: 2.8.1 Package Manager: [email protected] Builder: - User Config: - Runtime Modules: - Bui...
Want results from more Discord servers?
Add your server