Skip to content

refactor(language-service): handle the undefined value of a symbol … - #63002

Closed
ivanwonder wants to merge 1 commit into
angular:mainfrom
ivanwonder:get-symbol-for-primitive-type
Closed

ivanwonder wants to merge 1 commit into
angular:mainfrom
ivanwonder:get-symbol-for-primitive-type

Conversation

@ivanwonder

@ivanwonder ivanwonder commented Aug 5, 2025 •

Copy link
Copy Markdown
Contributor

…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:

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

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@angular-robot angular-robot Bot added the area: language-service Issues related to Angular's VS Code language service label Aug 5, 2025
@ngbot ngbot Bot added this to the Backlog milestone Aug 5, 2025
@ivanwonder
ivanwonder marked this pull request as ready for review August 5, 2025 03:58
@pullapprove
pullapprove Bot requested a review from kirjs August 5, 2025 03:58
@atscott

atscott commented Aug 5, 2025

Copy link
Copy Markdown
Contributor

Is this something you can write a test for?

@atscott atscott added the target: minor This PR is targeted for the next minor release label Aug 5, 2025
…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
ivanwonder force-pushed the get-symbol-for-primitive-type branch from e0d541f to 5df9bbe Compare August 6, 2025 02:45
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';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most cases, I think the name should be a signal.

@ivanwonder

Copy link
Copy Markdown
Contributor Author

Is this something you can write a test for?

Done

@thePunderWoman
thePunderWoman removed the request for review from kirjs August 6, 2025 13:26
@thePunderWoman thePunderWoman added the action: merge The PR is ready for merge by the caretaker label Aug 6, 2025
@crisbeto

crisbeto commented Aug 6, 2025

Copy link
Copy Markdown
Member

This PR was merged into the repository by commit b78de31.

The changes were merged into the following branches: main

@crisbeto crisbeto closed this in b78de31 Aug 6, 2025
@ivanwonder
ivanwonder deleted the get-symbol-for-primitive-type branch August 7, 2025 01:33
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: language-service Issues related to Angular's VS Code language service target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants