Excuse for confusing title, difficult explain my case in few words.
I'm declare custom class system and everything alright until not appearing property oops: JQuery, which suppress expected error:
declare var JQuery: any;
declare class BEM {
static decl<P, SP>(block: string, props: P, staticProps?: SP): Class<BEM & P> & SP;
static blocks: { [name: string]: Class<*> };
// oops: JQuery; // <- This line suppress an error.
}
var Provider = BEM.decl('provider', {}, {
foo: function(a: string) {}
});
var p: typeof Provider = BEM.blocks['provider'];
p.foo('');
p.bla(); // <- Expected error "property `bla`. Property not found in."
Experimentally I found that declaration below is not suppress an error:
declare class JQuery {}
But why the first code has the described behavior? Is it bug?
Flow version 0.40.0.
If you use oops: typeof JQuery;, it works as intended. You're using a value as a type, which normally throws an error, but doesn't for some reason with any.
Having no error message seems like a bug?
If you use oops: typeof JQuery;, it works as intended.
Thank you for explanation, typeof fixes that behavior.
Having no error message seems like a bug?
Yes, I'm expect error about missing p.bla(). But oops: JQuery; suppressed her.
Having no error message seems like a bug?
Yes, it seems so
Here is a minimal test case:
declare var A: any;
declare var y: { a: A } & {};
y.foo;
Most helpful comment
Here is a minimal test case: