Typescript Support
Opened this issue ยท 15 comments
Is there a plan for typescript?
You can (sort of) use typescript right now!
Run
yarn add dreidels@next
or
npm install dreidels@next
I am saying sort of because I really rushed the typescript conversion,
and I am not 100% sure I have every method properly typed in accordance
to it's documentation and implementation.
Also if I had to guess there are a bunch of as any
and //@ts-expect-error
since I was just rushing to get it out.
Pretty sure custom status methods like .success
and .fail
on a spinner are not typed at all.
Some things have any type because I was only typing the methods I needed to use at the time.
It's really incomplete.
It should be sort of useable, I have used it myself.
If you do use it and find any typing problems, I would love if you report them or even create a PR.
Good luck!
You can (sort of) use typescript right now! Run
yarn add dreidels@next
ornpm install dreidels@next
I am saying sort of because I really rushed the typescript conversion, and I am not 100% sure I have every method properly typed in accordance to it's documentation and implementation. Also if I had to guess there are a bunch of
as any
and//@ts-expect-error
since I was just rushing to get it out.Pretty sure custom status methods like
.success
and.fail
on a spinner are not typed at all. Some things have any type because I was only typing the methods I needed to use at the time. It's really incomplete.It should be sort of useable, I have used it myself. If you do use it and find any typing problems, I would love if you report them or even create a PR. Good luck!
Okay will try to put time if I can add other missing typings. Thank you!
@SweetMNM I am having this error
import Spinnies from 'dreidels'
const spinnies = new Spinnies() // typescript error: This expression is not constructable
I'm using it as an esm and have to import it like this to make it work
import { default as Spinnies } from 'dreidels';
I have to use this approach:
/* eslint-disable new-cap */
import Spinnies from 'dreidels'
// @ts-expect-error something wrong with package
const spinnies = new Spinnies.default()
ref on code where the approach used: OleksandrKucherenko/chatgpt-translate-md#4
i'm gonna add it here because it's about TS:
the type for the Animation option is wrong when using spinners from cli-spinner
Spinnies({spinner:'arrow3'})
throws an error because it's only typed with SpinnerAnimation
(frames and interval) and not also string
this would probably need a bit more refactoring than just changing the type of SpinnerOptions
because some other code will throw errors because of the typing
i'll try to fix it sooner or later but i can't fix it right now because i don't have more time today
but i think this project is dead because @SweetMNM has not been active on Github at all since about a year ago
but i think this project is dead because @SweetMNM has not been active on Github at all since about a year ago
I have been a busy with other stuff yeah. When I tried to update the project to properly support ts and also commonjs and esm at the same time it was too confusing, especially since I haven't been using node for a while at that point.
I think functionality wise the project is pretty complete (I am glad with how it turned out). If anyone that has some experience with esm modules wants to PR I will gladly test it out and merge when I get the chance :)
Hi, love this project!
i also think that it's pretty complete at this point, but i'll try to improve the typings and esm / commonjs support with a PR soon
Good to see that you're still available so i don't have to use my own fork and instead can use your npm package :)
one question though: what node versions do you want to support? (probably Node 14 and up i expect?)
and also: some of the dependencies have put out new versions where they better support esm, i think it would be a good idea to upgrade some of them
is-observable
for example has fully moved to esm (v3.0.0)
i just found this article that describes an easy solution to the problem:
https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html
Hi, love this project!
i also think that it's pretty complete at this point, but i'll try to improve the typings and esm / commonjs support with a PR soon
Good to see that you're still available so i don't have to use my own fork and instead can use your npm package :)one question though: what node versions do you want to support? (probably Node 14 and up i expect?)
Glad to hear someone enjoys my work :D
Last time I used node I think the latest was 12 lol. Try to support as back as possible as long as it's not too much trouble, not sure what it depends on but I trust that you make the right decision on it.
and also: some of the dependencies have put out new versions where they better support esm, i think it would be a good idea to upgrade some of them
is-observable
for example has fully moved to esm (v3.0.0)
Feel free to update them, I will take a look at the new versions you upgrade to. Shouldn't be a problem. Thanks for working on this!
Glad to hear someone enjoys my work :D
Last time I used node I think the latest was 12 lol. Try to support as back as possible as long as it's not too much trouble, not sure what it depends on but I trust that you make the right decision on it.
I think i'm going to try to support node 12 and up and run local tests to see if the versions work ๐
i just looked it up, Node 12 LTS and Node 14 LTS have reached end-of-life a while ago, current officially supported node versions are Node 18 (Maintenance), Node 20 (LTS), Node 21 (Current)
[see: https://github.com/nodejs/Release]
I'd say that we'll try to support node 14 and up.
(The project isn't even compiling in Node 12 because the nullish coalescence operator ??
was not available until Node 14)