block-content-to-hyperscript icon indicating copy to clipboard operation
block-content-to-hyperscript copied to clipboard

Convert to TypeScript

Open balazsorban44 opened this issue 5 years ago • 2 comments

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:

  • [x] ~convert files~
  • [x] ~fix all TS errors~
  • [x] ~get tests working~
  • [x] ~create multiple bundles~
  • [ ] fix imports/exports

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 avatar Oct 16 '20 11:10 balazsorban44

~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 avatar Oct 16 '20 15:10 balazsorban44

@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 🙈.

balazsorban44 avatar Oct 17 '20 10:10 balazsorban44