craftedbygc / taxi

Taxi is a 🤏 small and 🐊 snappy js library for adding slick PJAX navigation and beautiful transitions to your website.
https://taxi.js.org
565 stars 11 forks source link

fix type error when registering custom transitions and/or renderers #14

Closed tobimori closed 1 year ago

tobimori commented 1 year ago

previously - taxi types were expecting an instance of the class yet taxi wants the class itself

CleanShot 2023-06-01 at 00 12 54@2x
jakewhiteley commented 1 year ago

My issue is this will break upon rebuilding of the library as the typedefs are generated automatically so cannot be manually edited.

From my reading, typescript supports covariance by default and passing MyRenderer which extends Renderer should have no type errors.

Or am I missing the issue?

tobimori commented 1 year ago

TypeScript expects an instance of the class here and not the class itself, therefore throwing the error (see screenshot). Using typeof fixes this.

tobimori commented 1 year ago

I've updated the PR so the changes are generated automatically now