mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat: define nitro #storage
and #assets
types (#1377)
This commit is contained in:
parent
06e9c7ebc1
commit
281790e036
@ -129,6 +129,11 @@ export function setupNitroBridge () {
|
||||
// Add typed route responses
|
||||
nuxt.hook('prepare:types', (opts) => {
|
||||
opts.references.push({ path: resolve(nuxt.options.buildDir, 'nitro.d.ts') })
|
||||
|
||||
for (const stub of ['#storage', '#assets']) {
|
||||
// The `@nuxt/nitro` types will be overwritten by packages/nitro/types/shims.d.ts
|
||||
opts.tsConfig.compilerOptions.paths[stub] = ['@nuxt/nitro']
|
||||
}
|
||||
})
|
||||
|
||||
// nuxt build/dev
|
||||
|
4
packages/nitro/types/shims.d.ts
vendored
4
packages/nitro/types/shims.d.ts
vendored
@ -5,7 +5,7 @@ declare module '#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 readAsset<T = any> (id: string): Promise<T>
|
||||
export function statAsset (id: string): Promise<AssetMeta>
|
||||
export function getKeys() : Promise<string[]>
|
||||
}
|
||||
|
@ -27,7 +27,10 @@ export const writeTypes = async (nuxt: Nuxt) => {
|
||||
|
||||
const aliases = {
|
||||
...nuxt.options.alias,
|
||||
'#build': nuxt.options.buildDir
|
||||
'#build': nuxt.options.buildDir,
|
||||
// The `@nuxt/nitro` types will be overwritten by packages/nitro/types/shims.d.ts
|
||||
'#storage': '@nuxt/nitro',
|
||||
'#assets': '@nuxt/nitro'
|
||||
}
|
||||
|
||||
for (const alias in aliases) {
|
||||
|
Loading…
Reference in New Issue
Block a user