Package Exports
- non-null
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (non-null) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
non-null
TypeScript helper. Assert if a value is neither null nor undefined.
Declaration
export default function nonNull<T = any>(arg?: T | null, message?: string): T
export { nonNull as nn }
Usage
import nonNull from 'non-null'
nonNull(1) // = 1
nonNull(null) // throws an error
nonNull(undefined) // throws an error
Assert if a value is neither null nor undefined using the assert
module. Returns the value.
Note that the type return value is coerced to be non-null.
Tip
To remove assert
calls, use a tool such as unassert.