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

More TypeScript. Missing types or wrong usage? #3367

Open
LeJared opened this issue Mar 11, 2021 · 2 comments
Open

More TypeScript. Missing types or wrong usage? #3367

LeJared opened this issue Mar 11, 2021 · 2 comments

Comments

@LeJared
Copy link

LeJared commented Mar 11, 2021

Description:

I've some more questions on typescript. Either there are some missing types/signatures or I may be using it wrong:

Ractive.transitions seems to be missing entirely in the types

Ractive.WELCOME_MESSAGE seems to be missing in types or is there another way to silence the welcome message`?

Types for EventPlugin state, that the fire callback takes one argument of type Event but Examples at https://ractive.js.org/plugins/#writing_4 it's used like this: fire({ node: node, original: event }) which does not match the signature. Is the matching signature missing in the types or is it supposed to be used in another way?

I've used Ractive.defaults to add some global helpers to all ractive instances, e.g. to use them in the templates like @.helper()
This used to work back in good old JS days:

Ractive.defaults.helper = function () {
   // do stuff
};

But typescript says that Ractive.defaults does not accept custom properties. Is this missing in the TS types or are there new ways to add methods to all instances, primarily to use them in the templates.

Versions affected:

1.3.14

@evs-chris
Copy link
Contributor

These are likely issues with the .d.ts file for ractive. I took a file from @typings, adjusted it, filled in a bunch of missing stuff, and added it to the package, but there are some use-cases I don't typically hit. We've had a number of typings contributions to fill in some of the gaps, and it looks like these just haven't been encountered yet. Looking at each:

  1. Yep, transitions is just missing from the Static ractive definition. Ractive is a little harder to model in typescript.
  2. WELCOME_MESSAGE looks like it was just overlooked too.
  3. Event plugins did change a little, so I'll have to poke at the code a little to verify.
  4. I haven't used shared defaults for helpers before, but if it does work that way, the defaults definition will just need to have an index property added.

@evs-chris
Copy link
Contributor

I think I've got all of these resolved on edge once travis finishes doing its thing.

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

2 participants