[email protected] type level problem

just curious what happen here, is my Option usage is wrong? i wanna check is Some is null for retry, because i can't use async inside match or map
No description
No description
9 Replies
kyra
kyra3w ago
Do you have this in a repository or something so I can check?
Dan
DanOP3w ago
umm sadly is not yet, because im in rewriting to using your new rewrite of Result and i think my screenshot already showing every context, i can comeback later and tag you when rewriting is done for full context
No description
kyra
kyra3w ago
I'd really love to compress types anytime But nevertheless you have a pretty complex match that can be simplified Something like
const result = run.ok().mapInto((r) => {
// ...
});
const result = run.ok().mapInto((r) => {
// ...
});
But lemme try to investigate this
Dan
DanOP3w ago
wait, let me finish rewriting because i found another weird type problem, i will tag you later
kyra
kyra3w ago
Nevertheless in case of doubt, you can cast it using as Option<GplResponse<T>[] | null>
Dan
DanOP3w ago
just to report, that this one caused "expression is not callable" problem
public isOkAnd<R extends T>(cb: (value: T) => value is R): this is Ok<R, E>;
public isErrAnd<R extends E>(cb: (error: E) => error is R): this is Err<R, T>;
public isOkAnd<R extends T>(cb: (value: T) => value is R): this is Ok<R, E>;
public isErrAnd<R extends E>(cb: (error: E) => error is R): this is Err<R, T>;
also "value: If<Success, T, never>" corrently infer value instead of any type
public isOkAnd<R extends boolean>(cb: (value: If<Success, T, never>) => R): this is Ok<T, E> & R {
return this.isOk() && cb(this[ValueProperty] as If<Success, T, never>)
}

public isErrAnd<R extends boolean>(cb: (error: If<Success, never, E>) => R): this is Err<E, T> & R {
return this.isErr() && cb(this[ValueProperty] as If<Success, never, E>)
}
public isOkAnd<R extends boolean>(cb: (value: If<Success, T, never>) => R): this is Ok<T, E> & R {
return this.isOk() && cb(this[ValueProperty] as If<Success, T, never>)
}

public isErrAnd<R extends boolean>(cb: (error: If<Success, never, E>) => R): this is Err<E, T> & R {
return this.isErr() && cb(this[ValueProperty] as If<Success, never, E>)
}
No description
Dan
DanOP3w ago
this one if "value: T" any is infer from Result.err
No description
kyra
kyra3w ago
Ooh, good catch, thank you I should have the PR done in around 30 minutes, I want to add type tests to ensure this never happens again :) Sorry, I'll have the PR done tomorrow... I got an infinite loop issue in my bot that I need to investigate
Dan
DanOP3w ago
take your time, because i see a lot similiar behaviour at other methods too
Want results from more Discord servers?
Add your server