Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: should display error in overlay when exist type errors in dev mode #13

Merged
merged 3 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 in the error overlay
chenjiahan marked this conversation as resolved.
Show resolved Hide resolved

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
Loading