-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Fix crash in abstract property checking #62923
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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)) { |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
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.
Fixes #62920.