In my project, I was using [email protected]
and it was working fine, but now I updated its version to latest [email protected]
and it is giving me a lot of errors. I am unable to find anything in documentations and not getting any Idea how to resolve this issue.
here is my code:
abstract class SystemValidator {
constructor() {}
abstract async validate(addr:Addr):Promise<[boolean, Addr[], SystemValidationErrors]>
}
This is giving me error:
error TS1243: 'async' modifier cannot be used with 'abstract' modifier.
Any idea to resolve this issue?? Should I remove aync
from here??
Yes you should remove async
.
You should not force to use async
to the class that implements it. There are other ways to return a Promise
, not just async
.
Since it is not clear for some people why the async
is not important. Here a couple of ways to return a promise:
async function iAmAsync(): Promise<boolean>{
return false;
}
function iAmNotAsync(): Promise<boolean>{
return new Promise(resolve => resolve(false));
}
function iAmAlsoNotAsync(): Promise<boolean>{
return new Observable().pipe(first()).toPromise();
}
iAmAsync().then();
iAmNotAsync().then();
Playground Link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With