BVB Source Codes

prettier Show rest_type.js Source code

Return Download prettier: download rest_type.js Source code - Download prettier Source code - Type:.js
  1. /* regression tests */
  2.  
  3. type rest_array = <T>(...xs: Array<T>) => T; // Ok, arrays can be rest params
  4.  
  5. type rest_tuple = <T>(...xs: [T]) => T; // Ok, tuples can be rest params
  6.  
  7. type rest_ro_array = <T>(...xs: $ReadOnlyArray<T>) => T;  // Ok
  8.  
  9. type rest_any = (...xs: any) => any; // Ok, any can be a rest param
  10.  
  11. type rest_t = <U, T: Array<U>>(...xs: T) => U; // Ok, bounded targ can be rest
  12.  
  13. type unbound_rest_t = <T>(...xs: T) => void; // Should be error but no way to check yet :(
  14. function test_unbound_rest(f: <T>(x: T, ...xs: T) => void) {
  15.   f(123); // Error - number ~> array - luckily this errors
  16. }
  17.  
  18. type string_rest_t = (...xs: string) => void; // Should be error but no way to check yet :(
  19. function test_string_rest(f: string_rest_t) {
  20.   f('hello'); // Error - string ~> array - luckily this errors
  21. }
  22.  
  23. type Rest = Array<string>;
  24. type rest_alias = (...xs: Rest) => void; // Ok
  25.  
  26. type rest_union = (...xs: [1,2] | Array<number>) => number; // OK
  27.  
  28. type rest_intersection = (...xs: { x: number } & [1,2]) => number; // OK
  29.  
  30. type empty_rest = <T:Array<mixed>>(...xs: T) => T; // OK
  31. ((f: empty_rest) => (f(): empty)); // Error Array ~> empty
  32.  
downloadrest_type.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