mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
types: add global and shims for app and nitro (#102)
This commit is contained in:
parent
5646770cd1
commit
a63347b0ba
@ -5,9 +5,10 @@
|
||||
"license": "MIT",
|
||||
"main": "./dist/app/index.js",
|
||||
"module": "./dist/app/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"types": "./types/index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"types",
|
||||
"meta.js"
|
||||
],
|
||||
"scripts": {
|
||||
|
@ -1,3 +1,2 @@
|
||||
export * from './nuxt'
|
||||
export * from './shim'
|
||||
export * from './composables'
|
||||
|
3
packages/app/types/index.d.ts
vendored
Normal file
3
packages/app/types/index.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import './shims'
|
||||
|
||||
export * from '../dist/app'
|
@ -1,24 +1,36 @@
|
||||
import type { Nuxt } from './nuxt'
|
||||
|
||||
declare module 'vue' {
|
||||
interface App {
|
||||
$nuxt: Nuxt
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__NUXT__?: Record<string, any>
|
||||
}
|
||||
import type { $Fetch } from 'ohmyfetch'
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
var $fetch: $Fetch
|
||||
|
||||
namespace NodeJS {
|
||||
interface Global {
|
||||
$fetch: $Fetch
|
||||
}
|
||||
interface Process {
|
||||
browser: boolean
|
||||
client: boolean
|
||||
mode: 'spa' | 'universal'
|
||||
modern: boolean
|
||||
server: boolean
|
||||
static: boolean
|
||||
}
|
||||
}
|
||||
|
||||
interface Window {
|
||||
__NUXT__?: Record<string, any>
|
||||
}
|
||||
}
|
||||
|
||||
declare module '*.vue' {
|
||||
import Vue from 'vue'
|
||||
export default Vue
|
||||
}
|
||||
|
||||
declare module 'vue' {
|
||||
import type { Nuxt } from '../dist/app'
|
||||
|
||||
interface App {
|
||||
$nuxt: Nuxt
|
||||
}
|
||||
}
|
@ -3,8 +3,10 @@
|
||||
"version": "0.5.2",
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
"types": "./types/index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"types",
|
||||
"compat.js"
|
||||
],
|
||||
"scripts": {
|
||||
|
@ -2,5 +2,4 @@ export * from './build'
|
||||
export * from './context'
|
||||
export * from './server/middleware'
|
||||
export * from './server/dev'
|
||||
export * from './types'
|
||||
export { wpfs } from './utils/wpfs'
|
||||
|
@ -1,11 +0,0 @@
|
||||
import type { $Fetch } from 'ohmyfetch'
|
||||
|
||||
declare global {
|
||||
const $fetch: $Fetch
|
||||
|
||||
namespace NodeJS {
|
||||
interface Global {
|
||||
$fetch: $Fetch
|
||||
}
|
||||
}
|
||||
}
|
3
packages/nitro/types/index.d.ts
vendored
Normal file
3
packages/nitro/types/index.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import './shims'
|
||||
|
||||
export * from '../dist/index'
|
22
packages/nitro/types/shims.d.ts
vendored
Normal file
22
packages/nitro/types/shims.d.ts
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
declare global {
|
||||
import type { $Fetch } from 'ohmyfetch'
|
||||
// eslint-disable-next-line no-var
|
||||
var $fetch: $Fetch
|
||||
namespace NodeJS {
|
||||
interface Global {
|
||||
$fetch: $Fetch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module '#storage' {
|
||||
import type { Storage } from 'unstorage'
|
||||
export const storage: Storage
|
||||
}
|
||||
|
||||
declare module '#assets' {
|
||||
export interface AssetMeta { type?: string, etag?: string, mtime?: string }
|
||||
export function readAsset<T=any>(id: string): Promise<T>
|
||||
export function statAsset(id: string): Promise<AssetMeta>
|
||||
export function getAsset<T=any>(id: string): { read: () => Promise<T>, meta: AssetMeta }
|
||||
}
|
@ -10,7 +10,9 @@
|
||||
"resolveJsonModule": true,
|
||||
"types": [
|
||||
"node",
|
||||
"jest"
|
||||
"jest",
|
||||
"@nuxt/app",
|
||||
"@nuxt/nitro",
|
||||
]
|
||||
},
|
||||
"exclude": ["./packages/*/dist/*"]
|
||||
|
Loading…
Reference in New Issue
Block a user