Last active
May 27, 2016 00:04
-
-
Save vilterp/3a344a27d2e2f55d9b2679900a70c60d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
peterv@vilterp-mbp:flow-test$ flow version | |
Flow, a static type checker for JavaScript, version 0.25.0 | |
peterv@vilterp-mbp:flow-test$ flow | |
flowTest.js:7 | |
7: var y: Foo = {...x, a: 5}; | |
^^^^^^^^^^^^ object literal. This type is incompatible with | |
7: var y: Foo = {...x, a: 5}; | |
^^^ union: object type(s) | |
Member 1: | |
3: type Foo = { type: 'foo', a: number, b: number } | { type: 'bar', c: string }; | |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ object type | |
Error: | |
3: type Foo = { type: 'foo', a: number, b: number } | { type: 'bar', c: string }; | |
^^^^^ string literal `bar`. Expected string literal `foo`, got `bar` instead | |
3: type Foo = { type: 'foo', a: number, b: number } | { type: 'bar', c: string }; | |
^^^^^ string literal `foo` | |
Member 2: | |
3: type Foo = { type: 'foo', a: number, b: number } | { type: 'bar', c: string }; | |
^^^^^^^^^^^^^^^^^^^^^^^^^^ object type | |
Error: | |
3: type Foo = { type: 'foo', a: number, b: number } | { type: 'bar', c: string }; | |
^^^^^ string literal `foo`. Expected string literal `bar`, got `foo` instead | |
3: type Foo = { type: 'foo', a: number, b: number } | { type: 'bar', c: string }; | |
^^^^^ string literal `bar` | |
Found 1 error | |
peterv@vilterp-mbp:flow-test$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @flow */ | |
type Foo = { type: 'foo', a: number, b: number } | { type: 'bar', c: string }; | |
var x: Foo = { type: 'foo', a: 1, b: 2 }; | |
var y: Foo = {...x, a: 5}; // this is a valid `Foo`, but Flow says it's not |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment