Skip to content

refactor(types): strip internals from the built declarations - #107

Merged
kamilmysliwiec merged 1 commit into
masterfrom
chore/strip-internal
Dec 4, 2026
Merged

kamilmysliwiec merged 1 commit into
masterfrom
chore/strip-internal

Conversation

@kamilmysliwiec

Copy link
Copy Markdown
Member

PR Checklist

PR Type

  • Refactoring (no functional changes; the declarations change)

What is the current behavior?

Members marked @internal ship in the published declarations, because the build doesn't set stripInternal. An app can call them through the types, which would make them part of what 1.0.0 freezes. Same change as nestjs/authentication#146.

What is the new behavior?

Internal members are stripped from the declarations. The JavaScript is unchanged. What disappears from the types: WebhookVerifier.receiverConfig() and requireInbox().

Now exported, so an app can name what public signatures use: WebhooksModuleRootOptions (what forRoot() takes) and WebhooksModuleStructure.

Two checks in CI, after the build: tests/declarations type-checks the built declarations as a consumer does (it expects an error on each stripped member), and tests/declarations/tsconfig.lib.json type-checks the declarations themselves with skipLibCheck off, so a declaration that names something stripped fails there.

Decision to confirm

The strict check also covers the declarations of our dependencies, so a dependency that ships a broken type file would turn build red. It passes today.

Does this PR introduce a breaking change?

  • Yes, in the types only: code that called an internal member no longer compiles.

Tests

  • The consumer test fails on a build without stripInternal (unused @ts-expect-error), and passes on this one.
  • The root typecheck still passes with dist removed, as the e2e jobs run it.
  • 590 passed locally (the database targets skip without a server). One PGlite store spec failed once under a parallel run and passed alone and on the rerun; nothing at run time changed.

@kamilmysliwiec kamilmysliwiec added the enhancement New feature or request label Dec 4, 2026
What the package marks as internal no longer ships in its declarations
(`stripInternal`), such as `WebhookVerifier.receiverConfig()` and
`requireInbox()`. The JavaScript is unchanged; an app can no longer call
them through the types.

`WebhooksModuleRootOptions`, which `forRoot()` takes, and
`WebhooksModuleStructure` are now exported.

CI now type-checks the built declarations, as a consumer does and with
`skipLibCheck` off, so a declaration that names something stripped
fails there instead of in an application.
@kamilmysliwiec
kamilmysliwiec merged commit 42e0860 into master Dec 4, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant