Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript Support #2

Open
davidkhierl opened this issue Jul 21, 2022 · 15 comments
Open

Typescript Support #2

davidkhierl opened this issue Jul 21, 2022 · 15 comments

Comments

@davidkhierl
Copy link

Is there a plan for typescript?

@SweetMNM
Copy link
Owner

SweetMNM commented Jul 21, 2022

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!

@davidkhierl
Copy link
Author

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!

Okay will try to put time if I can add other missing typings. Thank you!

@davidkhierl
Copy link
Author

@SweetMNM I am having this error

import Spinnies from 'dreidels'

const spinnies = new Spinnies() // typescript error: This expression is not constructable

@davidkhierl
Copy link
Author

I'm using it as an esm and have to import it like this to make it work

import { default as Spinnies } from 'dreidels';

@OleksandrKucherenko
Copy link

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

@thunfisch987
Copy link

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

@thunfisch987
Copy link

but i think this project is dead because @SweetMNM has not been active on Github at all since about a year ago

@SweetMNM
Copy link
Owner

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 :)

@thunfisch987
Copy link

thunfisch987 commented Dec 19, 2023

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?)

@thunfisch987
Copy link

thunfisch987 commented Dec 19, 2023

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)

@thunfisch987
Copy link

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

@SweetMNM
Copy link
Owner

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.

@SweetMNM
Copy link
Owner

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!

@thunfisch987
Copy link

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 👍

@thunfisch987
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants