Typescript compilation fails on 4.0.0, Cannot find name 'this'
Describe the bug
Typescript fail to compile, that is a simple error that can be fixed in a patch
node_modules/whatsapp-api-js/lib/types/index.d.ts:155:139 - error TS2304: Cannot find name 'this'.
155 broadcastMessage(phoneID: string, to: string[], message: ClientMessage, batch_size?: number, delay?: number): Array<ReturnType<typeof this.sendMessage>>;
Expected behavior tsc should pass...
Desktop (please complete the following information):
- OS: Windows
- Runtime node@20
- Library Version 4.0.0
Hello there,
This is not the first time I have come across this bug, it has been there since broadcastMessage was created.
Back then I didn't know how to solve it, and I'm guessing I still don't know. If by any chance you have an idea or clue on how to solve it, I would love the input.
Anyway, my best recommendation right now is setting "skipLibCheck": true inside your tsconfig.json, as the error only appears when type-checking the compiled library and it still works with full type support.
That's the annoying thing, it doesn't throw an error while building, only in prod.
I will try to mess with it later today, thanks for raising this issue!
Yes that's exacly what i did, thank you! I think it should be something like typeof WhatsAppAPI['sendMessage'] instead of typeof this.sendMessage
Oh, wow, I'm just really dumb. I don't know why I never did the obvious thing 🤣.
I will try to do a release in a few hours, thanks for the help!