Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add type any to parameter e/err/err2, resolve ts error #4972

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vite/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ async function fetchUpdate({ path, acceptedPath, timestamp }: Update) {
`?import&t=${timestamp}${query ? `&${query}` : ''}`
)
moduleMap.set(dep, newMod)
} catch (e) {
} catch (e: any) {
warnFailedFetch(e, dep)
}
})
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ async function doBuild(
} else {
return await generate(outputs)
}
} catch (e) {
} catch (e: any) {
outputBuildError(e)
throw e
}
Expand Down
8 changes: 4 additions & 4 deletions packages/vite/src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ cli
server: cleanOptions(options)
})
await server.listen()
} catch (e) {
} catch (e: any) {
createLogger(options.logLevel).error(
chalk.red(`error when starting dev server:\n${e.stack}`),
{ error: e }
Expand Down Expand Up @@ -147,7 +147,7 @@ cli
clearScreen: options.clearScreen,
build: buildOptions
})
} catch (e) {
} catch (e: any) {
createLogger(options.logLevel).error(
chalk.red(`error during build:\n${e.stack}`),
{ error: e }
Expand Down Expand Up @@ -178,7 +178,7 @@ cli
'development'
)
await optimizeDeps(config, options.force, true)
} catch (e) {
} catch (e: any) {
createLogger(options.logLevel).error(
chalk.red(`error when optimizing deps:\n${e.stack}`),
{ error: e }
Expand Down Expand Up @@ -223,7 +223,7 @@ cli
'production'
)
await preview(config, cleanOptions(options))
} catch (e) {
} catch (e: any) {
createLogger(options.logLevel).error(
chalk.red(`error when starting preview server:\n${e.stack}`),
{ error: e }
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ export async function loadConfigFromFile(
delete require.cache[require.resolve(resolvedPath)]
userConfig = require(resolvedPath)
debug(`cjs config loaded in ${Date.now() - start}ms`)
} catch (e) {
} catch (e: any) {
const ignored = new RegExp(
[
`Cannot use import statement`,
Expand Down Expand Up @@ -866,7 +866,7 @@ export async function loadConfigFromFile(
config,
dependencies
}
} catch (e) {
} catch (e: any) {
createLogger(logLevel).error(
chalk.red(`failed to load config from ${resolvedPath}`),
{ error: e }
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/optimizer/registerMissing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function createMissingImporterRegisterFn(
chalk.greenBright(`✨ dependencies updated, reloading page...`),
{ timestamp: true }
)
} catch (e) {
} catch (e: any) {
logger.error(
chalk.red(`error while updating dependencies:\n${e.stack}`),
{ timestamp: true, error: e }
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ async function resolvePostcssConfig(
typeof inlineOptions === 'string' ? inlineOptions : config.root
// @ts-ignore
result = await postcssrc({}, searchPath)
} catch (e) {
} catch (e: any) {
if (!/No PostCSS Config found/.test(e.message)) {
throw e
}
Expand Down Expand Up @@ -1055,7 +1055,7 @@ const scss: SassStylePreprocessor = async (
errors: [],
deps
}
} catch (e) {
} catch (e: any) {
// normalize SASS error
e.id = e.file
e.frame = e.formatted
Expand Down Expand Up @@ -1248,7 +1248,7 @@ const styl: StylePreprocessor = async (source, root, options) => {
const deps = [...ref.deps(), ...importsDeps]

return { code: result, errors: [], deps }
} catch (e) {
} catch (e: any) {
return { code: '', errors: [e], deps: [] }
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
value.loc.end.offset,
`"${url}"`
)
} catch (e) {
} catch (e: any) {
// #1885 preload may be pointing to urls that do not exist
// locally on disk
if (e.code !== 'ENOENT') {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function jsonPlugin(
}),
map: { mappings: '' }
}
} catch (e) {
} catch (e: any) {
const errorMessageList = /[\d]+/.exec(e.message)
const position = errorMessageList && parseInt(errorMessageList[0], 10)
const msg = position
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ export function resolvePackageEntry(
} else {
packageEntryFailure(id)
}
} catch (e) {
} catch (e: any) {
packageEntryFailure(id, e.message)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ export async function createServer(
if (serverConfig.hmr !== false) {
try {
await handleHMRUpdate(file, server)
} catch (err) {
} catch (err: any) {
ws.send({
type: 'error',
err: prepareError(err)
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/server/pluginContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export async function createPluginContainer(
let errLocation
try {
errLocation = numberToPos(ctx._activeCode, pos)
} catch (err2) {
} catch (err2: any) {
logger.error(
chalk.red(
`Error in error handler:\n${err2.stack || err2.message}\n`
Expand Down Expand Up @@ -506,7 +506,7 @@ export async function createPluginContainer(
let result: TransformResult | string | undefined
try {
result = await plugin.transform.call(ctx as any, code, id, ssr)
} catch (e) {
} catch (e: any) {
ctx.error(e)
}
if (!result) continue
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/transformRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function transformRequest(
try {
code = await fs.readFile(file, 'utf-8')
isDebug && debugLoad(`${timeFrom(loadStart)} [fs] ${prettyUrl}`)
} catch (e) {
} catch (e: any) {
if (e.code !== 'ENOENT') {
throw e
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/ssr/ssrModuleLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async function instantiateModule(
ssrDynamicImport,
ssrExportAll
)
} catch (e) {
} catch (e: any) {
const stacktrace = ssrRewriteStacktrace(e.stack, moduleGraph)
rebindErrorStacktrace(e, stacktrace)
server.config.logger.error(
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/ssr/ssrStacktrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ModuleGraph } from '../server/moduleGraph'
let offset: number
try {
new Function('throw new Error(1)')()
} catch (e) {
} catch (e: any) {
// in Node 12, stack traces account for the function wrapper.
// in Node 13 and later, the function wrapper adds two lines,
// which must be subtracted to generate a valid mapping
Expand Down