lukeed / trouter

:fish: A fast, small-but-mighty, familiar fish...errr, router*
MIT License
634 stars 23 forks source link

Typescript definitions #4

Closed fwilkerson closed 6 years ago

fwilkerson commented 6 years ago

Even if you aren't using typescript this adds some decent intellisense to Trouter (at least in vscode). Would you be interested in adding? I could make use of this to cover polka as well.

fwilkerson commented 6 years ago

Good question, I thought the same thing but was selfish and only added what I cared about. If you are using in a typescript project, it would throw an error if you tried to use a prop no on the definition.

It's mostly copy pasta. I can whip up the others.

lukeed commented 6 years ago

Up to you! I'm totally not plugged into this tooling/ecosystem, so whatever makes the most sense and/or whatever most people would expect.

Also, the handler isn't required to be a function. It can be anything & in Polka land may very well be an array of functions in near future.

fwilkerson commented 6 years ago

Yep, that makes sense. Perhaps a nice compromise would be to update the handler comment to The function(s) that should be tied to this pattern. as that's the most likely use case. Then update the type to any. For those of us using js, the method signatures and comments are the most helpful. And typescript users at least won't have to worry about typescript throwing errors if they want to use a Map for a handler.

lukeed commented 6 years ago

Thank you @fwilkerson ~!