documentationjs / documentationjs/documentation

TypeScript support crashing on valid TS files

Open
#1,260 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.8k
Forks
481
PR merge metrics
No merged PRs in 30d

Description

We've been using documentation.js for https://github.com/keybase/keybase-bot for a while and up until our migration to TypeScript it worked perfectly. I'm currently trying to get it running once again and I'm struggling to get it to properly parse TS.

```
✘ piotr@workstation  ~/gopath/src/github.com/keybase/keybase-bot   pzduniak/ts-docs ✚  yarn docs
yarn run v1.15.2
$ documentation readme src/index.ts --config documentation.yml --section=API
Error: Parsing file /home/piotr/gopath/src/github.com/keybase/keybase-bot/src/index.ts: Unexpected token (15:9)
at Deps.parseDeps (/home/piotr/gopath/src/github.com/keybase/keybase-bot/node_modules/module-deps-sortable/index.js:515:28)
at fromSource (/home/piotr/gopath/src/github.com/keybase/keybase-bot/node_modules/module-deps-sortable/index.js:450:44)
at /home/piotr/gopath/src/github.com/keybase/keybase-bot/node_modules/module-deps-sortable/index.js:444:17
at ConcatStream. (/home/piotr/gopath/src/github.com/keybase/keybase-bot/node_modules/module-deps-sortable/node_modules/concat-stream/index.js:36:43)
at ConcatStream.emit (events.js:194:15)
at finishMaybe (/home/piotr/gopath/src/github.com/keybase/keybase-bot/node_modules/module-deps-sortable/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:475:14)
at endWritable (/home/piotr/gopath/src/github.com/keybase/keybase-bot/node_modules/module-deps-sortable/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:485:3)
at ConcatStream.Writable.end (/home/piotr/gopath/src/github.com/keybase/keybase-bot/node_modules/module-deps-sortable/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:455:41)
at DuplexWrapper.onend (/home/piotr/gopath/src/github.com/keybase/keybase-bot/node_modules/readable-stream/lib/_stream_readable.js:577:10)
at Object.onceWrapper (events.js:277:13)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

```

The code is located there: https://github.com/keybase/keybase-bot/pull/154. The parser is failing on the following snippet of code:

```ts
import Service from './service'
import ChatClient from './chat-client'
import WalletClient from './wallet-client'
import TeamClient from './team-client'
import {BotInfo} from './utils/keybaseStatus'
import mkdirp from 'mkdirp'
import {randomTempDir, whichKeybase, rmdirRecursive} from './utils'
import {promisify} from 'util'
import {copyFile} from 'fs'
import path from 'path'
import {InitOptions} from './utils/options'

/** A Keybase bot. */
class Bot {
public chat: ChatClient // FAILS ON THIS LINE
public wallet: WalletClient
public team: TeamClient
private _workingDir: string // where KB binary copied, and homeDir (if not existing svc)
private _service: Service

/**
* Create a bot. Note you can't do much too exciting with your bot after you instantiate it; you have to initialize it first.
* @memberof Bot
* @example
* const bot = new Bot()
*/
public constructor() {
this._workingDir = randomTempDir()
this._service = new Service(this._workingDir)
this.chat = new ChatClient(this._workingDir)
this.wallet = new WalletClient(this._workingDir)
this.team = new TeamClient(this._workingDir)
}
```

Any ideas on how we could make it work? Due to my unfamiliarity with this project's internals I'm struggling to figure out the root cause.

* What version of documentation.js are you using?: 11.0.1
* How are you running documentation.js (on the CLI, Node.js API, Grunt, other?): CLI using yarn

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.