Skip to content

Commit 98dc767

Browse files
authored
chore: upgrade TypeScript to ^6.0.2 (#170)
1 parent ebf5a33 commit 98dc767

10 files changed

Lines changed: 54 additions & 51 deletions

File tree

client-src/overlay.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// The error overlay is inspired (and mostly copied) from Create React App (https://github.com/facebookincubator/create-react-app)
1212
// They, in turn, got inspired by webpack-hot-middleware (https://github.com/glenjamin/webpack-hot-middleware).
1313

14-
import ansiHTML from './utils/ansiHTML';
14+
import ansiHTML from './utils/ansiHTML.js';
1515

1616
const getCodePoint = !!String.prototype.codePointAt
1717
? (input: string, position: number): number | undefined =>
@@ -422,13 +422,17 @@ type CreateOverlayOptions = {
422422
catchRuntimeError?: boolean | ((error: Error) => void);
423423
};
424424

425+
type OverlayTrustedTypePolicy = {
426+
createHTML: (value: string) => string;
427+
};
428+
425429
declare global {
426430
interface Window {
427431
trustedTypes?: {
428432
createPolicy: (
429433
name: string,
430434
policy: { createHTML: (value: string) => string },
431-
) => TrustedTypePolicy;
435+
) => OverlayTrustedTypePolicy;
432436
};
433437
}
434438
}
@@ -438,9 +442,7 @@ const createOverlay = (options: CreateOverlayOptions): StateMachine => {
438442
let containerElement: HTMLDivElement | null | undefined;
439443
let headerElement: HTMLDivElement | null | undefined;
440444
let onLoadQueue: ((element: HTMLDivElement) => void)[] = [];
441-
let overlayTrustedTypesPolicy:
442-
| Omit<TrustedTypePolicy, 'createScript' | 'createScriptURL'>
443-
| undefined;
445+
let overlayTrustedTypesPolicy: OverlayTrustedTypePolicy | undefined;
444446

445447
type CSSStyleDeclarationKeys = Extract<keyof CSSStyleDeclaration, 'string'>;
446448

@@ -645,8 +647,7 @@ const createOverlay = (options: CreateOverlayOptions): StateMachine => {
645647
const errorObject =
646648
error instanceof Error
647649
? error
648-
: // @ts-expect-error error options
649-
new Error(error || fallbackMessage, { cause: error });
650+
: new Error(error || fallbackMessage, { cause: error });
650651

651652
const shouldDisplay =
652653
typeof options.catchRuntimeError === 'function'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"selfsigned": "^5.5.0",
8585
"simple-git-hooks": "^2.13.1",
8686
"style-loader": "^4.0.0",
87-
"typescript": "^5.9.3"
87+
"typescript": "^6.0.2"
8888
},
8989
"peerDependencies": {
9090
"@rspack/core": "^2.0.0-0",

pnpm-lock.yaml

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
ServerConfiguration,
77
WatchFiles,
88
WebSocketServerConfiguration,
9-
} from './types';
9+
} from './types.js';
1010

1111
export interface ResolvedDevServer extends DevServer {
1212
port: number | string;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export { Server as RspackDevServer } from './server';
1+
export { Server as RspackDevServer } from './server.js';
22
export type { DevServer as Configuration } from '@rspack/core';

src/server.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ import type {
3535
import compression from 'http-compression';
3636
import ipaddr from 'ipaddr.js';
3737
import type { App } from 'open';
38-
import { getPort } from './getPort';
39-
import { WebsocketServer } from './servers/WebsocketServer';
38+
import { getPort } from './getPort.js';
39+
import { WebsocketServer } from './servers/WebsocketServer.js';
4040
import type {
4141
AddressInfo,
4242
BasicApplication,
@@ -78,8 +78,8 @@ import type {
7878
WebSocketServer,
7979
WebSocketServerConfiguration,
8080
WebSocketServerImplementation,
81-
} from './types';
82-
import type { ConnectApplication } from './types';
81+
} from './types.js';
82+
import type { ConnectApplication } from './types.js';
8383

8484
const { styleText } = util;
8585
const require = createRequire(import.meta.url);
@@ -574,7 +574,7 @@ class Server<
574574
// Configuration with the `devServer` options
575575
const compilerWithDevServer = (
576576
this.compiler as MultiCompiler
577-
).compilers.find((config) => config.options.devServer);
577+
).compilers.find((config: Compiler) => config.options.devServer);
578578

579579
if (compilerWithDevServer) {
580580
return compilerWithDevServer.options;
@@ -583,7 +583,7 @@ class Server<
583583
// Compiler for `web` target
584584
const compilerWithWebTarget = (
585585
this.compiler as MultiCompiler
586-
).compilers.find((compiler) => Boolean(compiler.platform.web));
586+
).compilers.find((compiler: Compiler) => Boolean(compiler.platform.web));
587587

588588
if (compilerWithWebTarget) {
589589
return compilerWithWebTarget.options;
@@ -1396,7 +1396,7 @@ class Server<
13961396

13971397
if (this.options.hot) {
13981398
const HMRPluginExists = compiler.options.plugins.find(
1399-
(plugin) =>
1399+
(plugin: EXPECTED_ANY) =>
14001400
plugin && plugin.constructor === HotModuleReplacementPlugin,
14011401
);
14021402

src/servers/BaseServer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
99
*/
1010

11-
import type { Server } from '../server';
12-
import type { ClientConnection } from '../types';
11+
import type { Server } from '../server.js';
12+
import type { ClientConnection } from '../types.js';
1313

1414
// base class that users should extend if they are making their own
1515
// server implementation

src/servers/WebsocketServer.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
*/
1010

1111
import * as Ws from 'ws';
12-
import type { Server } from '../server';
13-
import type { ClientConnection, WebSocketServerConfiguration } from '../types';
14-
import BaseServer from './BaseServer';
12+
import type { Server } from '../server.js';
13+
import type {
14+
ClientConnection,
15+
WebSocketServerConfiguration,
16+
} from '../types.js';
17+
import BaseServer from './BaseServer.js';
1518

1619
export class WebsocketServer extends BaseServer {
1720
static heartbeatInterval = 1000;

tsconfig.client.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"rootDir": "client-src",
5-
"outDir": "client"
5+
"outDir": "client",
6+
"module": "esnext",
7+
"moduleResolution": "bundler",
8+
"composite": true
69
},
710
"include": ["client-src/**/*"]
811
}

tsconfig.json

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
{
22
"compilerOptions": {
3-
"module": "preserve",
4-
"moduleResolution": "bundler",
5-
"target": "ES2021",
6-
"esModuleInterop": true,
3+
"rootDir": "./src",
4+
"outDir": "./dist",
5+
"target": "ES2023",
6+
"types": ["node"],
7+
"lib": ["DOM", "ESNext"],
78
"declaration": true,
89
"isolatedModules": true,
9-
"composite": true,
10-
"forceConsistentCasingInFileNames": true,
11-
"checkJs": true,
12-
"strict": true,
1310
"skipLibCheck": true,
14-
"noUnusedLocals": true,
15-
"outDir": "dist",
16-
"rootDir": "src"
11+
"module": "nodenext",
12+
"moduleResolution": "nodenext"
1713
},
1814
"references": [
1915
{
2016
"path": "./tsconfig.client.json"
2117
}
2218
],
23-
"include": ["src/**/*"]
19+
"include": ["src"]
2420
}

0 commit comments

Comments
 (0)