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

fix(plugin-type-check): options type should be non nullable #1830

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions packages/plugin-type-check/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
} from '@rsbuild/shared';
import type ForkTSCheckerPlugin from 'fork-ts-checker-webpack-plugin';

type ForkTsCheckerOptions = ConstructorParameters<
typeof ForkTSCheckerPlugin
>[0];
type ForkTsCheckerOptions = NonNullable<
ConstructorParameters<typeof ForkTSCheckerPlugin>[0]
>;

export type PluginTypeCheckerOptions = {
/**
Expand Down
28 changes: 28 additions & 0 deletions packages/plugin-type-check/tests/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,34 @@ exports[`plugin-type-check > should allow to configure fork-ts-checker-webpack-p
}
`;

exports[`plugin-type-check > should allow to configure fork-ts-checker-webpack-plugin options via function 1`] = `
{
"plugins": [
ForkTsCheckerWebpackPlugin {
"options": {
"async": false,
"issue": {
"exclude": [
[Function],
],
},
"logger": {
"error": [Function],
"log": [Function],
},
"typescript": {
"build": false,
"configFile": "<ROOT>/packages/plugin-type-check/tests/tsconfig.json",
"memoryLimit": 8192,
"mode": "readonly",
"typescriptPath": "<ROOT>/node_modules/<PNPM_INNER>/typescript/lib/typescript.js",
},
},
},
],
}
`;

exports[`plugin-type-check > should apply fork-ts-checker-webpack-plugin correctly 1`] = `
{
"plugins": [
Expand Down
18 changes: 18 additions & 0 deletions packages/plugin-type-check/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ describe('plugin-type-check', () => {
expect(config).toMatchSnapshot();
});

it('should allow to configure fork-ts-checker-webpack-plugin options via function', async () => {
const rsbuild = await createStubRsbuild({
cwd: __dirname,
rsbuildConfig: {},
plugins: [
pluginTypeCheck({
forkTsCheckerOptions(options) {
options.async = false;
return options;
},
}),
],
});

const config = await rsbuild.unwrapConfig();
expect(config).toMatchSnapshot();
});

it('should only apply one ts-checker plugin when there is multiple targets', async () => {
const rsbuild = await createStubRsbuild({
cwd: __dirname,
Expand Down