Skip to content

Commit 2150156

Browse files
authored
feat: support TypeScript 7 (#87)
* feat: support ts-checker-rspack-plugin 1.5.0 * fix: set TypeScript Go package marker * fix: preserve user TypeScript path options * fix: sync tsgo package for custom paths * fix: delegate TypeScript runtime resolution
1 parent a569c06 commit 2150156

9 files changed

Lines changed: 325 additions & 123 deletions

File tree

README.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,8 @@ const defaultOptions = {
117117
memoryLimit: 8192,
118118
// use tsconfig of user project
119119
configFile: tsconfigPath,
120-
// use TypeScript checker by default
121-
tsgo: false,
122-
// use typescript of user project
123-
typescriptPath: tsgo
124-
? require.resolve('@typescript/native-preview/package.json')
125-
: require.resolve('typescript'),
120+
// resolve the default TypeScript package from user project
121+
resolveRoot: api.context.rootPath,
126122
},
127123
issue: {
128124
// ignore types errors from node_modules
@@ -134,17 +130,34 @@ const defaultOptions = {
134130
// we only want to display error messages
135131
},
136132
error(message: string) {
137-
console.error(message.replace(/ERROR/g, 'Type Error'));
133+
console.error(
134+
message
135+
.replace(/ERROR/g, 'Type Error')
136+
.replace(/WARNING/g, 'Type Warning'),
137+
);
138138
},
139139
},
140140
};
141141
```
142142

143143
#### TypeScript Go support
144144

145-
TypeScript Go support is powered by `ts-checker-rspack-plugin`'s experimental, CLI-based integration for [typescript-go](https://github.com/microsoft/typescript-go). It runs the `tsgo` binary for type checking and can reduce type-checking time by about 5-10x.
145+
TypeScript Go support is powered by `ts-checker-rspack-plugin`'s experimental, CLI-based integration for [typescript-go](https://github.com/microsoft/typescript-go). It runs the TypeScript Go checker binary for type checking and can reduce type-checking time by about 5-10x.
146146

147-
To enable it, install `@typescript/native-preview` and set `typescript.tsgo` to `true`:
147+
Install TypeScript 7.0 RC to use TypeScript Go automatically:
148+
149+
```sh
150+
# with npm
151+
npm install -D typescript@rc
152+
153+
# with yarn
154+
yarn add -D typescript@rc
155+
156+
# with pnpm
157+
pnpm add -D typescript@rc
158+
```
159+
160+
You can also install `@typescript/native-preview` and set `typescript.tsgo` to `true`:
148161

149162
```ts
150163
pluginTypeCheck({
@@ -156,7 +169,9 @@ pluginTypeCheck({
156169
});
157170
```
158171

159-
When `tsgo` is enabled, the default `typescript.typescriptPath` resolves to `@typescript/native-preview/package.json`. If you set `typescript.typescriptPath` manually in `tsgo` mode, it must be an absolute path to `@typescript/native-preview/package.json`.
172+
When `tsgo` is enabled and `typescript.typescriptPath` is set manually, it must point to an absolute `typescript/package.json` path from TypeScript 7+ or `@typescript/native-preview/package.json`.
173+
174+
> The `@typescript/native-preview` usage is deprecated and kept only for compatibility. We recommend installing `typescript@rc` to use `tsgo`.
160175
161176
For supported options and limitations, see [ts-checker-rspack-plugin - TypeScript Go support](https://github.com/rstackjs/ts-checker-rspack-plugin#typescript-go-support).
162177

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"deepmerge": "^4.3.1",
3636
"json5": "^2.2.3",
3737
"reduce-configs": "^1.1.2",
38-
"ts-checker-rspack-plugin": "^1.4.0"
38+
"ts-checker-rspack-plugin": "^1.5.1"
3939
},
4040
"devDependencies": {
4141
"@playwright/test": "^1.61.1",

0 commit comments

Comments
 (0)