-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Repo: Switch from explicit-function-return-type to isolatedDeclarations and/or explicit-module-boundary-type #9419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I always thought this rule is just for stylistic reasons. Otherwise (if you just care about declaration stability) why would you not use |
Same question as @Josh-Cena. Also I personally very much like the stylistic preference of always enforcing return types, but no strong opinion. |
I would be happy with |
The big reason EFRT has remained is because it makes it easier to review PRs in github alone. But TBH we're getting to a point of scale where most changes are pretty complicated and reviewing them in GH alone is hard. Additionally the place where EFRT shines is complex cross-boundary interactions where a change can cause unseen side-effects downstream somewhere. But almost all of our code is isolated and used within a single file - so you just don't have the same opportunity for actions-at-a-distance. I think we're at this point where EFRT gets in the way more than it helps us. But I'm personally very strongly in favour of strictly typed module boundaries - so I don't think going to nothing at all is correct. Which leads us to EMBT or ID. Realistically - ideally we should deprecate and remove EMBT now that isolatedDeclarations exists. The two systems look to implement the same things - though EMBT is actually much, much weaker of a check than what ID is. I don't really see a reason why all EMBT users couldn't migrate to ID. The added benefit of ID is that you can switch ypur build over to oxc/swc/etc on top as well for that sweet sweet build speed improvement. Which I'm sure we would love too for a faster devloop and CI time. |
Proposal: let's switch the repo to EMBT in the meantime, and file a followup issue each for deprecating EFRT and EMBT? Even if we decline either or both of those deprecations, IMO it'd be good to discuss separately. |
To clarify: EFRT is great and a completely useful style - just not one that I think has use for our project any longer. The rule should stay - people find value in it and there is no alternative. EMBT is a great and useful style - but it's a weak subset of ID and realistically should be deprecated in favour of people just using ID. |
Also note that ID would be easy to migrate to. But we never built any tools for EMBT. |
Having played around with ID a little bit - my experience was I don't think it's actually easy to migrate to, in general
(In my quick test in the typescript-eslint repo, we get no ID errors for the packages that currently specify Note that ID is also not actually a superset of EMBT, since it does allow inferred return types, as long as they're "simple" for computers to infer (as opposed to for humans to infer). (reference: go to the phrase "There are also certain expressions where the type is "trivial" to calculate." in the TS 5.5 blog) Conclusion - I'd say if we turn off EFRT, I would significantly prefer using EMBT rather than trying to switch to ID. (also will preemptively say -1 on deprecating EMBT or EFRT) |
Suggestion
Forking out of #8173 (comment):
I'd be in favor of moving to a lighter-weight enforcement of function return types internally. My understanding of the context is that we've traditionally enforced function return types for these reasons:
isolatedDeclarations
enforcesNow that
isolatedDeclarations
are stable, it seems reasonable to me that we'd switch our internal linting to only enforcing what it requires. We'd get the type performance and stability, without the more heavy-handed stylistic requirements. Our non-exported functions would now be able to have inferred return types! What does the team think?💖
The text was updated successfully, but these errors were encountered: