Current goal of genType with regard to type safety

Hello. A long time since I’ve posted here, so it’s possible I’ve missed something, although I have done a search to check. I have also been stuck on rescript@9 for several years, so I’ve totally missed the latest changes.

I’m now trying out rescript@11 and it seems like a fundamental goal of genType has changed. If I understand correctly, genType now imports functions from typescript packages with as any, which means that there is no type safety at that crucial point.

Is there a reason for this?

Thanks for getting me up to speed!

I should add – this is what I currently see:

And this is what I expected/hoped to see:

I’m not sure to follow, what are you trying to do? Gentype is meant to be type safe from rescript to typescript, and the goal is to make it runtime free.

Thanks for the reply!

Gentype is meant to be type safe from rescript to typescript

This is a change, whether intentionally or not, from what used to be to contract that genType provided (whether intentionally or not). I wrote a blog post about this long ago. The TL;DR is that genType used to also guarantee that your imports from typescript into rescript were typechecked against the TS types distributed with the third party library you were importing. Therefore you could npm upgrade that library safe in the knowledge that your bindings would continue to be correct.

2 Likes

And it turns out I was right, this was an unintended (or unforeseen at least) change.

1 Like