Reputation: 311
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()
Upvotes: 3
Views: 1357
Reputation: 6894
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()
Upvotes: 4