Skip to content

Autocompletion broken for generic function parameter with optional properties #30507

Closed
@timsuchanek

Description

@timsuchanek

As #30212 has been closed incorrectly (it's not a duplicate) and the comments there are not reacted on anymore, I reopen the issue here.

  • VSCode Version: Version 1.31.1 (1.31.1)
  • OS Version: macOS High Sierra 10.13.6

Steps to Reproduce:

typescript autocompletion

Open a TypeScript file with this content:

type Params = {
  foo?: string
  bar?: number
  visible?: boolean
}

export const obj = {
  paramsIdentityInline<T extends Params>(params: T): T {
    return params
  },
}

obj.paramsIdentityInline({
  
})

function direct(params: Params) {}

direct({

})

When you have a type which only consists of optional properties and use it in a generic context as a type parameter, the autocompletion doesn't work, while it works when you use that type directly without being generic in the function signature.
However, as soon as at least one of the properties on that type is non-optional, the autocompletion works, even for the optional properties.

Does this issue occur when all extensions are disabled?: Yes

As @hediet correctly notes, the referenced fix doesn't work for this bug.
Please see #30212 for more infos.

Ping @mjbvz

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions