Skip to content

Commit

Permalink
changed: simplify types
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Pasynok committed Nov 2, 2024
1 parent c84e79b commit 532ac24
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/createContainer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ type ExtractDeps<D extends Container<string, AnyObject>[]> = {
};

const ERROR = {
EMPTY_STRING_CONTAINER_ID: 'Container ID cannot be an empty string.',
CONTAINER_ID_EMPTY_STRING: 'Container ID cannot be an empty string.',
CONTAINER_ID_NOT_UNIQ: 'Container ID must be unique.',
} as const;

type ContainerIdEmptyStringError = { id: never; error: typeof ERROR.CONTAINER_ID_EMPTY_STRING };

// todo: return on start and enable fn instead of API
// todo: create composer fn
// todo: resolve features graph
Expand All @@ -34,7 +36,7 @@ type Params<
Deps extends NonEmptyTuple<AnyContainer> | void = void,
OptionalDeps extends NonEmptyTuple<AnyContainer> | void = void,
> = '' extends Id
? { id: never; error: typeof ERROR.EMPTY_STRING_CONTAINER_ID }
? ContainerIdEmptyStringError
: Deps extends void
? OptionalDeps extends void
? {
Expand Down Expand Up @@ -80,7 +82,7 @@ const createContainer = <
params: Params<Id, API, Deps, OptionalDeps>,
) => {
if (params.id === '') {
throw new Error(ERROR.EMPTY_STRING_CONTAINER_ID);
throw new Error(ERROR.CONTAINER_ID_EMPTY_STRING);
}

if (IDS_SET.has(params.id)) {
Expand Down

0 comments on commit 532ac24

Please sign in to comment.