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 { NuxtPlugin, resolvePlugins } from './plugins'
|
||||
export interface NuxtApp {
|
||||
main: string
|
||||
main?: string
|
||||
routes: NuxtRoute[]
|
||||
dir: string
|
||||
extensions: string[]
|
||||
|
@ -2,6 +2,8 @@ import path from 'path'
|
||||
import querystring from 'querystring'
|
||||
import webpack from 'webpack'
|
||||
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
|
||||
import type { ClientOptions } from 'webpack-hot-middleware'
|
||||
|
||||
import { applyPresets, WebpackConfigContext } from '../utils/config'
|
||||
import { nuxt } from '../presets/nuxt'
|
||||
|
||||
@ -47,14 +49,14 @@ function clientHMR (ctx: WebpackConfigContext) {
|
||||
return
|
||||
}
|
||||
|
||||
const clientOptions = options.build.hotMiddleware?.client || {}
|
||||
const clientOptions = options.build.hotMiddleware?.client || {} as ClientOptions
|
||||
const hotMiddlewareClientOptions = {
|
||||
reload: true,
|
||||
timeout: 30000,
|
||||
ansiColors: JSON.stringify(clientOptions.ansiColors || {}),
|
||||
overlayStyles: JSON.stringify(clientOptions.overlayStyles || {}),
|
||||
path: `${options.router.base}/__webpack_hmr/${ctx.name}`.replace(/\/\//g, '/'),
|
||||
...clientOptions,
|
||||
ansiColors: JSON.stringify(clientOptions.ansiColors || {}),
|
||||
overlayStyles: JSON.stringify(clientOptions.overlayStyles || {}),
|
||||
name: ctx.name
|
||||
}
|
||||
const hotMiddlewareClientOptionsStr = querystring.stringify(hotMiddlewareClientOptions)
|
||||
|
@ -31,7 +31,7 @@ function readDir (dirName) {
|
||||
}
|
||||
return module
|
||||
})
|
||||
.reduce(function (prev, next) {
|
||||
.reduce<string[]>(function (prev, next) {
|
||||
return prev.concat(next)
|
||||
}, [])
|
||||
} catch (e) {
|
||||
|
@ -1,4 +1,7 @@
|
||||
import { WebpackError } from 'webpack'
|
||||
export default class WarningIgnorePlugin {
|
||||
filter: (warn: WebpackError) => boolean
|
||||
|
||||
constructor (filter) {
|
||||
this.filter = filter
|
||||
}
|
||||
|
@ -1,2 +1 @@
|
||||
export { default as StyleLoader } from './style-loader'
|
||||
export { reservedVueTags } from './reserved-tags'
|
||||
|
@ -2,12 +2,14 @@ import path from 'path'
|
||||
import pify from 'pify'
|
||||
import { Volume, createFsFromVolume } from 'memfs'
|
||||
|
||||
import type { IFs } from 'memfs'
|
||||
|
||||
export function createMFS () {
|
||||
// Create a new volume
|
||||
const fs = createFsFromVolume(new Volume())
|
||||
|
||||
// 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
|
||||
// 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
|
||||
|
||||
interface CommonConfiguration {
|
||||
_majorVersion: Number
|
||||
_modules: NuxtModule[]
|
||||
_nuxtConfigFile?: string
|
||||
alias: Record<string, string>
|
||||
@ -129,6 +130,7 @@ interface CommonConfiguration {
|
||||
}
|
||||
|
||||
export default (): CommonConfiguration => ({
|
||||
_majorVersion: undefined,
|
||||
// Env
|
||||
dev: Boolean(env.dev),
|
||||
test: Boolean(env.test),
|
||||
@ -170,6 +172,7 @@ export default (): CommonConfiguration => ({
|
||||
_nuxtConfigFile: undefined,
|
||||
srcDir: undefined,
|
||||
buildDir: '.nuxt',
|
||||
vite: false,
|
||||
modulesDir: [
|
||||
'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 RouteConfig = UnionToIntersection<RouteRecordRaw>
|
||||
@ -25,7 +25,7 @@ export interface RouterConfigurationNormalized {
|
||||
prefetchPayloads: boolean
|
||||
routes: Route[]
|
||||
routeNameSplitter: string
|
||||
scrollBehavior: null | ScrollBehavior
|
||||
scrollBehavior: null | RouterScrollBehavior
|
||||
stringifyQuery: boolean
|
||||
trailingSlash?: boolean
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user