BVB Source Codes

prettier Show infer.js Source code

Return Download prettier: download infer.js Source code - Download prettier Source code - Type:.js
  1. /* @flow */
  2.  
  3. var Foo = {
  4.   a: function(arg) {  // missing arg annotation
  5.     return arg;
  6.   },
  7.  
  8.   b: function(arg) {  // missing arg annotation
  9.     return {
  10.       bar: arg
  11.     };
  12.   },
  13.  
  14.   c: function(arg: string) {  // no return annotation required
  15.     return {
  16.       bar: arg
  17.     };
  18.   },
  19.  
  20.   d: function(arg: string): {
  21.     bar: string
  22.   } {
  23.     return {
  24.       bar: arg
  25.     };
  26.   },
  27.  
  28.   // return type annotation may be omitted, but if so, input positions on
  29.   // observed return type (e.g. param types in a function type) must come
  30.   // from annotations
  31.   e: function(arg: string) {
  32.     return function(x) {  // missing param annotation
  33.       return x;
  34.     }
  35.   },
  36.  
  37.   // ...if the return type is annotated explicitly, this is unnecessary
  38.   f: function(arg: string): (x:number) => number {
  39.     return function(x) {  // no error
  40.       return x;
  41.     }
  42.   }
  43.  
  44. };
  45.  
  46. var Bar = {
  47.   a: Foo.a('Foo'),    // no annotation required
  48.  
  49.   // object property types are inferred, so make sure that this doesn't cause
  50.   // us to also infer the parameter's type.
  51.   b: Foo.b('bar'),    // no annotation required
  52.  
  53.   c: Foo.c('bar'),            // no annotation required
  54.  
  55.   d: Foo.d('bar'),            // no annotation required
  56. };
  57.  
  58. module.exports = Foo, Bar;
  59.  
downloadinfer.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