BVB Source Codes

prettier Show base_class.js Source code

Return Download prettier: download base_class.js Source code - Download prettier Source code - Type:.js
  1. // @flow
  2.  
  3. class Base {
  4.   unannotatedField;
  5.   annotatedField: number;
  6.   initializedField = 42;
  7.   initializedFieldWithThis = this.initializedField;
  8.   annotatedInitializedFieldValid: ?number = 42;
  9.   annotatedInitializedFieldInvalid: number = 'asdf'; // Error: string ~> number
  10.  
  11.   static unannotatedField;
  12.   static annotatedField: number;
  13.   static initializedField = 'asdf';
  14.   static initializedFieldWithThis = this.initializedField;
  15.   static annotatedInitializedFieldValid: ?number = 42;
  16.   static annotatedInitializedFieldInvalid: number = 'asdf'; // Error: string ~> number
  17. }
  18.  
  19. var o = new Base();
  20.  
  21. /**
  22.  * Unannotated fields are open.
  23.  */
  24. (o.unannotatedField: string);
  25. (o.unannotatedField: number);
  26. (Base.unannotatedField: string);
  27. (Base.unannotatedField: number);
  28.  
  29. /**
  30.  * Annotated (but uninitialized) fields still have a type.
  31.  */
  32. (o.annotatedField: number);
  33. (o.annotatedField: string); // Error: number ~> string
  34. (Base.annotatedField: number);
  35. (Base.annotatedField: string); // Error: number ~> string
  36.  
  37. /**
  38.  * Initialized (but unannotated) fields assume the type of their initializer.
  39.  */
  40. (o.initializedField: number);
  41. (o.initializedField: string); // Error: number ~> string
  42. (Base.initializedField: string);
  43. (Base.initializedField: number); // Error: string ~> number
  44.  
  45. /**
  46.  * Initialized fields can reference `this`.
  47.  */
  48. (o.initializedFieldWithThis: number);
  49. (o.initializedFieldWithThis: string); // Error: number ~> string
  50. (Base.initializedFieldWithThis: string);
  51. (Base.initializedFieldWithThis: number); // Error: string ~> number
  52.  
  53. /**
  54.  * Initialized + annotated fields take the type of the annotation.
  55.  * (Note that this matters when the annotation is more general than the type of
  56.  *  the initializer)
  57.  */
  58. (o.annotatedInitializedFieldValid: ?number);
  59. (o.annotatedInitializedFieldValid: number); // Error: ?number ~> number
  60. (Base.annotatedInitializedFieldValid: ?number);
  61. (Base.annotatedInitializedFieldValid: number); // Error: ?number ~> number
  62.  
  63. /**
  64.  * Initialized + annotated fields where the init/annot combo is a mismatch
  65.  * should assume the type of the annotation.
  66.  *
  67.  * (This happens in addition to erroring at the site of initialization)
  68.  */
  69. (o.annotatedInitializedFieldInvalid: number);
  70. (o.annotatedInitializedFieldInvalid: string); // Error: number ~> string
  71. (Base.annotatedInitializedFieldInvalid: number);
  72. (Base.annotatedInitializedFieldInvalid: string); // Error: number ~> string
  73.  
downloadbase_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