Skip to content

Commit

Permalink
Fix type output for types missing symbol reference
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Oct 14, 2019
1 parent e0a83b5 commit 660bcf8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) : [])
}
}

Expand Down

0 comments on commit 660bcf8

Please sign in to comment.