prateekbh / preact-async-route

Async route component for preact-router
MIT License
138 stars 14 forks source link

TypeScript Definitions #16

Closed Silic0nS0ldier closed 6 years ago

Silic0nS0ldier commented 6 years ago

I've added TypeScript definitions and the appropriate testing. If there are any suggestions or corrections to be made, just let me know.

Silic0nS0ldier commented 6 years ago

Oh, off topic but I think prepare or prepublishOnly would be a better choice than prepublish in scripts. NPM has a weird behaviour with the command, wherein despite its name, it gets run after npm install. End result is that with how the scripts are set up, Travis wastes time performing build twice. No... Actually 3 times. Huh.

Silic0nS0ldier commented 6 years ago

Don't merge this. Thought I had it all done and dusted, but when I applied it to my TypeScript based project it threw everything back in my face. Bare with me while I figure this out.

Silic0nS0ldier commented 6 years ago

Bad case of me not observing the obvious. Ultimately it boiled down to TypeScript not allowing an untyped generic as a type for a field. I've updated to account for this inability. No clue why the test case failed to pick this up (the values before should have raised errors).

prateekbh commented 6 years ago

@Silic0nS0ldier Thank you so much for this. Is it all good to review?

Silic0nS0ldier commented 6 years ago

Yeah, its good for review.

prateekbh commented 6 years ago

published 🎉 🎉 🎉 🎉

Thanks @Silic0nS0ldier

andybons commented 6 years ago

This doesn’t allow for extension of the component (to allow for additional props to be passed).

Example code that now doesn’t work:

<AsyncRoute
  path="/sign-in"
  getComponent={() =>
    import(/* webpackChunkName: "sign-in" */ './routes/sign-in').then(
      module => module.default
    )
  }
  authService={App.authService}
  fetchService={App.fetchService}
/>