BVB Source Codes

prettier Show import_type.js Source code

Return Download prettier: download import_type.js Source code - Download prettier Source code - Type:.js
  1. /**
  2.  * @flow
  3.  */
  4.  
  5. /////////////////////////////////////////////////
  6. // == Importing Class Type (Default Export) == //
  7. /////////////////////////////////////////////////
  8.  
  9. import type ClassFoo1 from "./ExportDefault_Class";
  10. import {foo1Inst} from "./ExportDefault_Class";
  11.  
  12. var a1: ClassFoo1 = foo1Inst;
  13. var a2: number = foo1Inst; // Error: ClassFoo1 ~> number
  14. new ClassFoo1(); // Error: ClassFoo1 is not a value-identifier
  15.  
  16. ///////////////////////////////////////////////
  17. // == Importing Class Type (Named Export) == //
  18. ///////////////////////////////////////////////
  19.  
  20. import type {ClassFoo2} from "./ExportNamed_Class";
  21. import {foo2Inst} from "./ExportNamed_Class";
  22.  
  23. var b1: ClassFoo2 = foo2Inst;
  24. var b2: number = foo2Inst; // Error: ClassFoo2 ~> number
  25. new ClassFoo2(); // Error: ClassFoo2 is not a value-identifier
  26.  
  27. /////////////////////////////////////////////////////
  28. // == Importing Class Type (CJS Default Export) == //
  29. /////////////////////////////////////////////////////
  30.  
  31. import type ClassFoo3T from "./ExportCJSDefault_Class";
  32. import ClassFoo3 from "./ExportCJSDefault_Class";
  33. var c1: ClassFoo3T = new ClassFoo3();
  34. new ClassFoo3T(); // Error: ClassFoo3 is not a value-identifier
  35.  
  36. ///////////////////////////////////////////////////
  37. // == Importing Class Type (CJS Named Export) == //
  38. ///////////////////////////////////////////////////
  39.  
  40. import type {ClassFoo4, ClassFoo5} from "./ExportCJSNamed_Class";
  41. import {foo4Inst, foo5Inst} from "./ExportCJSNamed_Class";
  42.  
  43. var d1: ClassFoo4 = foo4Inst;
  44. var d2: number = foo4Inst; // Error: ClassFoo4 ~> number
  45. new ClassFoo4(); // Error: ClassFoo4 is not a value-identifier
  46. // TODO: this errors correctly, but the message is just 'can't resolve name'
  47. var d3: typeof ClassFoo5 = foo5Inst; // Error: Can't typeof a type alias
  48.  
  49. ////////////////////////////////////////////
  50. // == Import Type Alias (Named Export) == //
  51. ////////////////////////////////////////////
  52.  
  53. import type {AliasFoo3} from "./ExportNamed_Alias";
  54. import {givesAFoo3Obj} from "./ExportNamed_Alias";
  55. var e1: AliasFoo3 = givesAFoo3Obj();
  56. var e2: number = givesAFoo3Obj(); // Error: AliasFoo3 ~> number
  57. var e3: typeof AliasFoo3 = givesAFoo3Obj(); // Error: Can't typeof a type alias
  58.  
  59. //////////////////////////////////////////////
  60. // == Import Type Alias (Default Export) == //
  61. //////////////////////////////////////////////
  62.  
  63. // TODO: No support for this right now. It's most likely possible, but it's
  64. //       unclear how useful it is at the moment and it entails a little
  65. //       more work than named type exports, so I'm punting on it for now.
  66.  
  67. ///////////////////////////////////////////////////////
  68. // == Import Type With Non-Alias Compatible Value == //
  69. ///////////////////////////////////////////////////////
  70.  
  71. import type {numValue} from "./ExportsANumber"; // Error: Cannot import-type a number value
  72.  
  73. ////////////////////////////////////////////////////////////////////////
  74. // == Regression Test: https://github.com/facebook/flow/issues/359 == //
  75. // Ensure that type bindings stay type bindings across function body  //
  76. // env contexts.                                                      //
  77. ////////////////////////////////////////////////////////////////////////
  78.  
  79. import type ClassFoo6 from "./issue-359";
  80. function foo() {
  81.   ClassFoo6; // Error: Not a value binding
  82. }
  83.  
downloadimport_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