Skip to content

Commit 385739a

Browse files
committed
Merge branch 'master' of github.com:pedronauck/reworm
* 'master' of github.com:pedronauck/reworm: fix: selectors type declaration (#8)
2 parents 34523c3 + 17d6e44 commit 385739a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ type GetFn<T> = (state: T) => React.ReactNode
129129
interface State<T> {
130130
get: (fn: GetFn<T>) => React.ReactNode
131131
set: (param: T | PrevState<T>) => void
132-
select: (selector: (state: T) => T) => (fn: GetFn<T>) => React.ReactNode
132+
select: <S = T>(selector: (state: T) => S) => (fn: GetFn<S>) => React.ReactNode
133133
State: React.ComponentType<ProviderProps<T>>
134134
}
135135

src/reworm.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ interface ConsumerProps<T> {
1414
interface State<T> {
1515
get: (fn: GetFn<T>) => React.ReactNode
1616
set: (param: T | PrevState<T>) => void
17-
select: (selector: (state: T) => any) => (fn: GetFn<T>) => React.ReactNode
17+
select: <S = any>(
18+
selector: (state: T) => S
19+
) => (fn: GetFn<S>) => React.ReactNode
1820
}
1921

2022
export function create<T = any>(initial: T = {} as T): State<T> {

0 commit comments

Comments
 (0)