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: force emit types even when there're errors #320

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

hyrious
Copy link
Contributor

@hyrious hyrious commented Oct 28, 2024

The dts plugin runs TypeScript to generate .d.ts files for .ts inputs. This often just works. However in some cases it still fails to fetch types from deep dependencies. I used to turn off all strict type-checking options to get rid of these errors, but today I found a special case which doesn't work in any option settings:

// @ts-expect-error
expectString(null)

function expectString(a: string) {}
  1. If strictNullChecks: false, the code above raises Unused '@ts-expect-error' directive.
  2. If I remove the directive, the code above cannot pass my projects type checking.

I only want to generate and bundle types and don't want to handle any type errors. So today I found that the TypeScript Playground actually can emit types even when there're errors in the code. After digging a while I found the hidden option to force emitting types.

@hyrious hyrious changed the title fix: force emit types even when there's errors fix: force emit types even when there're errors Oct 28, 2024
@Swatinem Swatinem merged commit a985a6f into Swatinem:master Oct 28, 2024
8 checks passed
@hyrious hyrious deleted the force-emit-dts branch November 4, 2024 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants