Skip to content

fix(36936): tsc crashes with: Cannot read property 'get' of undefined#37077

Merged
sandersn merged 1 commit intomicrosoft:masterfrom
a-tarasyuk:bug/36936
Mar 17, 2020
Merged

fix(36936): tsc crashes with: Cannot read property 'get' of undefined#37077
sandersn merged 1 commit intomicrosoft:masterfrom
a-tarasyuk:bug/36936

Conversation

@a-tarasyuk
Copy link
Copy Markdown
Contributor

Fixes #36936

@a-tarasyuk a-tarasyuk marked this pull request as ready for review February 27, 2020 19:06
@sandersn sandersn added the For Milestone Bug PRs that fix a bug with a specific milestone label Mar 9, 2020
@sandersn sandersn requested a review from andrewbranch March 9, 2020 23:22
@sandersn sandersn requested a review from weswigham March 10, 2020 22:49
Copy link
Copy Markdown
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

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

I'm OK with the change as-is, but it'd be nicer to track down why we're calling resolveExternalModuleSymbol on a symbol with no exports instead. Generally speaking, we only call that on a symbol we know to be a module, which, by extension, has exports. So the "real" fix for the underlying issue probably should be tracking down where we fail to give exports to a module-ish symbol.

@a-tarasyuk
Copy link
Copy Markdown
Contributor Author

@weswigham You are right. Sorry that I didn't provide more details. I was able to reproduce the bug by debugging the checker. The issue in the interface property, in my case it called Test. I'm not sure that adding an additional condition in resolveExternalModuleSymbol is the right fix for this case, maybe resolveAlias should not return property Test.

getAccessibleSymbolChain -> forEachSymbolTableInScope

11

For this case forEachSymbolTableInScope returns location.locals

22

Test is the name from import statement

getAccessibleSymbolChainFromSymbolTable -> trySymbolTable

33

For the Test symbol, resolveAlias returns a reference to the Test property which is declared inside interface Foo

44
55

Then getCandidateListForSymbol ->
66

-> getExportsOfSymbol -> getExportsOfModule -> getExportsOfModuleWorker
77

And finally in resolveExternalModuleSymbol we get moduleSymbol without exports.

@sandersn sandersn merged commit a510cad into microsoft:master Mar 17, 2020
@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

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

tsc crashes with: Cannot read property 'get' of undefined

4 participants