Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppressed error with when exist property with any type in class #3431

Closed
tenorok opened this issue Feb 25, 2017 · 5 comments
Closed

Suppressed error with when exist property with any type in class #3431

tenorok opened this issue Feb 25, 2017 · 5 comments

Comments

@tenorok
Copy link

tenorok commented Feb 25, 2017

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.

@mwalkerwells
Copy link
Contributor

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?

@tenorok
Copy link
Author

tenorok commented Feb 27, 2017

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.

@vkurchatkin
Copy link
Contributor

Having no error message seems like a bug?

Yes, it seems so

@vkurchatkin
Copy link
Contributor

vkurchatkin commented Feb 27, 2017

Here is a minimal test case:

declare var A: any;
declare var y: { a: A } & {};
y.foo;

@SamChou19815
Copy link
Contributor

This is expected

@SamChou19815 SamChou19815 closed this as not planned Won't fix, can't repro, duplicate, stale May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants