Skip to content

Commit

Permalink
fix(store): rename template literal to string literal for createActio…
Browse files Browse the repository at this point in the history
…nGroup (#3426)
  • Loading branch information
markostanimirovic committed May 24, 2022
1 parent f15dd1e commit 7d08db1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions modules/store/spec/types/action_group_creator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ describe('createActionGroup', () => {
});

describe('source', () => {
it('should fail when source is not a template literal type', () => {
it('should fail when source is not a string literal type', () => {
expectSnippet(`
const booksApiActions = createActionGroup({
source: 'Books API' as string,
events: {},
});
`).toFail(/source must be a template literal type/);
`).toFail(/source must be a string literal type/);
});
});

Expand Down Expand Up @@ -116,15 +116,15 @@ describe('createActionGroup', () => {
);
});

it('should fail when event name is not a template literal type', () => {
it('should fail when event name is not a string literal type', () => {
expectSnippet(`
const booksApiActions = createActionGroup({
source: 'Books API',
events: {
['Load Books Success' as string]: emptyProps()
},
});
`).toFail(/event name must be a template literal type/);
`).toFail(/event name must be a string literal type/);
});

describe('forbidden characters', () => {
Expand Down
8 changes: 4 additions & 4 deletions modules/store/src/action_group_creator_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ type EmptyStringCheck<
? `${Name} cannot be an empty string or contain only spaces`
: unknown;

type TemplateLiteralCheck<
type StringLiteralCheck<
Str extends string,
Name extends string
> = string extends Str ? `${Name} must be a template literal type` : unknown;
> = string extends Str ? `${Name} must be a string literal type` : unknown;

type UniqueEventNameCheck<
EventNames extends string,
Expand Down Expand Up @@ -120,11 +120,11 @@ export interface ActionGroupConfig<
Source extends string,
Events extends Record<string, ActionCreatorProps<unknown> | Creator>
> {
source: Source & TemplateLiteralCheck<Source, 'source'>;
source: Source & StringLiteralCheck<Source, 'source'>;
events: {
[EventName in keyof Events]: Events[EventName] &
EmptyStringCheck<EventName & string, 'event name'> &
TemplateLiteralCheck<EventName & string, 'event name'> &
StringLiteralCheck<EventName & string, 'event name'> &
ForbiddenCharactersCheck<EventName & string, 'event name'> &
UniqueEventNameCheck<keyof Events & string, EventName & string> &
NotAllowedEventPropsCheck<Events[EventName]>;
Expand Down

0 comments on commit 7d08db1

Please sign in to comment.