Skip to content

Port "Fixed a JSDoc-related crash when obtaining type of a type literal type argument" #1039

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

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Jun 4, 2025

@Copilot Copilot AI review requested due to automatic review settings June 4, 2025 11:22
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Ports the fix from the TypeScript repo to prevent a JSDoc-related crash when obtaining the type of a type literal type argument by adding a nil check and caching the symbol before use.

  • Introduce a local sym variable to store node.Symbol()
  • Add sym == nil check in the condition to avoid dereferencing nil

@@ -21669,7 +21669,7 @@ func (c *Checker) getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node *as
if links.resolvedType == nil {
// Deferred resolution of members is handled by resolveObjectTypeMembers
alias := c.getAliasForTypeNode(node)
if len(c.getMembersOfSymbol(node.Symbol())) == 0 && alias == nil {
if sym := node.Symbol(); sym == nil || len(c.getMembersOfSymbol(sym)) == 0 && alias == nil {
Copy link
Preview

Copilot AI Jun 4, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding parentheses around the second part of the condition to clarify operator precedence, e.g., sym == nil || (len(c.getMembersOfSymbol(sym)) == 0 && alias == nil).

Copilot uses AI. Check for mistakes.

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

We don't have the tests for this yet but this looks correct to me.

@jakebailey jakebailey added this pull request to the merge queue Jun 4, 2025
Merged via the queue into microsoft:main with commit 0c16bc2 Jun 4, 2025
23 checks passed
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.

2 participants