Skip to content

Commit 86ff212

Browse files
authored
fix(types): fix nonsensible intersection
1 parent 367d0f6 commit 86ff212

File tree

9 files changed

+21
-26
lines changed

9 files changed

+21
-26
lines changed

lib/AliasFieldPlugin.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ module.exports = class AliasFieldPlugin {
4444
if (fieldData === null || typeof fieldData !== "object") {
4545
if (resolveContext.log) {
4646
resolveContext.log(
47-
`Field '${
48-
this.field
49-
}' doesn't contain a valid alias configuration`,
47+
`Field '${this.field}' doesn't contain a valid alias configuration`,
5048
);
5149
}
5250
return callback();

lib/AliasPlugin.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ module.exports = class AliasPlugin {
131131
return resolver.doResolve(
132132
target,
133133
obj,
134-
`aliased with mapping '${item.name}': '${alias}' to '${
135-
newRequestStr
136-
}'`,
134+
`aliased with mapping '${item.name}': '${alias}' to '${newRequestStr}'`,
137135
resolveContext,
138136
(err, result) => {
139137
if (err) return callback(err);

lib/DescriptionFilePlugin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ module.exports = class DescriptionFilePlugin {
6666
}
6767
return callback();
6868
}
69-
const relativePath = `.${path.slice(result.directory.length).replace(/\\/g, "/")}`;
69+
const relativePath = `.${path
70+
.slice(result.directory.length)
71+
.replace(/\\/g, "/")}`;
7072
/** @type {ResolveRequest} */
7173
const obj = {
7274
...request,
@@ -78,9 +80,7 @@ module.exports = class DescriptionFilePlugin {
7880
resolver.doResolve(
7981
target,
8082
obj,
81-
`using description file: ${result.path} (relative path: ${
82-
relativePath
83-
})`,
83+
`using description file: ${result.path} (relative path: ${relativePath})`,
8484
resolveContext,
8585
(err, result) => {
8686
if (err) return callback(err);

lib/DescriptionFileUtils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ function getField(content, field) {
185185
current = null;
186186
break;
187187
}
188-
current = /** @type {JsonObject} */ (current)[field[j]];
188+
current = /** @type {JsonValue} */ (
189+
/** @type {JsonObject} */
190+
(current)[field[j]]
191+
);
189192
}
190193
return current;
191194
}

lib/LogInfoPlugin.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ module.exports = class LogInfoPlugin {
4949
}
5050
if (request.relativePath) {
5151
log(
52-
`${prefix}Relative path from description file is: ${
53-
request.relativePath
54-
}`,
52+
`${prefix}Relative path from description file is: ${request.relativePath}`,
5553
);
5654
}
5755
callback();

lib/Resolver.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ const {
289289
/** @typedef {string | number | boolean | null} JsonPrimitive */
290290
/** @typedef {JsonValue[]} JsonArray */
291291
/** @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue */
292-
/** @typedef {{[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined}} JsonObject */
292+
/** @typedef {{ [Key in string]?: JsonValue | undefined }} JsonObject */
293293

294294
// eslint-disable-next-line jsdoc/require-property
295295
/** @typedef {object} Context */
@@ -365,9 +365,9 @@ class Resolver {
365365
static createStackEntry(hook, request) {
366366
return `${hook.name}: (${request.path}) ${request.request || ""}${
367367
request.query || ""
368-
}${request.fragment || ""}${
369-
request.directory ? " directory" : ""
370-
}${request.module ? " module" : ""}`;
368+
}${request.fragment || ""}${request.directory ? " directory" : ""}${
369+
request.module ? " module" : ""
370+
}`;
371371
}
372372

373373
/**

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,20 @@
5252
"homepage": "http://github.com/webpack/enhanced-resolve",
5353
"scripts": {
5454
"prepare": "husky install",
55-
"lint": "yarn lint:code && yarn lint:types && yarn lint:types-test && yarn lint:special && yarn lint:spellcheck",
55+
"lint": "yarn lint:code && yarn lint:types && yarn lint:types-test && yarn lint:special && yarn fmt:check && yarn lint:spellcheck",
5656
"lint:code": "eslint --cache .",
5757
"lint:special": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-file-header && node node_modules/tooling/generate-types",
5858
"lint:types": "tsc",
5959
"lint:types-test": "tsc -p tsconfig.types.test.json",
6060
"lint:spellcheck": "cspell --no-must-find-files \"**/*.*\"",
6161
"fmt": "yarn fmt:base --loglevel warn --write",
6262
"fmt:check": "yarn fmt:base --check",
63-
"fmt:base": "prettier --cache --ignore-unknown .",
63+
"fmt:base": "node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
6464
"fix": "yarn fix:code && yarn fix:special",
6565
"fix:code": "yarn lint:code --fix",
6666
"fix:special": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/generate-types --write",
6767
"type-report": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html",
68-
"pretest": "yarn lintqqq",
68+
"pretest": "yarn lint",
6969
"test": "yarn test:coverage",
7070
"test:only": "jest",
7171
"test:watch": "yarn test:only --watch",

test/missing.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ describe("missing", () => {
8787
resolve(testCase[0], testCase[1], { missingDependencies }, callback);
8888
});
8989

90-
it(`should report error details exactly once when trying to resolve ${
91-
testCase[1]
92-
}`, (done) => {
90+
it(`should report error details exactly once when trying to resolve ${testCase[1]}`, (done) => {
9391
/**
9492
* @param {Error & { details: string } | null} err err
9593
* @param {string} _filename _filename

types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ declare interface Iterator<T, Z> {
542542
i: number,
543543
): void;
544544
}
545-
type JsonObject = { [index: string]: JsonValue } & {
545+
declare interface JsonObject {
546546
[index: string]:
547547
| undefined
548548
| null
@@ -551,7 +551,7 @@ type JsonObject = { [index: string]: JsonValue } & {
551551
| boolean
552552
| JsonObject
553553
| JsonValue[];
554-
};
554+
}
555555
type JsonValue = null | string | number | boolean | JsonObject | JsonValue[];
556556
declare interface KnownHooks {
557557
/**

0 commit comments

Comments
 (0)