BVB Source Codes

prettier Show create_class.js Source code

Return Download prettier: download create_class.js Source code - Download prettier Source code - Type:.js
  1. import React from "react";
  2.  
  3. const A = React.createClass({
  4.   mixins: [{ propTypes: { foo: React.PropTypes.string.isRequired } }],
  5.   propTypes: { bar: React.PropTypes.number.isRequired },
  6.   m() {
  7.     (this.props.foo: empty); // error: string ~> empty
  8.     (this.props.bar: empty); // error: number ~> empty
  9.   }
  10. });
  11.  
  12. const B = React.createClass({
  13.   p: "",
  14.   m() {
  15.     this.p = 0; // error: number ~> string
  16.   },
  17.   mm() {
  18.     this.m.apply(null); // OK: this.m is autobound, so `this.p` will always be found
  19.   }
  20. });
  21.  
  22. const C = React.createClass({
  23.   getInitialState(): Object {
  24.     return { foo: 0 };
  25.   },
  26.   m() {
  27.     this.state.foo; // OK: state is unknown
  28.   }
  29. });
  30.  
  31. const D = React.createClass({
  32.   mixins: [{
  33.     getInitialState(): Object {
  34.       return { foo: 0 };
  35.     },
  36.   }],
  37.   getInitialState() {
  38.     return { bar: 0 };
  39.   },
  40.   m() {
  41.     this.state.foo; // OK: state is unknown (due to unknown mixin)
  42.   }
  43. });
  44.  
  45. const E = React.createClass({
  46.   foo: 0,
  47.   m() {
  48.     (this.foo: string); // error: number ~> string
  49.   },
  50.   mm() {
  51.     var props: { m(): void } = { m: this.m };
  52.     props.m(); // OK: this.m is autobound, so `this.foo` will always be found
  53.   }
  54. });
  55.  
  56. const F = React.createClass({
  57.   getInitialState(): { [string]: mixed } {
  58.     return { foo: 0 };
  59.   },
  60.   m() {
  61.     this.state.foo;
  62.     this.state.bar;
  63.   },
  64. });
  65.  
  66. const G = React.createClass({
  67.   mixins: [],
  68.   autobind: true,
  69.   statics: {},
  70.   m() {
  71.     (this.mixins: mixed); // error: property `mixins` not found
  72.     (this.autobind: mixed); // error: property `autobind` not found
  73.     (this.statics: mixed); // error: property `statics` not found
  74.   },
  75. });
  76.  
  77. const H = React.createClass({
  78.   statics: { q: 0 },
  79.   getDefaultProps() {
  80.     (this.q: empty); // error: number ~> empty
  81.     return {};
  82.   },
  83. });
  84.  
  85. const I = React.createClass({
  86.   propTypes: ({}: {[string]: any}),
  87.   m() {
  88.     (this.props.foo: empty); // OK
  89.   }
  90. });
  91.  
  92. const J = React.createClass({
  93.   mixins: [{
  94.     getInitialState() {
  95.       return this.constructor.calculateState();
  96.     },
  97.   }],
  98.   statics: {
  99.     calculateState() {
  100.       return { foo: 0 };
  101.     },
  102.   },
  103.   m() {
  104.     (this.state.foo: empty); // number ~> empty
  105.   },
  106. });
  107.  
  108. const K = React.createClass({
  109.   propTypes: {
  110.     foo: React.PropTypes.string.isRequired,
  111.   },
  112.   getInitialState() {
  113.     this.mm(); // cause error in mm below
  114.     return this.props;
  115.   },
  116.   m() {
  117.     (this.props.foo: empty); // string ~> empty
  118.     (this.state.foo: empty); // string ~> empty
  119.   },
  120.   mm() {
  121.     this.state.foo; // error: property fo not found (called by getInitialState)
  122.   }
  123. });
  124.  
  125. const L = React.createClass({
  126.   propTypes: {
  127.     foo: React.PropTypes.string.isRequired,
  128.   },
  129.   getInitialState() {
  130.     return { bar: 0 };
  131.   },
  132.   componentWillMount() {
  133.     (this.props.foo: empty); // string ~> empty
  134.     return 0; // number ~> void
  135.   },
  136.   componentDidMount() {
  137.     (this.props.foo: empty); // string ~> empty
  138.     return 0; // number ~> void
  139.   },
  140.   componentWillReceiveProps(nextProps) {
  141.     (this.props.foo: empty); // string ~> empty
  142.     (nextProps.foo: empty); // string ~> empty
  143.     return 0; // number ~> void
  144.   },
  145.   shouldComponentUpdate(nextProps, nextState) {
  146.     (this.props.foo: empty); // string ~> empty
  147.     (this.state.bar: empty); // number ~> empty
  148.     (nextProps.foo: empty); // string ~> empty
  149.     (nextState.bar: empty); // number ~> empty
  150.     return 0; // number ~> bool
  151.   },
  152.   componentWillUpdate(nextProps, nextState) {
  153.     (this.props.foo: empty); // string ~> empty
  154.     (this.state.bar: empty); // number ~> empty
  155.     (nextProps.foo: empty); // string ~> empty
  156.     (nextState.bar: empty); // number ~> empty
  157.     return 0; // number ~> void
  158.   },
  159.   componentDidUpdate(nextProps, nextState) {
  160.     (this.props.foo: empty); // string ~> empty
  161.     (this.state.bar: empty); // number ~> empty
  162.     (nextProps.foo: empty); // string ~> empty
  163.     (nextState.bar: empty); // number ~> empty
  164.     return 0; // number ~> void
  165.   },
  166.   componentWillUnmount() {
  167.     (this.props.foo: empty); // string ~> empty
  168.     (this.state.bar: empty); // number ~> empty
  169.     return 0; // number ~> void
  170.   },
  171. });
  172.  
  173. React.createClass({}); // error: spec must be [x] exact and [ ] sealed
  174. React.createClass(({}: {})); // error: spec must be [ ] exact and [x] sealed
  175.  
downloadcreate_class.js Source code - Download prettier Source code
Related Source Codes/Software:
storybook - 2017-06-07
ionicons - The premium icon font for Ionic ... 2017-06-07
AsyncDisplayKit - Smooth asynchronous user interfaces for iOS apps. ... 2017-06-07
lottie-android - Render After Effects animations natively on Androi... 2017-06-07
parse-server - Parse-compatible API server module for Node/Expres... 2017-06-07
inferno - An extremely fast, React-like JavaScript library f... 2017-06-08
guetzli - Perceptual JPEG encoder 2017-06-08
cs-video-courses - List of Computer Science courses with video lectur... 2017-06-08
interviews - Everything you need to know to get the job. 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top