Repository navigation
refactor(language-service): handle the undefined value of a symbol … - #63002
Closed
ivanwonder wants to merge 1 commit into
Closed
ivanwonder wants to merge 1 commit into
ivanwonder wants to merge 1 commit into
Conversation
ivanwonder
marked this pull request as ready for review
August 5, 2025 03:58
Contributor
|
Is this something you can write a test for? |
…for a type
using the `getSymbol` instead of the `type.symbol`, for the primitive type,
the `type.symbol` returns the `undefined` value. The return type of `getSymbol`
includes `undefined`, while `type.symbol` does not.
For example:
```ts
class BarComponent {
/**
* @deprecated
*/
name = ""
}
```
The type of `name` is `string`, the `type.symbol` for the `string`
returns `undefined` here.
https://github.com/microsoft/TypeScript/blob/e3ef7ff50db66b6a2af8090f79d9039356ec0096/src/services/types.ts#L111
https://github.com/microsoft/TypeScript/blob/e3ef7ff50db66b6a2af8090f79d9039356ec0096/src/compiler/types.ts#L6445
ivanwonder
force-pushed
the
get-symbol-for-primitive-type
branch
from
August 6, 2025 02:45
e0d541f to
5df9bbe
Compare
ivanwonder
commented
Aug 6, 2025
Comment on lines
+611
to
+618
| export class AppComponent { | ||
| /** | ||
| * @deprecated | ||
| * | ||
| * Used to test to get the symbol of the type "string", using the | ||
| * "type.getSymbol()" to check if the symbol is "undefined". | ||
| */ | ||
| name = 'test'; |
Contributor
Author
There was a problem hiding this comment.
In most cases, I think the name should be a signal.
Contributor
Author
Done |
atscott
approved these changes
Aug 6, 2025
Member
|
This PR was merged into the repository by commit b78de31. The changes were merged into the following branches: main |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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.
…for a type
using the
getSymbolinstead of thetype.symbol, for the primitive type, thetype.symbolreturns theundefinedvalue. The return type ofgetSymbolincludesundefined, whiletype.symboldoes not.For example:
The type of
nameisstring, thetype.symbolfor thestringreturnsundefinedhere.https://github.com/microsoft/TypeScript/blob/e3ef7ff50db66b6a2af8090f79d9039356ec0096/src/services/types.ts#L111 https://github.com/microsoft/TypeScript/blob/e3ef7ff50db66b6a2af8090f79d9039356ec0096/src/compiler/types.ts#L6445
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information