Unverified Commit 78cb07a4 authored by zoomdong's avatar zoomdong Committed by GitHub

chore: remove unsless @ts-ignore (#40992)



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [x] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent fa19f172
...@@ -45,7 +45,6 @@ export class AppBuildManifestPlugin { ...@@ -45,7 +45,6 @@ export class AppBuildManifestPlugin {
compilation.hooks.processAssets.tap( compilation.hooks.processAssets.tap(
{ {
name: PLUGIN_NAME, name: PLUGIN_NAME,
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS, stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
}, },
(assets: any) => this.createAsset(assets, compilation) (assets: any) => this.createAsset(assets, compilation)
......
...@@ -266,11 +266,9 @@ export default class BuildManifestPlugin { ...@@ -266,11 +266,9 @@ export default class BuildManifestPlugin {
apply(compiler: webpack.Compiler) { apply(compiler: webpack.Compiler) {
compiler.hooks.make.tap('NextJsBuildManifest', (compilation) => { compiler.hooks.make.tap('NextJsBuildManifest', (compilation) => {
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
compilation.hooks.processAssets.tap( compilation.hooks.processAssets.tap(
{ {
name: 'NextJsBuildManifest', name: 'NextJsBuildManifest',
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS, stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
}, },
(assets: any) => { (assets: any) => {
......
...@@ -35,7 +35,6 @@ export class CopyFilePlugin { ...@@ -35,7 +35,6 @@ export class CopyFilePlugin {
hook.tapPromise( hook.tapPromise(
{ {
name: PLUGIN_NAME, name: PLUGIN_NAME,
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS, stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
}, },
async () => { async () => {
...@@ -69,7 +68,6 @@ export class CopyFilePlugin { ...@@ -69,7 +68,6 @@ export class CopyFilePlugin {
}) })
} }
// @ts-ignore
compilation.emitAsset(file, source, { compilation.emitAsset(file, source, {
...this.info, ...this.info,
}) })
......
...@@ -60,7 +60,6 @@ export class CssMinimizerPlugin { ...@@ -60,7 +60,6 @@ export class CssMinimizerPlugin {
compilation.hooks.processAssets.tapPromise( compilation.hooks.processAssets.tapPromise(
{ {
name: 'CssMinimizerPlugin', name: 'CssMinimizerPlugin',
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE, stage: webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,
}, },
async (assets: any) => { async (assets: any) => {
......
...@@ -255,11 +255,9 @@ export class FontStylesheetGatheringPlugin { ...@@ -255,11 +255,9 @@ export class FontStylesheetGatheringPlugin {
}) })
compiler.hooks.make.tap(this.constructor.name, (compilation) => { compiler.hooks.make.tap(this.constructor.name, (compilation) => {
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
compilation.hooks.processAssets.tap( compilation.hooks.processAssets.tap(
{ {
name: this.constructor.name, name: this.constructor.name,
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS, stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
}, },
(assets: any) => { (assets: any) => {
......
...@@ -18,7 +18,6 @@ export class DropClientPage implements webpack.WebpackPluginInstance { ...@@ -18,7 +18,6 @@ export class DropClientPage implements webpack.WebpackPluginInstance {
function findEntryModule(mod: any): webpack.Module | null { function findEntryModule(mod: any): webpack.Module | null {
const queue = new Set([mod]) const queue = new Set([mod])
for (const module of queue) { for (const module of queue) {
// @ts-ignore TODO: webpack 5 types
const incomingConnections = const incomingConnections =
compilation.moduleGraph.getIncomingConnections(module) compilation.moduleGraph.getIncomingConnections(module)
...@@ -73,11 +72,9 @@ export class DropClientPage implements webpack.WebpackPluginInstance { ...@@ -73,11 +72,9 @@ export class DropClientPage implements webpack.WebpackPluginInstance {
compilation.hooks.seal.tap(PLUGIN_NAME, () => { compilation.hooks.seal.tap(PLUGIN_NAME, () => {
for (const [name, entryData] of compilation.entries) { for (const [name, entryData] of compilation.entries) {
for (const dependency of entryData.dependencies) { for (const dependency of entryData.dependencies) {
// @ts-ignore TODO: webpack 5 types
const module = compilation.moduleGraph.getModule(dependency) const module = compilation.moduleGraph.getModule(dependency)
if (module?.buildInfo?.NEXT_ampFirst) { if (module?.buildInfo?.NEXT_ampFirst) {
ampFirstEntryNamesItem.push(name) ampFirstEntryNamesItem.push(name)
// @ts-ignore @types/webpack has outdated types for webpack 5
compilation.entries.delete(name) compilation.entries.delete(name)
} }
} }
......
...@@ -466,11 +466,9 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance { ...@@ -466,11 +466,9 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
'next-trace-entrypoint-plugin' 'next-trace-entrypoint-plugin'
) )
traceEntrypointsPluginSpan.traceFn(() => { traceEntrypointsPluginSpan.traceFn(() => {
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
compilation.hooks.processAssets.tapAsync( compilation.hooks.processAssets.tapAsync(
{ {
name: PLUGIN_NAME, name: PLUGIN_NAME,
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE, stage: webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
}, },
(assets: any, callback: any) => { (assets: any, callback: any) => {
......
...@@ -127,11 +127,9 @@ export default class PagesManifestPlugin ...@@ -127,11 +127,9 @@ export default class PagesManifestPlugin
apply(compiler: webpack.Compiler): void { apply(compiler: webpack.Compiler): void {
compiler.hooks.make.tap('NextJsPagesManifest', (compilation) => { compiler.hooks.make.tap('NextJsPagesManifest', (compilation) => {
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
compilation.hooks.processAssets.tap( compilation.hooks.processAssets.tap(
{ {
name: 'NextJsPagesManifest', name: 'NextJsPagesManifest',
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS, stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
}, },
(assets: any) => { (assets: any) => {
......
...@@ -187,11 +187,9 @@ export class ReactLoadablePlugin { ...@@ -187,11 +187,9 @@ export class ReactLoadablePlugin {
apply(compiler: webpack.Compiler) { apply(compiler: webpack.Compiler) {
compiler.hooks.make.tap('ReactLoadableManifest', (compilation) => { compiler.hooks.make.tap('ReactLoadableManifest', (compilation) => {
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
compilation.hooks.processAssets.tap( compilation.hooks.processAssets.tap(
{ {
name: 'ReactLoadableManifest', name: 'ReactLoadableManifest',
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS, stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
}, },
(assets: any) => { (assets: any) => {
......
...@@ -14,7 +14,6 @@ export class ServerlessPlugin { ...@@ -14,7 +14,6 @@ export class ServerlessPlugin {
hook.tap('ServerlessPlugin', (chunks) => { hook.tap('ServerlessPlugin', (chunks) => {
for (const chunk of chunks) { for (const chunk of chunks) {
// If chunk is not an entry point skip them // If chunk is not an entry point skip them
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
if (compilation.chunkGraph.getNumberOfEntryModules(chunk) === 0) { if (compilation.chunkGraph.getNumberOfEntryModules(chunk) === 0) {
continue continue
} }
...@@ -22,14 +21,11 @@ export class ServerlessPlugin { ...@@ -22,14 +21,11 @@ export class ServerlessPlugin {
// Async chunks are usages of import() for example // Async chunks are usages of import() for example
const dynamicChunks = chunk.getAllAsyncChunks() const dynamicChunks = chunk.getAllAsyncChunks()
for (const dynamicChunk of dynamicChunks) { for (const dynamicChunk of dynamicChunks) {
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
for (const module of compilation.chunkGraph.getChunkModulesIterable( for (const module of compilation.chunkGraph.getChunkModulesIterable(
dynamicChunk dynamicChunk
)) { )) {
// Add module back into the entry chunk // Add module back into the entry chunk
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
if (!compilation.chunkGraph.isModuleInChunk(module, chunk)) { if (!compilation.chunkGraph.isModuleInChunk(module, chunk)) {
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
compilation.chunkGraph.connectChunkAndModule(chunk, module) compilation.chunkGraph.connectChunkAndModule(chunk, module)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment