Repository navigation
[No QA] TSConfig cleanup – Phase 2: switch to web and native tsconfigs with a native error baseline - #107739
Draft
fabioh8010 wants to merge 6 commits into
Conversation
… native error baseline
…e2-99287/split-app-programs-with-baseline
…dioModeAsync typing, re-baseline after merging main
Contributor
|
|
This branch has not been deployed
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.
Explanation of Change
Note
Draft while CI and a self-review run. The commits get squashed before it's ready for review.
Part of the tsconfig cleanup, phase 2. This is the switch: the app is now type-checked twice, once as web and once as native, instead of once with DOM types and no platform resolution.
Configs
tsconfig.app.web.json(moduleSuffixes: [".web", ""], DOM) andtsconfig.app.native.json([".ios", ".android", ".native", ""], no DOM) replacetsconfig.app.json. Both include all ofsrc, because screens load throughrequire('@pages/…'), which TypeScript doesn't follow.src/typesis split intoapp/,web/andnative/.customConditions: []. Expo's base sets["react-native"], which Rsbuild never uses, and it made the web program typecheckreact-native-nitro-sqlitefrom its raw sources.tsconfig.jest.jsonextends web.modules/ExpensifyNitroUtils/tsconfig.jsonextends native. The VCR project excludes the native types.tsconfig.jsonthat includes a file, so shared files get the web types and.native/.ios/.androidfiles the native ones.Native globals.
src/types/native/globals.d.tsdeclares the web APIs React Native provides without typing them:performance.now(),queueMicrotask,requestIdleCallback/cancelIdleCallback,atob/btoaandTextEncoder/TextDecoder. On native,windowis the global object itself, with nodocument, andnavigatoris only{product: 'ReactNative'}. All of them were checked on iOS and Android debug builds.Native error baseline. Native still has 1,869 errors in 408 files, so it ships with a per-file baseline,
config/typescript/native-baseline.tsv, instead of a hard gate:npm run typecheck, and only those files' errors are printed;mainthe typecheck workflow commits it back as OSBotify, the same waylint.ymltightens the oxlint seatbelt;TYPECHECK_BASELINE_UPDATE=1 npm run typecheckrewrites it, for moving or renaming a file that already has errors;DOM lib guard. The typecheck fails if the native program ever loads
lib.dom.d.ts, and names the file that pulled it in. That's how #99495 passed CI:react-native-nitro-fetch@1.5.4loadedweb-streams-polyfill, whose typings reference the DOM lib.Docs.
CROSS-PLATFORM.mdgets a "Type-checking web and native" section: the shared-contract rule, native globals, how the baseline works and how to update it, linting and tests, and the dependency-bump policy.AGENTS.mdpoints to it.Jest. Jest runs tests with native resolution, but its typecheck now uses web types, so a few tests of native-only code needed changes:
SimplifiedKeyboardEventmoves tosrc/utils/keyboard/types.ts;jsi_*globals;LegendListTestand its mock cast the web typings of@legendapp/list/react-nativeback to the React Native ones;ExpensifyNitroUtilsrestates the nativeNitroModulestype, since nitro-modules types it as{}on web. To keep shared code from loading it at runtime on web, a new Oxlint rule bans runtime imports of@expensify/nitro-utilsoutside.native,.iosand.androidfiles.Fixed Issues
$ #99287
Tests
npm run typecheckand verify it passes, and that native reports the known errors as within the baseline.export const probe = document.body;to a shared file likesrc/libs/Parser.ts, runnpm run typecheckand verify it fails, listing that file with 1 error and 0 allowed./// <reference lib="dom" />at the top ofsrc/types/native/metro.d.ts, runnpm run typecheckand verify it fails, saying the native program loads the DOM lib through that file.// @ts-nocheckat the top ofsrc/GlobalModals.tsx, then runCI=true npm run typecheckand verify it passes and removes that file fromconfig/typescript/native-baseline.tsv.npm run test:bun -- -t 'TypecheckBaseline|findDomLibraries'and verify the tests pass.Offline tests
N/A
QA Steps
N/A
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari