mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Add diagnostic info to getNameForExportedSymbol crash (#39790)
* Add diagnostic info to getNameForExportedSymbol crash * Add JS indicator
This commit is contained in:
parent
79e2ed2e77
commit
8f04f91ef5
@ -2867,11 +2867,23 @@ namespace ts {
|
||||
if (symbol.escapedName === InternalSymbolName.ExportEquals || symbol.escapedName === InternalSymbolName.Default) {
|
||||
// Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
|
||||
return firstDefined(symbol.declarations, d => isExportAssignment(d) && isIdentifier(d.expression) ? d.expression.text : undefined)
|
||||
|| codefix.moduleSymbolToValidIdentifier(Debug.checkDefined(symbol.parent), scriptTarget);
|
||||
|| codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget);
|
||||
}
|
||||
return symbol.name;
|
||||
}
|
||||
|
||||
function getSymbolParentOrFail(symbol: Symbol) {
|
||||
return Debug.checkDefined(
|
||||
symbol.parent,
|
||||
`Symbol parent was undefined. Flags: ${Debug.formatSymbolFlags(symbol.flags)}. ` +
|
||||
`Declarations: ${symbol.declarations?.map(d => {
|
||||
const kind = Debug.formatSyntaxKind(d.kind);
|
||||
const inJS = isInJSFile(d);
|
||||
const { expression } = d as any;
|
||||
return (inJS ? "[JS]" : "") + kind + (expression ? ` (expression: ${Debug.formatSyntaxKind(expression.kind)})` : "");
|
||||
}).join(", ")}.`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Useful to check whether a string contains another string at a specific index
|
||||
* without allocating another string or traversing the entire contents of the outer string.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user