From e17d230f7849238bbe5e5758b8535edb5d9e1acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sat, 18 Oct 2025 01:28:43 +0200 Subject: [PATCH] Fix requireNodeAddon return type --- .changeset/bumpy-things-poke.md | 5 +++++ .../host/src/react-native/NativeNodeApiHost.ts | 8 -------- packages/host/src/react-native/index.ts | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 .changeset/bumpy-things-poke.md delete mode 100644 packages/host/src/react-native/NativeNodeApiHost.ts diff --git a/.changeset/bumpy-things-poke.md b/.changeset/bumpy-things-poke.md new file mode 100644 index 00000000..dd1de884 --- /dev/null +++ b/.changeset/bumpy-things-poke.md @@ -0,0 +1,5 @@ +--- +"react-native-node-api": patch +--- + +Fix requireNodeAddon return type diff --git a/packages/host/src/react-native/NativeNodeApiHost.ts b/packages/host/src/react-native/NativeNodeApiHost.ts deleted file mode 100644 index fdf04dc8..00000000 --- a/packages/host/src/react-native/NativeNodeApiHost.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { TurboModule } from "react-native"; -import { TurboModuleRegistry } from "react-native"; - -export interface Spec extends TurboModule { - requireNodeAddon(libraryName: string): void; -} - -export default TurboModuleRegistry.getEnforcing("NodeApiHost"); diff --git a/packages/host/src/react-native/index.ts b/packages/host/src/react-native/index.ts index c34ae8b7..0a077c75 100644 --- a/packages/host/src/react-native/index.ts +++ b/packages/host/src/react-native/index.ts @@ -1,3 +1,14 @@ -import native from "./NativeNodeApiHost"; +import { type TurboModule, TurboModuleRegistry } from "react-native"; -export const requireNodeAddon = native.requireNodeAddon.bind(native); +export interface Spec extends TurboModule { + requireNodeAddon(libraryName: string): T; +} + +const native = TurboModuleRegistry.getEnforcing("NodeApiHost"); + +/** + * Loads a native Node-API addon by filename. + */ +export function requireNodeAddon(libraryName: string): T { + return native.requireNodeAddon(libraryName); +}