Skip to content

Commit

Permalink
Merge pull request #10240 from jeffin143/fix-10217
Browse files Browse the repository at this point in the history
Get rid of some hacks in declarations file for webpack-4
  • Loading branch information
sokra committed Jan 15, 2020
2 parents 45ecebc + ef73991 commit 5e9f083
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 44 deletions.
32 changes: 0 additions & 32 deletions declarations.d.ts
Expand Up @@ -228,36 +228,4 @@ declare module "@webassemblyjs/ast" {
export function isFuncImportDescr(n: Node): boolean;
}

// This "hack" is needed because typescript doesn't support recursive type definitions
// It's referenced from "ruleSet-conditions" in schemas/WebpackOptions.json
interface RuleSetConditionsRecursive
extends Array<import("./declarations/WebpackOptions").RuleSetCondition> {}
interface RuleSetConditionsAbsoluteRecursive
extends Array<
import("./declarations/WebpackOptions").RuleSetConditionAbsolute
> {}

/**
* Global variable declarations
* @todo Once this issue is resolved, remove these globals and add JSDoc onsite instead
* https://github.com/Microsoft/TypeScript/issues/15626
*/
declare const $hash$;
declare const $requestTimeout$;
declare const installedModules;
declare const $require$;
declare const hotDownloadManifest;
declare const hotDownloadUpdateChunk;
declare const hotDisposeChunk;
declare const modules;
declare const installedChunks;
declare const hotAddUpdateChunk;
declare const parentHotUpdateCallback;
declare const $hotChunkFilename$;
declare const $hotMainFilename$;
declare namespace WebAssembly {}
declare const importScripts;
declare const $crossOriginLoading$;
declare const chunkId;

type TODO = any;
4 changes: 2 additions & 2 deletions declarations/WebpackOptions.d.ts
Expand Up @@ -132,7 +132,7 @@ export type RuleSetCondition =
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetConditions".
*/
export type RuleSetConditions = RuleSetConditionsRecursive;
export type RuleSetConditions = RuleSetCondition[];
/**
* One or multiple rule conditions
*
Expand Down Expand Up @@ -181,7 +181,7 @@ export type RuleSetConditionAbsolute =
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetConditionsAbsolute".
*/
export type RuleSetConditionsAbsolute = RuleSetConditionsAbsoluteRecursive;
export type RuleSetConditionsAbsolute = RuleSetConditionAbsolute[];
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetLoader".
Expand Down
13 changes: 11 additions & 2 deletions lib/HotModuleReplacement.runtime.js
Expand Up @@ -2,7 +2,17 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
/*global $hash$ $requestTimeout$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk hotDisposeChunk modules */
// eslint-disable no-unused-vars
var $hash$ = undefined;
var $requestTimeout$ = undefined;
var installedModules = undefined;
var $require$ = undefined;
var hotDownloadManifest = undefined;
var hotDownloadUpdateChunk = undefined;
var hotDisposeChunk = undefined;
var modules = undefined;
var chunkId = undefined;

module.exports = function() {
var hotApplyOnUpdate = true;
// eslint-disable-next-line no-unused-vars
Expand Down Expand Up @@ -204,7 +214,6 @@ module.exports = function() {
/*foreachInstalledChunks*/
// eslint-disable-next-line no-lone-blocks
{
/*globals chunkId */
hotEnsureUpdateChunk(chunkId);
}
if (
Expand Down
7 changes: 6 additions & 1 deletion lib/node/NodeMainTemplate.runtime.js
Expand Up @@ -2,7 +2,12 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
/*global installedChunks $hotChunkFilename$ hotAddUpdateChunk $hotMainFilename$ */
// eslint-disable-next-line no-unused-vars
var $hotChunkFilename$ = undefined;
var hotAddUpdateChunk = undefined;
var installedChunks = undefined;
var $hotMainFilename$ = undefined;

module.exports = function() {
// eslint-disable-next-line no-unused-vars
function hotDownloadUpdateChunk(chunkId) {
Expand Down
8 changes: 7 additions & 1 deletion lib/node/NodeMainTemplateAsync.runtime.js
Expand Up @@ -2,7 +2,13 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
/*global installedChunks $hotChunkFilename$ $require$ hotAddUpdateChunk $hotMainFilename$ */
// eslint-disable-next-line no-unused-vars
var $hotChunkFilename$ = undefined;
var $require$ = undefined;
var hotAddUpdateChunk = undefined;
var $hotMainFilename$ = undefined;
var installedChunks = undefined;

module.exports = function() {
// eslint-disable-next-line no-unused-vars
function hotDownloadUpdateChunk(chunkId) {
Expand Down
9 changes: 8 additions & 1 deletion lib/web/JsonpMainTemplate.runtime.js
Expand Up @@ -2,7 +2,14 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
/*globals hotAddUpdateChunk parentHotUpdateCallback document XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ $crossOriginLoading$ */
// eslint-disable-next-line no-unused-vars
var hotAddUpdateChunk = undefined;
var parentHotUpdateCallback = undefined;
var $require$ = undefined;
var $hotMainFilename$ = undefined;
var $hotChunkFilename$ = undefined;
var $crossOriginLoading$ = undefined;

module.exports = function() {
// eslint-disable-next-line no-unused-vars
function webpackHotUpdateCallback(chunkId, moreModules) {
Expand Down
10 changes: 9 additions & 1 deletion lib/webworker/WebWorkerMainTemplate.runtime.js
Expand Up @@ -2,7 +2,15 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
/*globals installedChunks hotAddUpdateChunk parentHotUpdateCallback importScripts XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ */
// eslint-disable-next-line no-unused-vars
var hotAddUpdateChunk = undefined;
var parentHotUpdateCallback = undefined;
var $require$ = undefined;
var $hotChunkFilename$ = undefined;
var $hotMainFilename$ = undefined;
var installedChunks = undefined;
var importScripts = undefined;

module.exports = function() {
// eslint-disable-next-line no-unused-vars
function webpackHotUpdateCallback(chunkId, moreModules) {
Expand Down
6 changes: 2 additions & 4 deletions schemas/WebpackOptions.json
Expand Up @@ -1428,8 +1428,7 @@
"$ref": "#/definitions/RuleSetCondition"
}
]
},
"tsType": "RuleSetConditionsRecursive"
}
},
"RuleSetConditionsAbsolute": {
"type": "array",
Expand All @@ -1440,8 +1439,7 @@
"$ref": "#/definitions/RuleSetConditionAbsolute"
}
]
},
"tsType": "RuleSetConditionsAbsoluteRecursive"
}
},
"RuleSetLoader": {
"type": "string",
Expand Down

0 comments on commit 5e9f083

Please sign in to comment.