microsoft / microsoft/TypeScript

Unrelated interface causes assignability to change

Abierto
#56,099 2 comentarios 3 reacciones 1 asignado Ver en GitHub

@ahejlsberg ya está trabajando en esto.

Desde el 16/10/2023.

Needs Investigation
Lenguaje dominante
Go
Estrellas
111k
Forks
14.4k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

Descripción

🔎 Search Terms

5.3 regression

🕗 Version & Regression Information
  • This changed between versions 5.3.0-dev.20230823 and 5.3.0-dev.20230824
⏯ Playground Link

Playground Link

💻 Code
export { }
interface Map<V> extends Collection<V> {
    flatMap<VM>(): Map<VM>;
}

interface Collection<V> {
    value: V; // sprinkle some covariance
    map: Map<V>;
    concat(): Collection<unknown>;
    flatMap(): Collection<V>;
    flatMap<VM>(): Collection<VM>;
}

// Comment out and it works like in 5.2
interface Keyed extends Collection<number> {
    concat(): Keyed;
}

type R = Map<never> extends Collection<infer V> ? V : "NO";

const r = null! as R;
const t: "NO" = r;
🙁 Actual behavior

R is unknown. Removing Keyed makes R "NO", even though Keyed is unused otherwise.

🙂 Expected behavior

Not really sure. I'd settle for the stable 5.2 behavior, which is for R to be "NO" although that also seems wrong (Why doesn't Map<never> extends Collection? If we remove flatMap(): Collection<V> from Collection then Map<never> extends Collection. This seems like the correct behavior.)

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.