Skip to content

Commit

Permalink
fix: Improve some types
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Nov 19, 2024
1 parent 5f84624 commit 26d5849
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
12 changes: 4 additions & 8 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {LintConfig} from '@diplodoc/transform/lib/yfmlint';
import {IncludeMode, Lang, ResourceType, Stage} from './constants';
import {FileContributors, VCSConnector, VCSConnectorConfig} from './vcs-connector/connector-models';

export type VarsPreset = 'internal' | 'external';
export type VarsPreset = string;

export type VarsMetadata = {
[field: string]: string;
Expand Down Expand Up @@ -51,7 +51,7 @@ interface VCSConfiguration {
*
* you should pass `https://github.com/foo-org/bar/tree/main/docs` as a value for this parameter.
*/
remoteBase: string;
remoteBase?: string;
}

interface YfmConfig {
Expand Down Expand Up @@ -152,18 +152,14 @@ export interface YfmTocInclude {
export type YfmTocIncluders = YfmTocIncluder[];

export type YfmTocIncluder = {
name: YfmTocIncluderName;
name: string;
// arbitrary includer parameters
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} & Record<string, unknown>;

export const includersNames = ['sourcedocs', 'openapi', 'generic', 'unarchive'] as const;

export type YfmTocIncluderName = (typeof includersNames)[number];

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type Includer<FnParams = any> = {
name: YfmTocIncluderName;
name: string;
includerFunction: IncluderFunction<FnParams>;
};

Expand Down
2 changes: 1 addition & 1 deletion src/program/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const BaseProgram = <
}
}

apply(program?: IProgram) {
apply(program?: IProgram<TArgs>) {
// @ts-ignore
this['parent'] = program;

Expand Down
2 changes: 1 addition & 1 deletion src/program/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class Program
}),
},
})
implements IProgram
implements IProgram<ProgramArgs>
{
readonly command: Command = new Command(NAME)
.helpOption(true)
Expand Down
6 changes: 3 additions & 3 deletions src/program/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type {Logger} from '~/logger';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Hooks = Record<string, Hook<any, any> | HookMap<any>>;

export interface ICallable {
apply(program?: IProgram): void;
export interface ICallable<TArgs extends Hash = Hash> {
apply(program?: IProgram<TArgs>): void;
}

/**
Expand All @@ -28,7 +28,7 @@ export interface ICallable {
* 5. Complex hook calls should be designed as external private methods named as 'hookMethodName'
* (example: hookConfig)
*/
export interface IProgram<Args extends Hash = Hash> extends ICallable {
export interface IProgram<Args extends Hash = Hash> extends ICallable<Args> {
command: Command;

parent?: IParent;
Expand Down

0 comments on commit 26d5849

Please sign in to comment.