microsoft / microsoft/TypeScript
Incorrect type resolution with nested constructors
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
🔎 Search Terms
nested constructors type resolution anti-pattern
🕗 Version & Regression Information
- This changed between versions ______ and _______
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because I only report bugs to be helpful, but I don't have time to dive deeper myself.
⏯ Playground Link
💻 Code
export declare const Base: {
new(): {
kind: 'A'
new(): { kind: 'B' }
}
}
const A = new class extends Base { }
const B = new class extends A { }
B.kind // shows 'A', but should be 'B'
🙁 Actual behavior
If a ctor returns another ctor, it repeats the first level. In the above example, B.kind is 'A', but since we extended and instantiated twice, it should be 'B'.
🙂 Expected behavior
After extending twice, it should reach the inner class, instead of repeating the outer one.
Additional information about the issue
I can only reproduce this bug with this weird experimental anti-pattern - so on its own probably not a priority at all, but types should probably reflect the runtime state as much as possible, even in weird edge cases such as this, and it might indicate a deeper underlying issue.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con la reproducción enlazada en TypeScript Playground y sigue la resolución de tipos para las dos expresiones anidadas new class extends .... El trabajo estará terminado cuando el ejemplo informe de B.kind como 'B' en lugar de 'A' después de las dos extensiones e instanciaciones.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100