Skip to content

Commit 27dde6e

Browse files
authored
Merge pull request #859 from acacode/fix-lint-errors
Make types slightly better
2 parents 062f3be + 8e354f9 commit 27dde6e

File tree

1 file changed

+41
-36
lines changed

1 file changed

+41
-36
lines changed

types/index.d.ts

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ interface GenerateApiParamsBase {
184184
requestOptions?: null | Partial<RequestInit>;
185185

186186
/** ts compiler configuration object (for --to-js option) */
187-
compilerTsConfig?: Record<string, any>;
187+
compilerTsConfig?: Record<string, unknown>;
188188

189189
/**
190190
* custom ts->* translator
@@ -257,28 +257,28 @@ type CodeGenConstruct = {
257257
CodeGenKeyword: {
258258
UtilRequiredKeys: string;
259259
};
260-
ArrayType: (content: any) => string;
261-
StringValue: (content: any) => string;
262-
BooleanValue: (content: any) => string;
263-
NumberValue: (content: any) => string;
264-
NullValue: (content: any) => string;
265-
UnionType: (content: any) => string;
266-
ExpressionGroup: (content: any) => string;
267-
IntersectionType: (content: any) => string;
268-
RecordType: (content: any) => string;
269-
TypeField: (content: any) => string;
270-
InterfaceDynamicField: (content: any) => string;
271-
EnumField: (content: any) => string;
272-
EnumFieldsWrapper: (content: any) => string;
273-
ObjectWrapper: (content: any) => string;
274-
MultilineComment: (content: any) => string;
275-
TypeWithGeneric: (content: any) => string;
260+
ArrayType: (content: unknown) => string;
261+
StringValue: (content: unknown) => string;
262+
BooleanValue: (content: unknown) => string;
263+
NumberValue: (content: unknown) => string;
264+
NullValue: (content: unknown) => string;
265+
UnionType: (content: unknown) => string;
266+
ExpressionGroup: (content: unknown) => string;
267+
IntersectionType: (content: unknown) => string;
268+
RecordType: (content: unknown) => string;
269+
TypeField: (content: unknown) => string;
270+
InterfaceDynamicField: (content: unknown) => string;
271+
EnumField: (content: unknown) => string;
272+
EnumFieldsWrapper: (content: unknown) => string;
273+
ObjectWrapper: (content: unknown) => string;
274+
MultilineComment: (content: unknown) => string;
275+
TypeWithGeneric: (content: unknown) => string;
276276
};
277277

278278
type PrimitiveTypeStructValue =
279279
| string
280280
| ((
281-
schema: Record<string, any>,
281+
schema: Record<string, unknown>,
282282
parser: import("../src/schema-parser/schema-parser").SchemaParser,
283283
) => string);
284284

@@ -341,60 +341,65 @@ type BuildRoutePath = {
341341

342342
export interface Hooks {
343343
/** calls before parse\process route path */
344-
onPreBuildRoutePath: (routePath: string) => string | void;
344+
onPreBuildRoutePath: (routePath: string) => string | undefined;
345345
/** calls after parse\process route path */
346-
onBuildRoutePath: (data: BuildRoutePath) => BuildRoutePath | void;
346+
onBuildRoutePath: (data: BuildRoutePath) => BuildRoutePath | undefined;
347347
/** calls before insert path param name into string path interpolation */
348348
onInsertPathParam: (
349349
paramName: string,
350350
index: number,
351351
arr: BuildRouteParam[],
352352
resultRoute: string,
353-
) => string | void;
353+
) => string | undefined;
354354
/** calls after parse schema component */
355-
onCreateComponent: (component: SchemaComponent) => SchemaComponent | void;
355+
onCreateComponent: (
356+
component: SchemaComponent,
357+
) => SchemaComponent | undefined;
356358
/** calls before parse any kind of schema */
357359
onPreParseSchema: (
358-
originalSchema: any,
360+
originalSchema: unknown,
359361
typeName: string,
360362
schemaType: string,
361-
) => any;
363+
) => undefined;
362364
/** calls after parse any kind of schema */
363-
onParseSchema: (originalSchema: any, parsedSchema: any) => any | void;
365+
onParseSchema: (
366+
originalSchema: unknown,
367+
parsedSchema: unknown,
368+
) => unknown | undefined;
364369
/** calls after parse route (return type: customized route (ParsedRoute), nothing change (void), false (ignore this route)) */
365-
onCreateRoute: (routeData: ParsedRoute) => ParsedRoute | void | false;
370+
onCreateRoute: (routeData: ParsedRoute) => ParsedRoute | false | undefined;
366371
/** Start point of work this tool (after fetching schema) */
367372
onInit?: <C extends GenerateApiConfiguration["config"]>(
368373
configuration: C,
369374
codeGenProcess: import("../src/code-gen-process").CodeGenProcess,
370-
) => C | void;
375+
) => C | undefined;
371376
/** customize configuration object before sending it to ETA templates */
372377
onPrepareConfig?: <C extends GenerateApiConfiguration>(
373378
currentConfiguration: C,
374-
) => C | void;
379+
) => C | undefined;
375380
/** customize route name as you need */
376381
onCreateRouteName?: (
377382
routeNameInfo: RouteNameInfo,
378383
rawRouteInfo: RawRouteInfo,
379-
) => RouteNameInfo | void;
384+
) => RouteNameInfo | undefined;
380385
/** customize request params (path params, query params) */
381386
onCreateRequestParams?: (
382387
rawType: SchemaComponent["rawTypeData"],
383-
) => SchemaComponent["rawTypeData"] | void;
388+
) => SchemaComponent["rawTypeData"] | undefined;
384389
/** customize name of model type */
385390
onFormatTypeName?: (
386391
typeName: string,
387392
rawTypeName?: string,
388393
schemaType?: "type-name" | "enum-key",
389-
) => string | void;
394+
) => string | undefined;
390395
/** customize name of route (operationId), you can do it with using onCreateRouteName too */
391396
onFormatRouteName?: (
392397
routeInfo: RawRouteInfo,
393398
templateRouteName: string,
394-
) => string | void;
399+
) => string | undefined;
395400
}
396401

397-
export type RouteNameRouteInfo = {};
402+
export type RouteNameRouteInfo = Record<unknown, unknown>;
398403

399404
export type RouteNameInfo = {
400405
usage: string;
@@ -407,7 +412,7 @@ export type SchemaTypePrimitiveContent = {
407412
schemaType: string;
408413
type: string;
409414
typeIdentifier: string;
410-
name?: any;
415+
name?: unknown;
411416
description: string;
412417
content: string;
413418
};
@@ -593,7 +598,7 @@ export interface GenerateApiConfiguration {
593598
input: string;
594599
output: string;
595600
url: string;
596-
spec: any;
601+
spec: unknown;
597602
fileName: string;
598603
templatePaths: {
599604
/** `templates/base` */
@@ -650,7 +655,7 @@ export interface GenerateApiConfiguration {
650655
hooks: Hooks;
651656
enumNamesAsValues: boolean;
652657
version: string;
653-
compilerTsConfig: Record<string, any>;
658+
compilerTsConfig: Record<string, unknown>;
654659
enumKeyResolverName: string;
655660
typeNameResolverName: string;
656661
specificArgNameResolverName: string;

0 commit comments

Comments
 (0)