Skip to content

Commit

Permalink
refactor(formatToString): switch to method from property
Browse files Browse the repository at this point in the history
  • Loading branch information
RealShadowNova committed Sep 19, 2022
1 parent ae4722f commit 4d52f65
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 42 deletions.
4 changes: 2 additions & 2 deletions src/lib/structures/class-parser/ClassConstructorParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export class ClassConstructorParser extends Parser {
* @param parser The parser to generate the string representation of.
* @returns The string representation of the given parser.
*/
public static formatToString = (parser: ClassConstructorParser): string => {
public static formatToString(parser: ClassConstructorParser): string {
return `new ${parser.parent.name}(${parser.parameters.map((parameter) => parameter.name).join(', ')})`;
};
}

/**
* Generates a new {@link ClassConstructorParser} instance from the given data.
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/ArrayTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class ArrayTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: ArrayTypeParser): string => {
public static formatToString(parser: ArrayTypeParser): string {
return `${TypeParser.wrap(parser.type, TypeParser.BindingPowers[TypeParser.Kind.Array])}[]`;
};
}
}

export namespace ArrayTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/ConditionalTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ export class ConditionalTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: ConditionalTypeParser): string => {
public static formatToString(parser: ConditionalTypeParser): string {
return `${TypeParser.wrap(
parser.checkType,
TypeParser.BindingPowers[TypeParser.Kind.Conditional]
)} extends ${parser.extendsType.toString()} ? ${parser.trueType.toString()} : ${parser.falseType.toString()}`;
};
}
}

export namespace ConditionalTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/IndexedAccessTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export class IndexedAccessTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: IndexedAccessTypeParser): string => {
public static formatToString(parser: IndexedAccessTypeParser): string {
return `${parser.objectType.toString()}[${parser.indexType.toString()}]`;
};
}
}

export namespace IndexedAccessTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/InferredTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class InferredTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: InferredTypeParser): string => {
public static formatToString(parser: InferredTypeParser): string {
return `infer ${parser.type}`;
};
}
}

export namespace InferredTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/IntersectionTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class IntersectionTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: IntersectionTypeParser): string => {
public static formatToString(parser: IntersectionTypeParser): string {
return parser.types.map((type) => TypeParser.wrap(type, TypeParser.BindingPowers[TypeParser.Kind.Intersection])).join(' & ');
};
}
}

export namespace IntersectionTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/IntrinsicTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class IntrinsicTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: IntrinsicTypeParser): string => {
public static formatToString(parser: IntrinsicTypeParser): string {
return parser.type;
};
}
}

export namespace IntrinsicTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/LiteralTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class LiteralTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: LiteralTypeParser): string => {
public static formatToString(parser: LiteralTypeParser): string {
return parser.value;
};
}
}

export namespace LiteralTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/MappedTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ export class MappedTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: MappedTypeParser): string => {
public static formatToString(parser: MappedTypeParser): string {
const readonly =
parser.readonly === MappedTypeParser.Modifier.Add ? 'readonly' : parser.readonly === MappedTypeParser.Modifier.Remove ? '-readonly' : '';

const optional = parser.optional === MappedTypeParser.Modifier.Add ? '?' : parser.optional === MappedTypeParser.Modifier.Remove ? '-?' : '';

return `{ ${readonly}[${parser.parameter} in ${parser.parameterType.toString()}]${optional}: ${parser.templateType.toString()} }`;
};
}
}

export namespace MappedTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/NamedTupleMemberTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ export class NamedTupleMemberTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: NamedTupleMemberTypeParser): string => {
public static formatToString(parser: NamedTupleMemberTypeParser): string {
return `${parser.name}${parser.optional ? '?' : ''}: ${parser.type.toString()}`;
};
}
}

export namespace NamedTupleMemberTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/OptionalTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class OptionalTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: OptionalTypeParser): string => {
public static formatToString(parser: OptionalTypeParser): string {
return `${TypeParser.wrap(parser.type, TypeParser.BindingPowers[TypeParser.Kind.Optional])}?`;
};
}
}

export namespace OptionalTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/PredicateTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export class PredicateTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: PredicateTypeParser): string => {
public static formatToString(parser: PredicateTypeParser): string {
return parser.asserts ? `asserts ${parser.name}` : `${parser.name} is ${parser.type!.toString()}`;
};
}
}

export namespace PredicateTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/QueryTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ export class QueryTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: QueryTypeParser): string => {
public static formatToString(parser: QueryTypeParser): string {
return `typeof ${parser.query.toString()}`;
};
}
}

export namespace QueryTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/ReferenceTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ export class ReferenceTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: ReferenceTypeParser): string => {
public static formatToString(parser: ReferenceTypeParser): string {
const typeArguments = parser.typeArguments.length > 0 ? `<${parser.typeArguments.map((type) => type.toString()).join(', ')}>` : '';

return `${parser.packageName ? `${parser.packageName}.` : ''}${parser.name}${typeArguments}`;
};
}
}

export namespace ReferenceTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/ReflectionTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ export class ReflectionTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: ReflectionTypeParser): string => {
public static formatToString(parser: ReflectionTypeParser): string {
return !parser.reflection?.children && parser.reflection?.signatures ? 'Function' : 'Object';
};
}
}

export namespace ReflectionTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/RestTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class RestTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: RestTypeParser): string => {
public static formatToString(parser: RestTypeParser): string {
return `...${TypeParser.wrap(parser.type, TypeParser.BindingPowers[TypeParser.Kind.Rest])}`;
};
}
}

export namespace RestTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/TemplateLiteralTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export class TemplateLiteralTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: TemplateLiteralTypeParser): string => {
public static formatToString(parser: TemplateLiteralTypeParser): string {
return `\`${parser.head}${parser.tail.map((tail) => `\${${tail.type.toString()}}${tail.text}`).join('')}\``;
};
}
}

export namespace TemplateLiteralTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/TupleTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class TupleTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: TupleTypeParser): string => {
public static formatToString(parser: TupleTypeParser): string {
return `[${parser.types.map((type) => type.toString()).join(', ')}]`;
};
}
}

export namespace TupleTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/TypeOperatorTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export class TypeOperatorTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: TypeOperatorTypeParser): string => {
public static formatToString(parser: TypeOperatorTypeParser): string {
return `${parser.operator} ${parser.type.toString()}`;
};
}
}

export namespace TypeOperatorTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/UnionTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class UnionTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: UnionTypeParser): string => {
public static formatToString(parser: UnionTypeParser): string {
return parser.types.map((type) => TypeParser.wrap(type, TypeParser.BindingPowers[TypeParser.Kind.Union])).join(' | ');
};
}
}

export namespace UnionTypeParser {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/structures/type-parsers/UnknownTypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class UnknownTypeParser implements TypeParser {
* @param parser The parser to format.
* @returns The string representation of this parser.
*/
public static formatToString = (parser: UnknownTypeParser): string => {
public static formatToString(parser: UnknownTypeParser): string {
return parser.name;
};
}
}

export namespace UnknownTypeParser {
Expand Down

0 comments on commit 4d52f65

Please sign in to comment.