Skip to content

Fix Cannot read property 'text' of undefined crash#32734

Merged
RyanCavanaugh merged 3 commits into
microsoft:masterfrom
rchaser53:fix-text-of-undefined-crash
Aug 19, 2019
Merged

Fix Cannot read property 'text' of undefined crash#32734
RyanCavanaugh merged 3 commits into
microsoft:masterfrom
rchaser53:fix-text-of-undefined-crash

Conversation

@rchaser53
Copy link
Copy Markdown
Contributor

This is a first time for me to send this repository.
I tried to fix the crash bug.
Fixes #32358

@msftclas
Copy link
Copy Markdown

msftclas commented Aug 6, 2019

CLA assistant check
All CLA requirements met.

@rchaser53
Copy link
Copy Markdown
Contributor Author

Sorry, I fixed my code.

Comment thread src/compiler/checker.ts Outdated
return [leftStr, rightStr];
}

function hasNoContextSymbolvalueDeclaration(type: Type): boolean {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This only operates on type.symbol, so can just take the symbol directly. Suggested name symbolValueDeclarationIsContextSensitive and invert the return value. Implementation then is just

   return symbol && symbol.valueDeclaration && isExpression(symbol.valueDeclaration) && isContextSensitive(symbol.valueDeclaration);

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.

Thank you for the review. Since the behavior changes when the return value is inverted, I changed your suggestion a bit.

@RyanCavanaugh RyanCavanaugh self-assigned this Aug 16, 2019
@rchaser53 rchaser53 force-pushed the fix-text-of-undefined-crash branch from 7e1d11b to f2abea4 Compare August 17, 2019 00:22
@RyanCavanaugh
Copy link
Copy Markdown
Member

Thanks!

@RyanCavanaugh RyanCavanaugh merged commit d75de60 into microsoft:master Aug 19, 2019
timsuchanek pushed a commit to timsuchanek/TypeScript that referenced this pull request Sep 11, 2019
* Fix Cannot read property 'text' of undefined crash

* fix condition for tsx

* Rename and improve the method
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsc crashes with TypeError: Cannot read property 'text' of undefined

3 participants