Repository: TypeScript
Issue: Remapped property names has wrong completion, error messages and code actions (snippets)
Labels: Bug,Help Wanted,Domain: Completion Lists

### 🔎 Search Terms

"remapped property", "mapped types"

### 🕗 Version & Regression Information

- This changed between versions 4.9.5 and 5.0.4

### ⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.7.0-dev.20240826#code/C4TwDgpgBAMglgZ2BAdhATgFQgWzAGwENkAeTAGigGUoIAPZFAEwSiXThQHNKBJWhqhZtgHblAC8UAEQASAN4BGAL7SAfJKjyAUFD0BtANJROUANYQQAewBmUTFEKtj9RsPacuuvT6gB+agE3VgADBU4bDCgAMWUFXjj5CKiAJWUQ-ygw+ViFQ0S0jIAuKGMSwwBdb18oEoAKfERGDHqwQhB8K0ImEswjCoBKSQ0ANys4JiGJUfGmAG5tZQXQSFgm1ABBAGNgOCsUQgAjfAgSAFENKXgkVAxsPCJSM8ppbqYAKmvm9GkoAB8ZOhcFYRhBPus0D8Xu91MtwNAAMKNLZmM6glDAKgAVzAYCs6GAmi+mx2ewOx1O8igSLgKJKAHIEFYcBAALRbZFmVkQdHAVltDpdJj0qDKNQLbRbfZIKCEqR1AYlGkotGoTE4vEE4ZaapQIHALHoFA6mo+AD0ZqgvGNmBoAAUiCAuOgrFjmLKABYYaCIKAoKxsFBwXEQYCsOr4q1QJj7emEsz+gDuUA9VmTwADqCOJ09uAGut8FqghyxhNMIwQUqY0GAXqBJlYhEDwcghJCb2VZmJkIaEIwAwydRWEErHDAwAAdAgsVwuCPJxynAgALK4Q4YKhBkNhidZik9WXoLEQfOmvRFxMe2kekwoBAYMNZTu9m6QoZU2QABlFGU4N26UC2FkHact2GAvt875QF+P66soixAA

### 💻 Code

```ts
type ListenerTemplate<T, S extends string, I extends string = "${1}"> = {
   [K in keyof T as K extends string
       ? S extends `${infer F}${I}${infer R}` ? `${F}${K}${R}` : K : K]
       : (listener: (payload: T[K]) => void) => void;
};
type ListenActionable<E> = ListenerTemplate<E, "add*Listener" | "remove*Listener", "*">;
type ClickEventSupport = ListenActionable<{ Click: 'some-click-event-payload' }>;

const t = (): ClickEventSupport => {
    return {
        // In TS Playground there is no snippets (or I don't know how to enable them)
        // but in vscode there is a snippet `addClickListener(listener)` (typescript.suggest.classMemberSnippets.enabled: true)
        // which inserts `Click(listener) { $0 }` instead of `addClickListener(listener) { $0 }`
    }
}
```

### 🙁 Actual behavior

Completion with snippets is generating methods which are not in the interface:

```ts
type ListenerTemplate<T, S extends string, I extends string = "${1}"> = {
    [K in keyof T as K extends string
    ? S extends `${infer F}${I}${infer R}` ? `${F}${K}${R}` : K : K]
    : (listener: (payload: T[K]) => void) => void;
};
type ListenActionable<E> = ListenerTemplate<E, "add*Listener" | "remove*Listener", "*">;
type ClickEventSupport = ListenActionable<{ Click: 'some-click-event-payload' }>;

const t = (): ClickEventSupport => {
    return {
        Click(listener) {
            
        },
    }
}
```


### 🙂 Expected behavior

I expect  completion to provide working snippets.

```ts
type ListenerTemplate<T, S extends string, I extends string = "${1}"> = {
    [K in keyof T as K extends string
    ? S extends `${infer F}${I}${infer R}` ? `${F}${K}${R}` : K : K]
    : (listener: (payload: T[K]) => void) => void;
};
type ListenActionable<E> = ListenerTemplate<E, "add*Listener" | "remove*Listener", "*">;
type ClickEventSupport = ListenActionable<{ Click: 'some-click-event-payload' }>;

const t = (): ClickEventSupport => {
    return {
        addClickListener(listener) {
            
        },
    }
}
```

### Additional information about the issue

I already reported a related [bug](https://github.com/microsoft/TypeScript/issues/54694),  it was fixed partially: only code action for implement interface was fixed.

I plan to fix this bug by myself, MR is in progress.