linter-bundle
Version:
Ready-to use bundle of linting tools, containing configurations for ESLint, stylelint and markdownlint.
19 lines (11 loc) • 469 B
Markdown
# Disallow unnecessary `typeof` checks (`linter-bundle/no-unnecessary-typeof`)
## Rule Details
If a `typeof` operant has only one type in TypeScript, it's unnecessary to check it's type at runtime.
Examples of **incorrect** code for this rule:
```ts
declare var myString: string;
if (typeof myString === 'string') {}
if (typeof myString === 'boolean') {}
declare var myBoolean: (boolean | string) & (boolean | number);
if (typeof myBoolean === 'boolean') {}
```