Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 23, 2025

Ports TypeScript PR #62923 which fixes a crash when checking abstract properties in unnamed class expressions. The compiler previously crashed with Cannot read properties of undefined (reading 'kind') when encountering abstract properties in class expressions without names.

Changes

  • internal/checker/checker.go: Modified checkPropertyAccessibilityAtLocation to check parent symbol flags directly instead of calling GetClassLikeDeclarationOfSymbol, which returns nil for unnamed class expressions. Now uses symbolToString(parentSymbol) for error messages, handling both named and unnamed classes.

  • testdata/tests/cases/compiler/errorInUnnamedClassExpression.ts: Added test case covering the crash scenario.

Example

Previously crashed:

let Foo = class {
    constructor() {
        this.bar++;  // Compiler crashes here
    }
    abstract bar;
};

Now produces proper error:

error TS2715: Abstract property 'bar' in class 'Foo' cannot be accessed in the constructor.
Original prompt

Port PR 62923


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

This ports TypeScript PR #62923 which fixes issue #62920 - a crash when
using abstract properties in class expressions.

The fix changes how we check for abstract properties in constructors:
- Instead of getting the class declaration and accessing its name (which
  crashes for unnamed class expressions), we now check the parent symbol
  directly using SymbolFlagsClass
- Use symbolToString() for the error message, which handles both named
  and unnamed classes correctly

Added test case errorInUnnamedClassExpression.ts to verify the fix.
Copilot AI changed the title [WIP] Port changes from PR 62923 Port PR 62923: Fix crash in abstract property checking for unnamed class expressions Dec 23, 2025
Copilot AI requested a review from ahejlsberg December 23, 2025 17:55
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