Nuxt.js: Missing $config type in Context

Created on 24 Jun 2020  路  5Comments  路  Source: nuxt/nuxt.js

Version

v2.13.1

Reproduction link

https://github.com/nuxt/nuxt.js/blob/40ceb61fabd682846b234059724d894e3f3127ea/packages/types/app/index.d.ts

Steps to reproduce

Nothing much actually.
Inside a Typescript environment, "$config" type doesn't exist inside the Context parameter.

What is expected ?

Context interface should expect a "$config" field

What is actually happening?

Type Error

This bug report is available on Nuxt community (#c10839)
bug-report

Most helpful comment

@pi0

image

I guess, you need to update @nuxt/typescript-build package with updated @nuxt/types package.

All 5 comments

For people interested in a workaround :

declare module 'vue/types/vue' {
  interface Vue {
    $config: any
  }
}

declare module '@nuxt/types' {
  interface Context {
    $config: any
  }
}

Hi @WTDuck. Types are provided i think you just need to add @nuxt/[email protected] (the one shipped with @nuxt/typescript is0.x and will be removed soon).

Please reopen if upgrading didn't resolve the issue.

Bonjour @pi0 !
I believe you got me wrong.
NuxtJS package already provides type definition for TypeScript and it's awesome (aka @nuxt/types)

I'm just pointing a missing key inside those definitions about the new context feature : $config

export interface Context {
  app: NuxtAppOptions
  base: string
  ...
  // missing $config
  }

@pi0

image

I guess, you need to update @nuxt/typescript-build package with updated @nuxt/types package.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gary149 picture gary149  路  3Comments

jaredreich picture jaredreich  路  3Comments

mikekidder picture mikekidder  路  3Comments

lazycrazy picture lazycrazy  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments