fix: stop leaking the internal "~api" export into .d.marko output - #584
Conversation
🦋 Changeset detectedLatest commit: 21e4375 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThe change centralizes generated runtime API identifiers and filters the internal API variable and 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@agent-feedback/dx.md`:
- Around line 4-15: Record the actionable declaration-emit test-coverage finding
from agent-feedback/dx.md in agent-feedback/README.md. Preserve the requested
scope and details, including the mtc fixture/snapshot validation, optional
re-check of emitted files, and verification of whether the recursive test
command covers packages/type-check.
In `@packages/language-tools/src/processors/marko.ts`:
- Around line 175-176: Update the filters around isInternalApiVar and
isExportInternalApi to match only generated internal API declarations: require
the exported property name to equal INTERNAL_API_VAR and ensure moduleSpecifier
is absent, excluding source exports and re-exports such as userApi. Apply
equally specific checks to isInternalApiVar so user-authored declarations are
preserved.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 247ad7ea-eb69-401b-b63c-b422de40faed
📒 Files selected for processing (4)
.changeset/dts-api-export.mdagent-feedback/dx.mdpackages/language-tools/src/extractors/script/index.tspackages/language-tools/src/processors/marko.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/type-check/package.json`:
- Around line 30-31: Update the package.json test and test:update scripts to run
the repository’s dependency-aware build command before invoking Mocha, ensuring
`@marko/language-tools` is built before type-check. Preserve the existing test
glob and update flag after the build step.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 92986839-9e21-4f41-9076-cf261d8e6c7f
⛔ Files ignored due to path filters (3)
packages/type-check/src/__tests__/fixtures/emit/__snapshots__/emits-declaration-files.expected/counter.d.markois excluded by!**/__snapshots__/**and included by**packages/type-check/src/__tests__/fixtures/emit/__snapshots__/emits-declaration-files.expected/greet.d.markois excluded by!**/__snapshots__/**and included by**packages/type-check/src/__tests__/fixtures/emit/__snapshots__/emits-declaration-files.expected/static.d.markois excluded by!**/__snapshots__/**and included by**
📒 Files selected for processing (7)
packages/type-check/.mocharc.jsonpackages/type-check/package.jsonpackages/type-check/src/__tests__/emit.test.tspackages/type-check/src/__tests__/fixtures/emit/src/counter.markopackages/type-check/src/__tests__/fixtures/emit/src/greet.markopackages/type-check/src/__tests__/fixtures/emit/src/static.markopackages/type-check/src/__tests__/fixtures/emit/tsconfig.json
f043eee to
8499935
Compare
The standalone `"~api"` export added to the extracted script was being copied
into generated `.d.marko` files as `static declare const __marko_internal_api`.
The `.d.marko` printer now skips it and the `const` backing it, matching on the
generated export's local name and rejecting re-exports so a source
`export { something as "~api" }` is left alone. The api is re-derived whenever
the `.d.marko` is itself extracted, so nothing is lost.
Also fixes `isVariableStatementForName` comparing `escapedText`, which
TypeScript prefixes with an extra underscore for `__`-prefixed identifiers.
Adds the missing coverage: `@marko/type-check` now snapshots every emitted
`.d.marko` for a fixture project and type checks the emitted files as Marko
sources, so leaked internals fail the build.
8499935 to
21e4375
Compare
The standalone
"~api"export added to the extracted script in e986bcb was being copied into generated.d.markofiles, which came out asstatic declare const __marko_internal_api = "class";plus the export itself. The.d.markoprinter now skips it and theconstbacking it — matching the generated export's local name and rejecting re-exports, so a sourceexport { something as "~api" }is left alone. The api is re-derived whenever the.d.markois extracted, so nothing is lost.Also fixes
isVariableStatementForNamecomparingescapedText, which TypeScript prefixes with an extra underscore for__-prefixed identifiers.Adds the coverage that was missing:
@marko/type-checknow snapshots every emitted.d.markofor a fixture project and type checks the emitted files as Marko sources, so leaked internals fail the build.