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 usage #83

Open
DjulLau opened this issue Jul 30, 2021 · 5 comments
Open

Typescript usage #83

DjulLau opened this issue Jul 30, 2021 · 5 comments

Comments

@DjulLau
Copy link

DjulLau commented Jul 30, 2021

Hi there,

First thanks for this great lib !
I've used it some years ago in pure JS with success. Now I'm trying to use it in a typescript project with no luck.
I've just installed it with npm and tried to run the example but I'm getting lots of errors like if the types were not in sync or so.

image

What am I missing ?

Thanks,

Julien

@fantasticsoul
Copy link
Contributor

image

Click Proton constructor type declaration to see detail types definition.

@DjulLau
Copy link
Author

DjulLau commented Aug 4, 2021

Thanks for your answer.
I know where to look for the definitions. I don't understand why the basic example generate so many errors (and so my old JS proton codes). Versions incompatibilities ? Wrong/incomplete types definitions ?

@drawcall
Copy link
Owner

Please download the latest version of proton and try

@dgoemans
Copy link

dgoemans commented Jan 20, 2022

Still doesn't help (using 5.3.2). Looks like the types are incorrect/don't match optional or polymorphic paramters:

For example, the addBehaviour function takes in a Behaviour array, but at no point does color implement a Behavior interface, so you can't call it with a Color.

    /**
     * add the Behaviour to particles;
     *
     * you can use Behaviours array:emitter.addBehaviour(Behaviour1,Behaviour2,Behaviour3);
     * @method addBehaviour
     * @param {Behaviour} behaviour like this new Color('random')
     */
    addBehaviour(...args: Behaviour[]): void;

Same goes for many different functions/constructors/etc

Are the types generated or hand crafted?

@fantasticsoul
Copy link
Contributor

fantasticsoul commented Jan 24, 2022

Are the types generated or hand crafted?

sorry, most of d.ts file content is generated by dts-gen, only a few part is written by hand, we appreciate it if you can help us to improve this d.ts file。

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