TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Refactor `getTypeOfSymbol` for Improved Readability and Maintainability

Open Bashamega opened this issue 10 months ago • 4 comments

Acknowledgement

  • [x] I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.

Comment

Hello:) I have noticed that the getTypeOfSymbol function in the compiler is overly complicated and could be simplified.

Bashamega avatar Mar 12 '25 04:03 Bashamega

Your suggestion is creating an unnecessary object and arrays every time the function is called. And IMO is more complicated and much less readable.

MartinJohns avatar Mar 12 '25 05:03 MartinJohns

Here's a declined PR that has the exact same change on another location: #57375

Relevant comments:

This incurs an object allocation on every call, and the object gets bigger every time we add more stuff.

and

There are over 2,000 issues in our Backlog that we're accepting PRs for. Please don't send stylistic/formatting/"cleanup" PRs that don't address an identified issue. Of all the things we could use help with, reformatting our code isn't one of them 😅

MartinJohns avatar Mar 12 '25 06:03 MartinJohns

Here's a declined PR that has the exact same change on another location: #57375

Relevant comments:

This incurs an object allocation on every call, and the object gets bigger every time we add more stuff.

and

There are over 2,000 issues in our Backlog that we're accepting PRs for. Please don't send stylistic/formatting/"cleanup" PRs that don't address an identified issue. Of all the things we could use help with, reformatting our code isn't one of them 😅

Why not add it to the Pre-Declined Feature Requests section in the FAQ if that is the case? I have re-read the FAQ multiple times to make sure my pr is allowed and it is.

Bashamega avatar Mar 12 '25 06:03 Bashamega

🤷‍♂ In the end it's up to the TypeScript team (which I am not a member of).

The PR template does mention:

There is an associated issue in the Backlog milestone (required)

And in the mentioned "Contributing" file it talks about contributing bugs and contributing features - yours is neither or a bug nor a feature.

Also, readability and maintability is very subjective. I find your changes neither more readable nor more maintainable. But definitely having worse performance due to the additional allocations.

Why not add it to the Pre-Declined Feature Requests section in the FAQ if that is the case?

This is not a feature request.

MartinJohns avatar Mar 12 '25 07:03 MartinJohns

Why not add it to the Pre-Declined Feature Requests section in the FAQ if that is the case?

People who aren't reading CONTRIBUTING.md are likely not reading the FAQ either; I don't see how that would help.

RyanCavanaugh avatar Mar 12 '25 16:03 RyanCavanaugh

Why not add it to the Pre-Declined Feature Requests section in the FAQ if that is the case?

People who aren't reading CONTRIBUTING.md are likely not reading the FAQ either; I don't see how that would help.

I am very sorry

Bashamega avatar Mar 12 '25 17:03 Bashamega