spencermountain / wtf_wikipedia

a pretty-committed wikipedia markup parser
https://observablehq.com/@spencermountain/wtf_wikipedia
MIT License
778 stars 129 forks source link

exported typescript types #500

Closed wvanderp closed 2 years ago

wvanderp commented 2 years ago

In this PR, I've exported all the classes for typescript applications.

All the other stuff is things my editor "fixed".

I have been on and off working on a rewrite in typescript. But the changes are too big to drop at once. So ill will look at what is helpful in the short term.

spencermountain commented 2 years ago

hey wouter, thank you. is there any way to not export those things in src/index.js?

I am open to a full re-write in ts. I'll admit that the current situation with types is a bit of a mess, and I'm to blame. I've been ignoring the red-lines that pop up in this project, and been sloppy with the typesfile, which is now obviously important.

I was really pleased a few years ago when I could remove babel, and I always thought typescript added more opaque tooling. These days though, with bun/deno executing ts, it is certainly less of a headache than it used to be. The maintainance of a seperate typefile has proven to be a pretty crappy time.

so, i'm open to it, if you wanted to go full ts with the project. You're obviously very good at this stuff. As long as there is no breaking changes on the js path. let me know if i can do anything to help with this. cheers!

spencermountain commented 2 years ago

i can merge this if you want - i'd prefer not to change the public-facing api, if we don't have to. let me know what you think

spencermountain commented 2 years ago

okay last thing - I work by running npm run watch on the scratch.js file - if we sub ts-node in there, is it gonna get slow or something? I haven't played around with this stuff in years. I guess those are the only two important things - that rollup strips the types out of the builds, and that npm run watch is still nice and brainless. I don't mind writing the actual types, throughout the project. ok that's all!

wvanderp commented 2 years ago

is there any way to not export those things in src/index.js?

I'm afraid we need to export these things to make this work. The types work fine as is right now, but there is no way to label an object as a Document or Sentence.

Going pure TS will also not solve this issue.

The good thing is that this is purely an addition, and there will be no breaking changes in this pr.

on the topic of the typescript rewrite

I was already working on this on and off. But in the last week, I started it up again. The first step was to separate all the js changes from the move to TS. So this includes rewriting all the other "classes" as classes.

Then I will rename everything to .ts and fix all the red lines.

if we sub ts-node in there, is it gonna get slow

The startup will be a bit slower because of type-checking, but I don't notice it

spencermountain commented 2 years ago

hey cool! this is exciting. I've added hacktoberfest tags back to the repo. let me know if I can do anything thank you!

wvanderp commented 2 years ago

This change is still required for ts.

Also, I just noticed that this is the 500th PR congratulations