Skip to content

Commit 321f622

Browse files
authored
ffi-napi: First argument to 'Library' can be null (DefinitelyTyped#45109)
Evidence: https://www.npmjs.com/package/ffi-napi#example
1 parent 44af094 commit 321f622

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

types/ffi-napi/ffi-napi-tests.ts

+7
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,10 @@ import TArray = require('ref-array-di');
104104
{
105105
const refCharArr = TArray('char')([1, 3, 5], 2).ref();
106106
}
107+
{
108+
// You can also access just functions in the current process by passing a null
109+
const current = ffi.Library(null, {
110+
atoi: [ 'int', [ 'string' ] ]
111+
});
112+
current.atoi('1234');
113+
}

types/ffi-napi/index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ export interface Library {
2020
* @param funcs hash of [retType, [...argType], opts?: {abi?, async?, varargs?}]
2121
* @param lib hash that will be extended
2222
*/
23-
new (libFile: string, funcs?: {[key: string]: any[]}, lib?: object): any;
23+
new (libFile: string | null, funcs?: {[key: string]: any[]}, lib?: object): any;
2424

2525
/**
2626
* @param libFile name of library
2727
* @param funcs hash of [retType, [...argType], opts?: {abi?, async?, varargs?}]
2828
* @param lib hash that will be extended
2929
*/
30-
(libFile: string, funcs?: {[key: string]: any[]}, lib?: object): any;
30+
(libFile: string | null, funcs?: {[key: string]: any[]}, lib?: object): any;
3131
}
3232
export const Library: Library;
3333

0 commit comments

Comments
 (0)