Skip to content

Commit 9f1a301

Browse files
authored
Fix requireNodeAddon return type (#267)
1 parent d8e90a8 commit 9f1a301

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

.changeset/bumpy-things-poke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-native-node-api": patch
3+
---
4+
5+
Fix requireNodeAddon return type

packages/host/src/react-native/NativeNodeApiHost.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1-
import native from "./NativeNodeApiHost";
1+
import { type TurboModule, TurboModuleRegistry } from "react-native";
22

3-
export const requireNodeAddon = native.requireNodeAddon.bind(native);
3+
export interface Spec extends TurboModule {
4+
requireNodeAddon<T = unknown>(libraryName: string): T;
5+
}
6+
7+
const native = TurboModuleRegistry.getEnforcing<Spec>("NodeApiHost");
8+
9+
/**
10+
* Loads a native Node-API addon by filename.
11+
*/
12+
export function requireNodeAddon<T = unknown>(libraryName: string): T {
13+
return native.requireNodeAddon<T>(libraryName);
14+
}

0 commit comments

Comments
 (0)