BVB Source Codes

prettier Show generic_class.js Source code

Return Download prettier: download generic_class.js Source code - Download prettier Source code - Type:.js
  1. // @flow
  2.  
  3. /**
  4.  * Fields annotated with a generic should assume a type once the type param
  5.  * is instantiated.
  6.  */
  7. class ClassAnnotated<T> {
  8.   p: T;
  9.   static p: T;
  10. }
  11.  
  12. var o1 = new ClassAnnotated();
  13. o1.p = 42;
  14. (o1.p: number);
  15. (o1.p: string); // Error: number ~> string
  16. ClassAnnotated.p = 42;
  17. (ClassAnnotated.p: number);
  18. (ClassAnnotated.p: string); // Error: number ~> string
  19.  
  20.  
  21. /**
  22.  * It's always an error to initialized a generically-typed field with an
  23.  * expression of any type other than the generic itself.
  24.  */
  25. class ClassGenericInitialized<T, U> {
  26.   invalid: T = 42; // Error: number ~> Generic<T>
  27.   valid: T = ((42:any):T);
  28.  
  29.   static invalid: T = 42; // Error: number ~> Generic<T>
  30.   static valid: T = ((42:any):T);
  31. }
  32.  
downloadgeneric_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