mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 01:17:16 +00:00
fix: improve type declarations (#1178)
This commit is contained in:
parent
99480696c4
commit
47c004ac97
4
packages/nitro/types/fetch.d.ts
vendored
4
packages/nitro/types/fetch.d.ts
vendored
@ -23,7 +23,7 @@ export declare type TypedInternalResponse<Route, Default> =
|
|||||||
: MiddlewareOf<Route>
|
: MiddlewareOf<Route>
|
||||||
: Default
|
: 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>>
|
<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>>>
|
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 { }
|
||||||
|
28
packages/nuxt3/src/app/types/augments.ts
Normal file
28
packages/nuxt3/src/app/types/augments.ts
Normal 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[]
|
||||||
|
}
|
||||||
|
}
|
1
packages/nuxt3/src/app/types/index.d.ts
vendored
1
packages/nuxt3/src/app/types/index.d.ts
vendored
@ -1,3 +1,4 @@
|
|||||||
|
import './augments'
|
||||||
import './shims'
|
import './shims'
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
|
35
packages/nuxt3/src/app/types/shims.d.ts
vendored
35
packages/nuxt3/src/app/types/shims.d.ts
vendored
@ -1,33 +1,6 @@
|
|||||||
import { Component } from '@vue/runtime-core'
|
// https://github.com/vitejs/vite/blob/main/packages/create-vite/template-vue-ts/src/env.d.ts
|
||||||
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' {
|
declare module '*.vue' {
|
||||||
export default Component
|
import { DefineComponent } from '@vue/runtime-core'
|
||||||
}
|
const component: DefineComponent<{}, {}, any>
|
||||||
|
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[]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user