Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript #129

Open
pperesbr opened this issue Oct 19, 2020 · 18 comments
Open

Typescript #129

pperesbr opened this issue Oct 19, 2020 · 18 comments

Comments

@pperesbr
Copy link

Hello,

Is there a plan for the library to support typescript?

Tks,

Paulo

@markabrahams
Copy link
Owner

Hi @dobicz - my original plan was to write the whole library with Typescript, but as things played out, this didn't end up happening.

While it's not on my immediate radar to convert to Typescript, I would be very interested in a pull request if you or anyone else is inclined to do this.

@cjimenezsaiz
Copy link

Hi @markabrahams ,

This is something that I want to to in the next months, but in the way, I think it'll be necessary to refactor some parts of the code in smaller files, to make it more manageable.

I don't know if this is something that you want to comment in order to establish any kind of rules or guides for future development.

@markabrahams
Copy link
Owner

Hi @cjimenezsaiz - thanks for looking into this! Suffice to say this project is a classic example of something growing incrementally to the point where the single-file approach is obviously not ideal for its current size!

I would be inclined to refactor into Typescript classes, one class per file. Fortunately, all of the code I've written (and a good portion of the code I inherited!) is fairly well segmented into "class-like" functions, as I had one eye on doing a Typescript/class conversion at some point.

Is that approach along the lines of what you're thinking?

@cjimenezsaiz
Copy link

Hi @markabrahams ,

Sounds good.
Of course it will be a big change, my idea is to create a fork where we can comment on the issues that appear: class names, classifications, structure ...

In about two weeks I think I will have time to start the change.

Greetings.

@cjimenezsaiz
Copy link

Hi @markabrahams, sorry for the delay.

I'have started with this topic, The first module that have been translated to typescript has been the asn1-ber, I'have tested it han its working without problems.
In the case of the MIB module it is difficult to define interfaces for the parsed object only reading the code, in order to speed up this task it would be great to have some guidance about the structure of MIBs that you try to create, specially in the case of "Modules".

@markabrahams
Copy link
Owner

Hi @cjimenezsaiz - no need to apologise - it's voluntary effort after all, and all appreciated!

Well done on asn1-ber! For the MIB module, it really could do with some documentation on the structure of the output, but unfortunately I don't have any :-( The easiest way to understand the structure created is to run the example/mib-parser.js code. If you look at the value of the "modules" variable at the end (the full set of parsed MIB modules), you'll find good examples of how each MIB module is parsed to JSON, which will give you a reasonable idea of the Typescript types required.

@mwoodpatrick
Copy link

Any update on where we are in providing a typescript interface to this module I am also interested in this

@cjimenezsaiz
Copy link

Hi @mwoodpatrick, I'm still working on it. I'll update the status in some weeks.

@mwoodpatrick
Copy link

Many thanks, let me know if I can help in some way. My current primary interest is in the api's to query info from nodes

@maks-plotnikoff
Copy link

Hey. Is there a plan for the library to support typescript?

@markabrahams
Copy link
Owner

Hi @maks-plotnikoff - you've come to the right place! This issue literally opens with "Hello, Is there a plan for the library to support typescript?" and the discussion about this proceeds from there.

@thejhh
Copy link

thejhh commented Sep 12, 2022

I have started creating a TypeScript index.d.ts support here: https://github.com/heusalagroup/node-net-snmp/blob/master/index.d.ts

It's still quite incomplete. I will add types as I need them.

I also started complete refactoring of the project as a compile time TypeScript git submodule last weekend, however that work was so incomplete and broken that I didn't want to publish it yet. I actually found few possible bugs and reported one already.

@nelsonjchen
Copy link

Could it be considered to take those definitions as it is and merging them into this repo/package? ?% > 0% typescript definitions? Gradually define the types for now? If there are problems, if there are under-definitions, anybody using Typescript would probably be inclined to help raise that up with the increased visibility if it's pulled in.

@nelsonjchen
Copy link

nelsonjchen commented Jul 3, 2023

I'll be blunt, would a PR for @thejhh 's work as it is be accepted? I will have my own additions too, but that can be in another PR. This isn't a rewrite, it's having definitions alongside.

@PeterTrotter
Copy link
Contributor

I've taken advantage of @thejhh 's definitions and they have been really useful.

I think the projects make sense being separate at the moment as there is still a big gap in coverage. Added to which, I think there is very much a maintenance focus for this project and anything that is going to be developing faster may want to live elsewhere until it is more mature.

Just an observation as I'm not an owner / maintainer here.

If there is enthusiasm to do more work on the type definitions I'd be interested in contributing.

@markabrahams
Copy link
Owner

Hi @nelsonjchen - I do take - and usually favour! - the argument that x% > 0% - and so incremental features are worthwhile. One exception is typing though! I do feel that adding incomplete type definitions to the library could lead to more interim confusion as to what or why what thing is or isn't supported. However, the laudable goal remains to support TypeScript with complete type definitions. So I'm a bit more aligned with your view @PeterTrotter - if we work on closing the coverage gap and aim to get a "library complete" - if not perfect - type definition for the first cut, that would serve us all well!

@Ristovski
Copy link

Is there any progress on this? @thejhh's fork seems to be inactive and is drifting behind (44 commits behind now).

@thejhh
Copy link

thejhh commented Oct 29, 2024

I haven't had reason to work on this lately. I actually did more work on the issue than I published, but that was too broken to share upstream. I believe my findings got added to upstream later. While porting I wound few bugs, which I believe made SNMP v3 support completely broken (but I think those got already fixed).

While I do not have free time to work on this issue, I happen to be available to work on it commercially through my company. I happen to be available for new gigs there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants