feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -89,7 +89,7 @@ function AnyTypeAnnotation() {
this.word("any");
}
function ArrayTypeAnnotation(node) {
this.print(node.elementType, node, true);
this.print(node.elementType, true);
this.tokenChar(91);
this.tokenChar(93);
}
@@ -118,11 +118,11 @@ function DeclareFunction(node, parent) {
}
this.word("function");
this.space();
this.print(node.id, node);
this.print(node.id.typeAnnotation.typeAnnotation, node);
this.print(node.id);
this.print(node.id.typeAnnotation.typeAnnotation);
if (node.predicate) {
this.space();
this.print(node.predicate, node);
this.print(node.predicate);
}
this.semicolon();
}
@@ -134,7 +134,7 @@ function DeclaredPredicate(node) {
this.tokenChar(37);
this.word("checks");
this.tokenChar(40);
this.print(node.value, node);
this.print(node.value);
this.tokenChar(41);
}
function DeclareInterface(node) {
@@ -147,9 +147,9 @@ function DeclareModule(node) {
this.space();
this.word("module");
this.space();
this.print(node.id, node);
this.print(node.id);
this.space();
this.print(node.body, node);
this.print(node.body);
}
function DeclareModuleExports(node) {
this.word("declare");
@@ -157,7 +157,7 @@ function DeclareModuleExports(node) {
this.word("module");
this.tokenChar(46);
this.word("exports");
this.print(node.typeAnnotation, node);
this.print(node.typeAnnotation);
}
function DeclareTypeAlias(node) {
this.word("declare");
@@ -178,8 +178,8 @@ function DeclareVariable(node, parent) {
}
this.word("var");
this.space();
this.print(node.id, node);
this.print(node.id.typeAnnotation, node);
this.print(node.id);
this.print(node.id.typeAnnotation);
this.semicolon();
}
function DeclareExportDeclaration(node) {
@@ -205,8 +205,8 @@ function EnumDeclaration(node) {
} = node;
this.word("enum");
this.space();
this.print(id, node);
this.print(body, node);
this.print(id);
this.print(body);
}
function enumExplicitType(context, name, hasExplicitType) {
if (hasExplicitType) {
@@ -225,7 +225,7 @@ function enumBody(context, node) {
context.indent();
context.newline();
for (const member of members) {
context.print(member, node);
context.print(member);
context.newline();
}
if (node.hasUnknownMembers) {
@@ -264,19 +264,15 @@ function EnumDefaultedMember(node) {
const {
id
} = node;
this.print(id, node);
this.print(id);
this.tokenChar(44);
}
function enumInitializedMember(context, node) {
const {
id,
init
} = node;
context.print(id, node);
context.print(node.id);
context.space();
context.token("=");
context.space();
context.print(init, node);
context.print(node.init);
context.token(",");
}
function EnumBooleanMember(node) {
@@ -291,13 +287,13 @@ function EnumStringMember(node) {
function FlowExportDeclaration(node) {
if (node.declaration) {
const declar = node.declaration;
this.print(declar, node);
this.print(declar);
if (!isStatement(declar)) this.semicolon();
} else {
this.tokenChar(123);
if (node.specifiers.length) {
this.space();
this.printList(node.specifiers, node);
this.printList(node.specifiers);
this.space();
}
this.tokenChar(125);
@@ -305,7 +301,7 @@ function FlowExportDeclaration(node) {
this.space();
this.word("from");
this.space();
this.print(node.source, node);
this.print(node.source);
}
this.semicolon();
}
@@ -314,26 +310,26 @@ function ExistsTypeAnnotation() {
this.tokenChar(42);
}
function FunctionTypeAnnotation(node, parent) {
this.print(node.typeParameters, node);
this.print(node.typeParameters);
this.tokenChar(40);
if (node.this) {
this.word("this");
this.tokenChar(58);
this.space();
this.print(node.this.typeAnnotation, node);
this.print(node.this.typeAnnotation);
if (node.params.length || node.rest) {
this.tokenChar(44);
this.space();
}
}
this.printList(node.params, node);
this.printList(node.params);
if (node.rest) {
if (node.params.length) {
this.tokenChar(44);
this.space();
}
this.token("...");
this.print(node.rest, node);
this.print(node.rest);
}
this.tokenChar(41);
const type = parent == null ? void 0 : parent.type;
@@ -344,30 +340,30 @@ function FunctionTypeAnnotation(node, parent) {
this.token("=>");
}
this.space();
this.print(node.returnType, node);
this.print(node.returnType);
}
function FunctionTypeParam(node) {
this.print(node.name, node);
this.print(node.name);
if (node.optional) this.tokenChar(63);
if (node.name) {
this.tokenChar(58);
this.space();
}
this.print(node.typeAnnotation, node);
this.print(node.typeAnnotation);
}
function InterfaceExtends(node) {
this.print(node.id, node);
this.print(node.typeParameters, node, true);
this.print(node.id);
this.print(node.typeParameters, true);
}
function _interfaceish(node) {
var _node$extends;
this.print(node.id, node);
this.print(node.typeParameters, node);
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, node);
this.printList(node.extends);
}
if (node.type === "DeclareClass") {
var _node$mixins, _node$implements;
@@ -375,17 +371,17 @@ function _interfaceish(node) {
this.space();
this.word("mixins");
this.space();
this.printList(node.mixins, node);
this.printList(node.mixins);
}
if ((_node$implements = node.implements) != null && _node$implements.length) {
this.space();
this.word("implements");
this.space();
this.printList(node.implements, node);
this.printList(node.implements);
}
}
this.space();
this.print(node.body, node);
this.print(node.body);
}
function _variance(node) {
var _node$variance;
@@ -403,9 +399,9 @@ function InterfaceDeclaration(node) {
this.space();
this._interfaceish(node);
}
function andSeparator() {
function andSeparator(occurrenceCount) {
this.space();
this.tokenChar(38);
this.token("&", false, occurrenceCount);
this.space();
}
function InterfaceTypeAnnotation(node) {
@@ -415,13 +411,13 @@ function InterfaceTypeAnnotation(node) {
this.space();
this.word("extends");
this.space();
this.printList(node.extends, node);
this.printList(node.extends);
}
this.space();
this.print(node.body, node);
this.print(node.body);
}
function IntersectionTypeAnnotation(node) {
this.printJoin(node.types, node, {
this.printJoin(node.types, {
separator: andSeparator
});
}
@@ -433,7 +429,7 @@ function EmptyTypeAnnotation() {
}
function NullableTypeAnnotation(node) {
this.tokenChar(63);
this.print(node.typeAnnotation, node);
this.print(node.typeAnnotation);
}
function NumberTypeAnnotation() {
this.word("number");
@@ -446,23 +442,23 @@ function ThisTypeAnnotation() {
}
function TupleTypeAnnotation(node) {
this.tokenChar(91);
this.printList(node.types, node);
this.printList(node.types);
this.tokenChar(93);
}
function TypeofTypeAnnotation(node) {
this.word("typeof");
this.space();
this.print(node.argument, node);
this.print(node.argument);
}
function TypeAlias(node) {
this.word("type");
this.space();
this.print(node.id, node);
this.print(node.typeParameters, node);
this.print(node.id);
this.print(node.typeParameters);
this.space();
this.tokenChar(61);
this.space();
this.print(node.right, node);
this.print(node.right);
this.semicolon();
}
function TypeAnnotation(node, parent) {
@@ -473,24 +469,24 @@ function TypeAnnotation(node, parent) {
} else if (node.optional) {
this.tokenChar(63);
}
this.print(node.typeAnnotation, node);
this.print(node.typeAnnotation);
}
function TypeParameterInstantiation(node) {
this.tokenChar(60);
this.printList(node.params, node, {});
this.printList(node.params, {});
this.tokenChar(62);
}
function TypeParameter(node) {
this._variance(node);
this.word(node.name);
if (node.bound) {
this.print(node.bound, node);
this.print(node.bound);
}
if (node.default) {
this.space();
this.tokenChar(61);
this.space();
this.print(node.default, node);
this.print(node.default);
}
}
function OpaqueType(node) {
@@ -498,18 +494,18 @@ function OpaqueType(node) {
this.space();
this.word("type");
this.space();
this.print(node.id, node);
this.print(node.typeParameters, node);
this.print(node.id);
this.print(node.typeParameters);
if (node.supertype) {
this.tokenChar(58);
this.space();
this.print(node.supertype, node);
this.print(node.supertype);
}
if (node.impltype) {
this.space();
this.tokenChar(61);
this.space();
this.print(node.impltype, node);
this.print(node.impltype);
}
this.semicolon();
}
@@ -523,7 +519,7 @@ function ObjectTypeAnnotation(node) {
if (props.length) {
this.newline();
this.space();
this.printJoin(props, node, {
this.printJoin(props, {
addNewlines(leading) {
if (leading && !props[0]) return 1;
},
@@ -559,7 +555,7 @@ function ObjectTypeInternalSlot(node) {
}
this.tokenChar(91);
this.tokenChar(91);
this.print(node.id, node);
this.print(node.id);
this.tokenChar(93);
this.tokenChar(93);
if (node.optional) this.tokenChar(63);
@@ -567,14 +563,14 @@ function ObjectTypeInternalSlot(node) {
this.tokenChar(58);
this.space();
}
this.print(node.value, node);
this.print(node.value);
}
function ObjectTypeCallProperty(node) {
if (node.static) {
this.word("static");
this.space();
}
this.print(node.value, node);
this.print(node.value);
}
function ObjectTypeIndexer(node) {
if (node.static) {
@@ -584,15 +580,15 @@ function ObjectTypeIndexer(node) {
this._variance(node);
this.tokenChar(91);
if (node.id) {
this.print(node.id, node);
this.print(node.id);
this.tokenChar(58);
this.space();
}
this.print(node.key, node);
this.print(node.key);
this.tokenChar(93);
this.tokenChar(58);
this.space();
this.print(node.value, node);
this.print(node.value);
}
function ObjectTypeProperty(node) {
if (node.proto) {
@@ -608,40 +604,40 @@ function ObjectTypeProperty(node) {
this.space();
}
this._variance(node);
this.print(node.key, node);
this.print(node.key);
if (node.optional) this.tokenChar(63);
if (!node.method) {
this.tokenChar(58);
this.space();
}
this.print(node.value, node);
this.print(node.value);
}
function ObjectTypeSpreadProperty(node) {
this.token("...");
this.print(node.argument, node);
this.print(node.argument);
}
function QualifiedTypeIdentifier(node) {
this.print(node.qualification, node);
this.print(node.qualification);
this.tokenChar(46);
this.print(node.id, node);
this.print(node.id);
}
function SymbolTypeAnnotation() {
this.word("symbol");
}
function orSeparator() {
function orSeparator(occurrenceCount) {
this.space();
this.tokenChar(124);
this.token("|", false, occurrenceCount);
this.space();
}
function UnionTypeAnnotation(node) {
this.printJoin(node.types, node, {
this.printJoin(node.types, {
separator: orSeparator
});
}
function TypeCastExpression(node) {
this.tokenChar(40);
this.print(node.expression, node);
this.print(node.typeAnnotation, node);
this.print(node.expression);
this.print(node.typeAnnotation);
this.tokenChar(41);
}
function Variance(node) {
@@ -655,18 +651,18 @@ function VoidTypeAnnotation() {
this.word("void");
}
function IndexedAccessType(node) {
this.print(node.objectType, node, true);
this.print(node.objectType, true);
this.tokenChar(91);
this.print(node.indexType, node);
this.print(node.indexType);
this.tokenChar(93);
}
function OptionalIndexedAccessType(node) {
this.print(node.objectType, node);
this.print(node.objectType);
if (node.optional) {
this.token("?.");
}
this.tokenChar(91);
this.print(node.indexType, node);
this.print(node.indexType);
this.tokenChar(93);
}