Skip to content

Commit

Permalink
feat: should display error in overlay when exist type errors in dev m…
Browse files Browse the repository at this point in the history
…ode (#13)

* fix: should display error in overlay when exist type errors in dev mode

* docs: Disable type errors in the error overlay

* Update README.md

---------

Co-authored-by: neverland <chenjiahan.jait@bytedance.com>
  • Loading branch information
9aoy and chenjiahan authored Dec 24, 2024
1 parent 2a191c0 commit e0ee4c1
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 29 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,20 @@ pluginTypeCheck({
});
```

#### Disable type errors from the error overlay

By default, type errors will be reported to Dev Server and displayed in the Rsbuild error overlay in development mode.

If you don't want type errors to be displayed in the error overlay, you can disable it by setting `devServer: false`:

```ts
pluginTypeCheck({
tsCheckerOptions: {
async: true,
devServer: false,
},
});
```
## Notes

- If you have enabled `ts-loader` in your project and manually configured `compileOnly: false`, please disable the Type Check plugin to avoid duplicate type checking.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"deepmerge": "^4.3.1",
"ts-checker-rspack-plugin": "^1.0.1",
"ts-checker-rspack-plugin": "^1.1.0",
"json5": "^2.2.3",
"reduce-configs": "^1.1.0"
},
Expand Down
55 changes: 27 additions & 28 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions test/basic/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,39 @@ test('should throw error when exist type errors in dev mode', async ({
await server.close();
});

test('should display error in overlay when exist type errors in dev mode', async ({
page,
}) => {
const { restore } = proxyConsole();

const rsbuild = await createRsbuild({
cwd: __dirname,
rsbuildConfig: {
plugins: [pluginTypeCheck()],
server: {
port: getRandomPort(),
},
},
});

const { server, urls } = await rsbuild.startDevServer();

await new Promise((resolve) => setTimeout(resolve, 1000));

await page.goto(urls[0]);

const errorOverlay = page.locator('rsbuild-error-overlay');

expect(
(await errorOverlay.locator('.content').allInnerTexts()).find((txt) =>
txt.includes('TS2345: Argument of type'),
),
).toBeDefined();

restore();
await server.close();
});

test('should not throw error when the file is excluded', async () => {
const rsbuild = await createRsbuild({
cwd: __dirname,
Expand Down

0 comments on commit e0ee4c1

Please sign in to comment.