microsoft / microsoft/TypeScript
refinement types
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
This is a further development of the idea of tag types.
There are situations where being able to encode a certain predicate about a given value using its type is tremendously helpful.
Let's imagine that we have a number. In order to proceed with it we need to assert that it is greater than 0. This assertion doesn't come for free, because it takes some processor time to get evaluated. Since numbers are immutable this assertion only needs to be evaluated once and will hold true from then on without having to be reevaluated. But due to having no way to attach this knowledge to the number value we:
- either need to play safe and reevaluate it every time immediately before using
- or take our chances trying to trace it through the code from the place where it was asserted keeping the result of the assertion in mind and hoping not to break things during the next refactoring
Being able to attach additional knowledge to the type of a value in form of predicate that is guaranteed to hold true as long as the value doesn't change is what is called refinement types.
@ahejlsberg, what are the chances of seeing the refinement types in TypeScript one day?
References:
- Refinement types: https://en.wikipedia.org/wiki/Refinement_(computing)
- Pre/post conditions, Hoare logic: https://en.wikipedia.org/wiki/Hoare_logic
- Design by contract: https://en.wikipedia.org/wiki/Design_by_contract
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
Empieza leyendo el enlace de tipos de etiquetas del issue y sus referencias a refinement types, lógica de Hoare y design by contract. El issue no menciona archivos, pruebas ni un punto de entrada para la implementación; una contribución completada requeriría primero un diseño definido en TypeScript y un alcance aceptado para refinement types.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 20/100