1 | "use strict";
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.AnyTypeAnnotation = AnyTypeAnnotation;
|
---|
7 | exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
|
---|
8 | exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation;
|
---|
9 | exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
|
---|
10 | exports.DeclareClass = DeclareClass;
|
---|
11 | exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration;
|
---|
12 | exports.DeclareExportDeclaration = DeclareExportDeclaration;
|
---|
13 | exports.DeclareFunction = DeclareFunction;
|
---|
14 | exports.DeclareInterface = DeclareInterface;
|
---|
15 | exports.DeclareModule = DeclareModule;
|
---|
16 | exports.DeclareModuleExports = DeclareModuleExports;
|
---|
17 | exports.DeclareOpaqueType = DeclareOpaqueType;
|
---|
18 | exports.DeclareTypeAlias = DeclareTypeAlias;
|
---|
19 | exports.DeclareVariable = DeclareVariable;
|
---|
20 | exports.DeclaredPredicate = DeclaredPredicate;
|
---|
21 | exports.EmptyTypeAnnotation = EmptyTypeAnnotation;
|
---|
22 | exports.EnumBooleanBody = EnumBooleanBody;
|
---|
23 | exports.EnumBooleanMember = EnumBooleanMember;
|
---|
24 | exports.EnumDeclaration = EnumDeclaration;
|
---|
25 | exports.EnumDefaultedMember = EnumDefaultedMember;
|
---|
26 | exports.EnumNumberBody = EnumNumberBody;
|
---|
27 | exports.EnumNumberMember = EnumNumberMember;
|
---|
28 | exports.EnumStringBody = EnumStringBody;
|
---|
29 | exports.EnumStringMember = EnumStringMember;
|
---|
30 | exports.EnumSymbolBody = EnumSymbolBody;
|
---|
31 | exports.ExistsTypeAnnotation = ExistsTypeAnnotation;
|
---|
32 | exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
---|
33 | exports.FunctionTypeParam = FunctionTypeParam;
|
---|
34 | exports.IndexedAccessType = IndexedAccessType;
|
---|
35 | exports.InferredPredicate = InferredPredicate;
|
---|
36 | exports.InterfaceDeclaration = InterfaceDeclaration;
|
---|
37 | exports.GenericTypeAnnotation = exports.ClassImplements = exports.InterfaceExtends = InterfaceExtends;
|
---|
38 | exports.InterfaceTypeAnnotation = InterfaceTypeAnnotation;
|
---|
39 | exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
|
---|
40 | exports.MixedTypeAnnotation = MixedTypeAnnotation;
|
---|
41 | exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation;
|
---|
42 | exports.NullableTypeAnnotation = NullableTypeAnnotation;
|
---|
43 | Object.defineProperty(exports, "NumberLiteralTypeAnnotation", {
|
---|
44 | enumerable: true,
|
---|
45 | get: function () {
|
---|
46 | return _types2.NumericLiteral;
|
---|
47 | }
|
---|
48 | });
|
---|
49 | exports.NumberTypeAnnotation = NumberTypeAnnotation;
|
---|
50 | exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
|
---|
51 | exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
|
---|
52 | exports.ObjectTypeIndexer = ObjectTypeIndexer;
|
---|
53 | exports.ObjectTypeInternalSlot = ObjectTypeInternalSlot;
|
---|
54 | exports.ObjectTypeProperty = ObjectTypeProperty;
|
---|
55 | exports.ObjectTypeSpreadProperty = ObjectTypeSpreadProperty;
|
---|
56 | exports.OpaqueType = OpaqueType;
|
---|
57 | exports.OptionalIndexedAccessType = OptionalIndexedAccessType;
|
---|
58 | exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
|
---|
59 | Object.defineProperty(exports, "StringLiteralTypeAnnotation", {
|
---|
60 | enumerable: true,
|
---|
61 | get: function () {
|
---|
62 | return _types2.StringLiteral;
|
---|
63 | }
|
---|
64 | });
|
---|
65 | exports.StringTypeAnnotation = StringTypeAnnotation;
|
---|
66 | exports.SymbolTypeAnnotation = SymbolTypeAnnotation;
|
---|
67 | exports.ThisTypeAnnotation = ThisTypeAnnotation;
|
---|
68 | exports.TupleTypeAnnotation = TupleTypeAnnotation;
|
---|
69 | exports.TypeAlias = TypeAlias;
|
---|
70 | exports.TypeAnnotation = TypeAnnotation;
|
---|
71 | exports.TypeCastExpression = TypeCastExpression;
|
---|
72 | exports.TypeParameter = TypeParameter;
|
---|
73 | exports.TypeParameterDeclaration = exports.TypeParameterInstantiation = TypeParameterInstantiation;
|
---|
74 | exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
|
---|
75 | exports.UnionTypeAnnotation = UnionTypeAnnotation;
|
---|
76 | exports.Variance = Variance;
|
---|
77 | exports.VoidTypeAnnotation = VoidTypeAnnotation;
|
---|
78 | exports._interfaceish = _interfaceish;
|
---|
79 | exports._variance = _variance;
|
---|
80 | var _t = require("@babel/types");
|
---|
81 | var _modules = require("./modules.js");
|
---|
82 | var _index = require("../node/index.js");
|
---|
83 | var _types2 = require("./types.js");
|
---|
84 | const {
|
---|
85 | isDeclareExportDeclaration,
|
---|
86 | isStatement
|
---|
87 | } = _t;
|
---|
88 | function AnyTypeAnnotation() {
|
---|
89 | this.word("any");
|
---|
90 | }
|
---|
91 | function ArrayTypeAnnotation(node) {
|
---|
92 | this.print(node.elementType, true);
|
---|
93 | this.tokenChar(91);
|
---|
94 | this.tokenChar(93);
|
---|
95 | }
|
---|
96 | function BooleanTypeAnnotation() {
|
---|
97 | this.word("boolean");
|
---|
98 | }
|
---|
99 | function BooleanLiteralTypeAnnotation(node) {
|
---|
100 | this.word(node.value ? "true" : "false");
|
---|
101 | }
|
---|
102 | function NullLiteralTypeAnnotation() {
|
---|
103 | this.word("null");
|
---|
104 | }
|
---|
105 | function DeclareClass(node, parent) {
|
---|
106 | if (!isDeclareExportDeclaration(parent)) {
|
---|
107 | this.word("declare");
|
---|
108 | this.space();
|
---|
109 | }
|
---|
110 | this.word("class");
|
---|
111 | this.space();
|
---|
112 | this._interfaceish(node);
|
---|
113 | }
|
---|
114 | function DeclareFunction(node, parent) {
|
---|
115 | if (!isDeclareExportDeclaration(parent)) {
|
---|
116 | this.word("declare");
|
---|
117 | this.space();
|
---|
118 | }
|
---|
119 | this.word("function");
|
---|
120 | this.space();
|
---|
121 | this.print(node.id);
|
---|
122 | this.print(node.id.typeAnnotation.typeAnnotation);
|
---|
123 | if (node.predicate) {
|
---|
124 | this.space();
|
---|
125 | this.print(node.predicate);
|
---|
126 | }
|
---|
127 | this.semicolon();
|
---|
128 | }
|
---|
129 | function InferredPredicate() {
|
---|
130 | this.tokenChar(37);
|
---|
131 | this.word("checks");
|
---|
132 | }
|
---|
133 | function DeclaredPredicate(node) {
|
---|
134 | this.tokenChar(37);
|
---|
135 | this.word("checks");
|
---|
136 | this.tokenChar(40);
|
---|
137 | this.print(node.value);
|
---|
138 | this.tokenChar(41);
|
---|
139 | }
|
---|
140 | function DeclareInterface(node) {
|
---|
141 | this.word("declare");
|
---|
142 | this.space();
|
---|
143 | this.InterfaceDeclaration(node);
|
---|
144 | }
|
---|
145 | function DeclareModule(node) {
|
---|
146 | this.word("declare");
|
---|
147 | this.space();
|
---|
148 | this.word("module");
|
---|
149 | this.space();
|
---|
150 | this.print(node.id);
|
---|
151 | this.space();
|
---|
152 | this.print(node.body);
|
---|
153 | }
|
---|
154 | function DeclareModuleExports(node) {
|
---|
155 | this.word("declare");
|
---|
156 | this.space();
|
---|
157 | this.word("module");
|
---|
158 | this.tokenChar(46);
|
---|
159 | this.word("exports");
|
---|
160 | this.print(node.typeAnnotation);
|
---|
161 | }
|
---|
162 | function DeclareTypeAlias(node) {
|
---|
163 | this.word("declare");
|
---|
164 | this.space();
|
---|
165 | this.TypeAlias(node);
|
---|
166 | }
|
---|
167 | function DeclareOpaqueType(node, parent) {
|
---|
168 | if (!isDeclareExportDeclaration(parent)) {
|
---|
169 | this.word("declare");
|
---|
170 | this.space();
|
---|
171 | }
|
---|
172 | this.OpaqueType(node);
|
---|
173 | }
|
---|
174 | function DeclareVariable(node, parent) {
|
---|
175 | if (!isDeclareExportDeclaration(parent)) {
|
---|
176 | this.word("declare");
|
---|
177 | this.space();
|
---|
178 | }
|
---|
179 | this.word("var");
|
---|
180 | this.space();
|
---|
181 | this.print(node.id);
|
---|
182 | this.print(node.id.typeAnnotation);
|
---|
183 | this.semicolon();
|
---|
184 | }
|
---|
185 | function DeclareExportDeclaration(node) {
|
---|
186 | this.word("declare");
|
---|
187 | this.space();
|
---|
188 | this.word("export");
|
---|
189 | this.space();
|
---|
190 | if (node.default) {
|
---|
191 | this.word("default");
|
---|
192 | this.space();
|
---|
193 | }
|
---|
194 | FlowExportDeclaration.call(this, node);
|
---|
195 | }
|
---|
196 | function DeclareExportAllDeclaration(node) {
|
---|
197 | this.word("declare");
|
---|
198 | this.space();
|
---|
199 | _modules.ExportAllDeclaration.call(this, node);
|
---|
200 | }
|
---|
201 | function EnumDeclaration(node) {
|
---|
202 | const {
|
---|
203 | id,
|
---|
204 | body
|
---|
205 | } = node;
|
---|
206 | this.word("enum");
|
---|
207 | this.space();
|
---|
208 | this.print(id);
|
---|
209 | this.print(body);
|
---|
210 | }
|
---|
211 | function enumExplicitType(context, name, hasExplicitType) {
|
---|
212 | if (hasExplicitType) {
|
---|
213 | context.space();
|
---|
214 | context.word("of");
|
---|
215 | context.space();
|
---|
216 | context.word(name);
|
---|
217 | }
|
---|
218 | context.space();
|
---|
219 | }
|
---|
220 | function enumBody(context, node) {
|
---|
221 | const {
|
---|
222 | members
|
---|
223 | } = node;
|
---|
224 | context.token("{");
|
---|
225 | context.indent();
|
---|
226 | context.newline();
|
---|
227 | for (const member of members) {
|
---|
228 | context.print(member);
|
---|
229 | context.newline();
|
---|
230 | }
|
---|
231 | if (node.hasUnknownMembers) {
|
---|
232 | context.token("...");
|
---|
233 | context.newline();
|
---|
234 | }
|
---|
235 | context.dedent();
|
---|
236 | context.token("}");
|
---|
237 | }
|
---|
238 | function EnumBooleanBody(node) {
|
---|
239 | const {
|
---|
240 | explicitType
|
---|
241 | } = node;
|
---|
242 | enumExplicitType(this, "boolean", explicitType);
|
---|
243 | enumBody(this, node);
|
---|
244 | }
|
---|
245 | function EnumNumberBody(node) {
|
---|
246 | const {
|
---|
247 | explicitType
|
---|
248 | } = node;
|
---|
249 | enumExplicitType(this, "number", explicitType);
|
---|
250 | enumBody(this, node);
|
---|
251 | }
|
---|
252 | function EnumStringBody(node) {
|
---|
253 | const {
|
---|
254 | explicitType
|
---|
255 | } = node;
|
---|
256 | enumExplicitType(this, "string", explicitType);
|
---|
257 | enumBody(this, node);
|
---|
258 | }
|
---|
259 | function EnumSymbolBody(node) {
|
---|
260 | enumExplicitType(this, "symbol", true);
|
---|
261 | enumBody(this, node);
|
---|
262 | }
|
---|
263 | function EnumDefaultedMember(node) {
|
---|
264 | const {
|
---|
265 | id
|
---|
266 | } = node;
|
---|
267 | this.print(id);
|
---|
268 | this.tokenChar(44);
|
---|
269 | }
|
---|
270 | function enumInitializedMember(context, node) {
|
---|
271 | context.print(node.id);
|
---|
272 | context.space();
|
---|
273 | context.token("=");
|
---|
274 | context.space();
|
---|
275 | context.print(node.init);
|
---|
276 | context.token(",");
|
---|
277 | }
|
---|
278 | function EnumBooleanMember(node) {
|
---|
279 | enumInitializedMember(this, node);
|
---|
280 | }
|
---|
281 | function EnumNumberMember(node) {
|
---|
282 | enumInitializedMember(this, node);
|
---|
283 | }
|
---|
284 | function EnumStringMember(node) {
|
---|
285 | enumInitializedMember(this, node);
|
---|
286 | }
|
---|
287 | function FlowExportDeclaration(node) {
|
---|
288 | if (node.declaration) {
|
---|
289 | const declar = node.declaration;
|
---|
290 | this.print(declar);
|
---|
291 | if (!isStatement(declar)) this.semicolon();
|
---|
292 | } else {
|
---|
293 | this.tokenChar(123);
|
---|
294 | if (node.specifiers.length) {
|
---|
295 | this.space();
|
---|
296 | this.printList(node.specifiers);
|
---|
297 | this.space();
|
---|
298 | }
|
---|
299 | this.tokenChar(125);
|
---|
300 | if (node.source) {
|
---|
301 | this.space();
|
---|
302 | this.word("from");
|
---|
303 | this.space();
|
---|
304 | this.print(node.source);
|
---|
305 | }
|
---|
306 | this.semicolon();
|
---|
307 | }
|
---|
308 | }
|
---|
309 | function ExistsTypeAnnotation() {
|
---|
310 | this.tokenChar(42);
|
---|
311 | }
|
---|
312 | function FunctionTypeAnnotation(node, parent) {
|
---|
313 | this.print(node.typeParameters);
|
---|
314 | this.tokenChar(40);
|
---|
315 | if (node.this) {
|
---|
316 | this.word("this");
|
---|
317 | this.tokenChar(58);
|
---|
318 | this.space();
|
---|
319 | this.print(node.this.typeAnnotation);
|
---|
320 | if (node.params.length || node.rest) {
|
---|
321 | this.tokenChar(44);
|
---|
322 | this.space();
|
---|
323 | }
|
---|
324 | }
|
---|
325 | this.printList(node.params);
|
---|
326 | if (node.rest) {
|
---|
327 | if (node.params.length) {
|
---|
328 | this.tokenChar(44);
|
---|
329 | this.space();
|
---|
330 | }
|
---|
331 | this.token("...");
|
---|
332 | this.print(node.rest);
|
---|
333 | }
|
---|
334 | this.tokenChar(41);
|
---|
335 | const type = parent == null ? void 0 : parent.type;
|
---|
336 | if (type != null && (type === "ObjectTypeCallProperty" || type === "ObjectTypeInternalSlot" || type === "DeclareFunction" || type === "ObjectTypeProperty" && parent.method)) {
|
---|
337 | this.tokenChar(58);
|
---|
338 | } else {
|
---|
339 | this.space();
|
---|
340 | this.token("=>");
|
---|
341 | }
|
---|
342 | this.space();
|
---|
343 | this.print(node.returnType);
|
---|
344 | }
|
---|
345 | function FunctionTypeParam(node) {
|
---|
346 | this.print(node.name);
|
---|
347 | if (node.optional) this.tokenChar(63);
|
---|
348 | if (node.name) {
|
---|
349 | this.tokenChar(58);
|
---|
350 | this.space();
|
---|
351 | }
|
---|
352 | this.print(node.typeAnnotation);
|
---|
353 | }
|
---|
354 | function InterfaceExtends(node) {
|
---|
355 | this.print(node.id);
|
---|
356 | this.print(node.typeParameters, true);
|
---|
357 | }
|
---|
358 | function _interfaceish(node) {
|
---|
359 | var _node$extends;
|
---|
360 | this.print(node.id);
|
---|
361 | this.print(node.typeParameters);
|
---|
362 | if ((_node$extends = node.extends) != null && _node$extends.length) {
|
---|
363 | this.space();
|
---|
364 | this.word("extends");
|
---|
365 | this.space();
|
---|
366 | this.printList(node.extends);
|
---|
367 | }
|
---|
368 | if (node.type === "DeclareClass") {
|
---|
369 | var _node$mixins, _node$implements;
|
---|
370 | if ((_node$mixins = node.mixins) != null && _node$mixins.length) {
|
---|
371 | this.space();
|
---|
372 | this.word("mixins");
|
---|
373 | this.space();
|
---|
374 | this.printList(node.mixins);
|
---|
375 | }
|
---|
376 | if ((_node$implements = node.implements) != null && _node$implements.length) {
|
---|
377 | this.space();
|
---|
378 | this.word("implements");
|
---|
379 | this.space();
|
---|
380 | this.printList(node.implements);
|
---|
381 | }
|
---|
382 | }
|
---|
383 | this.space();
|
---|
384 | this.print(node.body);
|
---|
385 | }
|
---|
386 | function _variance(node) {
|
---|
387 | var _node$variance;
|
---|
388 | const kind = (_node$variance = node.variance) == null ? void 0 : _node$variance.kind;
|
---|
389 | if (kind != null) {
|
---|
390 | if (kind === "plus") {
|
---|
391 | this.tokenChar(43);
|
---|
392 | } else if (kind === "minus") {
|
---|
393 | this.tokenChar(45);
|
---|
394 | }
|
---|
395 | }
|
---|
396 | }
|
---|
397 | function InterfaceDeclaration(node) {
|
---|
398 | this.word("interface");
|
---|
399 | this.space();
|
---|
400 | this._interfaceish(node);
|
---|
401 | }
|
---|
402 | function andSeparator(occurrenceCount) {
|
---|
403 | this.space();
|
---|
404 | this.token("&", false, occurrenceCount);
|
---|
405 | this.space();
|
---|
406 | }
|
---|
407 | function InterfaceTypeAnnotation(node) {
|
---|
408 | var _node$extends2;
|
---|
409 | this.word("interface");
|
---|
410 | if ((_node$extends2 = node.extends) != null && _node$extends2.length) {
|
---|
411 | this.space();
|
---|
412 | this.word("extends");
|
---|
413 | this.space();
|
---|
414 | this.printList(node.extends);
|
---|
415 | }
|
---|
416 | this.space();
|
---|
417 | this.print(node.body);
|
---|
418 | }
|
---|
419 | function IntersectionTypeAnnotation(node) {
|
---|
420 | this.printJoin(node.types, {
|
---|
421 | separator: andSeparator
|
---|
422 | });
|
---|
423 | }
|
---|
424 | function MixedTypeAnnotation() {
|
---|
425 | this.word("mixed");
|
---|
426 | }
|
---|
427 | function EmptyTypeAnnotation() {
|
---|
428 | this.word("empty");
|
---|
429 | }
|
---|
430 | function NullableTypeAnnotation(node) {
|
---|
431 | this.tokenChar(63);
|
---|
432 | this.print(node.typeAnnotation);
|
---|
433 | }
|
---|
434 | function NumberTypeAnnotation() {
|
---|
435 | this.word("number");
|
---|
436 | }
|
---|
437 | function StringTypeAnnotation() {
|
---|
438 | this.word("string");
|
---|
439 | }
|
---|
440 | function ThisTypeAnnotation() {
|
---|
441 | this.word("this");
|
---|
442 | }
|
---|
443 | function TupleTypeAnnotation(node) {
|
---|
444 | this.tokenChar(91);
|
---|
445 | this.printList(node.types);
|
---|
446 | this.tokenChar(93);
|
---|
447 | }
|
---|
448 | function TypeofTypeAnnotation(node) {
|
---|
449 | this.word("typeof");
|
---|
450 | this.space();
|
---|
451 | this.print(node.argument);
|
---|
452 | }
|
---|
453 | function TypeAlias(node) {
|
---|
454 | this.word("type");
|
---|
455 | this.space();
|
---|
456 | this.print(node.id);
|
---|
457 | this.print(node.typeParameters);
|
---|
458 | this.space();
|
---|
459 | this.tokenChar(61);
|
---|
460 | this.space();
|
---|
461 | this.print(node.right);
|
---|
462 | this.semicolon();
|
---|
463 | }
|
---|
464 | function TypeAnnotation(node, parent) {
|
---|
465 | this.tokenChar(58);
|
---|
466 | this.space();
|
---|
467 | if (parent.type === "ArrowFunctionExpression") {
|
---|
468 | this.tokenContext |= _index.TokenContext.arrowFlowReturnType;
|
---|
469 | } else if (node.optional) {
|
---|
470 | this.tokenChar(63);
|
---|
471 | }
|
---|
472 | this.print(node.typeAnnotation);
|
---|
473 | }
|
---|
474 | function TypeParameterInstantiation(node) {
|
---|
475 | this.tokenChar(60);
|
---|
476 | this.printList(node.params, {});
|
---|
477 | this.tokenChar(62);
|
---|
478 | }
|
---|
479 | function TypeParameter(node) {
|
---|
480 | this._variance(node);
|
---|
481 | this.word(node.name);
|
---|
482 | if (node.bound) {
|
---|
483 | this.print(node.bound);
|
---|
484 | }
|
---|
485 | if (node.default) {
|
---|
486 | this.space();
|
---|
487 | this.tokenChar(61);
|
---|
488 | this.space();
|
---|
489 | this.print(node.default);
|
---|
490 | }
|
---|
491 | }
|
---|
492 | function OpaqueType(node) {
|
---|
493 | this.word("opaque");
|
---|
494 | this.space();
|
---|
495 | this.word("type");
|
---|
496 | this.space();
|
---|
497 | this.print(node.id);
|
---|
498 | this.print(node.typeParameters);
|
---|
499 | if (node.supertype) {
|
---|
500 | this.tokenChar(58);
|
---|
501 | this.space();
|
---|
502 | this.print(node.supertype);
|
---|
503 | }
|
---|
504 | if (node.impltype) {
|
---|
505 | this.space();
|
---|
506 | this.tokenChar(61);
|
---|
507 | this.space();
|
---|
508 | this.print(node.impltype);
|
---|
509 | }
|
---|
510 | this.semicolon();
|
---|
511 | }
|
---|
512 | function ObjectTypeAnnotation(node) {
|
---|
513 | if (node.exact) {
|
---|
514 | this.token("{|");
|
---|
515 | } else {
|
---|
516 | this.tokenChar(123);
|
---|
517 | }
|
---|
518 | const props = [...node.properties, ...(node.callProperties || []), ...(node.indexers || []), ...(node.internalSlots || [])];
|
---|
519 | if (props.length) {
|
---|
520 | this.newline();
|
---|
521 | this.space();
|
---|
522 | this.printJoin(props, {
|
---|
523 | addNewlines(leading) {
|
---|
524 | if (leading && !props[0]) return 1;
|
---|
525 | },
|
---|
526 | indent: true,
|
---|
527 | statement: true,
|
---|
528 | iterator: () => {
|
---|
529 | if (props.length !== 1 || node.inexact) {
|
---|
530 | this.tokenChar(44);
|
---|
531 | this.space();
|
---|
532 | }
|
---|
533 | }
|
---|
534 | });
|
---|
535 | this.space();
|
---|
536 | }
|
---|
537 | if (node.inexact) {
|
---|
538 | this.indent();
|
---|
539 | this.token("...");
|
---|
540 | if (props.length) {
|
---|
541 | this.newline();
|
---|
542 | }
|
---|
543 | this.dedent();
|
---|
544 | }
|
---|
545 | if (node.exact) {
|
---|
546 | this.token("|}");
|
---|
547 | } else {
|
---|
548 | this.tokenChar(125);
|
---|
549 | }
|
---|
550 | }
|
---|
551 | function ObjectTypeInternalSlot(node) {
|
---|
552 | if (node.static) {
|
---|
553 | this.word("static");
|
---|
554 | this.space();
|
---|
555 | }
|
---|
556 | this.tokenChar(91);
|
---|
557 | this.tokenChar(91);
|
---|
558 | this.print(node.id);
|
---|
559 | this.tokenChar(93);
|
---|
560 | this.tokenChar(93);
|
---|
561 | if (node.optional) this.tokenChar(63);
|
---|
562 | if (!node.method) {
|
---|
563 | this.tokenChar(58);
|
---|
564 | this.space();
|
---|
565 | }
|
---|
566 | this.print(node.value);
|
---|
567 | }
|
---|
568 | function ObjectTypeCallProperty(node) {
|
---|
569 | if (node.static) {
|
---|
570 | this.word("static");
|
---|
571 | this.space();
|
---|
572 | }
|
---|
573 | this.print(node.value);
|
---|
574 | }
|
---|
575 | function ObjectTypeIndexer(node) {
|
---|
576 | if (node.static) {
|
---|
577 | this.word("static");
|
---|
578 | this.space();
|
---|
579 | }
|
---|
580 | this._variance(node);
|
---|
581 | this.tokenChar(91);
|
---|
582 | if (node.id) {
|
---|
583 | this.print(node.id);
|
---|
584 | this.tokenChar(58);
|
---|
585 | this.space();
|
---|
586 | }
|
---|
587 | this.print(node.key);
|
---|
588 | this.tokenChar(93);
|
---|
589 | this.tokenChar(58);
|
---|
590 | this.space();
|
---|
591 | this.print(node.value);
|
---|
592 | }
|
---|
593 | function ObjectTypeProperty(node) {
|
---|
594 | if (node.proto) {
|
---|
595 | this.word("proto");
|
---|
596 | this.space();
|
---|
597 | }
|
---|
598 | if (node.static) {
|
---|
599 | this.word("static");
|
---|
600 | this.space();
|
---|
601 | }
|
---|
602 | if (node.kind === "get" || node.kind === "set") {
|
---|
603 | this.word(node.kind);
|
---|
604 | this.space();
|
---|
605 | }
|
---|
606 | this._variance(node);
|
---|
607 | this.print(node.key);
|
---|
608 | if (node.optional) this.tokenChar(63);
|
---|
609 | if (!node.method) {
|
---|
610 | this.tokenChar(58);
|
---|
611 | this.space();
|
---|
612 | }
|
---|
613 | this.print(node.value);
|
---|
614 | }
|
---|
615 | function ObjectTypeSpreadProperty(node) {
|
---|
616 | this.token("...");
|
---|
617 | this.print(node.argument);
|
---|
618 | }
|
---|
619 | function QualifiedTypeIdentifier(node) {
|
---|
620 | this.print(node.qualification);
|
---|
621 | this.tokenChar(46);
|
---|
622 | this.print(node.id);
|
---|
623 | }
|
---|
624 | function SymbolTypeAnnotation() {
|
---|
625 | this.word("symbol");
|
---|
626 | }
|
---|
627 | function orSeparator(occurrenceCount) {
|
---|
628 | this.space();
|
---|
629 | this.token("|", false, occurrenceCount);
|
---|
630 | this.space();
|
---|
631 | }
|
---|
632 | function UnionTypeAnnotation(node) {
|
---|
633 | this.printJoin(node.types, {
|
---|
634 | separator: orSeparator
|
---|
635 | });
|
---|
636 | }
|
---|
637 | function TypeCastExpression(node) {
|
---|
638 | this.tokenChar(40);
|
---|
639 | this.print(node.expression);
|
---|
640 | this.print(node.typeAnnotation);
|
---|
641 | this.tokenChar(41);
|
---|
642 | }
|
---|
643 | function Variance(node) {
|
---|
644 | if (node.kind === "plus") {
|
---|
645 | this.tokenChar(43);
|
---|
646 | } else {
|
---|
647 | this.tokenChar(45);
|
---|
648 | }
|
---|
649 | }
|
---|
650 | function VoidTypeAnnotation() {
|
---|
651 | this.word("void");
|
---|
652 | }
|
---|
653 | function IndexedAccessType(node) {
|
---|
654 | this.print(node.objectType, true);
|
---|
655 | this.tokenChar(91);
|
---|
656 | this.print(node.indexType);
|
---|
657 | this.tokenChar(93);
|
---|
658 | }
|
---|
659 | function OptionalIndexedAccessType(node) {
|
---|
660 | this.print(node.objectType);
|
---|
661 | if (node.optional) {
|
---|
662 | this.token("?.");
|
---|
663 | }
|
---|
664 | this.tokenChar(91);
|
---|
665 | this.print(node.indexType);
|
---|
666 | this.tokenChar(93);
|
---|
667 | }
|
---|
668 |
|
---|
669 | //# sourceMappingURL=flow.js.map
|
---|