From 660bcf8a15a90b0a3f03fd269b71fe1bebc67191 Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Sun, 13 Oct 2019 18:01:50 -0700 Subject: [PATCH] Fix type output for types missing symbol reference --- src/index.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index df60ae343..e41439fb6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -414,15 +414,13 @@ export function register (opts: Options = {}): Register { const node = getTokenAtPosition(ts, sourceFile, position) const checker = builderProgram.getProgram().getTypeChecker() - const type = checker.getTypeAtLocation(node) - const documentation = type.symbol ? type.symbol.getDocumentationComment(checker) : [] + const symbol = checker.getSymbolAtLocation(node) - // Invalid type. - if (!type.symbol) return { name: '', comment: '' } + if (!symbol) return { name: '', comment: '' } return { - name: checker.typeToString(type), - comment: ts.displayPartsToString(documentation) + name: checker.typeToString(checker.getTypeOfSymbolAtLocation(symbol, node)), + comment: ts.displayPartsToString(symbol ? symbol.getDocumentationComment(checker) : []) } }