Skip to content

Instantly share code, notes, and snippets.

@ivanoats
Forked from anonymous/script3.jsx
Last active August 29, 2015 14:10
Show Gist options
  • Save ivanoats/0dfabc7660a04b83be94 to your computer and use it in GitHub Desktop.
Save ivanoats/0dfabc7660a04b83be94 to your computer and use it in GitHub Desktop.
Animal with Flow types
function Animal(name: string, speed: number, focus: number) {
this.name = name;
this.speed = speed || 1;
this.focus = focus || 1;
this.position = 0;
this.run = function() {
if (Math.random() * 10 < this.focus) {
this.position = this.position + this.speed;
}
};
}
@ivanoats
Copy link
Author

flow check script3.jsx                                                                                                                   

/Users/ivan/dev/jquery-race/script3.js:14:32,41: property focus
Property cannot be accessed on possibly undefined value
  /Users/ivan/dev/jquery-race/script3.js:6:7,14: undefined

/Users/ivan/dev/jquery-race/script3.js:14:32,41: property focus
Property cannot be accessed on possibly undefined value
  /Users/ivan/dev/jquery-race/script3.js:6:17,20: undefined

/Users/ivan/dev/jquery-race/script3.js:14:32,41: property focus
Property cannot be accessed on possibly undefined value
  /Users/ivan/dev/jquery-race/script3.js:6:23,26: undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment