BVB Source Codes

prettier Show import_typeof.js Source code

Return Download prettier: download import_typeof.js Source code - Download prettier Source code - Type:.js
  1. /**
  2.  * @flow
  3.  */
  4.  
  5. ///////////////////////////////////////////////////
  6. // == Importing Class Typeof (Default Export) == //
  7. ///////////////////////////////////////////////////
  8.  
  9. import typeof ClassFoo1T from "./ExportDefault_Class";
  10. import ClassFoo1 from "./ExportDefault_Class";
  11.  
  12. var a1: ClassFoo1T = ClassFoo1;
  13. var a2: ClassFoo1T = new ClassFoo1(); // Error: ClassFoo1 (inst) ~> ClassFoo1 (class)
  14. new ClassFoo1T(); // Error: ClassFoo1T is not bound to a value
  15.  
  16. /////////////////////////////////////////////////
  17. // == Importing Class Typeof (Named Export) == //
  18. /////////////////////////////////////////////////
  19.  
  20. import typeof {ClassFoo2 as ClassFoo2T} from "./ExportNamed_Class";
  21. import {ClassFoo2} from "./ExportNamed_Class";
  22.  
  23. var b1: ClassFoo2T = ClassFoo2;
  24. var b2: ClassFoo2T = new ClassFoo2(); // Error: ClassFoo2 (inst) ~> ClassFoo2 (class)
  25. new ClassFoo2T(); // Error: ClassFoo2T is not bound to a value
  26.  
  27. ///////////////////////////////////////////////////////
  28. // == Importing Class Typeof (CJS Default Export) == //
  29. ///////////////////////////////////////////////////////
  30.  
  31. import typeof ClassFoo3T from "./ExportCJSDefault_Class";
  32. import ClassFoo3 from "./ExportCJSDefault_Class";
  33.  
  34. var c1: ClassFoo3T = ClassFoo3;
  35. var c2: ClassFoo3T = new ClassFoo3(); // Error: ClassFoo3 (inst) ~> ClassFoo3 (class)
  36.  
  37. /////////////////////////////////////////////////////
  38. // == Importing Class Typeof (CJS Named Export) == //
  39. /////////////////////////////////////////////////////
  40.  
  41. import typeof {ClassFoo4 as ClassFoo4T} from "./ExportCJSNamed_Class";
  42. import {ClassFoo4} from "./ExportCJSNamed_Class";
  43.  
  44. var d1: ClassFoo4T = ClassFoo4;
  45. var d2: ClassFoo4T = new ClassFoo4(); // Error: ClassFoo4 (inst) ~> ClassFoo4 (class)
  46.  
  47. //////////////////////////////////////////////
  48. // == Import Typeof Alias (Named Export) == //
  49. //////////////////////////////////////////////
  50.  
  51. import typeof {AliasFoo3} from "./ExportNamed_Alias"; // Error: Can't `import typeof` type aliases!
  52.  
  53. ////////////////////////////////////////////////
  54. // == Import Typeof Alias (Default Export) == //
  55. ////////////////////////////////////////////////
  56.  
  57. // TODO: No support for this right now. It's most likely possible, but it's
  58. //       unclear how useful it is at the moment and it entails a little
  59. //       more work than named type exports, so I'm punting on it for now.
  60.  
  61. ///////////////////////////////////////////////////////////////
  62. // == Import Typeof With Non-Class Value (Default Export) == //
  63. ///////////////////////////////////////////////////////////////
  64.  
  65. import typeof num_default from "./ExportDefault_Number";
  66.  
  67. var f1: num_default = 42;
  68. var f2: num_default = 'asdf'; // Error: string ~> number
  69.  
  70. /////////////////////////////////////////////////////////////
  71. // == Import Typeof With Non-Class Value (Named Export) == //
  72. /////////////////////////////////////////////////////////////
  73.  
  74. import typeof {num as num_named} from "./ExportNamed_Number";
  75.  
  76. var g1: num_named = 42;
  77. var g2: num_named = 'asdf'; // Error: string ~> number
  78.  
  79. ///////////////////////////////////////////////////////////////////
  80. // == Import Typeof With Non-Class Value (CJS Default Export) == //
  81. ///////////////////////////////////////////////////////////////////
  82.  
  83. import typeof num_cjs_default from "./ExportCJSDefault_Number";
  84.  
  85. var h1: num_cjs_default = 42;
  86. var h2: num_cjs_default = 'asdf'; // Error: string ~> number
  87.  
  88. /////////////////////////////////////////////////////////////////
  89. // == Import Typeof With Non-Class Value (CJS Named Export) == //
  90. /////////////////////////////////////////////////////////////////
  91.  
  92. import typeof {num as num_cjs_named} from "./ExportCJSNamed_Number";
  93.  
  94. var i1: num_cjs_named = 42;
  95. var i2: num_cjs_named = 'asdf'; // Error: string ~> number
  96.  
  97. ///////////////////////////////////////////////
  98. // == Import Typeof ModuleNamespaceObject == //
  99. ///////////////////////////////////////////////
  100.  
  101. import typeof * as ModuleNSObjT from "./ExportNamed_Multi";
  102. var j1: ModuleNSObjT = {num: 42, str: 'asdf'};
  103. var j2: ModuleNSObjT = {num: 42, str: 42}; // Error: number ~> string
  104.  
downloadimport_typeof.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