nearley icon indicating copy to clipboard operation
nearley copied to clipboard

Official type definitions?

Open corwin-of-amber opened this issue 4 years ago • 4 comments

Cheers!

It seems that the type definitions at https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/nearley are a bit outdated. For example, the Parser constructor is provided as:

    constructor(grammar: Grammar, options?: ParserOptions);

Whereas the JS definition is https://github.com/kach/nearley/blob/be339244f1f2fde30d8dc163c66da2d3b1537095/lib/nearley.js#L242.

Perhaps it's time to bring those definitions over and have them as part of the nearley package, removing the need for @types/nearley and also making the types consistent with the implementation?

corwin-of-amber avatar Apr 14 '21 15:04 corwin-of-amber

(I see now that there are actually two possible constructors and that the JS code resolves the overloading.)

corwin-of-amber avatar Apr 14 '21 16:04 corwin-of-amber

Hey Shachar, good to hear from you. Again, I'm not a typescript expert, but if you think this is a reasonable thing to do and want to submit a PR, I'm happy to look it over.

kach avatar Apr 14 '21 17:04 kach

Yes I was actually going to suggest myself for the job but didn't want to step on anyone's toes in case they're already working on it :) I can definitely adapt the definitions from DefinitelyTyped; I assume some tests for these are also in order, will you be ok with some tests being written in TypeScript?

corwin-of-amber avatar Apr 15 '21 15:04 corwin-of-amber

Go ahead! Though to be clear, I only want TypeScript-related features tested in TypeScript. Also, please don't make any backwards-incompatible changes.

kach avatar Apr 15 '21 15:04 kach