Repository: TypeScript
Issue: Typescript: autocomplete won't work when "Parameters<Fn>" is used and "Fn" is passed through a generic
Labels: Bug

Issue Type: <b>Bug</b>

Hello everybody, I wasn't entirely sure of where to post this: vscode or typescript? Since Typescript correctly shows the type and the problem lies in the autocompletion itself, I'm thinking there's a higher chance for this problem to be related to vscode.

The problem is: the autocomplete won't work even though Typescript clearly knows the type. This happens when I use the helper "Parameters" from typescript applied to a function whose type has been passed through a generic. Let me show an example:

```typescript
interface Test {
  myFunction: (params: { a: number, b: number }) => void
}

type Wrapped<Fn extends (params: any) => any> = {
  myFunction: (params: Parameters<Fn>[0]) => ReturnType<Fn>,
}

function wrap<T extends Test>(test: T) {
  let result: Wrapped<T['myFunction']>

  return result
}

let t: Test
let w = wrap(t)

t.myFunction({})
w.myFunction({})
```

The autocompletion works as expected in `t.myFunction({})`, but it won't work at all in `w.myFunction({})`. The following image exemplifies the behavior:

![example 1](https://i.ibb.co/kq361GT/ts-bug1.gif)

Typescript correctly assigns the type for both functions, see:

![example 2](https://i.ibb.co/r4GPWP6/ts-bug2.gif)

Is this behavior expected? If yes, why two equal types show different behaviors when autocompleting?

I can easily fix this by instead of passing the function type as a generic, I pass the object type, see:

```typescript
interface Test {
  myFunction: (params: { a: number, b: number }) => void
}

type Wrapped<T extends Test> = {
  myFunction: (params: Parameters<T['myFunction']>[0]) => ReturnType<T['myFunction']>,
}

function wrap<T extends Test>(test: T) {
  let result: Wrapped<T>

  return result
}

let t: Test
let w = wrap(t)

t.myFunction({})
w.myFunction({})
```

The autocompletion works fine for both `t.myFunction` and `w.myFunction` now. But why doesn't it work when the function type itself is passed to the generic?

I appreciate any help. Thanks.

--------------
EDIT: it seems the problem occurs when using `extends (params: any) => any`. In the second example, where both calls had the autocompletion working, if I change `type Wrapped<T extends Test>` to `type Wrapped<T extends { myFunction: (params: any) => any }>` it goes back to the behavior of my first example. Again, the type gets correctly assigned by Typescript, the autocompletion is the only thing that won't work. If I use `extends any` instead of `extends (params: any) => any` to type the function, it will work in all cases. Pretty weird right?

VS Code version: Code 1.41.0 (9579eda04fdb3a9bba2750f15193e5fafe16b959, 2019-12-11T18:37:42.077Z)
OS version: Windows_NT x64 10.0.18362

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz (6 x 3600)|
|GPU Status|2d_canvas: enabled<br>flash_3d: enabled<br>flash_stage3d: enabled<br>flash_stage3d_baseline: enabled<br>gpu_compositing: enabled<br>metal: disabled_off<br>multiple_raster_threads: enabled_on<br>oop_rasterization: disabled_off<br>protected_video_decode: unavailable_off<br>rasterization: enabled<br>skia_renderer: disabled_off<br>surface_control: disabled_off<br>surface_synchronization: enabled_on<br>video_decode: enabled<br>viz_display_compositor: enabled_on<br>viz_hit_test_surface_layer: disabled_off<br>webgl: enabled<br>webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|15.94GB (10.81GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|
</details><details><summary>Extensions (7)</summary>

Extension|Author (truncated)|Version
---|---|---
color-info|bie|0.5.1
vscode-eslint|dba|2.0.11
auto-close-tag|for|0.5.6
vscode-styled-components|jpo|0.0.27
remote-wsl|ms-|0.41.6
markdown-preview-enhanced|shd|0.5.0
code-spell-checker|str|1.7.20


</details>
<!-- generated by issue reporter -->