nodejs / node-addon-examples

Node.js C++ addon examples from http://nodejs.org/docs/latest/api/addons.html
Other
2.5k stars 598 forks source link

Add .d.ts files in samples. #530

Open UrielCh opened 2 months ago

UrielCh commented 2 months ago

Hi,

Native Import in NodeJS do not provide any Typing by default.

src/1-getting-started/6_object_wrap/node-addon-api/myobject.cc register a class MyObject having a plusOne method. but coding in addon.js will not give access to any typing.

My I open a PR to add d.ts that contains somthink like:

class MyObject {
    public plusOne(): number;
    public value(): number;
    public multiply(num?: number): number;
}
UrielCh commented 2 months ago

I have a PR for that:

https://github.com/nodejs/node-addon-examples/pull/538