BVB Source Codes

prettier Show annot.js Source code

Return Download prettier: download annot.js Source code - Download prettier Source code - Type:.js
  1. function foo(str:string, i:number):string {
  2.   return str;
  3. }
  4. var bar: (str:number, i:number)=> string = foo;
  5.  
  6. var qux = function(str:string, i:number):number { return foo(str,i); }
  7.  
  8. var obj: {str:string; i:number; j:boolean} = {str: "...", i: "...", k: false};
  9.  
  10. var arr: Array<number> = [1,2,"..."];
  11.  
  12. // array sugar
  13. var array: number[] = [1,2,"..."];
  14.  
  15. var matrix: number[][] = [[1,2],[3,4]];
  16. var matrix_parens: (number[])[] = matrix;
  17.  
  18. var nullable_array: ?number[] = null;
  19. var nullable_array_parens: ?(number[]) = nullable_array;
  20.  
  21. var array_of_nullable: (?number)[] = [null, 3];
  22.  
  23. var array_of_tuple: [number, string][] = [[0, "foo"], [1, "bar"]];
  24. var array_of_tuple_parens: ([number, string])[] = array_of_tuple;
  25.  
  26. type ObjType = { 'bar-foo': string; 'foo-bar': number; };
  27. var test_obj: ObjType = { 'bar-foo': '23' };
  28.  
  29. // param type annos are strict UBs like var type annos
  30. function param_anno(n:number):void {
  31.   n = "hey"; // error
  32. }
  33.  
  34. // another error on param UB, more typical of www (mis)use-cases
  35. // this one cribbed from API.atlas.js
  36. function param_anno2(
  37.     batchRequests: Array<{method: string; path: string; params: ?Object}>,
  38.   ): void {
  39.  
  40.     // error below, since we're assigning elements to batchRequests
  41.     // which lack a path property.
  42.     // just assign result to new var instead of reassigning to param.
  43.  
  44.     // Transform the requests to the format the Graph API expects.
  45.     batchRequests = batchRequests.map((request) => {
  46.       return {
  47.         method: request.method,
  48.         params: request.params,
  49.         relative_url: request.path,
  50.       };
  51.     });
  52.     // ...
  53.   }
  54.  
  55. var toz : null = 3;
  56.  
  57. var zer : null = null;
  58.  
  59. function foobar(n : ?number) : number | null | void { return n; }
  60. function barfoo(n : number | null | void) : ?number { return n; }
  61.  
downloadannot.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