Skip to content

Commit

Permalink
fix: type error
Browse files Browse the repository at this point in the history
  • Loading branch information
chnliquan committed Jul 4, 2022
1 parent bb5f417 commit ed64dc5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"scripts": {
"dev": "node scripts/dev.js",
"build": "node scripts/build.js",
"lint": "eslint 'src/**/*.@(js|ts)' --fix",
"format": "prettier --write 'src/**/*.@(js|ts)'",
"lint": "eslint 'src/**/*.@(js|ts|jsx|tsx)' --fix",
"format": "prettier --write 'src/**/*.@(js|ts|jsx|tsx)'",
"test": "npm run test:once -- --watch",
"test:once": "jest --runInBand --colors --forceExit",
"coverage": "codecov",
Expand All @@ -32,10 +32,9 @@
"immutable"
],
"lint-staged": {
"{src,test}/**/*.{js,ts}": [
"{src,__tests__}/**/*.{js,jsx,ts,tsx}": [
"prettier --write",
"eslint --fix",
"git add"
"eslint --fix"
]
},
"dependencies": {
Expand Down
18 changes: 13 additions & 5 deletions src/core/Store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class Store<C extends Configs> {
return <>{children}</>
}

public withProvider = <P extends any>(Component: React.ComponentType<P>) => {
public withProvider = <P extends Record<string, any>>(Component: React.ComponentType<P>) => {
const WithProvider: React.FC<P> = props => {
return (
<this.Provider>
Expand Down Expand Up @@ -97,7 +97,9 @@ export class Store<C extends Configs> {

invariant(
modelNames.indexOf(modelName as string) > -1,
`[store.useModel] Expected the modelName to be one of ${modelNames}, but got ${modelName}.`
`[store.useModel] Expected the modelName to be one of ${modelNames}, but got ${
modelName as string
}.`
)

invariant(
Expand Down Expand Up @@ -206,7 +208,9 @@ export class Store<C extends Configs> {

invariant(
modelNames.indexOf(modelName as string) > -1,
`[store.getState] Expected the modelName to be one of ${modelNames}, but got ${modelName}.`
`[store.getState] Expected the modelName to be one of ${modelNames}, but got ${
modelName as string
}.`
)

return this.rootModel[modelName].state
Expand All @@ -228,7 +232,9 @@ export class Store<C extends Configs> {

invariant(
modelNames.indexOf(modelName as string) > -1,
`[store.getReducers] Expected the modelName to be one of ${modelNames}, but got ${modelName}.`
`[store.getReducers] Expected the modelName to be one of ${modelNames}, but got ${
modelName as string
}.`
)

return this.rootModel[modelName].reducers
Expand All @@ -250,7 +256,9 @@ export class Store<C extends Configs> {

invariant(
modelNames.indexOf(modelName as string) > -1,
`[store.getEffects] Expected the modelName to be one of ${modelNames}, but got ${modelName}.`
`[store.getEffects] Expected the modelName to be one of ${modelNames}, but got ${
modelName as string
}.`
)

return this.rootModel[modelName].effects
Expand Down

0 comments on commit ed64dc5

Please sign in to comment.