fix(declarations): Allow unique symbol computed properties with --isolatedDeclarations#61911
Closed
TJLSmith0831 wants to merge 3 commits intomicrosoft:mainfrom
Closed
fix(declarations): Allow unique symbol computed properties with --isolatedDeclarations#61911TJLSmith0831 wants to merge 3 commits intomicrosoft:mainfrom
TJLSmith0831 wants to merge 3 commits intomicrosoft:mainfrom
Conversation
Author
|
@microsoft-github-policy-service agree |
jakebailey
requested changes
Jul 1, 2025
Member
jakebailey
left a comment
There was a problem hiding this comment.
I'm not really sure what's going on in this PR. It's adding incorrect errors. The check it's adding does not seem correct (createTypeOfExpression is never used in this manner, and it returning a type node does not make it a unique symbol, and the code that needs to work doesn't involve typeof at all).
I'm not sure this is a good issue for someone who has not touched this part of the code.
Author
|
@jakebailey I appreciate the review and response. I wanted to give it a shot and learn more about the inner workings of TS. Bit off more than I could chew on this one. Going to Close the PR 🪓 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #61892
This PR fixes an issue where using --isolatedDeclarations would incorrectly produce an error (TS9038) for computed properties whose keys are of type unique symbol. This error also prevented these properties from being emitted in the generated declaration file.
The fix modifies the declaration transformer to correctly identify when a computed property's key is a unique symbol. It does this by checking if the resolver creates a TypeQueryNode for the expression, which is how these types are represented during declaration emit. This allows the transformer to bypass the incorrect error and preserve the property in the output .d.ts file as intended.
Testing
I added a new test case to tests/cases/compiler/isolatedDeclarationErrorsClasses.ts which includes a class with a computed property keyed by a unique symbol.
Without the fix, this test case fails with a TS9038 error.
With the fix, the test case no longer produces this error, and the new baseline confirms that the property is correctly emitted in the declaration file.
Checklist
[x] My code follows the style guidelines of this project.
[x] I have added a test that proves my fix is effective.
[x] New and existing unit tests pass locally with my changes.
[x] I have accepted the new baselines.
[x] I have read the CONTRIBUTING.md document.
Note
My laptop did not have the power to run all unit tests across the repo. Got some timeout errors but the
compilerandtranspiletests ran after accepting the new baselines