You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{assert}from'@sindresorhus/is'functionfoo(s: string|undefined){assert.truthy(s)// Type 'string | undefined' is not assignable to type 'string'.// Type 'undefined' is not assignable to type 'string'. ts(2322)constbar: string=s}
Nonetheless type guard for is is working well.
importisfrom'@sindresorhus/is'functionfoo(s: string|undefined){if(!is.truthy(s)){throwTypeError(`s is not a string: ${s}`)}constbar: string=s// Good!}
This can be verified by looking at dist/index.d.ts (line numbers in npm webpage do not align with the code well). For example:
// dist/index.d.ts (v5.5.0)declarenamespaceis{vartruthy: <T>(value: Falsy|T)=>value is T;// L66varfalsy: <T>(value: Falsy|T)=>value is Falsy;// L67}typeAssert={truthy: (value: unknown)=> asserts value is unknown;// L204falsy: (value: unknown)=> asserts value is unknown;// L205}
The text was updated successfully, but these errors were encountered:
wdzeng
changed the title
type guard for assert is not working
type guards for assert are not working
Jul 16, 2023
wdzeng
changed the title
type guards for assert are not working
Some type guards under assert are not working
Jul 16, 2023
Several type guards under
assert
are not working.Nonetheless type guard for
is
is working well.This can be verified by looking at dist/index.d.ts (line numbers in npm webpage do not align with the code well). For example:
The text was updated successfully, but these errors were encountered: