fix(ts): enforce browser-only compatibility in fable-library-ts tsconfig#4563
Merged
MangelMaxime merged 1 commit intoApr 26, 2026
Conversation
MangelMaxime
marked this pull request as ready for review
April 24, 2026 20:51
Member
|
It does seems like the fix proposed could work. If I comment out Let's see if the full CI passes |
Add \"types\": [] to both tsconfig files (source + build copy) to exclude all @types/* packages from automatic inclusion. This means @types/node (Buffer, process, etc.) is no longer silently available during tsc compilation, which catches browser-incompatible type usage. All current Buffer references already use the `globalThis as any` escape hatch, so the library compiles cleanly. Closes #4368 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
MangelMaxime
force-pushed
the
repo-assist/fix-issue-4368-fable-library-ts-browser-compat-check-e40d2210715632df
branch
from
April 24, 2026 21:19
158dc26 to
b16cf2b
Compare
41 tasks
MangelMaxime
deleted the
repo-assist/fix-issue-4368-fable-library-ts-browser-compat-check-e40d2210715632df
branch
April 26, 2026 18:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🤖 This is an automated draft PR from Repo Assist, created in response to maintainer request on #4368.
Problem
fable-library-tswas silently compiling with@types/nodetypes available (because the monorepo has@types/nodein its rootnode_modules). This masked browser-incompatible type usage: a user targeting browsers would see TypeScript errors for any directBufferreferences, even though the library code worked fine at runtime.The issue was raised in #4368 and the
Bufferusages inEncoding.tswere already fixed with theglobalThis as anypattern. The remaining gap was no CI check to prevent future regressions.Fix
Uncomment
"types": []in both tsconfig files:src/fable-library-ts/tsconfig.json— used by IDEs when editing the source filessrc/fable-library-ts/ts/tsconfig.json— copied totemp/fable-library-ts/and used bytscwhen buildingfable-library-jsWith
"types": [], TypeScript no longer auto-includes any@types/*package. Node.js-specific globals (Buffer,process,NodeJS.*, etc.) are excluded, simulating a browser-only environment.What
"types": []does NOT affect:lib.es2020.d.ts,lib.dom.d.ts, etc.) — still included via"target": "es2020"TextEncoder,TextDecoder,fetch,crypto,setInterval, etc.) — still availableimport typestatements — still workHow the check is enforced
The
tsccompilation step runs during./build.sh fable-library --javascript(BuildFableLibraryJavaScript.PostFableBuildStage()), which uses the tsconfig fromtemp/fable-library-ts/. With"types": []in place, any future accidental use of@types/nodeglobals would fail this step with a clear TypeScript error.Trade-offs
None expected. All
Bufferusages already use(globalThis as any).Bufferand compile cleanly. The change makes an implicit guarantee explicit.Closes #4368