Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Piece and Store namespaces for easier importing types #138

Merged
merged 5 commits into from
Nov 14, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 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,16 @@ 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 type Options = AliasPieceOptions;
export type Context = PieceContext;
export type Context = Piece.Context;
export type JSON = AliasPieceJSON;

export const { Location } = Piece;
Lioness100 marked this conversation as resolved.
Show resolved Hide resolved
export type LocationJSON = Piece.LocationJSON;
}
3 changes: 3 additions & 0 deletions src/lib/structures/Piece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,7 @@ export namespace Piece {
export type Options = PieceOptions;
export type Context = PieceContext;
export type JSON = PieceJSON;

export const Location = PieceLocation;
export type LocationJSON = PieceLocationJSON;
Lioness100 marked this conversation as resolved.
Show resolved Hide resolved
}
9 changes: 9 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,11 @@ export class Store<T extends Piece> extends Collection<string, T> {
}

type ErrorWithCode = Error & { code: string };

export namespace Store {
export type Options<T extends Piece> = StoreOptions<T>;
export type Logger = StoreLogger;

export const Registry = StoreRegistry;
Lioness100 marked this conversation as resolved.
Show resolved Hide resolved
export type RegistryEntries = StoreRegistryEntries;
}