fix: improve type declarations (#1178)

This commit is contained in:
Daniel Roe 2021-10-18 17:06:31 +01:00 committed by GitHub
parent 99480696c4
commit 47c004ac97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 33 deletions

View File

@ -23,7 +23,7 @@ export declare type TypedInternalResponse<Route, Default> =
: MiddlewareOf<Route>
: Default
export declare interface $Fetch<DefaultT = unknown, DefaultR = FetchRequest> {
export declare interface $Fetch<DefaultT = unknown, DefaultR extends FetchRequest = FetchRequest> {
<T = DefaultT, R extends FetchRequest = DefaultR> (request: R, opts?: FetchOptions): Promise<TypedInternalResponse<R, T>>
raw<T = DefaultT, R extends FetchRequest = DefaultR> (request: R, opts?: FetchOptions): Promise<FetchResponse<TypedInternalResponse<R, T>>>
}
@ -38,4 +38,4 @@ declare global {
}
}
export default {}
export { }

View File

@ -0,0 +1,28 @@
import { NuxtApp } from '../nuxt'
declare global {
namespace NodeJS {
interface Process {
browser: boolean
client: boolean
dev: boolean
mode: 'spa' | 'universal'
server: boolean
static: boolean
}
}
interface Window {
__NUXT__?: Record<string, any>
}
}
declare module '@vue/runtime-core' {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface App<HostElement> {
$nuxt: NuxtApp
}
interface ComponentInternalInstance {
_nuxtOnBeforeMountCbs: Function[]
}
}

View File

@ -1,3 +1,4 @@
import './augments'
import './shims'
// eslint-disable-next-line

View File

@ -1,33 +1,6 @@
import { Component } from '@vue/runtime-core'
import { NuxtApp } from '../nuxt'
declare global {
namespace NodeJS {
interface Process {
browser: boolean
client: boolean
dev: boolean
mode: 'spa' | 'universal'
server: boolean
static: boolean
}
}
interface Window {
__NUXT__?: Record<string, any>
}
}
// https://github.com/vitejs/vite/blob/main/packages/create-vite/template-vue-ts/src/env.d.ts
declare module '*.vue' {
export default Component
}
declare module '@vue/runtime-core' {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface App<HostElement> {
$nuxt: NuxtApp
}
interface ComponentInternalInstance {
_nuxtOnBeforeMountCbs: Function[]
}
import { DefineComponent } from '@vue/runtime-core'
const component: DefineComponent<{}, {}, any>
export default component
}