Replies: 1 comment 1 reply
-
This seems like a really good idea. The TypeScript is largely community driven as I tend to not use TS beyond small demos and honestly am just not aware of gaps like this. I've also never considered a linter because of how particular I can be around how JavaScript is written for performance in some cases. But for TS that could be helpful. It just never crossed my mind of doing so for only this. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
FYI, I've noticed that this repo does not manually define the return type of many exported functions. I also maintain a typescript repo (rSchedule) and I used to not manually define return types. This worked fine for quite a while (a year or two) until one day I pushed out an update and found users complaining of type errors.
In my case, it turned out declaration merging within a test was resulting in the repo's development environment (i.e. editor) having different inferred types than what end users saw when they consumed the package in their own projects. More broadly, when you don't explicitly define the type of an export, then typescript infers the type and then hardcodes that inferred type into the compiled typescript declaration file that is included on npm. Sometimes this inferred type is different than what you expect/realize.
For most repos, I don't think requiring explicite return types is worth the trouble. But for a repo like
solid-js
, which I expect has aspirations to be widely adopted, forcing explicite return types via a lint rule seems like a good long-term bit of hygiene.I totally respect if this isn't something you feel is appropriate/necessary (it is a lot of trouble for a questionable benefit), but figured I'd pass along my experience.
Beta Was this translation helpful? Give feedback.
All reactions