Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8f04f91

Browse filesBrowse files
authored
Add diagnostic info to getNameForExportedSymbol crash (microsoft#39790)
* Add diagnostic info to getNameForExportedSymbol crash * Add JS indicator
1 parent 79e2ed2 commit 8f04f91
Copy full SHA for 8f04f91

1 file changed

+13-1Lines changed: 13 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/services/utilities.ts‎

Copy file name to clipboardExpand all lines: src/services/utilities.ts
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2867,11 +2867,23 @@ namespace ts {
28672867
if (symbol.escapedName === InternalSymbolName.ExportEquals || symbol.escapedName === InternalSymbolName.Default) {
28682868
// Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
28692869
return firstDefined(symbol.declarations, d => isExportAssignment(d) && isIdentifier(d.expression) ? d.expression.text : undefined)
2870-
|| codefix.moduleSymbolToValidIdentifier(Debug.checkDefined(symbol.parent), scriptTarget);
2870+
|| codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget);
28712871
}
28722872
return symbol.name;
28732873
}
28742874

2875+
function getSymbolParentOrFail(symbol: Symbol) {
2876+
return Debug.checkDefined(
2877+
symbol.parent,
2878+
`Symbol parent was undefined. Flags: ${Debug.formatSymbolFlags(symbol.flags)}. ` +
2879+
`Declarations: ${symbol.declarations?.map(d => {
2880+
const kind = Debug.formatSyntaxKind(d.kind);
2881+
const inJS = isInJSFile(d);
2882+
const { expression } = d as any;
2883+
return (inJS ? "[JS]" : "") + kind + (expression ? ` (expression: ${Debug.formatSyntaxKind(expression.kind)})` : "");
2884+
}).join(", ")}.`);
2885+
}
2886+
28752887
/**
28762888
* Useful to check whether a string contains another string at a specific index
28772889
* without allocating another string or traversing the entire contents of the outer string.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.