I'm getting this error with a Typescript application trying to use Snoowrap (Reddit API package), but I'm getting the above error (TS1062) and TypeScript is failing to compile.
The VoteableContent
type has an expandReplies
method which returns a promise, but when I try to await it I get the error.
Here's a truncated snippet of where I'm seeing it:
async getAllRepliers(content: Submission | Comment): Promise<string[]> {
await content.expandReplies()
}
Submission
and Comment
both extend VoteableContent
and have the method, but TypeScript is throwing the error there.
This seems to be an issue with Typescript or the typings rather then my code or snoowrap's code? I'm unsure. I'm using the latest versions all around (TS 3.3.3, snoowrap 1.15.2, @types/snoowrap 1.15.3) so not sure what I can do or how I would fix this. Thanks.
It seems the method already implements and resolves its own then() method, meaning it sort of awaits itself.
I read this post to come to that conclusion: Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method
EDIT: I've tested this with snoowrap.Submission's upvote() function which had the same problem, and it works synchronously without an await.
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