Description
Bug Report
Scenario 1: Code completion stopped working by adding an undefined
as the default value for the generic type. TypeScript narrows down the range of expected argument types, and as a result, the code completion doesn't work correctly. It works fine in Typescript 5.0 or below.
Scenario 2: Code completion stopped when using an overloaded function type that combines union types with named tuples containing a generic type parameter. it works fine in Typescript 5.0 or below.
🔎 Search Terms
Code completion issues in typescript 5.1
🕗 Version & Regression Information
The Issue started occurring on typescript 5.1 and beyond. It works fine in versions 5.0 or below.
⏯ Playground Link
Scenario 1: https://tsplay.dev/w1xZGW
Scenario 2: https://tsplay.dev/WKvGZm
💻 Code
Scenario 1:
declare function func<
const T extends 'a' | 'b' | undefined = undefined,
>(arg?: T): string;
// Code completion does not work
func('')
Scenario 2:
interface Func {
<Key extends 'a' | 'b'>(
...args:
| [key: Key, options?: any]
| [key: Key, defaultValue: string, options?: any]
): string;
}
declare const func: Func;
// Code completion does not work
func('');
🙁 Actual behavior
Code completion doesn't work
🙂 Expected behavior
Code completion should work as in the images below:

