BVB Source Codes

prettier Show type.js Source code

Return Download prettier: download type.js Source code - Download prettier Source code - Type:.js
  1. declare class T {}
  2. declare var x: T;
  3.  
  4. declare class U {}
  5. declare var y: U;
  6.  
  7. declare var nil: {||};
  8.  
  9. // inexact: `p` may be non-own
  10. type O1 = {...{p:T}};
  11. declare var o1: O1;
  12. (o1: {p?:T}); // ok
  13. (o1: {p:T}); // error: o1.p is optional
  14. ({}: O1); // ok
  15. ({p:x}: O1); // ok
  16. ({p:y}: O1); // error: y ~> T
  17. ({p:x,q:y}: O1); // ok
  18.  
  19. // inexact: optional `p`, if own, must be `T`
  20. type O2 = {...{p?:T}};
  21. declare var o2: O2;
  22. (o2: {p?:T}); // ok
  23. (o2: {p:T}); // error: o2.p is optional
  24. ({}: O2); // ok
  25. ({p:x}: O2); // ok
  26. ({p:y}: O2); // error: y ~> T
  27. ({p:x,q:y}: O2); // ok
  28.  
  29. // can't make exact from inexact (TODO: force EvalT eagerly)
  30. type O3 = {|...{p:T}|}; ({p:x}: O3); // error: spread result is not exact
  31.  
  32. // exact
  33. type O4 = {...{|p:T|}};
  34. declare var o4: O4;
  35. (o4: {p:T}); // ok
  36. (o4: {|p:T|}); // error: not exact
  37. ({}: O4); // error: property `p` not found
  38. ({p:x}: O4); // ok
  39. ({p:y}: O4); // error: y ~> T
  40. ({p:x,q:y}: O4); // ok
  41.  
  42. // can make exact from exact
  43. type O5 = {|...{|p:T|}|};
  44. declare var o5: O5;
  45. (o5: {p:T}); // ok
  46. (o5: {|p:T|}); // ok
  47. (nil: O5); // error: property `p` not found
  48. ({p:x}: O5); // ok
  49. ({p:y}: O5); // error: y ~> T
  50. ({p:x,q:y}: O5); // error: additional property `q` found
  51.  
  52. // inexact p + exact p
  53. type O6 = {...{p:T},...{|p:U|}};
  54. declare var o6: O6;
  55. (o6: {p:U}); // ok
  56. ({}: O6); // error: property `p` not found
  57. ({p:x}: O6); // error: x ~> U
  58. ({p:y}: O6); // ok
  59. ({p:y,q:x}: O6); // ok
  60.  
  61. // inexact p + exact p ~> exact (TODO: force EvalT eagerly)
  62. type O7 = {|...{p:T},...{|p:U|}|}; ({p:y}: O7);// error: spread result is not exact
  63.  
  64. // exact p + inexact p
  65. type O8 = {...{|p:T|},...{p:U}};
  66. declare var o8: O8;
  67. (o8: {p:T|U}); // ok
  68. (o8.p: T); // error: U ~> T
  69. (o8.p: U); // error: T ~> U
  70.  
  71. // inexact p + exact q
  72. type O9 = {...{p:T},...{|q:U|}};
  73. declare var o9: O9;
  74. (o9: {p?:T,q:U});
  75. (o9.p: T); // error: o9.p is optional
  76. (o9.q: U); // ok
  77.  
  78. // exact p + inexact q
  79. type O10 = {...{|p:T|},...{q:U}};
  80. declare var o10: O10;
  81. (o10: {p:mixed, q?: U}); // ok
  82.  
  83. // inexact p + inexact q
  84. type O11 = {...{p:T},...{q:U}};
  85. declare var o11: O11;
  86. (o11: {p:mixed, q: mixed}); // ok
  87.  
  88. // exact + exact
  89. type O12 = {...{|p:T|},...{|q:U|}};
  90. declare var o12: O12;
  91. (o12: {p:T,q:U}); // ok
  92.  
  93. // inline properties are exact
  94. type O13 = {...{p:T},p:U};
  95. declare var o13: O13;
  96. (o13: {p:U});
  97.  
downloadtype.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