Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bypass few lines in Flow

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()

like image 463
Murasaki Aikon Avatar asked Dec 07 '25 18:12

Murasaki Aikon


1 Answers

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()
like image 128
TLadd Avatar answered Dec 09 '25 14:12

TLadd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!