Skip to content

Conversation

@zthxxx
Copy link

@zthxxx zthxxx commented Dec 17, 2025

Summary

  • pass abortOnError through dts pipeline (tsc/tsgo) instead of always failing when type-check has error
  • allow bundling to proceed when abortOnError is false despite diagnostics

Related Links

N/A

Checklist

  • Tests updated (not required).
  • Documentation updated (not required).

- pass `abortOnError` through dts pipeline (tsc/tsgo) instead of always failing
- allow bundling to proceed when `abortOnError` is `false` despite diagnostics
Copilot AI review requested due to automatic review settings December 17, 2025 12:27
@CLAassistant
Copy link

CLAassistant commented Dec 17, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the DTS generation pipeline to properly honor the abortOnError configuration option. Previously, the TypeScript compilation would always abort when encountering type errors, regardless of the abortOnError setting. The changes ensure that when abortOnError is set to false, the build continues and bundling proceeds even when type-check errors are present.

Key changes:

  • Thread abortOnError parameter through both tsc and tsgo compilation pipelines
  • Conditionally throw errors based on abortOnError setting instead of always aborting
  • Allow bundling to proceed when errors exist but abortOnError is false

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/plugin-dts/src/tsc.ts Added abortOnError to EmitDtsOptions type and modified error handling in handleDiagnosticsAndProcessFiles and solution builder path to conditionally throw based on this flag
packages/plugin-dts/src/tsgo.ts Modified handleDiagnosticsAndProcessFiles to accept and use abortOnError parameter, passing it through from emitDtsTsgo function
packages/plugin-dts/src/dts.ts Extracted abortOnError from options, passed it to emit functions, and updated tsgo bundling condition to allow bundling when errors exist but abortOnError is false

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// do not log the stack trace, diagnostic messages are enough
error.stack = '';
throw error;
if (abortOnError) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When bundle: false with abortOnError: false, the error should still be throwed I think. abortOnError means not exit the process instead of not throwing error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we throw an error here, the outer dts generation flow will fail due to promise rejection, no matter whether bundle is true or false.

packages/plugin-dts/src/dts.ts:265

In other words, even when abortOnError is set to false, throwing here will still cause the whole external pipeline to stop and skip subsequent steps.

That’s why the error is handled without throwing in this case, allowing the process to continue as intended when abortOnError is disabled.

Copy link
Contributor

@Timeless0911 Timeless0911 Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Promise rejection is handled in main process.

for (const result of promisesResult) {
if (result.status === 'error') {
if (options.abortOnError) {
const error = new Error(result.errorMessage);
// do not log the stack trace, it is not helpful for users
error.stack = '';
throw error;
}
result.errorMessage && logger.error(result.errorMessage);
logger.warn(
'With `abortOnError` configuration currently disabled, type errors will not fail the build, but proper type declaration output cannot be guaranteed.',
);
}
}
});

When abortOnError is set to false, a warning will be printed and the process continue.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may optimize the behaviour when abortOnError set to false with bundle set to true. Now, if tsc/tsgo throws error, the logic in apiExtractor.ts will not be called.

When bundle set to false, throwing error is reasonable since no other operations will be performed.

In other words, abortOnError is used to prevent a process from exiting with a non-zero exit code. If you want to ignore type errors, you should set noCheck to disable type checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants