Repository: TypeScript
Issue: No suggestions for extended classes.
Labels: Bug,Domain: Completion Lists,Domain: JavaScript

_From @zavr-1 on September 20, 2018 6:10_

Issue Type: <b>Bug</b>

There are no suggestions of the `super` class's methods.

VS Code version: Code - Insiders 1.28.0-insider (cd9d71a31f731baf17330a84448c3efdeabc873f, 2018-09-17T05:12:08.581Z)
OS version: Darwin x64 15.6.0

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM)2 Duo CPU     P7350  @ 2.00GHz (2 x 2000)|
|GPU Status|2d_canvas: unavailable_software<br>checker_imaging: disabled_off<br>flash_3d: unavailable_software<br>flash_stage3d: unavailable_software<br>flash_stage3d_baseline: unavailable_software<br>gpu_compositing: unavailable_software<br>multiple_raster_threads: disabled_off<br>native_gpu_memory_buffers: unavailable_software<br>rasterization: unavailable_software<br>video_decode: unavailable_software<br>video_encode: unavailable_software<br>webgl: unavailable_off<br>webgl2: unavailable_off|
|Load (avg)|2, 2, 2|
|Memory (System)|8.00GB (1.68GB free)|
|Process Argv|/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron -psn_0_36873|
|Screen Reader|no|
|VM|0%|

</details><details><summary>Extensions (5)</summary>

Extension|Author (truncated)|Version
---|---|---
vscode-eslint|dba|1.6.0
svg|joc|0.1.2
autoimport|ste|1.5.3
code-spell-checker|str|1.6.10
vscode-wakatime|Wak|1.2.3


</details>
<!-- generated by issue reporter -->

Suppose I want to spawn a process, and return it:

```js
export default function spawnCommand(command, args = [], options = {}) {
  if (!command) throw new Error('Please specify a command to spawn.')
  const proc = spawn(command, args, options)

  return proc
}
```

Then in suggestions, I can easily access it.

![screen shot 2018-09-20 at 09 03 02](https://user-images.githubusercontent.com/21156791/45798835-080cec80-bcb4-11e8-9ea4-0083307b2ca3.png)

Now suppose I want to add a `promise` property resolved on exit to it:

```js
export default function spawnCommand(command, args = [], options = {}) {
  if (!command) throw new Error('Please specify a command to spawn.')
  const proc = spawn(command, args, options)

  const promise = getPromise(proc)
  proc.promise = promise
  return proc
}
```

![screen shot 2018-09-20 at 09 04 35](https://user-images.githubusercontent.com/21156791/45798886-37235e00-bcb4-11e8-861d-63de38d6aa9c.png)

It is not suggested. What I really want to do, is to be able to write

```js
/** @typedef {Object} PromiseResult
 * @prop {string} stdout The accumulated result of the `stdout` stream.
 * @prop {string} stderr The accumulated result of the `stderr` stream.
 * @prop {number} code The code with which the process exited.
 *
 * @typedef {ChildProcess} ChildProcessWithPromise A child process with an extra `promise` property.
 * @prop {Promise.<PromiseResult>} promise A promise resolved when the process exits.
 */
```

And then use the `ChildProcessWithPromise` as my return type. However, this does not work as `ChildProcessWithPromise` type is only recognised as `ChildProcess`. 

Therefore, I want to extend the `ChildProcess` class, and transform the instance I got from a `spawn` into it:

```js
class ChildProcessWithPromise extends ChildProcess {
  /**
   * @param {ChildProcess}
   * @param {Promise.<PromiseResult>} promise The promise resolved when the process exits.
   */
  constructor(p, promise) {
    super()
    this.promise = promise
    Object.assign(this, p)
  }
}

export default function spawnCommand(command, args = [], options = {}) {
  if (!command) throw new Error('Please specify a command to spawn.')
  const proc = spawn(command, args, options)

  const promise = getPromise(proc)
  const p = new ChildProcessWithPromise(proc, promise)
  return p
}
```

However, now I loose all of the `ChildProcess` properties:

![screen shot 2018-09-20 at 09 08 07](https://user-images.githubusercontent.com/21156791/45799020-bf096800-bcb4-11e8-899c-787033b87fc2.png)

So could you please a) suggest extra properties written with `typedef`, and b) fix the suggestions for extended classes? 

Much appreciated!!! This is btw for my [`spawncommand`](https://github.com/artdecocode/spawncommand) package which just reduces the need to manually create a promise for processes.

_Copied from original issue: Microsoft/vscode#59015_