swup / scroll-plugin

A swup plugin for smooth scrolling 🏄‍♂️
https://swup.js.org/plugins/scroll-plugin
MIT License
3 stars 8 forks source link

Add TypeScript declaration file through JSDoc #35

Closed hirasso closed 1 year ago

hirasso commented 2 years ago

Out of curiosity I gave this a try:

We should discuss if this is the right way to do it. The process JSDoc->tsc could become quite a big maintenance chore, I can imagine. How could we make sure it doesn't diverge from the actual code? I have the feeling that, if we want to support TS, we would have to rewrite the actual code to TypeScript. It feels like this wouldn't be more work then adding JSDoc.

daun commented 2 years ago

Nice work! Good to have a baseline on the workflow and quality to expect.

What's a good way of validating/checking the generated types?

It feels like this wouldn't be more work then adding JSDoc.

I haven't ported over any projects to TS lately, but that sounds wildly optimistic to me 🤠 I agree with migrating to TS if it improves the codebase in the long term, but getting it right for the core and all plugins will take us a few weeks realistically, no?

hirasso commented 2 years ago

I haven't ported over any projects to TS lately, but that sounds wildly optimistic to me 🤠 I agree with migrating to TS if it improves the codebase in the long term, but getting it right for the core and all plugins will take us a few weeks realistically, no?

The less I know the more optimistic I get 😁 ...I have actually never written a single line of TypeScript myself.

What's a good way of validating/checking the generated types?

That's exactly what I don't know and why I thought, well, TypeScript checks correct typings, right? Here the consumers would be on the mercy of us not making mistakes in the JSDocs...

hirasso commented 2 years ago

TypeScript allows plain JS, right? We could just switch to .ts for all files in swup/src and incrementally add typings. No rewrite required, just some refactoring maybe?

daun commented 2 years ago

What's a good way of validating/checking the generated types?

That's exactly what I don't know and why I thought, well, TypeScript checks correct typings, right? Here the consumers would be on the mercy of us not making mistakes in the JSDocs...

Exactly, with TS we know they're correct, with JSDoc conversion we'd have to also check if the TS conversion produced the correct type definitions.

daun commented 2 years ago

I'd opt for not merging this until we figured out which way to go with the codebase.

hirasso commented 2 years ago

Ok, lets do this