Skip to content

Align SDK tsconfig lib with React Native - #64

Merged
ofalvai merged 1 commit into
masterfrom
typescript-sdk
Sep 23, 2026
Merged

ofalvai merged 1 commit into
masterfrom
typescript-sdk

Conversation

@ofalvai

@ofalvai ofalvai commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Why

tsconfig.build.json declares only the es6 lib, but it has no types setting. So TypeScript loads every @types/* package in node_modules, and @types/node adds its own ES2018 libs and Node globals. The lib setting has no effect. Code can use APIs outside it and still compile.

This came up in #63, which uses Object.entries (ES2017). That build passed only because of @types/node. This PR fixes the config first, and #63 builds on top of it.

What changes

  • lib is now the list from @react-native/typescript-config@0.76.0. RN 0.76 is the oldest version we support, and this list is RN's own statement of the runtime APIs available there.
  • "types": [] stops the build from loading ambient types, so the lib list is actually enforced.
  • src/globals.d.ts declares console.log, the one RN runtime global the SDK uses.

The emitted lib/ output is the same as before.

Decisions

  • Copy the lib list instead of extending the official config. @react-native/typescript-config is made for apps. It sets noEmit, bundler module resolution and ESM output. We emit CommonJS .js and .d.ts files, so we would have to override about half of it.
  • A small globals file instead of "types": ["react-native"]. The official config gets console from the RN types. RN 0.87 (our devDependency) exposes its types only through package.json exports, and TypeScript 4.9 with moduleResolution: "node" cannot resolve them. globals.d.ts has a TODO to remove it after the build moves to TypeScript 5.

Out of scope

  • Moving the build to TypeScript 5 and bundler resolution, or to react-native-builder-bob (see AGENTS.md). Extending the official config makes sense at that point.
  • The minimum RN version (0.76) is written only in the README and docs. Nothing in package.json declares or tests it.

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

All reviewed changes are focused and no unresolved issues were identified.

Review effort: Balanced
Findings: None

What changed in this PR

Aligns the SDK’s TypeScript build with React Native 0.76 runtime APIs while preventing ambient Node typings from widening available globals.

Changes:

  • Matches React Native’s supported ES libraries.
  • Disables automatic @types/* inclusion.
  • Adds a narrow console declaration.
File Description
tsconfig.build.json Restricts TypeScript libraries and ambient types.
src/​globals.d.ts Declares the required React Native console global.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ofalvai
ofalvai marked this pull request as ready for review September 23, 2026 09:35
Comment thread tsconfig.build.json Outdated
Comment on lines +16 to +27
"es2020.bigint",
"es2020.date",
"es2020.number",
"es2020.promise",
"es2020.string",
"es2020.symbol.wellknown",
"es2021.promise",
"es2021.string",
"es2021.weakref",
"es2022.array",
"es2022.object",
"es2022.string"

@zoltanszabo-bitrise zoltanszabo-bitrise Sep 23, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we use any of these? We can handpick the ones we want to use in the SDK, and what RN support. The SDK can be stricter than RN!

If we dont use anything from this big list, simply keep our list simple as can be: [es2019] for example.
And I would keep a link to the RN's list of the minimum supported version for sure, for easier lookup if we ever want to widen it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zoltanszabo-bitrise

Copy link
Copy Markdown

@ofalvai Additional questions:

  • Do newer RN versions have wider JS support?
  • Do we know what RN version most of the CodePush users are on?
  • Why is RN 0.76 the minimum we support?
  • Are we planning to go with a newer stricter min RN version later?

@ofalvai

ofalvai commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator Author

@zoltanszabo-bitrise

Do newer RN versions have wider JS support?

If you mean polyfill support, then yes. Perfect example from my main PR: https://github.com/bitrise-io/react-native-code-push/pull/63/changes#diff-3846a333c5be87762e72c131ab62f5015d1777f1c6c00fa4af419f07dc0dc6bfR294-R296

Do we know what RN version most of the CodePush users are on?

At the moment, we don't. I think we can be generous and support old versions as long as it doesn't have too much of an overhead for us, and decide case-by-case.

Why is RN 0.76 the minimum we support?

It comes from README.md and from the pre-fork state of things. Adding support for RN New Architecture meant breaking changes, so that first verison of the SDK cut support for older RN versions.

Are we planning to go with a newer stricter min RN version later?

Definitely, 0.76 is now 2 years old, I think we can start bumping this, but it's hard to say how aggressively.

tsconfig.build.json declared only the es6 lib, but it had no "types"
setting, so TypeScript loaded every @types/* package. @types/node then
added its own ES2018 libs and Node globals, which made the lib setting
meaningless: code could use APIs outside it and still compile.

Use lib es2019, a subset of the lib list in
@react-native/typescript-config@0.76.0 (the oldest supported RN
version), and set "types": [] so that lib is enforced. The SDK can be
stricter than RN: es2019 covers everything it uses today, and it can
be widened as far as RN's list when needed. The one
runtime global the SDK needs, console, is declared in src/globals.d.ts
until the build can use "types": ["react-native"] like the official
config (needs TypeScript 5 and bundler module resolution, since RN
exposes its types only through package.json "exports").

The emitted lib/ output does not change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ofalvai
ofalvai merged commit ed3c0b4 into master Sep 23, 2026
6 checks passed
@ofalvai
ofalvai deleted the typescript-sdk branch September 23, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants