microsoft / microsoft/TypeScript
strict boolean expressions compilerOption
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
require strict boolean
Suggestion
add yet another --strict check into compilerOptions, to only allow expressions that evaluate to Boolean for all conditional branching - if, for, while, ?: ternary operator, etc
basically this TSLint rule, built into TS compiler
https://palantir.github.io/tslint/rules/strict-boolean-expressions/
Use Cases
often people check the existence of function, before calling it:
if (somFunc) someFunc()
or they think that function is actualy a property, and hence dont call it
if (someVal)... . where it should have been if (someVal()) ...
if if required a strict boolean expression, both of the above would have been errors.
Examples
instead above examples would be written:
if (!!someFunc) someFunc()
and for someValue():boolean
if (someValue())..
Checklist
My suggestion meets these guidelines:
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
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 revisando el manejo de compilerOptions del compilador de TypeScript y las rutas de comprobación de tipos para if, for, while y las expresiones condicionales. Compara el comportamiento solicitado con la regla strict-boolean-expressions de TSLint enlazada. Se considera terminado cuando una opción del compilador impone expresiones condicionales con valor Boolean sin cambiar el JavaScript emitido.
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
- Bastante claro
- Aptitud para principiantes
- 25/100