bittrex-orderbook icon indicating copy to clipboard operation
bittrex-orderbook copied to clipboard

[WIP] Typescript migration

Open pkakelas opened this issue 6 years ago • 8 comments

pkakelas avatar Dec 21 '18 16:12 pkakelas

Let's not go crazy with style changes yet, these will only complicate and delay the reviewing process. Also let's do the work of converting to TypeScript while keeping the .js file type to start with so that the diffs can be reviewed easily. Then there can be a separate commit which just moves files to their .ts counterparts if need be.

gtklocker avatar Dec 21 '18 19:12 gtklocker

Also I'm not seeing changes to package.json for making this publishable. I'm guessing we need to add a build/prepare hook and somehow include the compiled JS and type definitions. I haven't done this before though.

gtklocker avatar Dec 21 '18 19:12 gtklocker

This is also a good opportunity to get rid of babel as a dependency. I think we're using the polyfill for some Array prototype function, but we can probably rely on the TS compiler for that now. If you do that please find the offending function call in the original JS source and make sure its TS compiled counterpart works.

gtklocker avatar Dec 21 '18 19:12 gtklocker

I'm seeing lots of any on the types. Not filling in all the types is OK but prefer to not type the thing at all instead of using any, as this disables the type checking entirely instead of allowing the compiler to infer the type. Make sure we don't have any option enabled in tsconfig which forces us to type everything.

gtklocker avatar Dec 21 '18 19:12 gtklocker

I got rid of the babel compiler and polyfill and use the TS compiler myself as of https://github.com/gtklocker/bittrex-orderbook/commit/1823ba8035cebd7bdf870016b5d40630225e2b99

gtklocker avatar Dec 21 '18 20:12 gtklocker

Also I'm not seeing changes to package.json for making this publishable. I'm guessing we need to add a build/prepare hook and somehow include the compiled JS and type definitions. I haven't done this before though.

Maybe it also makes sense to create a PR here: https://github.com/DefinitelyTyped/DefinitelyTyped

themicp avatar Dec 21 '18 21:12 themicp

@themicp definitelytyped is for when you type a JS package you don't control. Seeing as this will be in Typescript we'll provide our type definitions in-package. I think it may be as simple as creating the .d.ts file with tsc and adding a types key on package.json like ccxt has https://github.com/ccxt/ccxt/blob/master/package.json#L46

gtklocker avatar Dec 21 '18 21:12 gtklocker

@pkakelas please look at the previous comments before doing more work and rebase

gtklocker avatar Dec 23 '18 16:12 gtklocker