Skip to content

Best way to check for null or undefined in typescript using a type guard

Notifications You must be signed in to change notification settings

naqvitalha/ts-object-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ts-object-utils

Best way to check for null or undefined in typescript using a type guard. Other types also supported. Can strip out null or undefine or complex types like T | null etc.

npm install --save ts-object-utils

To use:

import ObjectUtil from "ts-object-utils";

let a: number | null = 0;

console.log(a*4); //Error: a might be null

if(!ObjectUtil.isNullOrUndefined(a)){
    console.log(a*4); //Works
}

About

Best way to check for null or undefined in typescript using a type guard

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published