Closed itsfarseen closed 5 years ago
Try adding "@nuxt/http" to types in your tsconfig.json:
{
"compilerOptions": {
/* ... */
"types": [
"@types/node",
"@nuxt/vue-app",
"@nuxt/http"
]
}
}
That didn't work :(
This is the error:
ERROR ERROR in nuxt-http-typescript-bug1-repro/node_modules/@nuxt/http/types/index.d.ts 19:03:18
2:85 Module '"../../../ky"' has no exported member 'JSONValue'.
1 | import Vue from 'vue'
> 2 | import { ResponsePromise, Options, BeforeRequestHook, AfterResponseHook, HTTPError, JSONValue } from 'ky'
| ^
3 | import './vuex'
4 |
5 | type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
Interestingly, the error says nuxt-http-typescript-bug1-repro/node_modules/@nuxt/http/types/index.d.ts
even when I don't have "@nuxt/http"
in tsconfig.json
.
Seems like there is something missing in the definition. As a workaround you can try placing this in an ambient declaration file (anyname.d.ts):
declare module "ky" {
interface JSONValue extends Object {}
}
This seems to be broken since the @nuxt/http bump from v0.1.2 to v0.2 since there the ky version got updated from v0.10.0 to v0.11.0.
They removed the type JSONValue
sindresorhus/ky#133. So since that type is always used as the return type of for example $get
$post
and so on we need to adjust the index.d.ts file.
The easiest option would be to change JSONValue
to unknown
like they did at the ky
repo or just use the old definition of JSONValue
from the ky
repo.
I would make a PR for that if @pi0 agrees.
Version
v0.3.2
Reproduction link
https://github.com/happycoder97/nuxt-http-typescript-bug1-repro
Steps to reproduce
Just run
yarn dev
What is expected ?
App compiles successfully.
What is actually happening?
Typechecking fails.