Skip to content
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

Resolve compiler errors that appear due to useDefineForClassFields #241544

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

trevorade
Copy link
Contributor

These changes go a ways towards addressing #186726

These changes DO NOT include setting useDefineForClassFields to true so backsliding is still possible.

These changes were done by hand over a period of about five focused hours. There were 500 errors when I started.

The process I used was:

  • Enable useDefineForClassFields in the base tsconfig file (NOT IN THIS PR)
  • Run npm run watch
  • Identify an error and open the file with an error
  • For any field initialization that references a parameter property:
    • Move the initialization into the constructor
    • Explicitly add the type via a plugin
    • Repeat for any remaining + new errors
  • Look for usages of waitForState and recomputeInitiallyAndOnChange and inline any impacted derived fields

To truly enable useDefineForClassFields, more changes will more than likely need to be made. For now, I was interested in tackling the compilation errors.

All tests pass with these changes.

If the VSCode team would like to take over this PR, that's fine.

The motivation for making these changes is that, at Google, we build this codebase internally. We are going to enable the compilation errors related to useDefineForClassFields in our internal typescript compiler settings (without actually turning on those transpilation changes, similar to microsoft/TypeScript#59623). So we would much prefer to fix these issues in your codebase rather than maintain a huge 200 file patch :P

@trevorade
Copy link
Contributor Author

@microsoft-github-policy-service agree company="Google"

@trevorade
Copy link
Contributor Author

@jrieken, would you be willing to take a look at this?

@jrieken jrieken self-assigned this Feb 25, 2025
@jrieken
Copy link
Member

jrieken commented Feb 25, 2025

@trevorade Thanks for reaching out and starting this. This is a large PR and something we need to coordinate across the team. Usually, we have reservations against PRs that touch very many code owner areas but this seems mostly mechanical and exception-worthy.

I will circle this with the team and see how folks respond. Generally, I am positive about this change and it seems this must happen anyways sooner or later.

To truly enable useDefineForClassFields, more changes will more than likely need to be made

Do you have a feel for what that would be?

@mjbvz You initial concern in #186726 (comment) seems to have fixed, right? Any other insights this that you have?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants