sanity-io / block-content-to-hyperscript

Function for transforming Sanity block content to HyperScript
MIT License
17 stars 8 forks source link

Convert to TypeScript #23

Open balazsorban44 opened 3 years ago

balazsorban44 commented 3 years ago

This is loosely related to https://sanity-io-land.slack.com/archives/C9Z7RC3V1/p1601637650136800

I probably should have opened an issue instead, but I got the impression that this would be a welcome change, so I proceed.

If the team has any suggestions/ideas/wishes how things should be done, please leave a comment under! Thanks :slightly_smiling_face:

This is a minimal conversion to TS, meaning I extensively used any to silence the TypeScript checker. I added some types though, where it seemed to be doable easily.

Probably the inner data structure types could have been written a bit better and exposed, so the generated .d.ts files could be used for example to create new parsers compatible with Portable Text.

balazsorban44 commented 3 years ago

~Some of the tests are failing, and I need some feedback/help to fix those. Also to fix the bundling part, I am not totally sure how it should be set up so multiple bundles are created for different environments.~

balazsorban44 commented 3 years ago

@rexxars @bjoerge @saasen This is ready for review!

Would accept some suggestions for the imports and exports, it is a bit messy, and I probably did not get it right. Not 100% sure where and what should be imported/exported 🙈.