-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add Typescript for type checking (but still with js files) #81
Conversation
76aca5c
to
053254d
Compare
add comments to types and types to package.json
@erikyo Thank you for your work! I'm so unfamilliar with TypeScript I didn't even realize it requires a build step. That's a bummer. However, before moving ahead with TypeScript, I'd very much appreciate @andris9 's feedback. He is the original author of this library and I'd like to know which approach he'd take. |
@andris9 the guy of node mailer? very gladly! About the requested changes give me the time and I'll see if I can do what you asked for... unfortunately some are strictly necessary to compile without errors or pass the tests, but I'll see what I can do |
As I haven't been active with this project for years, I don't consider myself to have any special rights to decide anything about the project's future. I think such decisions must be made by active maintainers only. |
Certainly, your comment, advice, or review is highly appreciated, as your expertise in the repository is invaluable. I acknowledge that the modification I propose may not be minor, but given the recent upgrade of the module to ES modules and the ongoing efforts to maintain its activity, I believe that this change, albeit potentially controversial, is worth submitting. To be honest, the adjustment I suggest isn't excessively radical and ensures robust type checking. in short, Is a matter of decision-making, so it would not be ideal to leave all the burden to @smhg |
For the time being yes, but simultaneously, it's the approach that ensures secure typing. It's a worthwhile endeavor. If you're interested, I can incorporate other automations to streamline the process. For instance, I could implement a It's essential to note that the compiled lib folder should no longer be published to github but only to npm (and, on other hands, the src folder isn't published on npm), check here |
@erikyo yes, having a But, let's split up this PR if ok for you. I will add some comments in the code to clarify what I'm thinking about. My current thinking: since I will be maintaining this library for the forseable future, I want to have the option to throw out types if I can't maintain them. It looks good currently, but I don't want to end up in a situation where I can't publish a bugfix because things don't run/build because of TS. Obviously I would rather first want to request your help when necessary to avoid this scenario. |
👍, and indeed sorry, I saw the review and indeed some edits were not required at all
at the current implementation types are only checked and generated using the typescript engine but the code isn't changed. i know that is a widely used repo, I will use white gloves
Obviously i'm here if you need! |
c0d9561
to
143f973
Compare
I have updated as you asked but I have a couple of concerns, that we may want to wipe out in the next PR:
lib/mocompiler.js(37,16): error TS2538: Type 'undefined' cannot be used as an index type.
lib/mocompiler.js(40,7): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
No index signature with a parameter of type 'string' was found on type '{}'.
lib/mocompiler.js(50,57): error TS7006: Parameter 'item' implicitly has an 'any' type.
lib/mocompiler.js(53,9): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
No index signature with a parameter of type 'string' was found on type '{}'.
lib/mocompiler.js(60,7): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
No index signature with a parameter of type 'string' was found on type '{}'.
lib/mocompiler.js(102,13): error TS2314: Generic type 'Array<T>' requires 1 type argument(s).
lib/mocompiler.js(152,19): error TS2307: Cannot find module './index.d.ts' or its corresponding type declarations.
lib/mocompiler.js(160,16): error TS7006: Parameter 'translation' implicitly has an 'any' type.
lib/mocompiler.js(187,19): error TS2307: Cannot find module './index.d.ts' or its corresponding type declarations.
lib/mocompiler.js(192,42): error TS2339: Property 'total' does not exist on type 'Object'.
lib/mocompiler.js(198,3): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Buffer'.
No index signature with a parameter of type 'string' was found on type 'Buffer'.
lib/mocompiler.js(201,3): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Buffer'.
No index signature with a parameter of type 'string' was found on type 'Buffer'.
lib/mocompiler.js(204,3): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Buffer'.
No index signature with a parameter of type 'string' was found on type 'Buffer'.
lib/mocompiler.js(207,3): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Buffer'.
No index signature with a parameter of type 'string' was found on type 'Buffer'.
lib/mocompiler.js(210,3): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Buffer'.
No index signature with a parameter of type 'string' was found on type 'Buffer'.
lib/mocompiler.js(213,3): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Buffer'.
No index signature with a parameter of type 'string' was found on type 'Buffer'.
lib/mocompiler.js(216,3): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Buffer'.
No index signature with a parameter of type 'string' was found on type 'Buffer'.
lib/mocompiler.js(222,5): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Buffer'.
No index signature with a parameter of type 'string' was found on type 'Buffer'.
lib/mocompiler.js(223,5): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Buffer'.
No index signature with a parameter of type 'string' was found on type 'Buffer'.
lib/mocompiler.js(224,5): error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'Buffer'.
lib/mocompiler.js(231,5): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Buffer'.
No index signature with a parameter of type 'string' was found on type 'Buffer'.
lib/mocompiler.js(232,5): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Buffer'.
No index signature with a parameter of type 'string' was found on type 'Buffer'.
lib/mocompiler.js(233,5): error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'Buffer'.
Try `npm i --save-dev @types/encoding` if it exists or add a new declaration (.d.ts) file containing `declare module 'encoding';`
lib/moparser.js(86,33): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.
lib/moparser.js(88,35): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.
lib/moparser.js(93,33): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.
lib/moparser.js(95,35): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.
lib/moparser.js(112,3): error TS2322: Type 'null' is not assignable to type 'Buffer'.
lib/moparser.js(131,3): error TS2322: Type 'Object' is not assignable to type 'undefined'.
lib/moparser.js(131,37): error TS2345: Argument of type 'Buffer' is not assignable to parameter of type 'string'.
lib/moparser.js(145,3): error TS2322: Type 'string[]' is not assignable to type 'string'.
lib/moparser.js(147,21): error TS2339: Property 'shift' does not exist on type 'string'.
lib/moparser.js(152,17): error TS2339: Property 'join' does not exist on type 'string'.
lib/moparser.js(155,3): error TS2322: Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
lib/moparser.js(163,3): error TS2322: Type 'string[]' is not assignable to type 'string'.
lib/moparser.js(164,3): error TS7008: Member 'msgstr' implicitly has an 'any[]' type.
lib/moparser.js(164,34): error TS2769: No overload matches this call.
Overload 1 of 2, '(...items: ConcatArray<never>[]): never[]', gave the following error.
Argument of type 'string | never[]' is not assignable to parameter of type 'ConcatArray<never>'.
Type 'string' is not assignable to type 'ConcatArray<never>'.
Overload 2 of 2, '(...items: ConcatArray<never>[]): never[]', gave the following error.
Argument of type 'string | never[]' is not assignable to parameter of type 'ConcatArray<never>'.
Type 'string' is not assignable to type 'ConcatArray<never>'.
lib/moparser.js(166,8): error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}'.
lib/moparser.js(167,5): error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}'.
lib/moparser.js(170,3): error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}'.
lib/moparser.js(186,39): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.
lib/moparser.js(191,36): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.
lib/moparser.js(196,46): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.
lib/moparser.js(201,49): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.
Try `npm i --save-dev @types/encoding` if it exists or add a new declaration (.d.ts) file containing `declare module 'encoding';`
lib/pocompiler.js(15,33): error TS7006: Parameter 'options' implicitly has an 'any' type.
lib/pocompiler.js(31,15): error TS2339: Property 'translations' does not exist on type 'Object'.
lib/pocompiler.js(31,42): error TS2339: Property 'translations' does not exist on type 'Object'.
lib/pocompiler.js(33,9): error TS2339: Property 'headers' does not exist on type 'Object'.
lib/pocompiler.js(39,14): error TS2538: Type 'undefined' cannot be used as an index type.
lib/pocompiler.js(41,7): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
No index signature with a parameter of type 'string' was found on type '{}'.
lib/pocompiler.js(47,15): error TS2339: Property 'headers' does not exist on type 'Object'.
lib/pocompiler.js(50,19): error TS2339: Property 'foldLength' does not exist on type '{}'.
lib/pocompiler.js(54,19): error TS2339: Property 'escapeCharacters' does not exist on type '{}'.
lib/pocompiler.js(58,19): error TS2339: Property 'sort' does not exist on type '{}'.
lib/pocompiler.js(62,19): error TS2339: Property 'eol' does not exist on type '{}'.
lib/pocompiler.js(78,9): error TS7034: Variable 'lines' implicitly has type 'any[]' in some locations where its type cannot be determined.
lib/pocompiler.js(97,10): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Object'.
No index signature with a parameter of type 'string' was found on type 'Object'.
lib/pocompiler.js(101,5): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Object'.
No index signature with a parameter of type 'string' was found on type 'Object'.
lib/pocompiler.js(101,50): error TS7006: Parameter 'line' implicitly has an 'any' type.
lib/pocompiler.js(106,10): error TS7005: Variable 'lines' implicitly has an 'any[]' type.
lib/pocompiler.js(106,35): error TS2339: Property 'eol' does not exist on type '{}'.
lib/pocompiler.js(119,28): error TS2339: Property 'msgctxt' does not exist on type 'Object'.
lib/pocompiler.js(119,45): error TS2339: Property 'msgctxt' does not exist on type 'Object'.
lib/pocompiler.js(120,26): error TS2339: Property 'msgid' does not exist on type 'Object'.
lib/pocompiler.js(120,41): error TS2339: Property 'msgid' does not exist on type 'Object'.
lib/pocompiler.js(121,32): error TS2339: Property 'msgid_plural' does not exist on type 'Object'.
lib/pocompiler.js(121,54): error TS2339: Property 'msgid_plural' does not exist on type 'Object'.
lib/pocompiler.js(122,9): error TS7005: Variable 'msgstr' implicitly has an 'any[]' type.
lib/pocompiler.js(122,37): error TS2339: Property 'msgstr' does not exist on type 'Object'.
lib/pocompiler.js(122,53): error TS2339: Property 'msgstr' does not exist on type 'Object'.
lib/pocompiler.js(123,27): error TS2339: Property 'comments' does not exist on type 'Object'.
lib/pocompiler.js(123,45): error TS2339: Property 'comments' does not exist on type 'Object'.
lib/pocompiler.js(146,38): error TS2339: Property 'eol' does not exist on type '{}'.
lib/pocompiler.js(163,9): error TS2339: Property 'foldLength' does not exist on type '{}'.
lib/pocompiler.js(163,21): error TS2339: Property 'eol' does not exist on type '{}'.
lib/pocompiler.js(163,26): error TS2339: Property 'escapeCharacters' does not exist on type '{}'.
lib/pocompiler.js(208,44): error TS2339: Property 'headers' does not exist on type 'Object'.
lib/pocompiler.js(210,45): error TS2339: Property 'charset' does not exist on type 'Object'.
lib/pocompiler.js(217,15): error TS2339: Property 'charset' does not exist on type 'Object'.
lib/pocompiler.js(218,15): error TS2339: Property 'headers' does not exist on type 'Object'.
lib/pocompiler.js(225,14): error TS2314: Generic type 'Array<T>' requires 1 type argument(s).
lib/pocompiler.js(228,7): error TS7034: Variable 'response' implicitly has type 'any[]' in some locations where its type cannot be determined.
lib/pocompiler.js(231,16): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Object'.
No index signature with a parameter of type 'string' was found on type 'Object'.
lib/pocompiler.js(235,17): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Object'.
No index signature with a parameter of type 'string' was found on type 'Object'.
lib/pocompiler.js(236,18): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Object'.
No index signature with a parameter of type 'string' was found on type 'Object'.
lib/pocompiler.js(244,21): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Object'.
No index signature with a parameter of type 'string' was found on type 'Object'.
lib/pocompiler.js(248,11): error TS2339: Property 'sort' does not exist on type '{}'.
lib/pocompiler.js(252,18): error TS7005: Variable 'response' implicitly has an 'any[]' type.
lib/pocompiler.js(254,18): error TS7005: Variable 'response' implicitly has an 'any[]' type.
lib/pocompiler.js(267,36): error TS2339: Property 'translations' does not exist on type 'Object'.
lib/pocompiler.js(267,68): error TS2339: Property 'translations' does not exist on type 'Object'.
lib/pocompiler.js(270,57): error TS2339: Property 'translations' does not exist on type 'Object'.
lib/pocompiler.js(273,26): error TS2339: Property 'obsolete' does not exist on type 'Object'.
lib/pocompiler.js(274,55): error TS2339: Property 'obsolete' does not exist on type 'Object'.
lib/pocompiler.js(280,11): error TS2339: Property 'eol' does not exist on type '{}'.
lib/pocompiler.js(283,40): error TS2339: Property 'headers' does not exist on type 'Object'.
lib/pocompiler.js(286,19): error TS2339: Property 'charset' does not exist on type 'Object'.
lib/pocompiler.js(286,54): error TS2339: Property 'charset' does not exist on type 'Object'.
lib/pocompiler.js(290,71): error TS2339: Property 'charset' does not exist on type 'Object'.
Try `npm i --save-dev @types/encoding` if it exists or add a new declaration (.d.ts) file containing `declare module 'encoding';`
lib/poparser.js(9,65): error TS2300: Duplicate identifier 'Options'.
lib/poparser.js(22,63): error TS2300: Duplicate identifier 'Options'.
lib/poparser.js(34,65): error TS2300: Duplicate identifier 'Options'.
lib/poparser.js(43,3): error TS7008: Member '_lex' implicitly has an 'any[]' type.
lib/poparser.js(53,46): error TS2345: Argument of type 'Buffer' is not assignable to parameter of type 'string'.
lib/poparser.js(95,40): error TS7006: Parameter 'buf' implicitly has an 'any' type.
lib/poparser.js(170,24): error TS2339: Property 'obsolete' does not exist on type '{}'.
lib/poparser.js(179,46): error TS2339: Property 'value' does not exist on type '{}'.
lib/poparser.js(180,22): error TS2339: Property 'value' does not exist on type '{}'.
lib/poparser.js(183,22): error TS2339: Property 'value' does not exist on type '{}'.
lib/poparser.js(190,26): error TS2339: Property 'value' does not exist on type '{}'.
lib/poparser.js(193,26): error TS2339: Property 'value' does not exist on type '{}'.
lib/poparser.js(196,26): error TS2339: Property 'value' does not exist on type '{}'.
lib/poparser.js(199,26): error TS2339: Property 'value' does not exist on type '{}'.
lib/poparser.js(203,34): error TS2339: Property 'quote' does not exist on type '{}'.
lib/poparser.js(209,24): error TS2339: Property 'value' does not exist on type '{}'.
lib/poparser.js(216,27): error TS2339: Property 'value' does not exist on type '{}'.
lib/poparser.js(217,96): error TS2339: Property 'value' does not exist on type '{}'.
lib/poparser.js(219,17): error TS2339: Property 'lineNumber' does not exist on type 'SyntaxError'.
lib/poparser.js(226,22): error TS2339: Property 'value' does not exist on type '{}'.
lib/poparser.js(243,32): error TS2339: Property 'length' does not exist on type 'Object'.
lib/poparser.js(244,21): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(245,25): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(246,28): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(247,32): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(249,21): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(250,18): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(264,10): error TS2339: Property 'forEach' does not exist on type 'Object'.
lib/poparser.js(264,18): error TS7006: Parameter 'node' implicitly has an 'any' type.
lib/poparser.js(279,19): error TS7006: Parameter 'line' implicitly has an 'any' type.
lib/poparser.js(282,34): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'.
lib/poparser.js(285,34): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'.
lib/poparser.js(288,29): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'.
lib/poparser.js(291,33): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'.
lib/poparser.js(296,35): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'.
lib/poparser.js(303,11): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ translator: never[]; extracted: never[]; reference: never[]; flag: never[]; previous: never[]; }'.
No index signature with a parameter of type 'string' was found on type '{ translator: never[]; extracted: never[]; reference: never[]; flag: never[]; previous: never[]; }'.
lib/poparser.js(303,27): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ translator: never[]; extracted: never[]; reference: never[]; flag: never[]; previous: never[]; }'.
No index signature with a parameter of type 'string' was found on type '{ translator: never[]; extracted: never[]; reference: never[]; flag: never[]; previous: never[]; }'.
lib/poparser.js(304,27): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ translator: never[]; extracted: never[]; reference: never[]; flag: never[]; previous: never[]; }'.
No index signature with a parameter of type 'string' was found on type '{ translator: never[]; extracted: never[]; reference: never[]; flag: never[]; previous: never[]; }'.
lib/poparser.js(320,32): error TS2339: Property 'length' does not exist on type 'Object'.
lib/poparser.js(321,9): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(323,14): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(325,11): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(326,18): error TS2339: Property 'obsolete' does not exist on type '{ key: any; }'.
lib/poparser.js(328,16): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(329,18): error TS2339: Property 'comments' does not exist on type '{ key: any; }'.
lib/poparser.js(329,29): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(331,16): error TS2339: Property 'value' does not exist on type '{ key: any; }'.
lib/poparser.js(333,16): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(334,16): error TS2339: Property 'value' does not exist on type '{ key: any; }'.
lib/poparser.js(334,25): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(353,32): error TS2339: Property 'length' does not exist on type 'Object'.
lib/poparser.js(354,9): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(355,20): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(356,21): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(357,16): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(359,16): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(361,11): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(362,18): error TS2339: Property 'obsolete' does not exist on type '{ msgid: any; }'.
lib/poparser.js(366,18): error TS2339: Property 'msgctxt' does not exist on type '{ msgid: any; }'.
lib/poparser.js(370,18): error TS2339: Property 'comments' does not exist on type '{ msgid: any; }'.
lib/poparser.js(373,11): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(373,43): error TS2339: Property 'comments' does not exist on type '{ msgid: any; }'.
lib/poparser.js(374,18): error TS2339: Property 'comments' does not exist on type '{ msgid: any; }'.
lib/poparser.js(374,29): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(380,16): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(383,104): error TS2339: Property 'msgctxt' does not exist on type '{ msgid: any; } & Record<"msgid_plural", unknown>'.
lib/poparser.js(386,18): error TS2339: Property 'msgid_plural' does not exist on type '{ msgid: any; }'.
lib/poparser.js(386,33): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(389,11): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(389,34): error TS18048: 'lastNode' is possibly 'undefined'.
lib/poparser.js(389,43): error TS2339: Property 'comments' does not exist on type '{ msgid: any; }'.
lib/poparser.js(390,9): error TS18048: 'lastNode' is possibly 'undefined'.
lib/poparser.js(390,18): error TS2339: Property 'comments' does not exist on type '{ msgid: any; }'.
lib/poparser.js(390,29): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(395,16): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(397,18): error TS2339: Property 'msgstr' does not exist on type '{ msgid: any; }'.
lib/poparser.js(397,37): error TS2339: Property 'msgstr' does not exist on type '{ msgid: any; }'.
lib/poparser.js(397,58): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(400,11): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(400,34): error TS18048: 'lastNode' is possibly 'undefined'.
lib/poparser.js(400,43): error TS2339: Property 'comments' does not exist on type '{ msgid: any; }'.
lib/poparser.js(401,9): error TS18048: 'lastNode' is possibly 'undefined'.
lib/poparser.js(401,18): error TS2339: Property 'comments' does not exist on type '{ msgid: any; }'.
lib/poparser.js(401,29): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(423,5): error TS2339: Property 'msgid' does not exist on type 'Object'.
lib/poparser.js(424,5): error TS2339: Property 'msgid_plural' does not exist on type 'Object'.
lib/poparser.js(425,5): error TS2339: Property 'msgstr' does not exist on type 'Object'.
lib/poparser.js(435,16): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Object'.
No index signature with a parameter of type 'string' was found on type 'Object'.
lib/poparser.js(462,32): error TS2339: Property 'length' does not exist on type 'Object'.
lib/poparser.js(463,15): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(465,9): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(466,18): error TS2339: Property 'obsolete' does not exist on type '{ charset: string; headers: undefined; translations: {}; }'.
lib/poparser.js(467,15): error TS2339: Property 'obsolete' does not exist on type '{ charset: string; headers: undefined; translations: {}; }'.
lib/poparser.js(470,18): error TS2339: Property 'obsolete' does not exist on type '{ charset: string; headers: undefined; translations: {}; }'.
lib/poparser.js(471,15): error TS2339: Property 'obsolete' does not exist on type '{ charset: string; headers: undefined; translations: {}; }'.
lib/poparser.js(474,14): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(476,13): error TS2339: Property 'obsolete' does not exist on type '{ charset: string; headers: undefined; translations: {}; }'.
lib/poparser.js(476,31): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(476,50): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(481,10): error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}'.
lib/poparser.js(482,7): error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}'.
lib/poparser.js(485,40): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(486,7): error TS2322: Type 'Object' is not assignable to type 'undefined'.
lib/poparser.js(486,35): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(490,25): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(492,5): error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}'.
lib/poparser.js(492,33): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(492,52): error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Object'.
No index signature with a parameter of type 'number' was found on type 'Object'.
lib/poparser.js(518,63): error TS2300: Duplicate identifier 'Options'.
lib/poparser.js(528,3): error TS7008: Member '_cache' implicitly has an 'any[]' type.
lib/poparser.js(531,43): error TS2339: Property 'initialTreshold' does not exist on type 'TransformOptions'.
lib/poparser.js(533,18): error TS2345: Argument of type 'this' is not assignable to parameter of type 'Transform'.
Type 'PoParserTransform' is missing the following properties from type 'Transform': _transformState, allowHalfOpen, destroyed, readable, and 72 more.
lib/poparser.js(534,8): error TS2339: Property '_writableState' does not exist on type 'PoParserTransform'.
lib/poparser.js(535,8): error TS2339: Property '_readableState' does not exist on type 'PoParserTransform'.
lib/poparser.js(544,52): error TS7006: Parameter 'chunk' implicitly has an 'any' type.
lib/poparser.js(544,59): error TS7006: Parameter 'encoding' implicitly has an 'any' type.
lib/poparser.js(544,69): error TS7006: Parameter 'done' implicitly has an 'any' type.
lib/poparser.js(565,5): error TS2322: Type 'Parser' is not assignable to type 'boolean'.
lib/poparser.js(594,20): error TS2339: Property '_lexer' does not exist on type 'boolean'.
lib/poparser.js(594,40): error TS2339: Property '_toString' does not exist on type 'boolean'.
lib/poparser.js(610,48): error TS7006: Parameter 'done' implicitly has an 'any' type.
lib/poparser.js(618,5): error TS2322: Type 'Parser' is not assignable to type 'boolean'.
lib/poparser.js(623,20): error TS2339: Property '_lexer' does not exist on type 'boolean'.
lib/poparser.js(623,40): error TS2339: Property '_toString' does not exist on type 'boolean'.
lib/poparser.js(634,10): error TS2339: Property 'push' does not exist on type 'PoParserTransform'.
lib/poparser.js(634,28): error TS2339: Property '_finalize' does not exist on type 'true'.
lib/poparser.js(634,51): error TS2339: Property '_lex' does not exist on type 'true'.
lib/shared.js(37,9): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
No index signature with a parameter of type 'string' was found on type '{}'.
lib/shared.js(52,33): error TS7053: Element implicitly has an 'any' type because expression of type '"Plural-Forms"' can't be used to index type 'Object'.
Property 'Plural-Forms' does not exist on type 'Object'.
lib/shared.js(80,17): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Object'.
No index signature with a parameter of type 'string' was found on type 'Object'.
lib/shared.js(155,33): error TS2339: Property 'msgid' does not exist on type 'Object'.
lib/shared.js(155,50): error TS2339: Property 'msgid' does not exist on type 'Object'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those needs to be fixed
- revert unneeded changes in package.json - revert files moved to src - linting
143f973
to
f18a115
Compare
About the jsDoc i did another branch where i implemented strict js type checking reducing type check issues (from > 400 to less than 50), but there is still a lot of work to be done though (some sections are really difficult to type without typescript). it should look like this: I also think in that way could close some issues such as the #29 that which I actually believe that is forced conversion between array and string, and other issues that are really related to js duck typing I would like to point out that I just use the tests to make sure that everything is OK so I am pretty sure that everything works exactly as before |
You already lost me with those. |
That the reason why i moved the changes into a separate branch (https://github.com/erikyo/gettext-parser/tree/enforcing-types), they are important to me and I would not like to lose them, but I understand that they are not part of the subject of this PR. I will create a dedicated pr for that, where we could address the transition to es2015 by creating classes and their related types |
fcbee39
to
8306b11
Compare
I did a small test with another repo and this other one that are using the gettext-parser types and it the first one works flawlessly simply replacing the line In the second case as for the most of the users, however, it will suffice to remove the line |
728ca78
to
ae8cba6
Compare
…rts the types, because index.js is in the repo root) fix msg_plural that despite the name is a "string" and not a "string[]"
ae8cba6
to
889a7ea
Compare
Hi @smhg, friendly ping on this since I haven't heard from you in a while, I modified the pr and also tested it on a couple of repos I was using it on and it works perfectly. If you have any doubts about anything tell me how to proceed |
@smhg, I'm writing to provide an update regarding the pull request I opened. Since I haven't heard back from you in over a week, I've decided to proceed independently and have completely rewritten the module in TypeScript to adapt it to my needs. Therefore, I would like to close the original pull request and publish my fork. If you have any questions or comments, please feel free to let me know otherwise i will proceed in this direction. |
Hi @erikyo! Thank you for following up on this. I'm sorry I wasn't able to get back earlier. I am not sure we are talking about the same things though. |
Certainly! I was anticipating your approval of this PR before proceeding with additional small PRs to address the other minor inaccuracies (and at this point I think it is the best thing to do to avoid merge conflicts). My plan is to submit one PR per issue, ensuring clarity and transparency throughout the process. I can create a tracking issue if you want (those with bullet points linking to the different pr) to wrap all the changes in a single issue. I apologize for any confusion, but this PR needed to implement significant changes to achieve the necessary improvements. |
I think perhaps the best thing is to create a What do you think? this way we can operate safely without modifying the main branch |
This PR introduces TypeScript support and adds types within the npm package, addressing the suggestion raised in issue #80.
Changes include setting up the TypeScript environment, restructuring files for better organization, and adding strict types for module functions.
These enhancements aim to improve the module's compatibility with modern development practices and facilitate easier contributions from the community.
😇 Sorry for the 19 modified files but I really tried to keep it as small as possible!
close #80