Skip to content

Commit

Permalink
fix(module:core): add type guard for isNotNil (#4431)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxiangmoe authored and vthinkxie committed Nov 18, 2019
1 parent 9451de5 commit b3c686c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions components/core/util/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import { TemplateRef, Type } from '@angular/core';

import { IndexableObject } from '../types/indexable';

// tslint:disable-next-line:no-any
export function isNotNil(value: any): boolean {
export function isNotNil<T>(value: T): value is NonNullable<T> {
return typeof value !== 'undefined' && value !== null;
}

// tslint:disable-next-line:no-any
export function isNil(value: any): value is null | undefined {
export function isNil(value: unknown): value is null | undefined {
return typeof value === 'undefined' || value === null;
}

Expand Down

0 comments on commit b3c686c

Please sign in to comment.