Skip to content

Commit 2279c5a

Browse files
authored
Merge pull request #15336 from webpack/deps/typescript
update typescript
2 parents ec98c0b + b531eb6 commit 2279c5a

9 files changed

Lines changed: 110 additions & 116 deletions

lib/ChunkGraph.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const compareModuleIterables = compareIterables(compareModulesByIdentifier);
4646

4747
/** @typedef {(c: Chunk, chunkGraph: ChunkGraph) => boolean} ChunkFilterPredicate */
4848
/** @typedef {(m: Module) => boolean} ModuleFilterPredicate */
49+
/** @typedef {[Module, Entrypoint | undefined]} EntryModuleWithChunkGroup */
4950

5051
/**
5152
* @typedef {Object} ChunkSizeOptions
@@ -1180,8 +1181,6 @@ class ChunkGraph {
11801181
return cgc.dependentHashModules;
11811182
}
11821183

1183-
/** @typedef {[Module, Entrypoint | undefined]} EntryModuleWithChunkGroup */
1184-
11851184
/**
11861185
* @param {Chunk} chunk the chunk
11871186
* @returns {Iterable<EntryModuleWithChunkGroup>} iterable of modules (do not modify)

lib/ProgressPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const createDefaultHandler = (profile, logger) => {
9696
/**
9797
* @callback ReportProgress
9898
* @param {number} p
99-
* @param {...string[]} [args]
99+
* @param {...string} [args]
100100
* @returns {void}
101101
*/
102102

lib/css/CssLoadingRuntimeModule.js

Lines changed: 63 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -274,78 +274,71 @@ class CssLoadingRuntimeModule extends RuntimeModule {
274274
"",
275275
withLoading
276276
? Template.asString([
277-
`${fn}.css = ${runtimeTemplate.basicFunction(
278-
"chunkId, promises",
279-
hasCssMatcher !== false
280-
? [
281-
"// css chunk loading",
282-
`var installedChunkData = ${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;`,
283-
'if(installedChunkData !== 0) { // 0 means "already installed".',
284-
Template.indent([
285-
"",
286-
'// a Promise means "currently loading".',
287-
"if(installedChunkData) {",
288-
Template.indent([
289-
"promises.push(installedChunkData[2]);"
290-
]),
291-
"} else {",
292-
Template.indent([
293-
hasCssMatcher === true
294-
? "if(true) { // all chunks have CSS"
295-
: `if(${hasCssMatcher("chunkId")}) {`,
277+
`${fn}.css = ${runtimeTemplate.basicFunction("chunkId, promises", [
278+
"// css chunk loading",
279+
`var installedChunkData = ${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;`,
280+
'if(installedChunkData !== 0) { // 0 means "already installed".',
281+
Template.indent([
282+
"",
283+
'// a Promise means "currently loading".',
284+
"if(installedChunkData) {",
285+
Template.indent(["promises.push(installedChunkData[2]);"]),
286+
"} else {",
287+
Template.indent([
288+
hasCssMatcher === true
289+
? "if(true) { // all chunks have CSS"
290+
: `if(${hasCssMatcher("chunkId")}) {`,
291+
Template.indent([
292+
"// setup Promise in chunk cache",
293+
`var promise = new Promise(${runtimeTemplate.expressionFunction(
294+
`installedChunkData = installedChunks[chunkId] = [resolve, reject]`,
295+
"resolve, reject"
296+
)});`,
297+
"promises.push(installedChunkData[2] = promise);",
298+
"",
299+
"// start chunk loading",
300+
`var url = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkCssFilename}(chunkId);`,
301+
"// create error before stack unwound to get useful stacktrace later",
302+
"var error = new Error();",
303+
`var loadingEnded = ${runtimeTemplate.basicFunction(
304+
"event",
305+
[
306+
`if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId)) {`,
296307
Template.indent([
297-
"// setup Promise in chunk cache",
298-
`var promise = new Promise(${runtimeTemplate.expressionFunction(
299-
`installedChunkData = installedChunks[chunkId] = [resolve, reject]`,
300-
"resolve, reject"
301-
)});`,
302-
"promises.push(installedChunkData[2] = promise);",
303-
"",
304-
"// start chunk loading",
305-
`var url = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkCssFilename}(chunkId);`,
306-
"// create error before stack unwound to get useful stacktrace later",
307-
"var error = new Error();",
308-
`var loadingEnded = ${runtimeTemplate.basicFunction(
309-
"event",
310-
[
311-
`if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId)) {`,
312-
Template.indent([
313-
"installedChunkData = installedChunks[chunkId];",
314-
"if(installedChunkData !== 0) installedChunks[chunkId] = undefined;",
315-
"if(installedChunkData) {",
316-
Template.indent([
317-
'if(event.type !== "load") {',
318-
Template.indent([
319-
"var errorType = event && event.type;",
320-
"var realSrc = event && event.target && event.target.src;",
321-
"error.message = 'Loading css chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';",
322-
"error.name = 'ChunkLoadError';",
323-
"error.type = errorType;",
324-
"error.request = realSrc;",
325-
"installedChunkData[1](error);"
326-
]),
327-
"} else {",
328-
Template.indent([
329-
`loadCssChunkData(${RuntimeGlobals.moduleFactories}, link, chunkId);`,
330-
"installedChunkData[0]();"
331-
]),
332-
"}"
333-
]),
334-
"}"
335-
]),
336-
"}"
337-
]
338-
)};`,
339-
"var link = loadStylesheet(chunkId, url, loadingEnded);"
308+
"installedChunkData = installedChunks[chunkId];",
309+
"if(installedChunkData !== 0) installedChunks[chunkId] = undefined;",
310+
"if(installedChunkData) {",
311+
Template.indent([
312+
'if(event.type !== "load") {',
313+
Template.indent([
314+
"var errorType = event && event.type;",
315+
"var realSrc = event && event.target && event.target.src;",
316+
"error.message = 'Loading css chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';",
317+
"error.name = 'ChunkLoadError';",
318+
"error.type = errorType;",
319+
"error.request = realSrc;",
320+
"installedChunkData[1](error);"
321+
]),
322+
"} else {",
323+
Template.indent([
324+
`loadCssChunkData(${RuntimeGlobals.moduleFactories}, link, chunkId);`,
325+
"installedChunkData[0]();"
326+
]),
327+
"}"
328+
]),
329+
"}"
340330
]),
341-
"} else installedChunks[chunkId] = 0;"
342-
]),
343-
"}"
344-
]),
345-
"}"
346-
]
347-
: "installedChunks[chunkId] = 0;"
348-
)};`
331+
"}"
332+
]
333+
)};`,
334+
"var link = loadStylesheet(chunkId, url, loadingEnded);"
335+
]),
336+
"} else installedChunks[chunkId] = 0;"
337+
]),
338+
"}"
339+
]),
340+
"}"
341+
])};`
349342
])
350343
: "// no chunk loading",
351344
"",

lib/javascript/StartupHelpers.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const { getAllChunks } = require("./ChunkHelpers");
1414
/** @typedef {import("../Chunk")} Chunk */
1515
/** @typedef {import("../Compilation")} Compilation */
1616
/** @typedef {import("../ChunkGraph")} ChunkGraph */
17+
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
1718
/** @typedef {import("../ChunkGroup")} ChunkGroup */
1819
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
1920
/** @typedef {(string|number)[]} EntryItem */
@@ -23,7 +24,7 @@ const EXPORT_PREFIX = "var __webpack_exports__ = ";
2324
/**
2425
* @param {ChunkGraph} chunkGraph chunkGraph
2526
* @param {RuntimeTemplate} runtimeTemplate runtimeTemplate
26-
* @param {import("../ChunkGraph").EntryModuleWithChunkGroup[]} entries entries
27+
* @param {EntryModuleWithChunkGroup[]} entries entries
2728
* @param {Chunk} chunk chunk
2829
* @param {boolean} passive true: passive startup with on chunks loaded
2930
* @returns {string} runtime code
@@ -101,7 +102,7 @@ exports.generateEntryStartup = (
101102
/**
102103
* @param {Hash} hash the hash to update
103104
* @param {ChunkGraph} chunkGraph chunkGraph
104-
* @param {import("../ChunkGraph").EntryModuleWithChunkGroup[]} entries entries
105+
* @param {EntryModuleWithChunkGroup[]} entries entries
105106
* @param {Chunk} chunk chunk
106107
* @returns {void}
107108
*/

lib/util/compileBooleanMatcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const toSimpleString = str => {
1818

1919
/**
2020
* @param {Record<string|number, boolean>} map value map
21-
* @returns {true|false|function(string): string} true/false, when unconditionally true/false, or a template function to determine the value at runtime
21+
* @returns {boolean|(function(string): string)} true/false, when unconditionally true/false, or a template function to determine the value at runtime
2222
*/
2323
const compileBooleanMatcher = map => {
2424
const positiveItems = Object.keys(map).filter(i => map[i]);

lib/util/deterministicGrouping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
498498

499499
// return the results
500500
return result.map(group => {
501-
/** @type {GroupedItems} */
501+
/** @type {GroupedItems<T>} */
502502
return {
503503
key: group.key,
504504
items: group.nodes.map(node => node.item),

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
66
"license": "MIT",
77
"dependencies": {
8-
"@types/eslint-scope": "^3.7.0",
9-
"@types/estree": "^0.0.50",
8+
"@types/eslint-scope": "^3.7.3",
9+
"@types/estree": "^0.0.51",
1010
"@webassemblyjs/ast": "1.11.1",
1111
"@webassemblyjs/wasm-edit": "1.11.1",
1212
"@webassemblyjs/wasm-parser": "1.11.1",
@@ -39,8 +39,8 @@
3939
"@babel/core": "^7.11.1",
4040
"@babel/preset-react": "^7.10.4",
4141
"@types/es-module-lexer": "^0.4.1",
42-
"@types/jest": "^27.0.2",
43-
"@types/node": "^15.0.1",
42+
"@types/jest": "^27.4.0",
43+
"@types/node": "^17.0.16",
4444
"assemblyscript": "^0.19.16",
4545
"babel-loader": "^8.1.0",
4646
"benchmark": "^2.1.4",
@@ -98,9 +98,9 @@
9898
"style-loader": "^2.0.0",
9999
"terser": "^5.7.0",
100100
"toml": "^3.0.0",
101-
"tooling": "webpack/tooling#v1.20.1",
101+
"tooling": "webpack/tooling#v1.21.0",
102102
"ts-loader": "^8.0.2",
103-
"typescript": "^4.2.0-beta",
103+
"typescript": "^4.5.5",
104104
"url-loader": "^4.1.0",
105105
"wast-loader": "^1.11.0",
106106
"webassembly-feature": "1.3.0",

types.d.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Run `yarn special-lint-fix` to update
55
*/
66

7+
import { Buffer } from "buffer";
78
import {
89
ArrayExpression,
910
ArrayPattern,
@@ -63,6 +64,7 @@ import {
6364
SimpleCallExpression,
6465
SimpleLiteral,
6566
SpreadElement,
67+
StaticBlock,
6668
Super,
6769
SwitchCase,
6870
SwitchStatement,
@@ -4462,12 +4464,12 @@ declare class Hash {
44624464
constructor();
44634465

44644466
/**
4465-
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
4467+
* Update hash {@link https ://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
44664468
*/
44674469
update(data: string | Buffer, inputEncoding?: string): Hash;
44684470

44694471
/**
4470-
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
4472+
* Calculates the digest {@link https ://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
44714473
*/
44724474
digest(encoding?: string): string | Buffer;
44734475
}
@@ -4488,7 +4490,7 @@ declare interface HashedModuleIdsPluginOptions {
44884490
/**
44894491
* The encoding to use when generating the hash, defaults to 'base64'. All encodings from Node.JS' hash.digest are supported.
44904492
*/
4491-
hashDigest?: "base64" | "latin1" | "hex";
4493+
hashDigest?: "latin1" | "hex" | "base64";
44924494

44934495
/**
44944496
* The prefix length of the hash digest to use, defaults to 4.
@@ -4902,6 +4904,7 @@ declare class JavascriptParser extends Parser {
49024904
| ClassDeclaration
49034905
| ExpressionStatement
49044906
| BlockStatement
4907+
| StaticBlock
49054908
| EmptyStatement
49064909
| DebuggerStatement
49074910
| WithStatement
@@ -4932,6 +4935,7 @@ declare class JavascriptParser extends Parser {
49324935
| ClassDeclaration
49334936
| ExpressionStatement
49344937
| BlockStatement
4938+
| StaticBlock
49354939
| EmptyStatement
49364940
| DebuggerStatement
49374941
| WithStatement
@@ -4962,6 +4966,7 @@ declare class JavascriptParser extends Parser {
49624966
| ClassDeclaration
49634967
| ExpressionStatement
49644968
| BlockStatement
4969+
| StaticBlock
49654970
| EmptyStatement
49664971
| DebuggerStatement
49674972
| WithStatement
@@ -5133,6 +5138,7 @@ declare class JavascriptParser extends Parser {
51335138
| ClassDeclaration
51345139
| ExpressionStatement
51355140
| BlockStatement
5141+
| StaticBlock
51365142
| EmptyStatement
51375143
| DebuggerStatement
51385144
| WithStatement
@@ -5355,7 +5361,7 @@ declare class JavascriptParser extends Parser {
53555361
setVariable(name: string, variableInfo: ExportedVariableInfo): void;
53565362
parseCommentOptions(
53575363
range?: any
5358-
): { options: null; errors: null } | { options: object; errors: any[] };
5364+
): { options: null; errors: null } | { options: object; errors: unknown[] };
53595365
extractMemberExpressionChain(expression: MemberExpression): {
53605366
members: string[];
53615367
object:
@@ -6034,9 +6040,8 @@ declare class LazySet<T> {
60346040
has(item: T): boolean;
60356041
keys(): IterableIterator<T>;
60366042
values(): IterableIterator<T>;
6037-
[Symbol.iterator](): IterableIterator<T>;
6038-
readonly [Symbol.toStringTag]: string;
60396043
serialize(__0: { write: any }): void;
6044+
[Symbol.iterator](): IterableIterator<T>;
60406045
static deserialize(__0: { read: any }): LazySet<any>;
60416046
}
60426047
declare interface LibIdentOptions {
@@ -7390,6 +7395,7 @@ type NodeEstreeIndex =
73907395
| PrivateIdentifier
73917396
| ExpressionStatement
73927397
| BlockStatement
7398+
| StaticBlock
73937399
| EmptyStatement
73947400
| DebuggerStatement
73957401
| WithStatement
@@ -7709,8 +7715,8 @@ type NormalizedStatsOptions = KnownNormalizedStatsOptions &
77097715
Omit<
77107716
StatsOptions,
77117717
| "context"
7712-
| "requestShortener"
77137718
| "chunkGroups"
7719+
| "requestShortener"
77147720
| "chunksSort"
77157721
| "modulesSort"
77167722
| "chunkModulesSort"
@@ -8987,7 +8993,7 @@ declare class ProgressPlugin {
89878993
showModules?: boolean;
89888994
showDependencies?: boolean;
89898995
showActiveModules?: boolean;
8990-
percentBy?: null | "dependencies" | "modules" | "entries";
8996+
percentBy?: null | "modules" | "dependencies" | "entries";
89918997
apply(compiler: Compiler | MultiCompiler): void;
89928998
static getReporter(
89938999
compiler: Compiler
@@ -9048,7 +9054,7 @@ declare interface ProgressPluginOptions {
90489054
/**
90499055
* Collect percent algorithm. By default it calculates by a median from modules, entries and dependencies percent.
90509056
*/
9051-
percentBy?: null | "dependencies" | "modules" | "entries";
9057+
percentBy?: null | "modules" | "dependencies" | "entries";
90529058

90539059
/**
90549060
* Collect profile data for progress steps. Default: false.
@@ -10173,8 +10179,8 @@ declare class RuntimeSpecSet {
1017310179
constructor(iterable?: any);
1017410180
add(runtime?: any): void;
1017510181
has(runtime?: any): boolean;
10176-
[Symbol.iterator](): IterableIterator<RuntimeSpec>;
1017710182
readonly size: number;
10183+
[Symbol.iterator](): IterableIterator<RuntimeSpec>;
1017810184
}
1017910185
declare abstract class RuntimeTemplate {
1018010186
compilation: Compilation;
@@ -10871,7 +10877,6 @@ declare abstract class SortableSet<T> extends Set<T> {
1087110877
* Iterates over values in the set.
1087210878
*/
1087310879
[Symbol.iterator](): IterableIterator<T>;
10874-
readonly [Symbol.toStringTag]: string;
1087510880
}
1087610881
declare class Source {
1087710882
constructor();
@@ -11061,6 +11066,7 @@ type Statement =
1106111066
| ClassDeclaration
1106211067
| ExpressionStatement
1106311068
| BlockStatement
11069+
| StaticBlock
1106411070
| EmptyStatement
1106511071
| DebuggerStatement
1106611072
| WithStatement

0 commit comments

Comments
 (0)