Skip to content

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

Open
@ishowta

Description

@ishowta

Bug Report

πŸ”Ž Search Terms

auto completion, suggestion, tuple, array, mapped types

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

// It doesn't work

type BaseTheme = {
  component?: string
}

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

extendTheme([{
  /* Can't autocomplete here */
}])



// list also doesn't work

type BaseTheme2 = {
  component?: string
}

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

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



// with required field works

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

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

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



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

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

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

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

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

declare function extendTheme4WithNoMapped<
  Extensions extends [BaseTheme4]
>(extensions: Extensions): Extensions

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



// no extend tuple works

type BaseTheme5 = {
  component?: string
}

declare function extendTheme5<
  Extensions extends BaseTheme5
>(extensions: [Extensions]): Extensions

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

πŸ™ Actual behavior

No autocomplete

πŸ™‚ Expected behavior

Autocomplete

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions