Napigen already has all the Zig function and struct signatures which means it should be easy to add .d.ts files generation
This would make the generated .node module type safe
For example this code
const std = @import("std");
const napigen = @import("napigen");
export fn add(a: i32, b: i32) i32 {
return a + b;
}
comptime {
napigen.defineModule(initModule);
}
fn initModule(js: *napigen.JsContext, exports: napigen.napi_value) !napigen.napi_value {
try js.setNamedProperty(exports, "add", try js.createFunction(add));
return exports;
}
Would generate the following declartation:
export function add(a: number, b: number): number
Napigen already has all the Zig function and struct signatures which means it should be easy to add .d.ts files generation
This would make the generated .node module type safe
For example this code
Would generate the following declartation: