Skip to content

Rewrite project into TypeScript#325

Closed
bernaferrari wants to merge 6 commits intohtml-to-text:masterfrom
bernaferrari:ts
Closed

Rewrite project into TypeScript#325
bernaferrari wants to merge 6 commits intohtml-to-text:masterfrom
bernaferrari:ts

Conversation

@bernaferrari
Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Thank you.

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

@KillyMXI
Copy link
Copy Markdown
Member

With upstream sorted out, I'm starting to look at html-to-text.

First question after looking at this PR:
It was authored by AI, right?

(Noted for future contribution guideline: require disclosing whether and how AI was used.)

@bernaferrari
Copy link
Copy Markdown
Author

bernaferrari commented Mar 27, 2026

It's been so long I don't even remember what I used, but yes. Maybe codex.

I don't see any changes, if you do them feel free to say and I can rebase on top.

@KillyMXI
Copy link
Copy Markdown
Member

I'm not going to accept this PR.
Not because it uses AI in principle, but because I see some oversights that are typical of what LLMs produce without close review and understanding by a human.

I can use AI services myself, with more control. A middleman who just passed the AI-generated code to me for review with significant oversights - is not helpful.

Conversion to TypeScript will happen, but I'll see when exactly I'll do it.

@KillyMXI KillyMXI closed this Mar 27, 2026
@bernaferrari
Copy link
Copy Markdown
Author

I can use AI services myself, with more control.

So do it, I'm just trying to help.

There hasn't been any updates in 3 years. You can just fork from my code and correct anything you want. That will save you time.

@KillyMXI
Copy link
Copy Markdown
Member

Thank you for trying to be helpful.

There are reasons why I struggled to work on this and other things for a while.
Unfortunately, the help I need most is beyond anybody's power to provide.

@bernaferrari bernaferrari deleted the ts branch March 27, 2026 23:19
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