Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Globals the RN runtime provides that are not in the ES lib, declared narrowly instead of pulling in lib "dom" or @types/node.
// Interface + var (not const) so this merges with those declarations when an editor or other config also loads them.
// TODO: replace this file with `"types": ["react-native"]` (as @react-native/typescript-config does) once the build
// moves to TypeScript 5 and `moduleResolution: "bundler"`: RN exposes its types only through package.json "exports".
interface Console {
log(...data: any[]): void;
}
declare var console: Console;
7 changes: 6 additions & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"lib": ["es6"],
// A subset of what RN supports at the oldest supported version (0.76). Widen it only as far as RN's list:
// https://github.com/facebook/react-native/blob/0.76-stable/packages/typescript-config/tsconfig.json
"lib": ["es2019"],
// No ambient @types/* (e.g. Node), otherwise they add their own libs and the list above is not enforced.
// RN globals come from src/globals.d.ts instead.
"types": [],
"declaration": true,
"noImplicitAny": true,
"noEmitOnError": true,
Expand Down
Loading