Skip to content

Conversation

@ahejlsberg
Copy link
Member

Fixes #62920.

Copilot AI review requested due to automatic review settings December 23, 2025 17:16
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Dec 23, 2025
@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Dec 23, 2025
Copy link
Contributor

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

This PR fixes a crash (issue #62920) that occurred when TypeScript tried to report an error about accessing an abstract property in the constructor of an unnamed class expression. The crash happened because the code attempted to access the name property of an unnamed class declaration, which is undefined for class expressions without explicit names.

Key Changes

  • Modified the abstract property accessibility check to avoid dereferencing potentially undefined values
  • Changed error message generation to use symbolToString() instead of accessing the class declaration's name property directly
  • Added a test case demonstrating the crash scenario with appropriate baselines

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/compiler/checker.ts Fixed crash by checking parent symbol validity and using symbolToString() instead of accessing declaration name
tests/cases/compiler/errorInUnnamedClassExpression.ts Added test case with unnamed class expression containing abstract property accessed in constructor
tests/baselines/reference/errorInUnnamedClassExpression.types Baseline for type information
tests/baselines/reference/errorInUnnamedClassExpression.symbols Baseline for symbol information
tests/baselines/reference/errorInUnnamedClassExpression.errors.txt Baseline showing correct error messages (TS2715, TS1253, TS7008)

const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)!);
if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) {
const parentSymbol = getParentOfSymbol(prop);
if (parentSymbol && parentSymbol.flags & SymbolFlags.Class && isNodeUsedDuringClassInitialization(location)) {
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

Missing spaces around the bitwise AND operator. The pattern should be parentSymbol.flags & SymbolFlags.Class with spaces on both sides of the & operator to match the codebase style.

Copilot uses AI. Check for mistakes.
@ahejlsberg
Copy link
Member Author

This was ported to typescript-go in microsoft/typescript-go#2423.

@github-project-automation github-project-automation bot moved this from Not started to Needs merge in PR Backlog Dec 28, 2025
@ahejlsberg ahejlsberg added this pull request to the merge queue Dec 28, 2025
Merged via the queue into main with commit f3770c9 Dec 28, 2025
33 checks passed
@ahejlsberg ahejlsberg deleted the fix-62920 branch December 28, 2025 21:22
@github-project-automation github-project-automation bot moved this from Needs merge to Done in PR Backlog Dec 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Crash: TypeError: Cannot read properties of undefined (reading 'kind') in checkPropertyAccessibility when using abstract in Class Expression

4 participants