BVB Source Codes

prettier Show destructuring.js Source code

Return Download prettier: download destructuring.js Source code - Download prettier Source code - Type:.js
  1. declare var a:string;
  2. declare var b:string;
  3. declare var c:string;
  4. [{a1:a, b},c] = [{a1:0, b:1},2];
  5.  
  6. var {m} = {m:0};
  7. ({m} = {m:m});
  8.  
  9. var obj;
  10. ({n: obj.x} = {n:3});
  11. [obj.x] = ['foo'];
  12.  
  13. function foo({p, z:[r]}) {
  14.     a = p;
  15.     b = z;
  16.     c = r;
  17. }
  18. foo({p:0, z:[1,2]});
  19.  
  20. [a,,b,...c] = [0,1,true,3];
  21.  
  22. function bar({x, ...z}) {
  23.     var o:{x: string; y: number;} = z;
  24. }
  25. bar({x:"",y:0});
  26.  
  27. var spread = {y:""};
  28. var extend: {x:number; y:string; z: boolean} = {x:0, ...spread};
  29.  
  30. function qux(_: {a:number}) { }
  31. qux({a:""});
  32. function corge({b}: {b:string}) { }
  33. corge({b:0});
  34.  
  35. var {n}:{n: number} = {n: ""}
  36.  
  37. function test() {
  38.   var {foo} = {bar: 123}; // error on foo
  39.   var {bar, baz} = {bar: 123} // error on baz
  40. }
  41.  
  42. function test() {
  43.   var x = {foo: 'abc', bar: 123};
  44.   var {foo, ...rest} = x;
  45.   (x.baz: string); // error, baz doesn't exist
  46.   (rest.baz: string); // no error, rest is unsealed
  47. }
  48.  
  49. module.exports = corge;
  50.  
  51. class Base {
  52.   baseprop1: number;
  53.   baseprop2: number;
  54. }
  55.  
  56. class Child extends Base {
  57.   childprop1: number;
  58.   childprop2: number;
  59. }
  60.  
  61. var {baseprop1, childprop1, ...others} = new Child();
  62.  
  63. var bp1: number = baseprop1;
  64. var bp1_err: string = baseprop1; // Error: number ~> string
  65. var bp2: number = others.baseprop2;
  66. var bp2_err: string = others.baseprop2; // Error: number ~> string
  67.  
  68. var cp1: number = childprop1;
  69. var cp1_err: string = childprop1; // Error: number ~> string
  70. var cp2: number = others.childprop1;
  71. var cp2_err: string = others.childprop2; // Error: number ~> string
  72.  
downloaddestructuring.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