Skip to content

Commit

Permalink
feat: add Piece and Store namespaces for easier importing types (#138)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeroen Claassens <support@favware.tech>
  • Loading branch information
Lioness100 and favna committed Nov 14, 2021
1 parent 93da687 commit 84e2d24
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/lib/structures/AliasPiece.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Piece, PieceContext, PieceJSON, PieceOptions } from './Piece';
import { Piece } from './Piece';

export interface AliasPieceOptions extends PieceOptions {
export interface AliasPieceOptions extends Piece.Options {
/**
* The aliases for the piece.
* @default []
Expand All @@ -17,7 +17,7 @@ export class AliasPiece<O extends AliasPieceOptions = AliasPieceOptions> extends
*/
public aliases: readonly string[];

public constructor(context: PieceContext, options: AliasPieceOptions = {}) {
public constructor(context: Piece.Context, options: AliasPieceOptions = {}) {
super(context, options);
this.aliases = options.aliases ?? [];
}
Expand All @@ -36,13 +36,15 @@ export class AliasPiece<O extends AliasPieceOptions = AliasPieceOptions> extends
/**
* The return type of {@link AliasPiece.toJSON}.
*/
export interface AliasPieceJSON extends PieceJSON {
export interface AliasPieceJSON extends Piece.JSON {
aliases: string[];
options: AliasPieceOptions;
}

export namespace AliasPiece {
export const { Location } = Piece;
export type Options = AliasPieceOptions;
export type Context = PieceContext;
export type Context = Piece.Context;
export type JSON = AliasPieceJSON;
export type LocationJSON = Piece.LocationJSON;
}
2 changes: 2 additions & 0 deletions src/lib/structures/Piece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ export interface PieceJSON {
}

export namespace Piece {
export const Location = PieceLocation;
export type Options = PieceOptions;
export type Context = PieceContext;
export type JSON = PieceJSON;
export type LocationJSON = PieceLocationJSON;
}
8 changes: 8 additions & 0 deletions src/lib/structures/Store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { LoaderError, LoaderErrorType } from '../errors/LoaderError';
import { container, Container } from '../shared/Container';
import type { HydratedModuleData, ILoaderResultEntry, ILoaderStrategy, ModuleData } from '../strategies/ILoaderStrategy';
import { LoaderStrategy } from '../strategies/LoaderStrategy';
import { StoreRegistry, StoreRegistryEntries } from './StoreRegistry';
import type { Piece } from './Piece';

/**
Expand Down Expand Up @@ -306,3 +307,10 @@ export class Store<T extends Piece> extends Collection<string, T> {
}

type ErrorWithCode = Error & { code: string };

export namespace Store {
export const Registry = StoreRegistry;
export type Options<T extends Piece> = StoreOptions<T>;
export type Logger = StoreLogger;
export type RegistryEntries = StoreRegistryEntries;
}

0 comments on commit 84e2d24

Please sign in to comment.