A
A
Andrew2020-12-04 17:53:11
typescript
Andrew, 2020-12-04 17:53:11

Is it possible in typescript to disable if for non-bool conditions?

In ts, as well as in js, constructions are allowed when using if you can check for an expression of any type.
For example, such options are valid

let x = 15;
if (x)...

let y = "hi";
if (y)...

let z = {...};
if (z)...


Is it possible to prevent the use of such conditions so that if only checks against bool conditions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2020-12-04
@byte916

Asked it myself, answered it myself - strict-boolean-expressions
https://palantir.github.io/tslint/rules/strict-boo...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question