Skip to content

Latest commit

 

History

History
18 lines (11 loc) · 455 Bytes

no-unnecessary-typeof.md

File metadata and controls

18 lines (11 loc) · 455 Bytes

Disallow unnecessary typeof checks (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:

declare var myString: string;

if (typeof myString === 'string') {}
if (typeof myString === 'boolean') {}

declare var myBoolean: (boolean | string) & (boolean | number);

if (typeof myBoolean === 'boolean') {}