Skip to content

strip-internal: widen the fast gate, and call the sibling script through pnpm - #1640

Merged
obiot merged 1 commit into
masterfrom
fix/strip-internal-gate
Sep 4, 2026
Merged

strip-internal: widen the fast gate, and call the sibling script through pnpm#1640
obiot merged 1 commit into
masterfrom
fix/strip-internal-gate

Conversation

@obiot

@obiot obiot commented Sep 4, 2026

Copy link
Copy Markdown
Member

Two follow-ups from Copilot's review of #1639.

The fast gate could skip a whole file

UNDERSCORE_HINT decides whether a .d.ts is worth parsing at all. It only matched an underscore member written bare or behind readonly:

/^\s*(readonly\s+)?_[A-Za-z0-9_]+\s*[?:(<]/m

A file whose underscore members all carry a modifier — private _secret, protected _hidden(), static _shared — fails that test and is skipped outright, so those members survive into the published types. The failure mode is silent: the file is never parsed, rather than parsed and passed over.

Nothing leaks today. No emitted declaration currently puts those modifiers on an underscore member, so the hole is latent. It opens the moment someone writes one in TypeScript source — which is exactly the kind of thing that gets noticed months later.

Verified in both directions against a probe declaration carrying only modified members and no @internal:

old pattern new pattern
parses the file no — skipped entirely yes

Erring wide costs one AST walk on a file with nothing to strip.

doc shelled out to npm

Every other script in the package uses pnpm (pnpm lint, pnpm types, pnpm clean); doc called npm run doc:css. Inconsistent, and npm can resolve differently in a workspace install.

Verified

  • 741 declarations stripped, unchanged
  • 0 internals in the reference, 0 in the published types
  • 6633 tests, lint and types clean, 156 doc warnings

…ugh pnpm

The pre-filter that decides whether a `.d.ts` is worth parsing only matched an
underscore member written bare or behind `readonly`. A file whose underscore
members all carry a modifier — `private _secret`, `protected _hidden()`,
`static _shared` — failed the gate and was skipped outright, so those members
survived into the published types. Silent, because the file was never parsed
rather than parsed and passed over.

Nothing leaks today: no emitted declaration currently uses those modifiers on
an underscore member, so the hole is latent rather than active. It would open
the moment someone wrote one in TypeScript source. Verified both ways against a
probe declaration carrying only modified members and no `@internal` — the old
pattern skipped the file, the new one parses it.

`doc` also shelled out to `npm run doc:css` while every other script here uses
pnpm, which can resolve differently in a workspace install.

Raised by Copilot on #1639.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Aa37KGXZcnVrbn1yG4j1N
Copilot AI lite review requested due to automatic review settings September 4, 2026 02:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The changes are small, targeted, and align with the stated goal of preventing silent .d.ts skipping while improving workspace script consistency.

Pull request overview

This PR tightens the type-declaration post-processing workflow in packages/melonjs by widening the “fast gate” heuristic used by scripts/strip-internal.ts so modified underscore-prefixed class members don’t cause entire .d.ts files to be skipped, and by making the docs pipeline consistently invoke sibling scripts via pnpm within the workspace.

Changes:

  • Widen UNDERSCORE_HINT to match underscore-prefixed members even when preceded by common class-member modifiers (e.g. private, protected, static, abstract, override, get, set).
  • Switch the doc script to call doc:css via pnpm instead of npm for workspace-consistent resolution.
File summaries
File Description
packages/melonjs/scripts/strip-internal.ts Expands the prefilter regex so files containing only modified underscore members are still parsed and stripped correctly.
packages/melonjs/package.json Makes doc invoke doc:css via pnpm to match the rest of the workspace scripts.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@obiot
obiot merged commit 16e3025 into master Sep 4, 2026
7 checks passed
@obiot
obiot deleted the fix/strip-internal-gate branch September 4, 2026 03:19
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