veliovgroup / flow-router

🚦 Carefully extended flow-router for Meteor
https://packosphere.com/ostrio/flow-router-extra
BSD 3-Clause "New" or "Revised" License
201 stars 30 forks source link

Flow-Router Extra Typescript types #95

Closed timsun28 closed 1 year ago

timsun28 commented 2 years ago

As discussed in issue there was an old request to add typescript types to this package.

This is a first start for implementing typescript types for Flow-Router extra. Basic setup from monti-apm routes types, but updated according to the docs from Flow-Router-Extra.

I still have a few small questions and a bug in the code itself that I wasn't able to figure out and could use the help from someone else with.

On the FlowRouter.current() documentation page, it is mentioned that the return value is an Object with 4 params, but there are more (as seen in the types file).

Later in the docs on the triggersEnter page, it is mentioned that the function has a property called: context {Route} that is equal to FlowRouter.current() function. But the FlowRouter.current() function has a context prop that it returns with different props. I think my implementation for the types is correct, but this might be a separate issue with the documentation that could be improved.

My issue is with the dynamic import (return type for waitOn function). type DynamicImport = Promise<typeof import(T)>; I have tried the following solution, but it's giving the error message at the last T: String literal expected.

timsun28 commented 1 year ago

@dr-dimitru Thank you for merging this PR.

[Update] I've removed the local package from my project and update FlowRouter and it successfully found all the types!

dr-dimitru commented 1 year ago

@timsun28 I'm suggesting to start with a small file making sure types are pulled and recognized