Skip to content

Instantly share code, notes, and snippets.

@asolove
Created April 20, 2016 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asolove/0875b45af779f115feccbfdd25cf6c75 to your computer and use it in GitHub Desktop.
Save asolove/0875b45af779f115feccbfdd25cf6c75 to your computer and use it in GitHub Desktop.
// @flow
type Foo = { n: number };
type Foo2 = Foo & { s: string };
type Bar = { foo: Foo };
type Bar2 = { foo: Foo2 };
function fooN(foo: Foo){ return foo.n; }
function barFooN(bar: Bar){ return bar.foo.n }
let bar2: Bar2 = { foo: { n: 2, s: "" }};
barFooN(bar2);
/*
subtype2.js:12
12: barFooN(bar2);
^^^^^^^^^^^^^ function call
3: type Foo2 = Foo & { s: string };
^^^^^^^^^^^^^ property `s`. Property not found in
5: type Bar = { foo: Foo };
^^^ object type
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment