File tree Expand file tree Collapse file tree
packages/graphiql-toolkit/src/async-helpers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @graphiql/toolkit ' : patch
3+ ---
4+
5+ Correctly handle ` null ` in type-guard functions for ` Promise ` and ` Observable `
Original file line number Diff line number Diff line change @@ -6,7 +6,11 @@ import {
66
77// Duck-type promise detection.
88export function isPromise < T > ( value : Promise < T > | any ) : value is Promise < T > {
9- return typeof value === 'object' && typeof value . then === 'function' ;
9+ return (
10+ typeof value === 'object' &&
11+ value !== null &&
12+ typeof value . then === 'function'
13+ ) ;
1014}
1115
1216// Duck-type Observable.take(1).toPromise()
@@ -29,6 +33,7 @@ function observableToPromise<T>(observable: Observable<T>): Promise<T> {
2933export function isObservable < T > ( value : any ) : value is Observable < T > {
3034 return (
3135 typeof value === 'object' &&
36+ value !== null &&
3237 'subscribe' in value &&
3338 typeof value . subscribe === 'function'
3439 ) ;
You can’t perform that action at this time.
0 commit comments