Skip to content

Completion does not work for generic type extending tuple or array of all partial type #2182

@ishowta

Description

@ishowta

Extension Version

0.20251202.1

VS Code Version

1.103.2

Operating system Version

Linux Mint 22.2 Zara

Steps to reproduce

  1. Paste the following code into VS Code.
  2. In each example, type com... and check whether it is auto-completed.

Issue

// All partial type works

type AllPartialObject = {
  component?: string
}

declare function extendTheme1<Extensions extends [AllPartialObject]>(
  extensions: Extensions
): void

extendTheme1([
  {
    /* Can autocomplete `component` here */
  },
])

// But all partial type with mapped types doesn't work

declare function extendTheme2<
  Extensions extends [AllPartialObject & Record<string, unknown>],
>(extensions: Extensions): void

extendTheme2([
  {
    /* Can't autocomplete `component` here */
  },
])

// with required field works

type PartialWithRequiredObject = {
  component?: string
  requiredField: string
}

declare function extendTheme3<
  Extensions extends [PartialWithRequiredObject & Record<string, unknown>],
>(extensions: Extensions): void

extendTheme3([
  {
    /* Can autocomplete `component` here */
  },
])

// but with required field and complete required field doesn't work

extendTheme3([
  {
    requiredField: 'foo',
    /* Can't autocomplete `component` here */
  },
])

// also BaseTheme with no mapped types doesn't work too

declare function extendTheme4<Extensions extends [PartialWithRequiredObject]>(
  extensions: Extensions
): Extensions

extendTheme4([
  {
    requiredField: 'foo',
    /* Can't autocomplete `component` here */
  },
])

// no extend tuple works

declare function extendTheme5<
  Extensions extends AllPartialObject & Record<string, unknown>,
>(extensions: [Extensions]): Extensions

extendTheme5([
  {
    /* Can autocomplete `component` here */
  },
])

Original issue: microsoft/TypeScript#45617

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: EditorRelated to the LSP server, editor experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions