mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(types): type definitions errors (#172)
This commit is contained in:
parent
52592a5d64
commit
52d28c041a
@ -4,7 +4,7 @@ import { Builder } from './builder'
|
|||||||
import { NuxtRoute, resolvePagesRoutes } from './pages'
|
import { NuxtRoute, resolvePagesRoutes } from './pages'
|
||||||
import { NuxtPlugin, resolvePlugins } from './plugins'
|
import { NuxtPlugin, resolvePlugins } from './plugins'
|
||||||
export interface NuxtApp {
|
export interface NuxtApp {
|
||||||
main: string
|
main?: string
|
||||||
routes: NuxtRoute[]
|
routes: NuxtRoute[]
|
||||||
dir: string
|
dir: string
|
||||||
extensions: string[]
|
extensions: string[]
|
||||||
|
@ -2,6 +2,8 @@ import path from 'path'
|
|||||||
import querystring from 'querystring'
|
import querystring from 'querystring'
|
||||||
import webpack from 'webpack'
|
import webpack from 'webpack'
|
||||||
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
|
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
|
||||||
|
import type { ClientOptions } from 'webpack-hot-middleware'
|
||||||
|
|
||||||
import { applyPresets, WebpackConfigContext } from '../utils/config'
|
import { applyPresets, WebpackConfigContext } from '../utils/config'
|
||||||
import { nuxt } from '../presets/nuxt'
|
import { nuxt } from '../presets/nuxt'
|
||||||
|
|
||||||
@ -47,14 +49,14 @@ function clientHMR (ctx: WebpackConfigContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const clientOptions = options.build.hotMiddleware?.client || {}
|
const clientOptions = options.build.hotMiddleware?.client || {} as ClientOptions
|
||||||
const hotMiddlewareClientOptions = {
|
const hotMiddlewareClientOptions = {
|
||||||
reload: true,
|
reload: true,
|
||||||
timeout: 30000,
|
timeout: 30000,
|
||||||
ansiColors: JSON.stringify(clientOptions.ansiColors || {}),
|
|
||||||
overlayStyles: JSON.stringify(clientOptions.overlayStyles || {}),
|
|
||||||
path: `${options.router.base}/__webpack_hmr/${ctx.name}`.replace(/\/\//g, '/'),
|
path: `${options.router.base}/__webpack_hmr/${ctx.name}`.replace(/\/\//g, '/'),
|
||||||
...clientOptions,
|
...clientOptions,
|
||||||
|
ansiColors: JSON.stringify(clientOptions.ansiColors || {}),
|
||||||
|
overlayStyles: JSON.stringify(clientOptions.overlayStyles || {}),
|
||||||
name: ctx.name
|
name: ctx.name
|
||||||
}
|
}
|
||||||
const hotMiddlewareClientOptionsStr = querystring.stringify(hotMiddlewareClientOptions)
|
const hotMiddlewareClientOptionsStr = querystring.stringify(hotMiddlewareClientOptions)
|
||||||
|
@ -31,7 +31,7 @@ function readDir (dirName) {
|
|||||||
}
|
}
|
||||||
return module
|
return module
|
||||||
})
|
})
|
||||||
.reduce(function (prev, next) {
|
.reduce<string[]>(function (prev, next) {
|
||||||
return prev.concat(next)
|
return prev.concat(next)
|
||||||
}, [])
|
}, [])
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
|
import { WebpackError } from 'webpack'
|
||||||
export default class WarningIgnorePlugin {
|
export default class WarningIgnorePlugin {
|
||||||
|
filter: (warn: WebpackError) => boolean
|
||||||
|
|
||||||
constructor (filter) {
|
constructor (filter) {
|
||||||
this.filter = filter
|
this.filter = filter
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1 @@
|
|||||||
export { default as StyleLoader } from './style-loader'
|
|
||||||
export { reservedVueTags } from './reserved-tags'
|
export { reservedVueTags } from './reserved-tags'
|
||||||
|
@ -2,12 +2,14 @@ import path from 'path'
|
|||||||
import pify from 'pify'
|
import pify from 'pify'
|
||||||
import { Volume, createFsFromVolume } from 'memfs'
|
import { Volume, createFsFromVolume } from 'memfs'
|
||||||
|
|
||||||
|
import type { IFs } from 'memfs'
|
||||||
|
|
||||||
export function createMFS () {
|
export function createMFS () {
|
||||||
// Create a new volume
|
// Create a new volume
|
||||||
const fs = createFsFromVolume(new Volume())
|
const fs = createFsFromVolume(new Volume())
|
||||||
|
|
||||||
// Clone to extend
|
// Clone to extend
|
||||||
const _fs = { ...fs }
|
const _fs : Partial<IFs> & { join?(...paths: string[]): string } = { ...fs }
|
||||||
|
|
||||||
// fs.join method is (still) expected by webpack-dev-middleware
|
// fs.join method is (still) expected by webpack-dev-middleware
|
||||||
// There might be differences with https://github.com/webpack/memory-fs/blob/master/lib/join.js
|
// There might be differences with https://github.com/webpack/memory-fs/blob/master/lib/join.js
|
||||||
|
@ -81,6 +81,7 @@ export type NuxtModule = string | ModuleHandler | [string | ModuleHandler, any]
|
|||||||
export type ServerMiddleware = string | { path: string, prefix?: boolean, handler: string | express.NextFunction } | express.NextFunction
|
export type ServerMiddleware = string | { path: string, prefix?: boolean, handler: string | express.NextFunction } | express.NextFunction
|
||||||
|
|
||||||
interface CommonConfiguration {
|
interface CommonConfiguration {
|
||||||
|
_majorVersion: Number
|
||||||
_modules: NuxtModule[]
|
_modules: NuxtModule[]
|
||||||
_nuxtConfigFile?: string
|
_nuxtConfigFile?: string
|
||||||
alias: Record<string, string>
|
alias: Record<string, string>
|
||||||
@ -129,6 +130,7 @@ interface CommonConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default (): CommonConfiguration => ({
|
export default (): CommonConfiguration => ({
|
||||||
|
_majorVersion: undefined,
|
||||||
// Env
|
// Env
|
||||||
dev: Boolean(env.dev),
|
dev: Boolean(env.dev),
|
||||||
test: Boolean(env.test),
|
test: Boolean(env.test),
|
||||||
@ -170,6 +172,7 @@ export default (): CommonConfiguration => ({
|
|||||||
_nuxtConfigFile: undefined,
|
_nuxtConfigFile: undefined,
|
||||||
srcDir: undefined,
|
srcDir: undefined,
|
||||||
buildDir: '.nuxt',
|
buildDir: '.nuxt',
|
||||||
|
vite: false,
|
||||||
modulesDir: [
|
modulesDir: [
|
||||||
'node_modules'
|
'node_modules'
|
||||||
],
|
],
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { RouteRecordRaw, ScrollBehavior } from 'vue-router'
|
import { RouteRecordRaw, RouterScrollBehavior } from 'vue-router'
|
||||||
|
|
||||||
type UnionToIntersection<T> = (T extends any ? (k: T) => void : never) extends ((k: infer U) => void) ? U : never
|
type UnionToIntersection<T> = (T extends any ? (k: T) => void : never) extends ((k: infer U) => void) ? U : never
|
||||||
type RouteConfig = UnionToIntersection<RouteRecordRaw>
|
type RouteConfig = UnionToIntersection<RouteRecordRaw>
|
||||||
@ -25,7 +25,7 @@ export interface RouterConfigurationNormalized {
|
|||||||
prefetchPayloads: boolean
|
prefetchPayloads: boolean
|
||||||
routes: Route[]
|
routes: Route[]
|
||||||
routeNameSplitter: string
|
routeNameSplitter: string
|
||||||
scrollBehavior: null | ScrollBehavior
|
scrollBehavior: null | RouterScrollBehavior
|
||||||
stringifyQuery: boolean
|
stringifyQuery: boolean
|
||||||
trailingSlash?: boolean
|
trailingSlash?: boolean
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user