babel-schmooze-sprockets 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/bin/console +14 -0
  3. data/bin/export-external-helpers +3 -0
  4. data/bin/setup +6 -0
  5. data/bin/update-npm-deps +8 -0
  6. data/examples/myapp/Gemfile +4 -5
  7. data/examples/myapp/Gemfile.lock +69 -93
  8. data/examples/myapp/app/assets/javascripts/code/hello.es6 +5 -1
  9. data/examples/myapp/app/views/layouts/application.html.erb +1 -0
  10. data/examples/myapp/app/views/site/home.html.erb +0 -1
  11. data/lib/babel-schmooze-sprockets/babel_processor.rb +6 -4
  12. data/lib/babel-schmooze-sprockets/engine.rb +1 -4
  13. data/lib/babel-schmooze-sprockets/version.rb +1 -1
  14. data/node_modules/amdefine/package.json +8 -1
  15. data/node_modules/babel-core/node_modules/babel-runtime/package.json +9 -5
  16. data/node_modules/babel-core/node_modules/babel-traverse/.npmignore +3 -0
  17. data/node_modules/babel-core/node_modules/babel-traverse/README.md +1 -0
  18. data/node_modules/babel-core/node_modules/babel-traverse/lib/cache.js +20 -0
  19. data/node_modules/babel-core/node_modules/babel-traverse/lib/context.js +219 -0
  20. data/node_modules/babel-core/node_modules/babel-traverse/lib/hub.js +19 -0
  21. data/node_modules/babel-core/node_modules/babel-traverse/lib/index.js +250 -0
  22. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/ancestry.js +317 -0
  23. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/comments.js +55 -0
  24. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js +297 -0
  25. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/conversion.js +48 -0
  26. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/evaluation.js +406 -0
  27. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/family.js +168 -0
  28. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/index.js +245 -0
  29. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/inference/index.js +151 -0
  30. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/inference/inferer-reference.js +225 -0
  31. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/inference/inferers.js +198 -0
  32. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/introspection.js +518 -0
  33. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/lib/hoister.js +166 -0
  34. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/lib/removal-hooks.js +64 -0
  35. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/lib/virtual-types.js +141 -0
  36. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/modification.js +293 -0
  37. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/removal.js +72 -0
  38. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/replacement.js +302 -0
  39. data/node_modules/babel-core/node_modules/babel-traverse/lib/scope/binding.js +105 -0
  40. data/node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js +1222 -0
  41. data/node_modules/babel-core/node_modules/babel-traverse/lib/scope/lib/renamer.js +154 -0
  42. data/node_modules/babel-core/node_modules/babel-traverse/lib/visitors.js +360 -0
  43. data/node_modules/babel-core/node_modules/babel-traverse/package.json +107 -0
  44. data/node_modules/babel-core/node_modules/core-js/package.json +20 -2
  45. data/node_modules/babel-core/package.json +31 -24
  46. data/node_modules/babel-generator/lib/buffer.js +69 -70
  47. data/node_modules/babel-generator/lib/generators/base.js +16 -12
  48. data/node_modules/babel-generator/lib/generators/classes.js +28 -19
  49. data/node_modules/babel-generator/lib/generators/expressions.js +76 -99
  50. data/node_modules/babel-generator/lib/generators/flow.js +178 -119
  51. data/node_modules/babel-generator/lib/generators/jsx.js +38 -29
  52. data/node_modules/babel-generator/lib/generators/methods.js +34 -25
  53. data/node_modules/babel-generator/lib/generators/modules.js +67 -40
  54. data/node_modules/babel-generator/lib/generators/statements.js +93 -76
  55. data/node_modules/babel-generator/lib/generators/template-literals.js +12 -11
  56. data/node_modules/babel-generator/lib/generators/types.js +56 -49
  57. data/node_modules/babel-generator/lib/index.js +52 -39
  58. data/node_modules/babel-generator/lib/node/index.js +12 -18
  59. data/node_modules/babel-generator/lib/node/parentheses.js +23 -27
  60. data/node_modules/babel-generator/lib/node/whitespace.js +20 -26
  61. data/node_modules/babel-generator/lib/position.js +5 -5
  62. data/node_modules/babel-generator/lib/printer.js +52 -81
  63. data/node_modules/babel-generator/lib/source-map.js +9 -11
  64. data/node_modules/babel-generator/lib/whitespace.js +13 -13
  65. data/node_modules/babel-generator/node_modules/babel-runtime/package.json +19 -6
  66. data/node_modules/babel-generator/node_modules/babel-types/.npmignore +3 -0
  67. data/node_modules/babel-generator/node_modules/babel-types/README.md +1141 -0
  68. data/node_modules/babel-generator/node_modules/babel-types/lib/constants.js +40 -0
  69. data/node_modules/babel-generator/node_modules/babel-types/lib/converters.js +378 -0
  70. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/core.js +704 -0
  71. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/es2015.js +354 -0
  72. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/experimental.js +85 -0
  73. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/flow.js +319 -0
  74. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/index.js +247 -0
  75. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/init.js +15 -0
  76. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/jsx.js +137 -0
  77. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/misc.js +21 -0
  78. data/node_modules/babel-generator/node_modules/babel-types/lib/flow.js +129 -0
  79. data/node_modules/babel-generator/node_modules/babel-types/lib/index.js +848 -0
  80. data/node_modules/babel-generator/node_modules/babel-types/lib/react.js +83 -0
  81. data/node_modules/babel-generator/node_modules/babel-types/lib/retrievers.js +123 -0
  82. data/node_modules/babel-generator/node_modules/babel-types/lib/validators.js +276 -0
  83. data/node_modules/babel-generator/node_modules/babel-types/package.json +103 -0
  84. data/node_modules/babel-generator/node_modules/core-js/package.json +10 -5
  85. data/node_modules/babel-generator/package.json +19 -16
  86. data/node_modules/babel-helpers/node_modules/babel-runtime/package.json +19 -3
  87. data/node_modules/babel-helpers/node_modules/core-js/package.json +20 -4
  88. data/node_modules/babel-helpers/package.json +8 -1
  89. data/node_modules/babel-register/node_modules/babel-runtime/package.json +19 -3
  90. data/node_modules/babel-register/node_modules/core-js/package.json +20 -4
  91. data/node_modules/babel-register/package.json +8 -1
  92. data/node_modules/balanced-match/package.json +8 -1
  93. data/node_modules/brace-expansion/package.json +19 -12
  94. data/node_modules/concat-map/package.json +9 -2
  95. data/node_modules/convert-source-map/package.json +8 -1
  96. data/node_modules/detect-indent/package.json +8 -1
  97. data/node_modules/get-stdin/package.json +8 -1
  98. data/node_modules/home-or-tmp/package.json +9 -2
  99. data/node_modules/is-finite/package.json +8 -2
  100. data/node_modules/json5/package.json +8 -1
  101. data/node_modules/minimatch/README.md +2 -9
  102. data/node_modules/minimatch/minimatch.js +15 -3
  103. data/node_modules/minimatch/package.json +29 -21
  104. data/node_modules/minimist/package.json +8 -1
  105. data/node_modules/mkdirp/node_modules/minimist/package.json +8 -1
  106. data/node_modules/mkdirp/package.json +8 -1
  107. data/node_modules/number-is-nan/package.json +8 -1
  108. data/node_modules/os-tmpdir/package.json +8 -1
  109. data/node_modules/path-exists/package.json +8 -1
  110. data/node_modules/path-is-absolute/package.json +8 -1
  111. data/node_modules/repeating/package.json +15 -11
  112. data/node_modules/shebang-regex/package.json +8 -1
  113. data/node_modules/slash/package.json +8 -1
  114. data/node_modules/source-map-support/node_modules/source-map/package.json +8 -1
  115. data/node_modules/source-map-support/package.json +8 -1
  116. data/node_modules/source-map/package.json +8 -1
  117. data/node_modules/user-home/package.json +8 -1
  118. data/package.json +1 -1
  119. metadata +54 -6
  120. data/node_modules/brace-expansion/.npmignore +0 -3
  121. data/node_modules/brace-expansion/example.js +0 -8
  122. data/node_modules/minimatch/browser.js +0 -1159
@@ -1,28 +1,28 @@
1
- /*istanbul ignore next*/"use strict";
1
+ "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.TypeParameterDeclaration = exports.NumericLiteralTypeAnnotation = exports.GenericTypeAnnotation = exports.ClassImplements = undefined;
4
+ exports.TypeParameterDeclaration = exports.StringLiteralTypeAnnotation = exports.NumericLiteralTypeAnnotation = exports.GenericTypeAnnotation = exports.ClassImplements = undefined;
5
5
  exports.AnyTypeAnnotation = AnyTypeAnnotation;
6
- /*istanbul ignore next*/exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
7
- /*istanbul ignore next*/exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
8
- /*istanbul ignore next*/exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation;
9
- /*istanbul ignore next*/exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation;
10
- /*istanbul ignore next*/exports.DeclareClass = DeclareClass;
11
- /*istanbul ignore next*/exports.DeclareFunction = DeclareFunction;
12
- /*istanbul ignore next*/exports.DeclareInterface = DeclareInterface;
13
- /*istanbul ignore next*/exports.DeclareModule = DeclareModule;
14
- /*istanbul ignore next*/exports.DeclareTypeAlias = DeclareTypeAlias;
15
- /*istanbul ignore next*/exports.DeclareVariable = DeclareVariable;
16
- /*istanbul ignore next*/exports.ExistentialTypeParam = ExistentialTypeParam;
17
- /*istanbul ignore next*/exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
18
- /*istanbul ignore next*/exports.FunctionTypeParam = FunctionTypeParam;
19
- /*istanbul ignore next*/exports.InterfaceExtends = InterfaceExtends;
20
- /*istanbul ignore next*/exports._interfaceish = _interfaceish;
21
- /*istanbul ignore next*/exports.InterfaceDeclaration = InterfaceDeclaration;
22
- /*istanbul ignore next*/exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
23
- /*istanbul ignore next*/exports.MixedTypeAnnotation = MixedTypeAnnotation;
24
- /*istanbul ignore next*/exports.NullableTypeAnnotation = NullableTypeAnnotation;
25
- /*istanbul ignore next*/
6
+ exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
7
+ exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
8
+ exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation;
9
+ exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation;
10
+ exports.DeclareClass = DeclareClass;
11
+ exports.DeclareFunction = DeclareFunction;
12
+ exports.DeclareInterface = DeclareInterface;
13
+ exports.DeclareModule = DeclareModule;
14
+ exports.DeclareTypeAlias = DeclareTypeAlias;
15
+ exports.DeclareVariable = DeclareVariable;
16
+ exports.ExistentialTypeParam = ExistentialTypeParam;
17
+ exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
18
+ exports.FunctionTypeParam = FunctionTypeParam;
19
+ exports.InterfaceExtends = InterfaceExtends;
20
+ exports._interfaceish = _interfaceish;
21
+ exports.InterfaceDeclaration = InterfaceDeclaration;
22
+ exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
23
+ exports.MixedTypeAnnotation = MixedTypeAnnotation;
24
+ exports.NullableTypeAnnotation = NullableTypeAnnotation;
25
+
26
26
  var _types = require("./types");
27
27
 
28
28
  Object.defineProperty(exports, "NumericLiteralTypeAnnotation", {
@@ -31,116 +31,134 @@ Object.defineProperty(exports, "NumericLiteralTypeAnnotation", {
31
31
  return _types.NumericLiteral;
32
32
  }
33
33
  });
34
- /*istanbul ignore next*/exports.NumberTypeAnnotation = NumberTypeAnnotation;
35
- /*istanbul ignore next*/exports.StringLiteralTypeAnnotation = StringLiteralTypeAnnotation;
36
- /*istanbul ignore next*/exports.StringTypeAnnotation = StringTypeAnnotation;
37
- /*istanbul ignore next*/exports.ThisTypeAnnotation = ThisTypeAnnotation;
38
- /*istanbul ignore next*/exports.TupleTypeAnnotation = TupleTypeAnnotation;
39
- /*istanbul ignore next*/exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
40
- /*istanbul ignore next*/exports.TypeAlias = TypeAlias;
41
- /*istanbul ignore next*/exports.TypeAnnotation = TypeAnnotation;
42
- /*istanbul ignore next*/exports.TypeParameterInstantiation = TypeParameterInstantiation;
43
- /*istanbul ignore next*/exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
44
- /*istanbul ignore next*/exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
45
- /*istanbul ignore next*/exports.ObjectTypeIndexer = ObjectTypeIndexer;
46
- /*istanbul ignore next*/exports.ObjectTypeProperty = ObjectTypeProperty;
47
- /*istanbul ignore next*/exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
48
- /*istanbul ignore next*/exports.UnionTypeAnnotation = UnionTypeAnnotation;
49
- /*istanbul ignore next*/exports.TypeCastExpression = TypeCastExpression;
50
- /*istanbul ignore next*/exports.VoidTypeAnnotation = VoidTypeAnnotation;
51
-
52
- var /*istanbul ignore next*/_babelTypes = require("babel-types");
53
-
54
- /*istanbul ignore next*/
34
+ Object.defineProperty(exports, "StringLiteralTypeAnnotation", {
35
+ enumerable: true,
36
+ get: function get() {
37
+ return _types.StringLiteral;
38
+ }
39
+ });
40
+ exports.NumberTypeAnnotation = NumberTypeAnnotation;
41
+ exports.StringTypeAnnotation = StringTypeAnnotation;
42
+ exports.ThisTypeAnnotation = ThisTypeAnnotation;
43
+ exports.TupleTypeAnnotation = TupleTypeAnnotation;
44
+ exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
45
+ exports.TypeAlias = TypeAlias;
46
+ exports.TypeAnnotation = TypeAnnotation;
47
+ exports.TypeParameter = TypeParameter;
48
+ exports.TypeParameterInstantiation = TypeParameterInstantiation;
49
+ exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
50
+ exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
51
+ exports.ObjectTypeIndexer = ObjectTypeIndexer;
52
+ exports.ObjectTypeProperty = ObjectTypeProperty;
53
+ exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
54
+ exports.UnionTypeAnnotation = UnionTypeAnnotation;
55
+ exports.TypeCastExpression = TypeCastExpression;
56
+ exports.VoidTypeAnnotation = VoidTypeAnnotation;
57
+
58
+ var _babelTypes = require("babel-types");
59
+
55
60
  var t = _interopRequireWildcard(_babelTypes);
56
61
 
57
- /*istanbul ignore next*/
58
62
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
59
63
 
60
64
  function AnyTypeAnnotation() {
61
- this.push("any");
65
+ this.word("any");
62
66
  } /* eslint max-len: 0 */
63
67
 
64
68
  function ArrayTypeAnnotation(node) {
65
69
  this.print(node.elementType, node);
66
- this.push("[");
67
- this.push("]");
70
+ this.token("[");
71
+ this.token("]");
68
72
  }
69
73
 
70
74
  function BooleanTypeAnnotation() {
71
- this.push("bool");
75
+ this.word("bool");
72
76
  }
73
77
 
74
78
  function BooleanLiteralTypeAnnotation(node) {
75
- this.push(node.value ? "true" : "false");
79
+ this.word(node.value ? "true" : "false");
76
80
  }
77
81
 
78
82
  function NullLiteralTypeAnnotation() {
79
- this.push("null");
83
+ this.word("null");
80
84
  }
81
85
 
82
86
  function DeclareClass(node) {
83
- this.push("declare class ");
87
+ this.word("declare");
88
+ this.space();
89
+ this.word("class");
90
+ this.space();
84
91
  this._interfaceish(node);
85
92
  }
86
93
 
87
94
  function DeclareFunction(node) {
88
- this.push("declare function ");
95
+ this.word("declare");
96
+ this.space();
97
+ this.word("function");
98
+ this.space();
89
99
  this.print(node.id, node);
90
100
  this.print(node.id.typeAnnotation.typeAnnotation, node);
91
101
  this.semicolon();
92
102
  }
93
103
 
94
104
  function DeclareInterface(node) {
95
- this.push("declare ");
105
+ this.word("declare");
106
+ this.space();
96
107
  this.InterfaceDeclaration(node);
97
108
  }
98
109
 
99
110
  function DeclareModule(node) {
100
- this.push("declare module ");
111
+ this.word("declare");
112
+ this.space();
113
+ this.word("module");
114
+ this.space();
101
115
  this.print(node.id, node);
102
116
  this.space();
103
117
  this.print(node.body, node);
104
118
  }
105
119
 
106
120
  function DeclareTypeAlias(node) {
107
- this.push("declare ");
121
+ this.word("declare");
122
+ this.space();
108
123
  this.TypeAlias(node);
109
124
  }
110
125
 
111
126
  function DeclareVariable(node) {
112
- this.push("declare var ");
127
+ this.word("declare");
128
+ this.space();
129
+ this.word("var");
130
+ this.space();
113
131
  this.print(node.id, node);
114
132
  this.print(node.id.typeAnnotation, node);
115
133
  this.semicolon();
116
134
  }
117
135
 
118
136
  function ExistentialTypeParam() {
119
- this.push("*");
137
+ this.token("*");
120
138
  }
121
139
 
122
140
  function FunctionTypeAnnotation(node, parent) {
123
141
  this.print(node.typeParameters, node);
124
- this.push("(");
142
+ this.token("(");
125
143
  this.printList(node.params, node);
126
144
 
127
145
  if (node.rest) {
128
146
  if (node.params.length) {
129
- this.push(",");
147
+ this.token(",");
130
148
  this.space();
131
149
  }
132
- this.push("...");
150
+ this.token("...");
133
151
  this.print(node.rest, node);
134
152
  }
135
153
 
136
- this.push(")");
154
+ this.token(")");
137
155
 
138
156
  // this node type is overloaded, not sure why but it makes it EXTREMELY annoying
139
157
  if (parent.type === "ObjectTypeProperty" || parent.type === "ObjectTypeCallProperty" || parent.type === "DeclareFunction") {
140
- this.push(":");
158
+ this.token(":");
141
159
  } else {
142
160
  this.space();
143
- this.push("=>");
161
+ this.token("=>");
144
162
  }
145
163
 
146
164
  this.space();
@@ -149,8 +167,8 @@ function FunctionTypeAnnotation(node, parent) {
149
167
 
150
168
  function FunctionTypeParam(node) {
151
169
  this.print(node.name, node);
152
- if (node.optional) this.push("?");
153
- this.push(":");
170
+ if (node.optional) this.token("?");
171
+ this.token(":");
154
172
  this.space();
155
173
  this.print(node.typeAnnotation, node);
156
174
  }
@@ -160,118 +178,144 @@ function InterfaceExtends(node) {
160
178
  this.print(node.typeParameters, node);
161
179
  }
162
180
 
163
- /*istanbul ignore next*/exports.ClassImplements = InterfaceExtends;
164
- /*istanbul ignore next*/exports.GenericTypeAnnotation = InterfaceExtends;
181
+ exports.ClassImplements = InterfaceExtends;
182
+ exports.GenericTypeAnnotation = InterfaceExtends;
165
183
  function _interfaceish(node) {
166
184
  this.print(node.id, node);
167
185
  this.print(node.typeParameters, node);
168
186
  if (node.extends.length) {
169
- this.push(" extends ");
170
- this.printJoin(node.extends, node, { separator: ", " });
187
+ this.space();
188
+ this.word("extends");
189
+ this.space();
190
+ this.printList(node.extends, node);
171
191
  }
172
192
  if (node.mixins && node.mixins.length) {
173
- this.push(" mixins ");
174
- this.printJoin(node.mixins, node, { separator: ", " });
193
+ this.space();
194
+ this.word("mixins");
195
+ this.space();
196
+ this.printList(node.mixins, node);
175
197
  }
176
198
  this.space();
177
199
  this.print(node.body, node);
178
200
  }
179
201
 
180
202
  function InterfaceDeclaration(node) {
181
- this.push("interface ");
203
+ this.word("interface");
204
+ this.space();
182
205
  this._interfaceish(node);
183
206
  }
184
207
 
208
+ function andSeparator() {
209
+ this.space();
210
+ this.token("&");
211
+ this.space();
212
+ }
213
+
185
214
  function IntersectionTypeAnnotation(node) {
186
- this.printJoin(node.types, node, { separator: " & " });
215
+ this.printJoin(node.types, node, { separator: andSeparator });
187
216
  }
188
217
 
189
218
  function MixedTypeAnnotation() {
190
- this.push("mixed");
219
+ this.word("mixed");
191
220
  }
192
221
 
193
222
  function NullableTypeAnnotation(node) {
194
- this.push("?");
223
+ this.token("?");
195
224
  this.print(node.typeAnnotation, node);
196
225
  }
197
226
 
198
227
  function NumberTypeAnnotation() {
199
- this.push("number");
200
- }
201
-
202
- function StringLiteralTypeAnnotation(node) {
203
- this.push(this._stringLiteral(node.value));
228
+ this.word("number");
204
229
  }
205
230
 
206
231
  function StringTypeAnnotation() {
207
- this.push("string");
232
+ this.word("string");
208
233
  }
209
234
 
210
235
  function ThisTypeAnnotation() {
211
- this.push("this");
236
+ this.word("this");
212
237
  }
213
238
 
214
239
  function TupleTypeAnnotation(node) {
215
- this.push("[");
216
- this.printJoin(node.types, node, { separator: ", " });
217
- this.push("]");
240
+ this.token("[");
241
+ this.printList(node.types, node);
242
+ this.token("]");
218
243
  }
219
244
 
220
245
  function TypeofTypeAnnotation(node) {
221
- this.push("typeof ");
246
+ this.word("typeof");
247
+ this.space();
222
248
  this.print(node.argument, node);
223
249
  }
224
250
 
225
251
  function TypeAlias(node) {
226
- this.push("type ");
252
+ this.word("type");
253
+ this.space();
227
254
  this.print(node.id, node);
228
255
  this.print(node.typeParameters, node);
229
256
  this.space();
230
- this.push("=");
257
+ this.token("=");
231
258
  this.space();
232
259
  this.print(node.right, node);
233
260
  this.semicolon();
234
261
  }
235
262
 
236
263
  function TypeAnnotation(node) {
237
- this.push(":");
264
+ this.token(":");
238
265
  this.space();
239
- if (node.optional) this.push("?");
266
+ if (node.optional) this.token("?");
240
267
  this.print(node.typeAnnotation, node);
241
268
  }
242
269
 
270
+ function TypeParameter(node) {
271
+ if (node.variance === "plus") {
272
+ this.token("+");
273
+ } else if (node.variance === "minus") {
274
+ this.token("-");
275
+ }
276
+
277
+ this.word(node.name);
278
+
279
+ if (node.bound) {
280
+ this.print(node.bound, node);
281
+ }
282
+
283
+ if (node.default) {
284
+ this.space();
285
+ this.token("=");
286
+ this.space();
287
+ this.print(node.default, node);
288
+ }
289
+ }
290
+
243
291
  function TypeParameterInstantiation(node) {
244
- /*istanbul ignore next*/
245
292
  var _this = this;
246
293
 
247
- this.push("<");
248
- this.printJoin(node.params, node, {
249
- separator: ", ",
250
- iterator: function /*istanbul ignore next*/iterator(node) {
251
- /*istanbul ignore next*/_this.print(node.typeAnnotation, node);
294
+ this.token("<");
295
+ this.printList(node.params, node, {
296
+ iterator: function iterator(node) {
297
+ _this.print(node.typeAnnotation, node);
252
298
  }
253
299
  });
254
- this.push(">");
300
+ this.token(">");
255
301
  }
256
302
 
257
- /*istanbul ignore next*/exports.TypeParameterDeclaration = TypeParameterInstantiation;
303
+ exports.TypeParameterDeclaration = TypeParameterInstantiation;
258
304
  function ObjectTypeAnnotation(node) {
259
- /*istanbul ignore next*/
260
305
  var _this2 = this;
261
306
 
262
- this.push("{");
307
+ this.token("{");
263
308
  var props = node.properties.concat(node.callProperties, node.indexers);
264
309
 
265
310
  if (props.length) {
266
311
  this.space();
267
312
 
268
313
  this.printJoin(props, node, {
269
- separator: false,
270
314
  indent: true,
271
- iterator: function /*istanbul ignore next*/iterator() {
315
+ iterator: function iterator() {
272
316
  if (props.length !== 1) {
273
- /*istanbul ignore next*/_this2.semicolon();
274
- /*istanbul ignore next*/_this2.space();
317
+ _this2.semicolon();
318
+ _this2.space();
275
319
  }
276
320
  }
277
321
  });
@@ -279,33 +323,42 @@ function ObjectTypeAnnotation(node) {
279
323
  this.space();
280
324
  }
281
325
 
282
- this.push("}");
326
+ this.token("}");
283
327
  }
284
328
 
285
329
  function ObjectTypeCallProperty(node) {
286
- if (node.static) this.push("static ");
330
+ if (node.static) {
331
+ this.word("static");
332
+ this.space();
333
+ }
287
334
  this.print(node.value, node);
288
335
  }
289
336
 
290
337
  function ObjectTypeIndexer(node) {
291
- if (node.static) this.push("static ");
292
- this.push("[");
338
+ if (node.static) {
339
+ this.word("static");
340
+ this.space();
341
+ }
342
+ this.token("[");
293
343
  this.print(node.id, node);
294
- this.push(":");
344
+ this.token(":");
295
345
  this.space();
296
346
  this.print(node.key, node);
297
- this.push("]");
298
- this.push(":");
347
+ this.token("]");
348
+ this.token(":");
299
349
  this.space();
300
350
  this.print(node.value, node);
301
351
  }
302
352
 
303
353
  function ObjectTypeProperty(node) {
304
- if (node.static) this.push("static ");
354
+ if (node.static) {
355
+ this.word("static");
356
+ this.space();
357
+ }
305
358
  this.print(node.key, node);
306
- if (node.optional) this.push("?");
359
+ if (node.optional) this.token("?");
307
360
  if (!t.isFunctionTypeAnnotation(node.value)) {
308
- this.push(":");
361
+ this.token(":");
309
362
  this.space();
310
363
  }
311
364
  this.print(node.value, node);
@@ -313,21 +366,27 @@ function ObjectTypeProperty(node) {
313
366
 
314
367
  function QualifiedTypeIdentifier(node) {
315
368
  this.print(node.qualification, node);
316
- this.push(".");
369
+ this.token(".");
317
370
  this.print(node.id, node);
318
371
  }
319
372
 
373
+ function orSeparator() {
374
+ this.space();
375
+ this.token("|");
376
+ this.space();
377
+ }
378
+
320
379
  function UnionTypeAnnotation(node) {
321
- this.printJoin(node.types, node, { separator: " | " });
380
+ this.printJoin(node.types, node, { separator: orSeparator });
322
381
  }
323
382
 
324
383
  function TypeCastExpression(node) {
325
- this.push("(");
384
+ this.token("(");
326
385
  this.print(node.expression, node);
327
386
  this.print(node.typeAnnotation, node);
328
- this.push(")");
387
+ this.token(")");
329
388
  }
330
389
 
331
390
  function VoidTypeAnnotation() {
332
- this.push("void");
391
+ this.word("void");
333
392
  }