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
Order of type declarations affects union behavior #815
Comments
Turns out inlining types joined into /* @flow */
type VirtualElement = Thunk|VirtualNode;
type Child = VirtualElement;
type Children = Array<Child>;
class Thunk {}
class VirtualNode {
children: Children|Thunk|VirtualNode;
constructor(type, children/*:Children*/) {
this.children = children.length === 1 ? children[0] :
children;
}
} |
Sounds like #582. Linking the issues together so we can check/close them all when a fix arrives. |
This is still failing after the fix for #582. |
OK... so I was able to come up with a simple repro here, and it looks like a bug. @bhosmer, you'll probably like this one. Fails: /* @flow */
type T = A|B;
class U {};
declare var children: U;
(children: T|U);
class A {};
class B {};
Passes: (I just moved /* @flow */
type T = A|B;
class U {};
declare var children: U;
class A {};
class B {};
(children: T|U); Note this is totally non specific to classes. You can change |
To save me creating a new issue I'm wondering if the error I'm encountering is caused by the issue seen here? // decl
declare class Fixture {
title: string;
component: any;
props?: Object;
children?: Array<Object|string>|string; // this might just be bad syntax but breaks even with Object|string pulled out into a new type
expect?: {[key:string]: Array<Function>} // see ps. note about this =D
} // usage
export const a: Fixture = {
title: 'title',
component: 'component',
children: 'Test Child'
};
Ps. Unrelated but is |
@Gozala, @samwgoldman: Both of your examples will be fixed in an upcoming release. @chrisui: you seem to be exploiting an unrelated bug in your example, which has been fixed in an unrelated way: objects cannot be typed as class instances. |
Here is the code to reproduce this issue with 0.15.0 installed as flow-bin from npm:
I see following errors
The text was updated successfully, but these errors were encountered: