ractivejs / ractive

Next-generation DOM manipulation
http://ractive.js.org
MIT License
5.94k stars 396 forks source link

Fix #3425: Circumvent recursive typescript declarations #3432

Closed seijikun closed 8 months ago

seijikun commented 8 months ago

Description:

TypeScript doesn't like the recursiveness of the current typings. This is a quickfix that gets rid of some of the recursiveness, by trading in some type safety. Don't know whether you want to accept that or whether you have a better idea for a proper fix.

Fixes the following issues:

3425 (most cases)

evs-chris commented 8 months ago

Out of curiosity, how about:

interface CanComponent {
  new(opts?: InitOpts): { root: Ractive; };
}

// then
{
  components: Registry<CanComponent|Promise<CanComponent>>;
}

or something along those lines Just to get some whinging if you put something that's not a component in the registry? If that doesn't play out, I'm fine with using the any escape hatch.

seijikun commented 8 months ago

At least for our project, that seems to work! Should I change the PR to it?

evs-chris commented 8 months ago

If you don't mind. I'll see if I can get a build together later today once this gets merged.

seijikun commented 8 months ago

I'll see if I can get a build together later today once this gets merged.

You're a treasure! :heart: Thank you so much!