kornelski / slip

Slip.js — UI library for manipulating lists via swipe and drag gestures
BSD 2-Clause "Simplified" License
2.44k stars 213 forks source link

TypeScript rewrite #107

Closed SamuelMarks closed 3 years ago

SamuelMarks commented 6 years ago

Nothing too crazy (like a functionclass conversion). Just annotated with types, replaced var with let/const, moved to arrow functions, and switched to the new ES6 export syntax.

BTW: With arrow functions I think we can remove all the binds also.

SamuelMarks commented 6 years ago

@kornelski Decided to do the crazy functionclass conversion.

kornelski commented 6 years ago

This is a massive change, not only in the code, but also in the way it's used.

It's nice to see the code mostly works fine with strict(er) types. However, it also has some quirky bits in the state machine that are taking advantage of class-less ad-hoc nature of JS, so some places got nicer, some got less nice.

There are some small wins in syntax, but many of them are also in ES6.

I like TS in general, but I'm not sure if it brings enough to this codebase to be worth the churn and addition of compilation step.

SamuelMarks commented 6 years ago

My reasoning for the rewrite was that all the frontend frameworks I use—e.g.: Angular—are developed in TypeScript. Sure, I could write a tiny .d.ts for it, but I decided to go full throttle and rewrite.

Yeah, decided to use class expressions for your quirky state machine.

You can also change the target in the tsconfig.json to emit es6.

As for the advantages of TypeScript, generally it is easier to maintain due to:

(to name just a few… here's Ionic's list)

SamuelMarks commented 3 years ago

@kornelski Aww you closed this after 2.5 years

Still keen to get a TS rewrite of your library accepted…

kornelski commented 3 years ago

Well, nothing has changed since. It's still a small library. Survived without types so far.