fix(declarations): Allow unique symbol computed properties with --isolatedDeclarations #61911
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
compiler
andtranspile
tests ran after accepting the new baselines