Skip to content

Commit 04d620a

Browse files
authored
Added info about valid typeof
1 parent 19d9346 commit 04d620a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@
306306
- [22.4](#coercion--comment-deviations) Deviations
307307
- [22.5](#coercion--bitwise) Bitwise
308308
- [22.6](#coercion--booleans) Booleans
309+
- [22.7](#coercion--valid-typeof) Valid Typeof
309310

310311
</details>
311312

@@ -3641,6 +3642,19 @@
36413642
const hasAge = !!age;
36423643
```
36433644

3645+
<a name="coercion--valid-typeof"></a><a name="22.6"></a>
3646+
- [22.6](#coercion--valid-typeof) Only compare returned strings by `typeof` to valid strings: eslint: [`valid-typeof`](https://eslint.org/docs/rules/valid-typeof)
3647+
3648+
```javascript
3649+
3650+
// bad - will be prevented by linter
3651+
typeof foo === "strnig";
3652+
3653+
// good
3654+
typeof foo === "string";
3655+
typeof bar === typeof foo;
3656+
```
3657+
36443658
**[⬆ back to top](#table-of-contents-bookmark_tabs)**
36453659

36463660
## Naming Conventions

0 commit comments

Comments
 (0)