Skip to content

Conversation

@bernaferrari
Copy link

@bernaferrari bernaferrari commented Dec 18, 2025

I like this project and decided to give a shot into rewriting to TS.

  • Tests should pass.
  • Types should follow original d.ts.
  • Most files are git mv, instead of newly created/duplicated, so git diff will be very easy.
  • Dependencies are upgraded.
  • Change count looks scary but it is mostly package-lock.json.
  • Architecture is the same.

There should be no visible changes, and it is not supposed to be breaking.
I recognize there are many files and reviewing could be hard.

I did my best and if you need anything (such as splitting into 3 commits, one for each package) feel free to ask.

Close #311 (which was already closed? lol).

@bernaferrari bernaferrari force-pushed the ts branch 2 times, most recently from c0a4467 to 9ef8346 Compare December 18, 2025 05:38
@KillyMXI
Copy link
Member

Before making such a commitment, a good thing to do is to offer help in an issue. I'll need to put some contribution guideline later at some point.

You can't know what might be cooking behind the scenes or what concerns I might have.
I would've had to do this myself eventually. I have some other concerns I'd need to address during the transition. But perhaps it's not a bad thing to do in a separate step.

This might be handy after all, thanks!
But it is a lot to review indeed.
I appreciate the effort at keeping the commits clean.
Idk if doing it in 3 commits can help in any way.

Now, when I get to work on html-to-text and review this:
I'm trying to find some time every month or two to update my packages, one at a time. In the following few days, I plan to publish new version of parseley. January or February - new version of selderee. After that, it is finally html-to-text's turn.


Regarding #311 - I don't want zero effort, zero communication requests (I consider insulting) to occupy any space and attention. That's why I closed it.

@bernaferrari
Copy link
Author

bernaferrari commented Dec 18, 2025

If you prefer I can also not update any dependencies and just add typescript. But I thought you might want to be in the latest of rollup, etc, so it makes it even easier for you in the future.

Overall, most of the changes are very lightweight so it should be easy to review. There are places I'm just switching from jsdoc to typescript.

@KillyMXI
Copy link
Member

KillyMXI commented Dec 18, 2025

No, you're right it will be easier the way it is.

If you wish, you can refer to the dependencies in https://github.com/mxxii/peberminta (or parseley/selderee once updated).
I'm on Node 20, and I stick to previous minor version of TypeScript.

- Convert all source files from JavaScript to TypeScript
- Add proper type annotations to classes and functions
- Add WrapStateStackItem interface for stack item typing
- Add assertion functions for type safety
- Add tsconfig.json for TypeScript configuration
- Convert source files from JavaScript to TypeScript
- Add type annotations to formatters and table printer
- Add TypeScript build configuration
- Add type definitions for package consumers
- Update test files to TypeScript
- Convert source files from JavaScript to TypeScript
- Add type annotations to formatters and table printer
- Add TypeScript build configuration
- Add type definitions for package consumers
- Update test files to TypeScript
- Convert CLI source file from JavaScript to TypeScript
- Add type annotations to CLI functions
- Add TypeScript build configuration
- Add TypeScript dependencies and build scripts
- Add ESLint flat config with TypeScript support
- Convert example files to TypeScript
- Add root tsconfig.json and tsconfig.base.json
- Update .gitignore and remove .eslintignore
@bernaferrari
Copy link
Author

I split the PR into multiple commits, one for each package + one for everything else. I get

Could not find a declaration file for module 'selderee'. '.../node-html-to-text/node_modules/selderee/lib/selderee.mjs' implicitly has an 'any' type.
There are types at '.../node-html-to-text/node_modules/selderee/lib/selderee.d.ts', but this result could not be resolved when respecting package.json "exports". The 'selderee' library may need to update its package.json or typings.ts(7016)

I'm not sure you put the ts types in the wrong place or what in your other lib, or if I need to manually import the "types" in package-json (ideally not).

I made it support Node 18, so you should be safe. Feel free to review when you have time. I know maintaining a project takes a lot of time. If you have questions, disagree with anything, want partial PR or more conservative changes feel free to ask.

@KillyMXI
Copy link
Member

Thank you.

Yeah, I'm aware of the issue with exports of upstream packages - should be resolved once I'm done updating them.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add typescript and support esm

2 participants