I need to integrate the SDK into my next.js project via cdn
So I need to put the <script src='<url>' /> into my code.
then run window.sdk = new PrivateSDK() and
window.sdk.someFunction()
I can bypass the eslint unallowed reassign warning using /* eslint-disable */
But How can I bypass the flow checking ?
It returns Cannot resolve name PrivateSDK. in window.sdk = new PrivateSDK()
and
Cannot resolve name sdk. in window.sdk.someFunction()
Couple of options. If you want to simply suppress the errors, you can define the supress_comment option in your .flowconfig:
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
And then you can leave a comment // $FlowFixMe on the line above where you want to suppress the error.
Alternatively, you could do something like this to get around the type checking on window by reassigning it to a variable with any type:
let windowAny: any = window;
windowAny.sdk = new windowAny.PrivateSDK();
windowAny.sdk.someFunction()
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