| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660 | "use strict";Object.defineProperty(exports, "__esModule", {  value: true});exports.AnyTypeAnnotation = AnyTypeAnnotation;exports.ArrayTypeAnnotation = ArrayTypeAnnotation;exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation;exports.BooleanTypeAnnotation = BooleanTypeAnnotation;exports.DeclareClass = DeclareClass;exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration;exports.DeclareExportDeclaration = DeclareExportDeclaration;exports.DeclareFunction = DeclareFunction;exports.DeclareInterface = DeclareInterface;exports.DeclareModule = DeclareModule;exports.DeclareModuleExports = DeclareModuleExports;exports.DeclareOpaqueType = DeclareOpaqueType;exports.DeclareTypeAlias = DeclareTypeAlias;exports.DeclareVariable = DeclareVariable;exports.DeclaredPredicate = DeclaredPredicate;exports.EmptyTypeAnnotation = EmptyTypeAnnotation;exports.EnumBooleanBody = EnumBooleanBody;exports.EnumBooleanMember = EnumBooleanMember;exports.EnumDeclaration = EnumDeclaration;exports.EnumDefaultedMember = EnumDefaultedMember;exports.EnumNumberBody = EnumNumberBody;exports.EnumNumberMember = EnumNumberMember;exports.EnumStringBody = EnumStringBody;exports.EnumStringMember = EnumStringMember;exports.EnumSymbolBody = EnumSymbolBody;exports.ExistsTypeAnnotation = ExistsTypeAnnotation;exports.FunctionTypeAnnotation = FunctionTypeAnnotation;exports.FunctionTypeParam = FunctionTypeParam;exports.IndexedAccessType = IndexedAccessType;exports.InferredPredicate = InferredPredicate;exports.InterfaceDeclaration = InterfaceDeclaration;exports.GenericTypeAnnotation = exports.ClassImplements = exports.InterfaceExtends = InterfaceExtends;exports.InterfaceTypeAnnotation = InterfaceTypeAnnotation;exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;exports.MixedTypeAnnotation = MixedTypeAnnotation;exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation;exports.NullableTypeAnnotation = NullableTypeAnnotation;Object.defineProperty(exports, "NumberLiteralTypeAnnotation", {  enumerable: true,  get: function () {    return _types2.NumericLiteral;  }});exports.NumberTypeAnnotation = NumberTypeAnnotation;exports.ObjectTypeAnnotation = ObjectTypeAnnotation;exports.ObjectTypeCallProperty = ObjectTypeCallProperty;exports.ObjectTypeIndexer = ObjectTypeIndexer;exports.ObjectTypeInternalSlot = ObjectTypeInternalSlot;exports.ObjectTypeProperty = ObjectTypeProperty;exports.ObjectTypeSpreadProperty = ObjectTypeSpreadProperty;exports.OpaqueType = OpaqueType;exports.OptionalIndexedAccessType = OptionalIndexedAccessType;exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;Object.defineProperty(exports, "StringLiteralTypeAnnotation", {  enumerable: true,  get: function () {    return _types2.StringLiteral;  }});exports.StringTypeAnnotation = StringTypeAnnotation;exports.SymbolTypeAnnotation = SymbolTypeAnnotation;exports.ThisTypeAnnotation = ThisTypeAnnotation;exports.TupleTypeAnnotation = TupleTypeAnnotation;exports.TypeAlias = TypeAlias;exports.TypeAnnotation = TypeAnnotation;exports.TypeCastExpression = TypeCastExpression;exports.TypeParameter = TypeParameter;exports.TypeParameterDeclaration = exports.TypeParameterInstantiation = TypeParameterInstantiation;exports.TypeofTypeAnnotation = TypeofTypeAnnotation;exports.UnionTypeAnnotation = UnionTypeAnnotation;exports.Variance = Variance;exports.VoidTypeAnnotation = VoidTypeAnnotation;exports._interfaceish = _interfaceish;exports._variance = _variance;var _t = require("@babel/types");var _modules = require("./modules.js");var _index = require("../node/index.js");var _types2 = require("./types.js");const {  isDeclareExportDeclaration,  isStatement} = _t;function AnyTypeAnnotation() {  this.word("any");}function ArrayTypeAnnotation(node) {  this.print(node.elementType, true);  this.tokenChar(91);  this.tokenChar(93);}function BooleanTypeAnnotation() {  this.word("boolean");}function BooleanLiteralTypeAnnotation(node) {  this.word(node.value ? "true" : "false");}function NullLiteralTypeAnnotation() {  this.word("null");}function DeclareClass(node, parent) {  if (!isDeclareExportDeclaration(parent)) {    this.word("declare");    this.space();  }  this.word("class");  this.space();  this._interfaceish(node);}function DeclareFunction(node, parent) {  if (!isDeclareExportDeclaration(parent)) {    this.word("declare");    this.space();  }  this.word("function");  this.space();  this.print(node.id);  this.print(node.id.typeAnnotation.typeAnnotation);  if (node.predicate) {    this.space();    this.print(node.predicate);  }  this.semicolon();}function InferredPredicate() {  this.tokenChar(37);  this.word("checks");}function DeclaredPredicate(node) {  this.tokenChar(37);  this.word("checks");  this.tokenChar(40);  this.print(node.value);  this.tokenChar(41);}function DeclareInterface(node) {  this.word("declare");  this.space();  this.InterfaceDeclaration(node);}function DeclareModule(node) {  this.word("declare");  this.space();  this.word("module");  this.space();  this.print(node.id);  this.space();  this.print(node.body);}function DeclareModuleExports(node) {  this.word("declare");  this.space();  this.word("module");  this.tokenChar(46);  this.word("exports");  this.print(node.typeAnnotation);}function DeclareTypeAlias(node) {  this.word("declare");  this.space();  this.TypeAlias(node);}function DeclareOpaqueType(node, parent) {  if (!isDeclareExportDeclaration(parent)) {    this.word("declare");    this.space();  }  this.OpaqueType(node);}function DeclareVariable(node, parent) {  if (!isDeclareExportDeclaration(parent)) {    this.word("declare");    this.space();  }  this.word("var");  this.space();  this.print(node.id);  this.print(node.id.typeAnnotation);  this.semicolon();}function DeclareExportDeclaration(node) {  this.word("declare");  this.space();  this.word("export");  this.space();  if (node.default) {    this.word("default");    this.space();  }  FlowExportDeclaration.call(this, node);}function DeclareExportAllDeclaration(node) {  this.word("declare");  this.space();  _modules.ExportAllDeclaration.call(this, node);}function EnumDeclaration(node) {  const {    id,    body  } = node;  this.word("enum");  this.space();  this.print(id);  this.print(body);}function enumExplicitType(context, name, hasExplicitType) {  if (hasExplicitType) {    context.space();    context.word("of");    context.space();    context.word(name);  }  context.space();}function enumBody(context, node) {  const {    members  } = node;  context.token("{");  context.indent();  context.newline();  for (const member of members) {    context.print(member);    context.newline();  }  if (node.hasUnknownMembers) {    context.token("...");    context.newline();  }  context.dedent();  context.token("}");}function EnumBooleanBody(node) {  const {    explicitType  } = node;  enumExplicitType(this, "boolean", explicitType);  enumBody(this, node);}function EnumNumberBody(node) {  const {    explicitType  } = node;  enumExplicitType(this, "number", explicitType);  enumBody(this, node);}function EnumStringBody(node) {  const {    explicitType  } = node;  enumExplicitType(this, "string", explicitType);  enumBody(this, node);}function EnumSymbolBody(node) {  enumExplicitType(this, "symbol", true);  enumBody(this, node);}function EnumDefaultedMember(node) {  const {    id  } = node;  this.print(id);  this.tokenChar(44);}function enumInitializedMember(context, node) {  context.print(node.id);  context.space();  context.token("=");  context.space();  context.print(node.init);  context.token(",");}function EnumBooleanMember(node) {  enumInitializedMember(this, node);}function EnumNumberMember(node) {  enumInitializedMember(this, node);}function EnumStringMember(node) {  enumInitializedMember(this, node);}function FlowExportDeclaration(node) {  if (node.declaration) {    const declar = node.declaration;    this.print(declar);    if (!isStatement(declar)) this.semicolon();  } else {    this.tokenChar(123);    if (node.specifiers.length) {      this.space();      this.printList(node.specifiers);      this.space();    }    this.tokenChar(125);    if (node.source) {      this.space();      this.word("from");      this.space();      this.print(node.source);    }    this.semicolon();  }}function ExistsTypeAnnotation() {  this.tokenChar(42);}function FunctionTypeAnnotation(node, parent) {  this.print(node.typeParameters);  this.tokenChar(40);  if (node.this) {    this.word("this");    this.tokenChar(58);    this.space();    this.print(node.this.typeAnnotation);    if (node.params.length || node.rest) {      this.tokenChar(44);      this.space();    }  }  this.printList(node.params);  if (node.rest) {    if (node.params.length) {      this.tokenChar(44);      this.space();    }    this.token("...");    this.print(node.rest);  }  this.tokenChar(41);  const type = parent == null ? void 0 : parent.type;  if (type != null && (type === "ObjectTypeCallProperty" || type === "ObjectTypeInternalSlot" || type === "DeclareFunction" || type === "ObjectTypeProperty" && parent.method)) {    this.tokenChar(58);  } else {    this.space();    this.token("=>");  }  this.space();  this.print(node.returnType);}function FunctionTypeParam(node) {  this.print(node.name);  if (node.optional) this.tokenChar(63);  if (node.name) {    this.tokenChar(58);    this.space();  }  this.print(node.typeAnnotation);}function InterfaceExtends(node) {  this.print(node.id);  this.print(node.typeParameters, true);}function _interfaceish(node) {  var _node$extends;  this.print(node.id);  this.print(node.typeParameters);  if ((_node$extends = node.extends) != null && _node$extends.length) {    this.space();    this.word("extends");    this.space();    this.printList(node.extends);  }  if (node.type === "DeclareClass") {    var _node$mixins, _node$implements;    if ((_node$mixins = node.mixins) != null && _node$mixins.length) {      this.space();      this.word("mixins");      this.space();      this.printList(node.mixins);    }    if ((_node$implements = node.implements) != null && _node$implements.length) {      this.space();      this.word("implements");      this.space();      this.printList(node.implements);    }  }  this.space();  this.print(node.body);}function _variance(node) {  var _node$variance;  const kind = (_node$variance = node.variance) == null ? void 0 : _node$variance.kind;  if (kind != null) {    if (kind === "plus") {      this.tokenChar(43);    } else if (kind === "minus") {      this.tokenChar(45);    }  }}function InterfaceDeclaration(node) {  this.word("interface");  this.space();  this._interfaceish(node);}function andSeparator(occurrenceCount) {  this.space();  this.token("&", false, occurrenceCount);  this.space();}function InterfaceTypeAnnotation(node) {  var _node$extends2;  this.word("interface");  if ((_node$extends2 = node.extends) != null && _node$extends2.length) {    this.space();    this.word("extends");    this.space();    this.printList(node.extends);  }  this.space();  this.print(node.body);}function IntersectionTypeAnnotation(node) {  this.printJoin(node.types, undefined, undefined, andSeparator);}function MixedTypeAnnotation() {  this.word("mixed");}function EmptyTypeAnnotation() {  this.word("empty");}function NullableTypeAnnotation(node) {  this.tokenChar(63);  this.print(node.typeAnnotation);}function NumberTypeAnnotation() {  this.word("number");}function StringTypeAnnotation() {  this.word("string");}function ThisTypeAnnotation() {  this.word("this");}function TupleTypeAnnotation(node) {  this.tokenChar(91);  this.printList(node.types);  this.tokenChar(93);}function TypeofTypeAnnotation(node) {  this.word("typeof");  this.space();  this.print(node.argument);}function TypeAlias(node) {  this.word("type");  this.space();  this.print(node.id);  this.print(node.typeParameters);  this.space();  this.tokenChar(61);  this.space();  this.print(node.right);  this.semicolon();}function TypeAnnotation(node, parent) {  this.tokenChar(58);  this.space();  if (parent.type === "ArrowFunctionExpression") {    this.tokenContext |= _index.TokenContext.arrowFlowReturnType;  } else if (node.optional) {    this.tokenChar(63);  }  this.print(node.typeAnnotation);}function TypeParameterInstantiation(node) {  this.tokenChar(60);  this.printList(node.params);  this.tokenChar(62);}function TypeParameter(node) {  this._variance(node);  this.word(node.name);  if (node.bound) {    this.print(node.bound);  }  if (node.default) {    this.space();    this.tokenChar(61);    this.space();    this.print(node.default);  }}function OpaqueType(node) {  this.word("opaque");  this.space();  this.word("type");  this.space();  this.print(node.id);  this.print(node.typeParameters);  if (node.supertype) {    this.tokenChar(58);    this.space();    this.print(node.supertype);  }  if (node.impltype) {    this.space();    this.tokenChar(61);    this.space();    this.print(node.impltype);  }  this.semicolon();}function ObjectTypeAnnotation(node) {  if (node.exact) {    this.token("{|");  } else {    this.tokenChar(123);  }  const props = [...node.properties, ...(node.callProperties || []), ...(node.indexers || []), ...(node.internalSlots || [])];  if (props.length) {    this.newline();    this.space();    this.printJoin(props, true, true, undefined, undefined, function addNewlines(leading) {      if (leading && !props[0]) return 1;    }, () => {      if (props.length !== 1 || node.inexact) {        this.tokenChar(44);        this.space();      }    });    this.space();  }  if (node.inexact) {    this.indent();    this.token("...");    if (props.length) {      this.newline();    }    this.dedent();  }  if (node.exact) {    this.token("|}");  } else {    this.tokenChar(125);  }}function ObjectTypeInternalSlot(node) {  if (node.static) {    this.word("static");    this.space();  }  this.tokenChar(91);  this.tokenChar(91);  this.print(node.id);  this.tokenChar(93);  this.tokenChar(93);  if (node.optional) this.tokenChar(63);  if (!node.method) {    this.tokenChar(58);    this.space();  }  this.print(node.value);}function ObjectTypeCallProperty(node) {  if (node.static) {    this.word("static");    this.space();  }  this.print(node.value);}function ObjectTypeIndexer(node) {  if (node.static) {    this.word("static");    this.space();  }  this._variance(node);  this.tokenChar(91);  if (node.id) {    this.print(node.id);    this.tokenChar(58);    this.space();  }  this.print(node.key);  this.tokenChar(93);  this.tokenChar(58);  this.space();  this.print(node.value);}function ObjectTypeProperty(node) {  if (node.proto) {    this.word("proto");    this.space();  }  if (node.static) {    this.word("static");    this.space();  }  if (node.kind === "get" || node.kind === "set") {    this.word(node.kind);    this.space();  }  this._variance(node);  this.print(node.key);  if (node.optional) this.tokenChar(63);  if (!node.method) {    this.tokenChar(58);    this.space();  }  this.print(node.value);}function ObjectTypeSpreadProperty(node) {  this.token("...");  this.print(node.argument);}function QualifiedTypeIdentifier(node) {  this.print(node.qualification);  this.tokenChar(46);  this.print(node.id);}function SymbolTypeAnnotation() {  this.word("symbol");}function orSeparator(occurrenceCount) {  this.space();  this.token("|", false, occurrenceCount);  this.space();}function UnionTypeAnnotation(node) {  this.printJoin(node.types, undefined, undefined, orSeparator);}function TypeCastExpression(node) {  this.tokenChar(40);  this.print(node.expression);  this.print(node.typeAnnotation);  this.tokenChar(41);}function Variance(node) {  if (node.kind === "plus") {    this.tokenChar(43);  } else {    this.tokenChar(45);  }}function VoidTypeAnnotation() {  this.word("void");}function IndexedAccessType(node) {  this.print(node.objectType, true);  this.tokenChar(91);  this.print(node.indexType);  this.tokenChar(93);}function OptionalIndexedAccessType(node) {  this.print(node.objectType);  if (node.optional) {    this.token("?.");  }  this.tokenChar(91);  this.print(node.indexType);  this.tokenChar(93);}//# sourceMappingURL=flow.js.map
 |