Repository: TypeScript
Issue: Autocomplete breaks after one property for an array generic
Labels: Help Wanted,Domain: Completion Lists,Possible Improvement

### 🔎 Search Terms

array generic 

### 🕗 Version & Regression Information

- This is the behavior in every version I tried, and I reviewed the FAQ for entries about generics


### ⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.4.2#code/C4TwDgpgBAsg9gEwgGwMLIIYFcDOEA8AKgHxQC8UA3gFBR1QDyASgPwBcsiK62eRxAbQC6Ablr0AggDkAIu05I0mXARLCxAXygAyKAAUMAJ2ABLDMn5jqoSFABCGPAEUsEQyCJQIAD2AQAdgg4UDjAhib+AOYANFAAql6+AUFQcABGAFYQAMbApBQ09FAAtlzIHIRiRQCOru7y8Io8KvhxxJpWNtBxeIYubiDk9o4Q-e74AEQ9bhOxlFD+GMUQHKHhUSJQGJErC1jFaW5QGu3W4NB6cKE4Y4MUDs51HhOX17NUUKbAyLtrEZGbbJwfx+EGrML-Y6nM62W5DaZ9J5QAA++iuwBuTysADMsP5ciZgZ8IKF-p4fKCUrdiAAKWoDCrCACUVHEdCB-hwcB+ADpkHBInSnkzNNRqLj8aYiX5SVEAEzkpKBYK3YS0+nuCoswr0Dlc3n8wUakAi6gaMUy0xRGkCNmsopFUqKDhTXqzO01J4cHUOh2LZYuy3u32+gD0oaghHAkO20AAFm5oAB3EzIZBbLDAOBA4pgH5+D0h2McACMAAZC3QNNE7dXqEJTdYSVbInKbXafQ6nSgXQjgyHjd7K36lrsJkGayGHeHI+5PtGolsdlAE4YILETMAoEngQByLfYLM5vMQAtTutFOsNsRAA

### 💻 Code

```ts
type ModelClause<T> = {
    OR?: ModelClause<T>[];
    AND?: ModelClause<T>[];
} & Partial<T>;

type BaseQuery<T extends string, U extends object> = {
    model: T;
    query?: ModelClause<U>;
};

type UserQuery = BaseQuery<"User", { name: string; age: number }>;
type PostsQuery = BaseQuery<"Posts", { title: string; content: string }>;

type Query = UserQuery | PostsQuery;

function testing<T extends Query>(query: T[]) {
    console.log(query);
}

function testing2<T extends Query[]>(query: T) {
    console.log(query);
}

testing([
    {
        model: "User",
        query: {
            name: "test",
            // Typing age here will autocomplete
            age: 10
        },
    },
]);

testing2([
    {
        model: "User",
        query: {
            name: "test",
            // Try typing age here, it won't autocomplete
        },
    },
]);

```


### 🙁 Actual behavior

For the `testing` function, you correctly get suggested fields when filling in the `query` property.

![CleanShot 2024-03-21 at 11 57 26](https://github.com/microsoft/TypeScript/assets/11869830/4f65c296-1e14-49ec-a65a-1a397d7c1e23)

![CleanShot 2024-03-21 at 11 57 41](https://github.com/microsoft/TypeScript/assets/11869830/5378bbb7-b651-4585-939d-542671f0d560)

However, for `testing2`, the suggestion works for your first property, whichever one you try.

![CleanShot 2024-03-21 at 11 57 57](https://github.com/microsoft/TypeScript/assets/11869830/94a530c0-d39f-4b61-adf5-ab20d078c0db)

![CleanShot 2024-03-21 at 11 58 25](https://github.com/microsoft/TypeScript/assets/11869830/2a3acfdb-bb26-4ff6-b29a-e9f36c71cd18)

However, once the first one is provided, it will stop autocompleting.

![CleanShot 2024-03-21 at 11 58 56](https://github.com/microsoft/TypeScript/assets/11869830/c70261ec-4a88-4174-9fe6-867acf3a633c)

Once one has been provided, you can also list any key, regardless of if it's part of the model.

![CleanShot 2024-03-21 at 12 00 27](https://github.com/microsoft/TypeScript/assets/11869830/2f35780d-2466-4b05-a9fc-fe75c29700dc)

![CleanShot 2024-03-21 at 12 00 45](https://github.com/microsoft/TypeScript/assets/11869830/02b0401e-a9b2-4868-8d29-64d009cdc0c4)


### 🙂 Expected behavior

It should correctly suggest all properties and typecheck additional properties and not stop working after the first one.

### Additional information about the issue

Some extra context why I'm using the `testing2` approach, here's a [playground link](https://www.typescriptlang.org/play?ts=5.4.2#code/C4TwDgpgBAsg9gEwgGwMLIIYFcDOEA8AKgHxQC8UA3gFBR1QDyASgPwBcsiK62eRxAbQC6Ablr0AggDkAIu05I0mXARLCxAXygAyKAAUMAJ2ABLDMn5jqoSFABCGPAEUsEQyCJQIAD2AQAdgg4UDjAhib+AOYANFAAql6+AUFQcABGAFYQAMbApBQ09FAAtlzIHIRiRQCOru7y8Io8KvhxxJpWNtBxeIaNKORUUP4YxRAcoeFRIlAYkePDWMVpblAaYl3xvS5uIIMOznUeAEQ9bsexZ31l7dbg0Hpwof3Ig5RQpsDIC5MRkTPZOD+PzAiZhP5rDb3fRPYA4HbufaOCAIk6PUI4C4w543TrQ1GDK4EgA+2LhqLxtlRhDgL34g0IiRBKSJR3EdBYWzcL3ZUAqTOSwXR5LZRU5wp5RQ4-ggADc3JToDAMGBqXAmBAcFhkMBPD5mcFDBAMAggcg9qjhPkqLyBABpKARKAAawgIDgADMoIQhBw1XTCPahLd1tRqB6sP5ciYgR9NaYogAmPVJQLBS3BgAUtTcJk1FQAlBxlaqjjSNVqdfTCvRAf4cHBvgA6ZBwSLZup5nAFqxFI3ALCGfxQYSzYIltUV7W6kiaMN10IjlSGWKlRRCQZ+UJ-ROZgS8mtFOhrlAcU69C68mpHDiHo9FEZjM9b4CX+90DTRXmfg9X+gn8ooGOYVMS-d8oBzdxbz-e9Pm+M8AAkUFbKAAHc4EMZAEGOGC1m-agN0cKAF2AHtqCAA) that shows what I'm trying to achieve.

Basically, I want to make sure that the return value of my function adheres to what was passed in. I haven't found a way to do it with `testing`, so I went for `testing2`, which is a decrease in DX since it'll only autocomplete one query parameter.

But the return value is exactly what I want

![CleanShot 2024-03-21 at 12 10 32](https://github.com/microsoft/TypeScript/assets/11869830/fb2fe844-d2e7-4ccb-8f2d-062511ae7776)

(for reference for others who would stumble upon this issue, the last `as const` is important to ensure it returns the correct order, else it will have a type of `const returnValue: (UserModel | PostModel)[]`)