microsoft / microsoft/TypeScript

Instantiation expressions should filter overloads by type parameter constraints

Abierto
#63,126 6 comentarios 0 reacciones 1 asignado Ver en GitHub

@ahejlsberg ya está trabajando en esto.

Desde el 13/2/2026.

Needs Investigation
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

### 🔎 Search Terms

call signature constructor signature type parameter

### 🕗 Version & Regression Information

Tested in `v4.7.4`, `v5.9.3` and `Nightly` (`v6.0.0-dev.20260204`)
Syntax error before `v4.7.4`

### ⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.9.3#code/LAKAJgpgxgNghgJwgAigewHYGcAuyBmAXMgN6jIXIA8AKgHwAUAHsTQJSsDc5lGEA7rWQQmOCBjBZkaAEYAraDkYtk7LqAC+3EKHTY8cZAF4CVEshnEAjMg11tAegeVkAPQD8oXZlwXjpq3tQJxcPYOcaAE8ABxQAcgwAVwBbGQgEOOQwNAgpDDQ8LDgcAEssfEjkHAALFD1cBDgSjDw42QUoHDigA

### 💻 Code

```ts
declare const f: {
(x: T): T;
new(x: T): T;
};

const a = f<{ b: 1 }>;
// ^? const a: { (x: { b: 1; }): { b: 1; }; new (x: { b: 1; }): { b: 1; }; }

const b = f<1>;
// ^? const b: { (x: 1): 1; new (x: T): T; }
// Type 'number' does not satisfy the constraint 'object'
```

### 🙁 Actual behavior

The type argument I pass to the object must met the requirements of both signatures

### 🙂 Expected behavior

The incompatible signature should just be filtered out, leaving only the compatible one
```ts
const b = f<1>;
// ^? const b: (x: number) => number
```

### Additional information about the issue

_No response_

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.