From 6efb14e9b1a70f4ee3297b441402c44dea236c2d Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Thu, 30 Jul 2026 17:31:39 +0100 Subject: [PATCH] fix: Ship compiled test mock entry point MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 https://github.com/react-native-community/template/issues/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 --- .eslintignore | 3 +++ mock/index.d.ts | 1 + mock/index.js | 1 + {mock => src/mock}/index.ts | 4 ++-- tsconfig.json | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 mock/index.d.ts create mode 100644 mock/index.js rename {mock => src/mock}/index.ts (81%) diff --git a/.eslintignore b/.eslintignore index 19c084e4b..19b686707 100644 --- a/.eslintignore +++ b/.eslintignore @@ -8,6 +8,9 @@ lib/**/* scripts/**/* +# Shim entry points that re-export from the build output +mock/**/* + babel.config.js metro.config.js react-native.config.js diff --git a/mock/index.d.ts b/mock/index.d.ts new file mode 100644 index 000000000..db5d66033 --- /dev/null +++ b/mock/index.d.ts @@ -0,0 +1 @@ +export * from '../lib/typescript/src/mock/index'; diff --git a/mock/index.js b/mock/index.js new file mode 100644 index 000000000..b27cb3e73 --- /dev/null +++ b/mock/index.js @@ -0,0 +1 @@ +module.exports = require('../lib/commonjs/mock/index.js'); diff --git a/mock/index.ts b/src/mock/index.ts similarity index 81% rename from mock/index.ts rename to src/mock/index.ts index 73d0cb846..f66ad9cf8 100644 --- a/mock/index.ts +++ b/src/mock/index.ts @@ -1,5 +1,5 @@ -import {MarkdownTextInput} from '../src'; -import type {parseExpensiMark} from '../src'; +import {MarkdownTextInput} from '..'; +import type {parseExpensiMark} from '..'; global.jsi_setMarkdownRuntime = jest.fn(); global.jsi_registerMarkdownWorklet = jest.fn(); diff --git a/tsconfig.json b/tsconfig.json index 6fcc7e12b..d2e888637 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,6 +26,6 @@ "verbatimModuleSyntax": true, "typeRoots": ["node_modules/@types"] }, - "include": ["src/**/*", "mock/**/*"], + "include": ["src/**/*"], "exclude": ["**/node_modules/**/*", "**/lib/**/*", "example/src/**/*", "WebExample/**/*", "**/Pods"] }