Skip to content

Commit

Permalink
Fix crash when accessing type information
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Sep 22, 2015
1 parent 07d8633 commit 088100c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/bin/ts-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ function startRepl () {
;(<any> repl).defineCommand('type', {
help: 'Check the type of a TypeScript identifier',
action: function (identifier: string) {
if (!identifier) {
;(<any> repl).displayPrompt()
return
}

const undo = evalFile.input

evalFile.input += identifier
Expand Down
6 changes: 3 additions & 3 deletions src/ts-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ export function register (opts?: Options) {
addFileName(fileName)

const info = service.getQuickInfoAtPosition(fileName, position)
const name = ts.displayPartsToString(info.displayParts || [])
const comment = ts.displayPartsToString(info.documentation || [])
const name = ts.displayPartsToString(info ? info.displayParts : [])
const comment = ts.displayPartsToString(info ? info.documentation : [])

return chalk.bold(name) + (comment ? EOL + comment : '')
return chalk.bold(name) + (comment ? `\n${comment}` : '')
}

// Attach the loader to each defined extension.
Expand Down

0 comments on commit 088100c

Please sign in to comment.