BVB Source Codes

prettier Show defaults.js Source code

Return Download prettier: download defaults.js Source code - Download prettier Source code - Type:.js
  1. /* @flow */
  2.  
  3. function obj_prop_fun({p:{q=0}={q:true}}={p:{q:""}}) {
  4.   // errors:
  5.   // * number  ~> void, from default on _.p.q
  6.   // * boolean ~> void, from default on _.p
  7.   // * string  ~> void, from default on _
  8.   // * null    ~> void, from call below
  9.   (q:void);
  10. }
  11. obj_prop_fun(); // ok
  12. obj_prop_fun({}); // ok
  13. obj_prop_fun({p:{}}); // ok
  14. obj_prop_fun({p:{q:null}}); // ok, provides add'l lower bound
  15.  
  16. function obj_prop_var(o={p:{q:""}}) {
  17.   var {p:{q=0}={q:true}} = o;
  18.   // errors:
  19.   // * number  ~> void, from default on o.p.q
  20.   // * boolean ~> void, from default on o.p
  21.   // * string  ~> void, from default on o
  22.   // * null    ~> void, from call below
  23.   (q:void);
  24. }
  25. obj_prop_var(); // ok
  26. obj_prop_var({}); // ok
  27. obj_prop_var({p:{}}); // ok
  28. obj_prop_var({p:{q:null}}); // ok, provides add'l lower bound
  29.  
  30. function obj_rest({p:{q,...o}={q:0,r:0}}={p:{q:0,r:""}}) {
  31.   // errors:
  32.   // * number  ~> void, from default on _.p
  33.   // * string  ~> void, from default on _
  34.   // * null    ~> void, from call below
  35.   (o.r:void);
  36. }
  37. obj_rest(); // ok
  38. obj_rest({}); // ok
  39. obj_rest({p:{}}); // ok
  40. obj_rest({p:{q:0,r:null}});
  41.  
  42. function obj_prop_annot({
  43.   p = true // error: boolean ~> string
  44. }: {
  45.   p: string
  46. } = {
  47.   p: 0 // error: number ~> string
  48. }) {
  49.   (p:void); // error: string ~> void
  50. }
  51.  
  52. var {
  53.   p = true // error: boolean ~> string
  54. }: {
  55.   p: string
  56. } = {
  57.   p: 0 // error: number ~> string
  58. };
  59. (p:void); // error: string ~> void
  60.  
  61. function obj_prop_err({x:{y}}=null) {} // error: property `x` cannot be accessed on null
  62. function obj_rest_err({...o}=0) {} // error: expected object instead of number
  63. function arr_elem_err([x]=null) {} // error: element 0 cannot be accessed on null
  64. function arr_rest_err([...a]=null) {} // error: expected array instead of null
  65.  
  66. function gen<T>(x:T,{p=x}:{p:T}):T {
  67.   return p;
  68. }
  69.  
  70. // Default values in destructuring unwrap optional types
  71. obj_prop_fun(({} : {p?:{q?:null}})); // ok
  72. obj_prop_var(({} : {p?:{q?:null}})); // ok
  73.  
  74. // union-like upper bounds preserved through destructuring
  75. function obj_prop_opt({p}:{p?:string}={p:0}) {}
  76. function obj_prop_maybe({p}:{p:?string}={p:0}) {}
  77. function obj_prop_union({p}:{p:number|string}={p:true}) {}
  78.  
  79. // TODO: union-of-objects upper bounds preserved through destructuring
  80. function obj_prop_union2({p}:{p:number}|{p:string}={p:true}) {}
  81.  
  82. function default_expr_scope({a, b = a}) {}
  83.  
downloaddefaults.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