Skip to content

TypeScript autocompletion broken for generic function parameter with optional properties #30212

@timsuchanek

Description

@timsuchanek
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions