Flow-Router Extra Typescript types#95
Merged
dr-dimitru merged 6 commits intoveliovgroup:masterfrom Sep 19, 2022
Merged
Conversation
dr-dimitru
approved these changes
Sep 19, 2022
Member
dr-dimitru
left a comment
There was a problem hiding this comment.
@timsun28 looks great, thank you fro the contribution.
Is there a way to cover it with tests?
dr-dimitru
added a commit
that referenced
this pull request
Sep 19, 2022
Author
|
@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! |
Member
|
@timsun28 I'm suggesting to start with a small file making sure types are pulled and recognized |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.