BridgeJS: Check generated TypeScript validity in test suites #611
+18
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Should close: #593
Overview
BridgeJS generates
.d.tsTypeScript declaration files, but nothing validates they are actually valid TypeScript. PR #592 fixed a bug where thefunctionkeyword was missing from namespace function declarations.Any project running strict TypeScript type-checking (
tsc --noEmit) withoutskipLibCheckwould fail on the generated declarations (and it did 😅 ).Approach
Add a
tsc --noEmitcheck against all.d.tssnapshot files using the already-installedtypescript(^5.8.2) from the rootpackage.json, so no new dependencies.** why an npm script rather than a Swift test?** The BridgeJS Swift tests have no precedent for shelling out to Node tools. The
test-bridgejs-against-swift-versionsCI job runs in containers where tool availability differs. Keeping TypeScript validation in TypeScript tooling seems like the cleanest approach, but not an expert on that, so maybe there is better way.why not integrated into snapshot assertions? The
assertSnapshot()helper is a clean, general-purpose utility. Addingtsccoupling would slow every assertion and require handling "tsc not found" inside what should be a simple file comparison.Usage
Notes
This check immediately surfaced existing codegen bugs - issues with type definitions for
PointTag,TSDirectionTag,TSThemeTag, andTSHttpStatusTagin 3 snapshot files. I'll add separate issue for that, will fix in separate PR, then rebase this one, so we'll know that this approach actually works for us 👌🏻So failing CI for this one is actual sign it works, not a bug 😅