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
Currently the caseError implementation needs to return it's value as any cause we get an error of Task<TResult, EResult> is not assignable to the conditional type.
exportfunctioncaseError<E,TResult,EResult>(errorType: Constructor<E>,errorHandler: IErrorHandler<E,TResult,EResult>){returnfunction<RE>(err: RE): REextendsE ? Task<TResult,EResult> : Task<TResult,RE|EResult>{// If the error is of the type we are looking for (E)if(errinstanceoferrorType){// Transform the errorreturnerrorHandler(err)asany}else{// If not, leave as it isreturnTask.reject(err)asany}}}
We have to investigate conditional types further, because this base test is currently failing trough
the same problem;
functiontest<T>(val: T): Textendsnumber ? string : boolean{if(typeofval==='number'){val;// This gets infer as T & number, instead of just numberreturn'string';// this fails because string is not assignable to the conditional.}else{returnfalse;}}
The text was updated successfully, but these errors were encountered:
* fix(caseError): fixed caseError typings (now works with non-compatible errors and with Tasks errores with only one type)
* fix(caseError): improve caseError typings (fix#2)
* chore(caseError): removed debugging code
Currently the caseError implementation needs to return it's value
as any
cause we get an error of Task<TResult, EResult> is not assignable to the conditional type.We have to investigate conditional types further, because this base test is currently failing trough
the same problem;
The text was updated successfully, but these errors were encountered: