07akioni / naive-ui-nuxt-demo

53 stars 23 forks source link

`nuxtApp.ssrContext` may not be defined? #9

Closed RSS1102 closed 2 years ago

RSS1102 commented 2 years ago
[{
    "resource": "/f:/GitHubDesktop/blogs-nuxt3/plugins/naive-ui.ts",
    "owner": "typescript",
    "code": "2322",
    "severity": 8,
    "message": "Type '(SSRContext & { url: string; event: CompatibilityEvent; req?: IncomingMessage | undefined; res?: ServerResponse | undefined; ... 6 more ...; renderMeta?: (() => NuxtMeta | Promise<...>) | undefined; }) | {}' is not assignable to type '(SSRContext & { url: string; event: CompatibilityEvent; req?: IncomingMessage | undefined; res?: ServerResponse | undefined; ... 6 more ...; renderMeta?: (() => NuxtMeta | Promise<...>) | undefined; }) | undefined'.\n  Type '{}' is not assignable to type 'SSRContext & { url: string; event: CompatibilityEvent; req?: IncomingMessage | undefined; res?: ServerResponse | undefined; ... 6 more ...; renderMeta?: (() => NuxtMeta | Promise<...>) | undefined; }'.\n    Type '{}' is missing the following properties from type '{ url: string; event: CompatibilityEvent; req?: IncomingMessage | undefined; res?: ServerResponse | undefined; runtimeConfig: RuntimeConfig; ... 5 more ...; renderMeta?: (() => NuxtMeta | Promise<...>) | undefined; }': url, event, runtimeConfig, noSSR, and 2 more.",
    "source": "ts",
    "startLineNumber": 8,
    "startColumn": 5,
    "endLineNumber": 8,
    "endColumn": 23
}]

image

image

07akioni commented 2 years ago

Check ts version & ts config. You can assert it to have the attribute. The original type is not enough.

RSS1102 commented 2 years ago

Check ts version & ts config. You can assert it to have the attribute. The original type is not enough.

ok thanks。

i did this way,But I don't know if there will be any unexpected scenes. image