Skip to content

Commit c03ca92

Browse files
committed
fix: type error
1 parent b7840ef commit c03ca92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+440
-101
lines changed

crates/node_binding/tsconfig.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"noEmit": true
5+
}
6+
}

examples/arco-pro/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"esnext"
99
],
1010
"allowJs": true,
11+
// TODO: Remove skipLibCheck when fix upstream type bug
1112
"skipLibCheck": true,
1213
"esModuleInterop": true,
1314
"allowSyntheticDefaultImports": true,

examples/react-storybook/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"strict": true,
5+
// TODO: Remove skipLibCheck when fix upstream type bug
56
"skipLibCheck": true,
67
"jsx": "react-jsx",
78
"moduleResolution": "node"

packages/create-rspack/template-react-ts/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"target": "ES6",
44
"lib": ["DOM", "DOM.Iterable", "ESNext"],
55
"module": "ESNext",
6+
// TODO: Remove skipLibCheck when fix upstream type bug
67
"skipLibCheck": true,
78
"moduleResolution": "bundler",
89
"allowImportingTsExtensions": true,

packages/rspack-cli/jest.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
1+
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
22
const config = {
33
preset: "ts-jest",
44
testEnvironment: "../../scripts/test/patch-node-env.cjs",
55
testTimeout: process.env.CI ? 200000 : 30000,
66
testMatch: ["<rootDir>/tests/**/*.test.ts", "<rootDir>/tests/**/*.test.js"],
77
watchPathIgnorePatterns: ["<rootDir>/tests/.*/dist"],
8-
extensionsToTreatAsEsm: [".mts"]
8+
extensionsToTreatAsEsm: [".mts"],
9+
globals: {
10+
"ts-jest": {
11+
tsconfig: "<rootDir>/tests/tsconfig.json"
12+
}
13+
}
914
};
1015

1116
module.exports = config;

packages/rspack-cli/src/commands/build.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ export class BuildCommand implements RspackCommand {
2222
}),
2323
async options => {
2424
const logger = cli.getLogger();
25+
// @ts-expect-error
2526
let createJsonStringifyStream;
2627
if (options.json) {
2728
const jsonExt = await import("@discoveryjs/json-ext");
2829
createJsonStringifyStream = jsonExt.default.stringifyStream;
2930
}
3031

32+
// @ts-expect-error
3133
const callback = (error, stats: Stats | MultiStats) => {
3234
if (error) {
3335
logger.error(error);
@@ -45,10 +47,14 @@ export class BuildCommand implements RspackCommand {
4547
compiler.options ? compiler.options.stats : undefined
4648
)
4749
}
48-
: compiler.options
49-
? compiler.options.stats
50+
: // @ts-expect-error
51+
compiler.options
52+
? // @ts-expect-error
53+
compiler.options.stats
5054
: undefined;
55+
// @ts-expect-error
5156
if (options.json && createJsonStringifyStream) {
57+
// @ts-expect-error
5258
const handleWriteError = error => {
5359
logger.error(error);
5460
process.exit(2);
@@ -84,6 +90,7 @@ export class BuildCommand implements RspackCommand {
8490

8591
const rspackOptions = { ...options, argv: { ...options } };
8692

93+
// @ts-expect-error
8794
const errorHandler = (err, Stats) => {
8895
callback(err, Stats);
8996
};

packages/rspack-cli/src/rspack-cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export class RspackCLI {
5858
? (config as MultiRspackOptions).some(i => i.watch)
5959
: (config as RspackOptions).watch;
6060

61+
// @ts-expect-error
6162
return rspack(config, isWatch ? callback : undefined);
6263
}
6364
createColors(useColor?: boolean): RspackCLIColors {

packages/rspack-cli/src/utils/options.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,16 @@ export const previewOptions = (yargs: yargs.Argv) => {
8282
});
8383
};
8484

85+
// @ts-expect-error
8586
export function normalizeEnv(argv) {
87+
// @ts-expect-error
8688
function parseValue(previous, value) {
8789
const [allKeys, val] = value.split(/=(.+)/, 2);
8890
const splitKeys = allKeys.split(/\.(?!$)/);
8991

9092
let prevRef = previous;
9193

94+
// @ts-expect-error
9295
splitKeys.forEach((someKey, index) => {
9396
// https://github.com/webpack/webpack-cli/issues/3284
9497
if (someKey.endsWith("=")) {

packages/rspack-cli/src/utils/profile.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,15 @@ function resolveLoggingOptions(value: string): LoggingOptions {
167167
class RspackProfileJSCPUProfilePlugin {
168168
constructor(private output: string) {}
169169

170+
// @ts-expect-error
170171
apply(compiler) {
171172
const session = new inspector.Session();
172173
session.connect();
173174
session.post("Profiler.enable");
174175
session.post("Profiler.start");
175176
compiler.hooks.done.tapAsync(
176177
RspackProfileJSCPUProfilePlugin.name,
178+
// @ts-expect-error
177179
(stats, callback) => {
178180
if (compiler.watchMode) return callback();
179181
session.post("Profiler.stop", (error, param) => {
@@ -192,9 +194,11 @@ class RspackProfileJSCPUProfilePlugin {
192194
class RspackProfileLoggingPlugin {
193195
constructor(private output: string) {}
194196

197+
// @ts-expect-error
195198
apply(compiler) {
196199
compiler.hooks.done.tapAsync(
197200
RspackProfileLoggingPlugin.name,
201+
// @ts-expect-error
198202
(stats, callback) => {
199203
if (compiler.watchMode) return callback();
200204
const logging = stats.toJson({
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"strict": false,
5+
"checkJs": false,
6+
"rootDir": "."
7+
},
8+
"include": ["."],
9+
"references": []
10+
}

packages/rspack-cli/tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"extends": "../../tsconfig.base.json",
33
"include": ["src"],
44
"compilerOptions": {
5-
"strictNullChecks": true,
5+
// TODO: Remove skipLibCheck when fix upstream type bug
6+
"skipLibCheck": true,
67
"outDir": "dist",
7-
"rootDir": "src",
8-
"moduleResolution": "nodenext"
8+
"rootDir": "src"
99
},
1010
"references": [
1111
{
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
1+
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
22
const config = {
33
preset: "ts-jest",
44
testEnvironmentOptions: {
55
url: "http://localhost/"
66
},
77
testMatch: ["<rootDir>/tests/*.test.ts", "<rootDir>/tests/e2e/*.test.ts"],
88
cache: false,
9-
testTimeout: process.env.CI ? 120000 : 30000
9+
testTimeout: process.env.CI ? 120000 : 30000,
10+
globals: {
11+
"ts-jest": {
12+
tsconfig: "<rootDir>/tests/tsconfig.json"
13+
}
14+
}
1015
};
1116

1217
module.exports = config;

packages/rspack-dev-server/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"types": "./dist/index.d.ts",
88
"exports": {
99
".": {
10-
"types": "./dist/index.d.ts",
1110
"default": "./dist/index.js"
1211
},
1312
"./package.json": "./package.json"

packages/rspack-dev-server/src/middleware.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ export function getRspackMemoryAssets(
2727
}
2828

2929
// css hmr will append query string, so here need to remove query string
30+
// @ts-expect-error
3031
const path = parse(url).pathname;
3132
// asset name is not start with /, so path need to slice 1
33+
// @ts-expect-error
3234
const filename = path.startsWith(publicPath)
33-
? path.slice(publicPath.length)
34-
: path.slice(1);
35+
? // @ts-expect-error
36+
path.slice(publicPath.length)
37+
: // @ts-expect-error
38+
path.slice(1);
3539
const buffer =
3640
compiler.getAsset(filename) ??
3741
(() => {
@@ -50,6 +54,7 @@ export function getRspackMemoryAssets(
5054
contentType = "text/html; charset=utf-8";
5155
} else {
5256
contentType =
57+
// @ts-expect-error
5358
mime.contentType(extname(path)) || "text/plain; charset=utf-8";
5459
}
5560

packages/rspack-dev-server/src/patch.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function applyDevServerPatch() {
1717

1818
// @ts-expect-error private API
1919
WebpackDevServer.prototype.sendStats = function sendStats__rspack_patched(
20+
// @ts-expect-error
2021
...args
2122
) {
2223
let stats = args[1];

packages/rspack-dev-server/src/server.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,21 @@ export class RspackDevServer extends WebpackDevServer {
2525
/**
2626
* resolved after `normalizedOptions`
2727
*/
28+
// @ts-expect-error
2829
options: ResolvedDevServer;
30+
// @ts-expect-error
2931
staticWatchers: FSWatcher[];
32+
// @ts-expect-error
3033
sockets: Socket[];
34+
// @ts-expect-error
3135
server: Server;
3236
// @ts-expect-error
3337
public compiler: Compiler | MultiCompiler;
3438
webSocketServer: WebpackDevServer.WebSocketServerImplementation | undefined;
3539

3640
constructor(options: DevServer, compiler: Compiler | MultiCompiler) {
3741
super(
42+
// @ts-expect-error
3843
{
3944
...options,
4045
setupMiddlewares: (middlewares, devServer) => {
@@ -54,6 +59,7 @@ export class RspackDevServer extends WebpackDevServer {
5459
path: publicPath,
5560
middleware: getRspackMemoryAssets(
5661
compiler,
62+
// @ts-expect-error
5763
this.middleware
5864
)
5965
};
@@ -69,6 +75,7 @@ export class RspackDevServer extends WebpackDevServer {
6975
}
7076
}
7177

78+
// @ts-expect-error
7279
options.setupMiddlewares?.call(this, middlewares, devServer);
7380
return middlewares;
7481
}
@@ -136,6 +143,7 @@ export class RspackDevServer extends WebpackDevServer {
136143
);
137144
}
138145

146+
// @ts-expect-error
139147
return clientImplementation;
140148
}
141149

@@ -158,6 +166,7 @@ export class RspackDevServer extends WebpackDevServer {
158166
compiler.options.devServer ??= {};
159167
compiler.options.devServer.hot = true;
160168
if (
169+
// @ts-expect-error
161170
!compiler.options.experiments.rspackFuture.disableTransformByDefault
162171
) {
163172
compiler.options.builtins.react ??= {};
@@ -298,6 +307,7 @@ export class RspackDevServer extends WebpackDevServer {
298307
compilers.forEach(compiler => {
299308
if (compiler.options.experiments.lazyCompilation) {
300309
middlewares.push({
310+
// @ts-expect-error
301311
middleware: (req, res) => {
302312
if (req.url.indexOf("/lazy-compilation-web/") > -1) {
303313
const path = req.url.replace("/lazy-compilation-web/", "");
@@ -319,10 +329,13 @@ export class RspackDevServer extends WebpackDevServer {
319329

320330
middlewares.forEach(middleware => {
321331
if (typeof middleware === "function") {
332+
// @ts-expect-error
322333
this.app.use(middleware);
323334
} else if (typeof middleware.path !== "undefined") {
335+
// @ts-expect-error
324336
this.app.use(middleware.path, middleware.middleware);
325337
} else {
338+
// @ts-expect-error
326339
this.app.use(middleware.middleware);
327340
}
328341
});

packages/rspack-dev-server/tests/normalizeOptions.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { RspackOptions, rspack } from "@rspack/core";
22
import { RspackDevServer, Configuration } from "@rspack/dev-server";
33
import { createCompiler } from "@rspack/core";
44
import ReactRefreshPlugin from "@rspack/plugin-react-refresh";
5+
// @ts-expect-error
56
import serializer from "jest-serializer-path";
67
expect.addSnapshotSerializer(serializer);
78

@@ -174,16 +175,20 @@ async function getAdditionEntries(
174175
.reduce<Object>((acc, cur: any) => {
175176
const name = cur.options.name;
176177
const request = cur.entry;
178+
// @ts-expect-error
177179
if (acc[name]) {
180+
// @ts-expect-error
178181
acc[name].import.push(request);
179182
} else {
183+
// @ts-expect-error
180184
acc[name] = { import: [request] };
181185
}
182186
return acc;
183187
}, {});
184188
// some hack for snapshot
185189
const value = Object.fromEntries(
186190
Object.entries(entries).map(([key, item]) => {
191+
// @ts-expect-error
187192
const replaced = item.import?.map(entry => {
188193
const array = entry
189194
.replace(/\\/g, "/")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"checkJs": false,
5+
"rootDir": "."
6+
},
7+
"include": ["."],
8+
"references": []
9+
}

packages/rspack-dev-server/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"src"
55
],
66
"compilerOptions": {
7+
// TODO: Remove skipLibCheck when fix upstream type bug
8+
"skipLibCheck": true,
79
"outDir": "dist",
810
"rootDir": "src"
911
}

packages/rspack-plugin-html/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"typings": "dist/index.d.ts",
88
"exports": {
99
".": {
10-
"types": "./dist/index.d.ts",
1110
"default": "./dist/index.js"
1211
},
1312
"./package.json": "./package.json"
@@ -34,7 +33,6 @@
3433
"directory": "packages/rspack-plugin-html"
3534
},
3635
"dependencies": {
37-
"@types/html-minifier-terser": "7.0.0",
3836
"html-minifier-terser": "7.0.0",
3937
"lodash.template": "^4.5.0",
4038
"parse5": "7.1.1",
@@ -50,6 +48,7 @@
5048
},
5149
"devDependencies": {
5250
"@rspack/core": "workspace:*",
51+
"@types/html-minifier-terser": "7.0.0",
5352
"@types/lodash.template": "^4.5.1",
5453
"@types/pug": "^2.0.6",
5554
"html-loader": "^4.2.0",

0 commit comments

Comments
 (0)