Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bodil/master' into beta
Closes #2017
- Loading branch information
Showing
20 changed files
with
1,091 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import type * as ts from "typescript"; | ||
import * as ts from "typescript"; | ||
|
||
export function getQualifiedName(checker: ts.TypeChecker, symbol: ts.Symbol) { | ||
const qualifiedName = checker.getFullyQualifiedName(symbol); | ||
// I think this is less bad than depending on symbol.parent... | ||
// https://github.com/microsoft/TypeScript/issues/38344 | ||
// It will break if someone names a directory with a quote in it, but so will lots | ||
// of other things including other parts of TypeDoc. Until it *actually* breaks someone... | ||
if (qualifiedName.startsWith('"') && qualifiedName.includes('".')) { | ||
return qualifiedName.substring(qualifiedName.indexOf('".', 1) + 2); | ||
} else { | ||
return qualifiedName; | ||
export function getQualifiedName(symbol: ts.Symbol, defaultName: string) { | ||
// Two implementation options for this one: | ||
// 1. Use the internal symbol.parent, to walk up until we hit a source file symbol (if in a module) | ||
// or undefined (if in a global file) | ||
// 2. Use checker.getFullyQualifiedName and parse out the name from the returned string. | ||
// The symbol.parent method is easier to check for now. | ||
let sym: ts.Symbol | undefined = symbol; | ||
const parts: string[] = []; | ||
while (sym && !sym.declarations?.some(ts.isSourceFile)) { | ||
parts.unshift(sym.name); | ||
sym = sym.parent; | ||
} | ||
|
||
return parts.join(".") || defaultName; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.