typescript-go
typescript-go copied to clipboard
Completion does not work for generic type extending tuple or array of all partial type
Extension Version
0.20251202.1
VS Code Version
1.103.2
Operating system Version
Linux Mint 22.2 Zara
Steps to reproduce
- Paste the following code into VS Code.
- 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: https://github.com/microsoft/TypeScript/issues/45617