Skip to content

Commit

Permalink
Generic parameter defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzhixing committed Mar 31, 2023
1 parent dbac647 commit a7911b2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-hyper-action",
"version": "v1.0.1",
"version": "v1.0.3",
"description": "Human friendly enhanced redux action shape.",
"keywords": [
"react",
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export type AsyncMeta = {
uniq: boolean;
};

export type Meta<O> = O extends AsyncOption ? AsyncMeta : SyncMeta;
export type Meta<O = Option> = O extends AsyncOption ? AsyncMeta : SyncMeta;

export type Action<O, P> = {
export type Action<O = Option, P = Payload> = {
type: string;
error: boolean;
payload?: P extends Error ? Error : PlainValue;
Expand All @@ -71,7 +71,7 @@ const MetaRequiredProperties = ['sign', 'id', 'ctime', 'async', 'uniq'];
const invalidAction = (action: unknown) => `Invalid Action. ${JSON.stringify(action)}! <redux-saga-mate>`;
const invalidAsyncAction = (action: unknown) => `Invalid Async Action. ${JSON.stringify(action)}! <redux-saga-mate>`;

export const isValidAction = (action: any): boolean => {
export const isValidAction = (action: unknown): boolean => {
if (!isPlainObject(action)) {
return false;
}
Expand Down
5 changes: 5 additions & 0 deletions src/module.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type {PlainObect} from './index';

declare module 'is-plain-object' {
export function isPlainObject(o: unknown): o is PlainObect;
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@tsconfig/recommended/tsconfig.json",
"include": ["src/**/*"],
"include": ["./src"],
"compilerOptions": {
"outDir": "./dist",
"declaration": true
Expand Down

0 comments on commit a7911b2

Please sign in to comment.