BVB Source Codes

prettier Show scope.js Source code

Return Download prettier: download scope.js Source code - Download prettier Source code - Type:.js
  1. function block_scope() {
  2.   let a: number = 0;
  3.   var b: number = 0;
  4.   {
  5.     let a = ""; // ok: local to block
  6.     var b = ""; // error: string ~> number
  7.   }
  8. }
  9.  
  10. function switch_scope(x: string) {
  11.   let a: number = 0;
  12.   var b: number = 0;
  13.   switch (x) {
  14.     case "foo":
  15.       let a = ""; // ok: local to switch
  16.       var b = ""; // error: string ~> number
  17.       break;
  18.     case "bar":
  19.       let a = ""; // error: a already bound in switch
  20.       break;
  21.   }
  22. }
  23.  
  24. // a switch is a single lexical scope, so lets and non-disjoint
  25. // cases can mix in odd ways. our support for edge cases is not
  26. // yet perfect.
  27. function switch_scope2(x: number) {
  28.   switch (x) {
  29.     case 0:
  30.      a = "";     // error: assign before declaration
  31.      break;
  32.     case 1:
  33.      var b = a;  // error: use before declaration
  34.      break;
  35.     case 2:
  36.       let a = "";
  37.       break;
  38.     case 3:
  39.       a = "";     // error: skipped initializer
  40.       break;
  41.     case 4:
  42.       var c:string = a;  // error: skipped initializer
  43.       break;
  44.   }
  45.   a = ""; // error: a no longer in scope
  46. }
  47.  
  48. function try_scope() {
  49.   let a: number = 0;
  50.   try {
  51.     let a = ""; // ok
  52.   } catch (e) {
  53.     let a = ""; // ok
  54.   } finally {
  55.     let a = ""; // ok
  56.   }
  57. }
  58.  
  59. function for_scope_let() {
  60.   let a: number = 0;
  61.   for (let a = "" /* ok: local to init */;;) {}
  62. }
  63.  
  64. function for_scope_var() {
  65.   var a: number = 0;
  66.   for (var a = "" /* error: string ~> number */;;) {}
  67. }
  68.  
  69. function for_in_scope_let(o: Object) {
  70.   let a: number = 0;
  71.   for (let a /* ok: local to init */ in o) {}
  72. }
  73.  
  74. function for_in_scope_var(o: Object) {
  75.   var a: number = 0;
  76.   for (var a /* error: string ~> number */ in o) {}
  77. }
  78.  
  79. function for_of_scope_let(xs: string[]) {
  80.   let a: number = 0;
  81.   for (let a /* ok: local to init */ of xs) {}
  82. }
  83.  
  84. function for_of_scope_var(xs: string[]) {
  85.   var a: number = 0;
  86.   for (var a /* error: string ~> number */ of xs) {}
  87. }
  88.  
  89. function default_param_1() {
  90.   // function binding in scope in default expr
  91.   function f(
  92.     x: () => string = f // error: number ~> string
  93.   ): number {
  94.     return 0;
  95.   }
  96. }
  97.  
  98. function default_param_2() {
  99.   // fn body bindings not visible from param scope
  100.   let a = "";
  101.   function f0(x = () => a): number {
  102.     let a = 0;
  103.     return x(); // error: string ~> number
  104.   }
  105.   function f1(x = b /* error: cannot resolve b */): number {
  106.     let b = 0;
  107.     return x;
  108.   }
  109. }
  110.  
downloadscope.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