fix: Ship compiled test mock entry point (fix TS under RN 0.87) - #771
Open
huntie wants to merge 1 commit into
Open
fix: Ship compiled test mock entry point (fix TS under RN 0.87)#771huntie wants to merge 1 commit into
huntie wants to merge 1 commit into
Conversation
Minimal fix for `@expensify/react-native-live-markdown` compatibility in React Native 0.87+ projects that wire up the test mock from a TypeScript setup file. See react-native-community/template#245. **Context** React Native 0.87 ships the Strict TypeScript API by default (moving to a user opt-out). Typically, this change is scoped to the user's project (`@react-native/typescript-config` includes `skipLibCheck: true`) and does not reach library source code. However, this library ships a Jest mock at `@expensify/react-native-live-markdown/mock`, which is an exception that crosses this boundary. **Problem** `@expensify/react-native-live-markdown/mock` resolved to raw `mock/index.ts` — no sibling `.d.ts` existed at that path — so it pulled this library's `../src/*` into the scope of the user's TypeScript analysis instead of the compiled `lib/` code. That produces a type error against deep imports such as `react-native/Libraries/Types/CodegenTypes`, which no longer resolve under the Strict TypeScript API (`TS2307`). `skipLibCheck` does not contain it because it does not apply to `.ts`/`.tsx`. **This diff** Move the mock into the builder-bob build so consuming projects only ever see this library's `.d.ts` files, which are exempt from typechecking. - Move `mock/index.ts` to `src/mock/index.ts` so builder-bob compiles it like the rest of the library; repoint its imports from `'../src'` to `'..'`. - Preserve the `@expensify/react-native-live-markdown/mock` subpath via shims: `mock/index.js` re-exports `../lib/commonjs/mock/index.js`, `mock/index.d.ts` re-exports `../lib/typescript/src/mock/index`. - Drop `mock/**/*` from tsconfig `include` so the source is only picked up under `src/`, and lint-ignore `mock/**/*` since the shims point into build output. No `exports` map is introduced — the package has none today, and shims are the conservative, non-breaking equivalent. Changelog: [Fixed] - Ship a compiled `/mock` entry point so consumers resolve declarations instead of raw source
|
All contributors have signed the CLA ✍️ ✅ |
huntie
marked this pull request as ready for review
July 30, 2026 16:40
Author
|
I have read the CLA Document and I hereby sign the CLA |
huntie
commented
Jul 30, 2026
| @@ -0,0 +1 @@ | |||
| module.exports = require('../lib/commonjs/mock/index.js'); | |||
Author
There was a problem hiding this comment.
Shims prevent this from being a breaking change. Also achievable by introducing a package.json "exports" field.
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.
Details
Minimal fix for
@expensify/react-native-live-markdowncompatibility in React Native 0.87+ projects that wire up the test mock from a TypeScript setup file. See react-native-community/template#245.Context
React Native 0.87 ships the Strict TypeScript API by default (moving to a user opt-out).
Typically, this change is scoped to the user's project (
@react-native/typescript-configincludesskipLibCheck: true) and does not reach library source code.However, this library ships a Jest mock at
@expensify/react-native-live-markdown/mock, which is an exception that crosses this boundary.Problem
@expensify/react-native-live-markdown/mockresolved to rawmock/index.ts— no sibling.d.tsexisted at that path — so it pulled this library's../src/*into the scope of the user's TypeScript analysis instead of the compiledlib/code. That produces a type error against deep imports such asreact-native/Libraries/Types/CodegenTypes, which no longer resolve under the Strict TypeScript API (TS2307, see also AppAndFlow/react-native-safe-area-context#744).skipLibCheckdoes not contain it because it does not apply to.ts/.tsx.This diff
Move the mock into the builder-bob build so consuming projects only ever see this library's
.d.tsfiles, which are exempt from typechecking. Same fix as AppAndFlow/react-native-safe-area-context#745, independent of the deep-import cleanup in #744.mock/index.tstosrc/mock/index.tsso builder-bob compiles it like the rest of the library; repoint its imports from'../src'to'..'.@expensify/react-native-live-markdown/mocksubpath via shims:mock/index.jsre-exports../lib/commonjs/mock/index.js,mock/index.d.tsre-exports../lib/typescript/src/mock/index.mock/**/*from tsconfigincludeso the source is only picked up undersrc/, and lint-ignoremock/**/*since the shims point into build output..d.tsfiles, which are exempt from typechecking due toskipLibCheck: true.No
exportsmap is introduced — the package has none today, and shims are the conservative, non-breaking equivalent.Related Issues
Manual Tests
yarn typecheck,yarn lint:root, and the Jest suite (153 tests) all pass.yarn prepare(bob build) emitslib/commonjs/mock/index.js,lib/module/mock/index.js, andlib/typescript/src/mock/index.d.ts; the stalelib/typescript/mock/is gone.npm pack --dry-runconfirms the threelib/**/mockoutputs plus themock/index.js/mock/index.d.tsshims ship, andmock/index.tsno longer appears at the publicmock/path.lib/commonjs/mock/index.jsretains the module-scopeglobal.jsi_*assignments and the'worklet'directive.Linked PRs