fix(rspack): must run type check with @nx/rspack:rspack when skipTypeChecking is false (#31027)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
- Create a project that uses @nx/rspack:rspack as build target with
SkipTypeChecking set to false.
- Run build target for project.
- Type check has not been run and will not bail in case of any
typescript errors

<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
- It should run type checking as documented:
https://nx.dev/nx-api/rspack/executors/rspack#skiptypechecking
I looked at the webpack executor and there it also runs the type check
based on `skipTypeChecking` and not the `typeCheck` alias. So I've
adjusted it accordingly for the rspack executor.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #31026

---------

Co-authored-by: Colum Ferry <cferry09@gmail.com>
This commit is contained in:
dpnolte 2025-06-09 12:08:01 +02:00 committed by GitHub
parent b38f966707
commit 438457ab12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 1 deletions

View File

@ -30,7 +30,7 @@ export default async function* runExecutor(
normalizedOptions.mode = process.env.NODE_ENV; normalizedOptions.mode = process.env.NODE_ENV;
} }
if (normalizedOptions.typeCheck) { if (!normalizedOptions.skipTypeChecking) {
await executeTypeCheck(normalizedOptions, context); await executeTypeCheck(normalizedOptions, context);
} }

View File

@ -82,6 +82,37 @@ export function normalizeOptions(
); );
} }
// Normalize typeCheck and skipTypeChecking options
let normalizedTypeCheck: boolean;
let normalizedSkipTypeChecking: boolean;
if (
combinedPluginAndMaybeExecutorOptions.typeCheck !== undefined &&
combinedPluginAndMaybeExecutorOptions.skipTypeChecking !== undefined
) {
// Both options are provided - use typeCheck as the source of truth
normalizedTypeCheck = combinedPluginAndMaybeExecutorOptions.typeCheck;
normalizedSkipTypeChecking =
!combinedPluginAndMaybeExecutorOptions.typeCheck;
} else if (combinedPluginAndMaybeExecutorOptions.typeCheck !== undefined) {
// Only typeCheck is provided
normalizedTypeCheck = combinedPluginAndMaybeExecutorOptions.typeCheck;
normalizedSkipTypeChecking =
!combinedPluginAndMaybeExecutorOptions.typeCheck;
} else if (
combinedPluginAndMaybeExecutorOptions.skipTypeChecking !== undefined
) {
// Only skipTypeChecking is provided
normalizedSkipTypeChecking =
combinedPluginAndMaybeExecutorOptions.skipTypeChecking;
normalizedTypeCheck =
!combinedPluginAndMaybeExecutorOptions.skipTypeChecking;
} else {
// Neither option is provided - use defaults
normalizedTypeCheck = true;
normalizedSkipTypeChecking = false;
}
return { return {
...combinedPluginAndMaybeExecutorOptions, ...combinedPluginAndMaybeExecutorOptions,
assets: combinedPluginAndMaybeExecutorOptions.assets assets: combinedPluginAndMaybeExecutorOptions.assets
@ -126,6 +157,7 @@ export function normalizeOptions(
combinedPluginAndMaybeExecutorOptions.sassImplementation ?? combinedPluginAndMaybeExecutorOptions.sassImplementation ??
'sass-embedded', 'sass-embedded',
scripts: combinedPluginAndMaybeExecutorOptions.scripts ?? [], scripts: combinedPluginAndMaybeExecutorOptions.scripts ?? [],
skipTypeChecking: normalizedSkipTypeChecking,
sourceMap: combinedPluginAndMaybeExecutorOptions.sourceMap ?? !isProd, sourceMap: combinedPluginAndMaybeExecutorOptions.sourceMap ?? !isProd,
sourceRoot, sourceRoot,
styles: combinedPluginAndMaybeExecutorOptions.styles ?? [], styles: combinedPluginAndMaybeExecutorOptions.styles ?? [],
@ -133,6 +165,7 @@ export function normalizeOptions(
combinedPluginAndMaybeExecutorOptions.subresourceIntegrity ?? false, combinedPluginAndMaybeExecutorOptions.subresourceIntegrity ?? false,
target: combinedPluginAndMaybeExecutorOptions.target ?? 'web', target: combinedPluginAndMaybeExecutorOptions.target ?? 'web',
targetName, targetName,
typeCheck: normalizedTypeCheck,
vendorChunk: combinedPluginAndMaybeExecutorOptions.vendorChunk ?? !isProd, vendorChunk: combinedPluginAndMaybeExecutorOptions.vendorChunk ?? !isProd,
}; };
} }