Skip to content

Instantly share code, notes, and snippets.

@jeffmo
Created December 4, 2016 19:47
Show Gist options
  • Save jeffmo/035498c44ad9595bd06160a07df76667 to your computer and use it in GitHub Desktop.
Save jeffmo/035498c44ad9595bd06160a07df76667 to your computer and use it in GitHub Desktop.
/* flow-typed/lib.js */
type JSXHelper<T> = Class<React$Component<{}, T, any>>;
// $JSXIntrinsics is special and magic.
// This declares the types for `div` and `span`
type $JSXIntrinsics = {
div: JSXHelper<{id: string}>,
span: JSXHelper<{id: string, class: string}>,
};
// @flow
let myDiv = <div id={42} />;
> flow version
Flow, a static type checker for JavaScript, version 0.36.0
> flow check
main.js:3
3: let myDiv = <div id={42} />;
^^^^^^^^^^^^^^^ React element `div`
3: let myDiv = <div id={42} />;
^^ number. This type is incompatible with
6: div: JSXHelper<{id: string}>,
^^^^^^ string. See lib: flow-typed/lib.js:6
Found 1 error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment