-
Notifications
You must be signed in to change notification settings - Fork 569
TypeScript Error: global.__turboModuleProxy type definition missing for React Native Turbo Modules #773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Same issue here ! |
+1 |
Workaround globals.d.ts declare global {
// https://github.com/morenoh149/react-native-contacts/issues/773
declare const global: typeof globalThis & { __turboModuleProxy: unknown }
}
export {} |
the fact that i can't ingore node_modules in tsc is such a pain, we need to work on the tooling better. i solved(workaround) it using this: react-native-contacts.d.ts declare global {
var __turboModuleProxy: unknown | null;
}
export {}; |
Other packages, such as FullStory use the @ts-expect-error directive: // @ts-expect-error
const isTurboModuleEnabled = global.__turboModuleProxy != null; Becuase of this adding the global declaration breaks other packages and instead i've opted to patch File name: diff --git a/node_modules/react-native-contacts/index.ts b/node_modules/react-native-contacts/index.ts
index 9f15471..72f1834 100644
--- a/node_modules/react-native-contacts/index.ts
+++ b/node_modules/react-native-contacts/index.ts
@@ -2,6 +2,7 @@ import { NativeModules } from "react-native";
import NativeContacts from "./src/NativeContacts";
import { Contact, PermissionType } from "./type";
+// @ts-expect-error
const isTurboModuleEnabled = global.__turboModuleProxy != null;
const Contacts = isTurboModuleEnabled ? NativeContacts : NativeModules.Contacts; |
I think we remove usage of it here d927fec |
When using
react-native-contacts
with TypeScript strict mode enabled, the following type error occurs:This error occurs because the package uses React Native's Turbo Modules feature but doesn't include the necessary type definitions for the global
__turboModuleProxy
property.Environment
Steps to Reproduce
strict: true
in tsconfig.jsonExpected Behavior
TypeScript should recognize the
__turboModuleProxy
property on the global object as it's a valid React Native Turbo Modules property.Additional Context
This is related to React Native's Turbo Modules architecture. The property is valid and works at runtime, but lacks proper TypeScript definitions.
The text was updated successfully, but these errors were encountered: