mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Adds support for showing default exports in the navtree (#35477)
* Adds support for showing default exports in the navtree - Fixes #34601 * Handle the feedback in #35477 * Navigation items using default export or export = will get noted if they are a const vs function
This commit is contained in:
@@ -860,10 +860,10 @@ namespace FourSlash {
|
||||
|
||||
if (kind !== undefined || kindModifiers !== undefined) {
|
||||
if (actual.kind !== kind) {
|
||||
this.raiseError(`Unexpected kind for ${actual.name}: Expected ${kind}, actual ${actual.kind}`);
|
||||
this.raiseError(`Unexpected kind for ${actual.name}: Expected '${kind}', actual '${actual.kind}'`);
|
||||
}
|
||||
if (actual.kindModifiers !== (kindModifiers || "")) {
|
||||
this.raiseError(`Bad kind modifiers for ${actual.name}: Expected ${kindModifiers || ""}, actual ${actual.kindModifiers}`);
|
||||
this.raiseError(`Bad kindModifiers for ${actual.name}: Expected ${kindModifiers || ""}, actual ${actual.kindModifiers}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2873,7 +2873,7 @@ namespace FourSlash {
|
||||
|
||||
private verifyNavigationTreeOrBar(json: any, tree: any, name: "Tree" | "Bar", options: { checkSpans?: boolean } | undefined) {
|
||||
if (JSON.stringify(tree, replacer) !== JSON.stringify(json)) {
|
||||
this.raiseError(`verifyNavigation${name} failed - expected: ${stringify(json)}, got: ${stringify(tree, replacer)}`);
|
||||
this.raiseError(`verifyNavigation${name} failed - \n${showTextDiff(stringify(json), stringify(tree, replacer))}`);
|
||||
}
|
||||
|
||||
function replacer(key: string, value: any) {
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace ts.NavigationBar {
|
||||
|
||||
/**
|
||||
* Maximum amount of characters to return
|
||||
* The amount was choosen arbitrarily.
|
||||
* The amount was chosen arbitrarily.
|
||||
*/
|
||||
const maxLength = 150;
|
||||
|
||||
@@ -307,6 +307,7 @@ namespace ts.NavigationBar {
|
||||
addNodeWithRecursiveChild(node, getInteriorModule(<ModuleDeclaration>node).body);
|
||||
break;
|
||||
|
||||
case SyntaxKind.ExportAssignment:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.IndexSignature:
|
||||
@@ -681,6 +682,9 @@ namespace ts.NavigationBar {
|
||||
return isExternalModule(sourceFile)
|
||||
? `"${escapeString(getBaseFileName(removeFileExtension(normalizePath(sourceFile.fileName))))}"`
|
||||
: "<global>";
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return isExportAssignment(node) && node.isExportEquals ? InternalSymbolName.ExportEquals : InternalSymbolName.Default;
|
||||
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
|
||||
@@ -438,6 +438,10 @@ namespace ts {
|
||||
}
|
||||
case SyntaxKind.Identifier:
|
||||
return isImportClause(node.parent) ? ScriptElementKind.alias : ScriptElementKind.unknown;
|
||||
case SyntaxKind.ExportAssignment:
|
||||
const scriptKind = getNodeKind((node as ExportAssignment).expression);
|
||||
// If the expression didn't come back with something (like it does for an identifiers)
|
||||
return scriptKind === ScriptElementKind.unknown ? ScriptElementKind.constElement : scriptKind;
|
||||
default:
|
||||
return ScriptElementKind.unknown;
|
||||
}
|
||||
@@ -1154,6 +1158,7 @@ namespace ts {
|
||||
if (flags & ModifierFlags.Abstract) result.push(ScriptElementKindModifier.abstractModifier);
|
||||
if (flags & ModifierFlags.Export) result.push(ScriptElementKindModifier.exportedModifier);
|
||||
if (node.flags & NodeFlags.Ambient) result.push(ScriptElementKindModifier.ambientModifier);
|
||||
if (node.kind === SyntaxKind.ExportAssignment) result.push(ScriptElementKindModifier.exportedModifier);
|
||||
|
||||
return result.length > 0 ? result.join(",") : ScriptElementKindModifier.none;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user