Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ishowta opened this issue Aug 28, 2021 · 2 comments
Labels
Bug A bug in TypeScript Domain: Completion Lists The issue relates to showing completion lists in an editor Effort: Difficult Good luck. Help Wanted You can do this
Milestone

Comments

@ishowta
Copy link

ishowta commented Aug 28, 2021

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

@andrewbranch
Copy link
Member

Probably related to #33937

@andrewbranch andrewbranch added Bug A bug in TypeScript Domain: Completion Lists The issue relates to showing completion lists in an editor labels Aug 30, 2021
@andrewbranch andrewbranch added this to the Backlog milestone Aug 30, 2021
@andrewbranch andrewbranch added Effort: Difficult Good luck. Help Wanted You can do this labels Aug 30, 2021
@ishowta ishowta changed the title Completion does not work in extend tuple or array of object with mapped types Completion does not work in extend tuple or array of optional object Aug 31, 2021
@ishowta
Copy link
Author

ishowta commented Aug 31, 2021

Sorry, the mapped type was not relevant to this problem, so I removed it to simplify problem. (BaseTheme & Record<string, unknown => BaseTheme)

edit: Some patterns did not work without the mapped type, but others did.

@ishowta ishowta changed the title Completion does not work in extend tuple or array of optional object Completion does not work for generic type extending tuple or array of all partial type Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Completion Lists The issue relates to showing completion lists in an editor Effort: Difficult Good luck. Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

2 participants