Created
April 18, 2016 19:21
-
-
Save jeffmo/0c683cb38cd908251bc49be18d9a05c3 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
// @flow | |
declare function getElem(name: 'a'): HTMLCollection<HTMLAnchorElement>; | |
declare function getElem(name: 'button'): HTMLCollection<HTMLButtonElement>; | |
function getElem(name) { return (42: any); }; | |
let a: HTMLCollection<HTMLButtonElement> = getElem('a'); // Error | |
let b: HTMLCollection<HTMLAnchorElement> = getElem('a'); // No Error |
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 version | |
Flow, a static type checker for JavaScript, version 0.23.0 | |
> flow check | |
main.js:4 | |
4: declare function getElem(name: 'a'): HTMLCollection<HTMLAnchorElement>; | |
^^^^^^^^^^^^^^^^^ HTMLAnchorElement. This type is incompatible with | |
9: let a: HTMLCollection<HTMLButtonElement> = getElem('a'); // Error | |
^^^^^^^^^^^^^^^^^ HTMLButtonElement | |
main.js:9 | |
9: let a: HTMLCollection<HTMLButtonElement> = getElem('a'); // Error | |
^^^^^^^^^^^^^^^^^ HTMLButtonElement. This type is incompatible with | |
4: declare function getElem(name: 'a'): HTMLCollection<HTMLAnchorElement>; | |
^^^^^^^^^^^^^^^^^ HTMLAnchorElement | |
Found 2 errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment