In a NuxtJs 3 project I tried to add some specific stuff into my app.config.ts a the root directory of my project.
When I tried to call useAppConfig() to use my config data, VSCode raise an error appConfig.as is unknown type
I'm stuck with that :(
The app.config.ts :
interface asAppConfig {
layout: {
nav: {
isOpen: boolean
}
}
}
export default defineAppConfig({
ui: {
notifications: {
position: 'top-0 right-0 bottom-auto',
},
},
as: {
layout: {
nav: {
isOpen: false,
},
},
} satisfies asAppConfig,
})
Below after calling useAppConfig(), I have appConfig.as is unknown type
<script lang="ts" setup>
const appConfig = useAppConfig()
const isOpen = computed({
get: () => appConfig.as.layout.nav.isOpen,
set: (value: boolean) => (appConfig.as.layout.nav.isOpen = value)
})
I haven't tried using the
useAppConfig()composable. But, based on the documentation, it says,~/index.d.tsNote: Once you added that file, you might want to reload your IDE.
~/app.config.tsNow, it should show the available typings for you.
Again, I haven't used the
useAppConfigcomposable. My answer is just based on the Nuxt documentation.