microsoft / microsoft/TypeScript

Unexpected distributive behaviour on type alias

Abierto
#62,761 6 comentarios 1 reacción 1 asignado Ver en GitHub

@ahejlsberg ya está trabajando en esto.

Desde el 17/11/2025.

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

distributive conditional types, naked type parameter, type alias, unions

🕗 Version & Regression Information
  • This changed between versions 3.8.3 and 3.9.7.
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about distributive conditional types, naked type parameter, type alias, unions.
⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.9.3#code/C4TwDgpgBAaghgGwK7QLxQIxQD5QEwBQBokUAKhALZhToDa8yEAulBAB7AQB2AJgM5Q6AS24AzCACdYzAlCgB+WG048BUJNwDW3APYB3bnPmKhMADSxEKWSagAuKNwgA3KccfO3koiWgAlCH4kBGBacioaAHoolUgAYzC6DEssXDxWXDo8VJx8WxMYgD0FIA

💻 Code
type Value = 1 | 2

type Result = [Value] extends [infer V]
  ? V extends unknown
    ? [V, Value]
    : never
  : never
🙁 Actual behavior
[1, 1] | [2, 2]
🙂 Expected behavior
[1, 1 | 2] | [2, 1 | 2]
Additional information about the issue

It shouldn't work the way it does now, for several reasons:

  1. Value is not naked type parameter.
  2. Using brackets, distributive behaviour must be disabled.

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.