Skip to content

Convert to async function refactoring loses generic parameter #28529

@ianp

Description

@ianp

Issue Type: Bug

This method

private get<T = any>(url: string, options: GotOptions<any>) {
  return this.authorize('GET', url, options)
      .then(opts => await got.get(url, opts))
      .then<T>(parseJson)
}

gets converted into this

private async get<T = any>(url: string, options: GotOptions<any>) {
  const opts = await this.authorize('GET', url, options)
  const response = await got.get(url, opts)
  return parseJson(response)
  //              ^ look, no <T> !
}

it should keep the explicit parameter on parseJson<T>.

Here’s the parseJson function in case that helps:

const parseJson = <T>(response: Response<string>) => JSON.parse(response.body) as T

VS Code version: Code - Insiders 1.30.0-insider (5fc60ec, 2018-11-14T07:58:01.008Z)
OS version: Darwin x64 18.2.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 1, 2, 2
Memory (System) 16.00GB (2.98GB free)
Process Argv -psn_0_1835456
Screen Reader no
VM 0%
Extensions (14)
Extension Author (truncated) Version
vscode-hie-server ala 0.0.24
Handlebars and 0.4.1
bracket-pair-colorizer Coe 1.0.61
gitlens eam 8.5.6
prettier-vscode esb 1.7.2
input-assist fre 0.0.7
vscode-pull-request-github Git 0.2.3
language-haskell jus 2.5.0
dotenv mik 1.0.1
vsliveshare ms- 0.3.954
ide-purescript nwo 0.19.1
language-purescript nwo 0.2.0
elm sbr 0.22.0
FilterText yhi 0.0.11

(1 theme extensions excluded)

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: LS: Refactoringse.g. extract to constant or function, rename symbolFix AvailableA PR has been opened for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions