Skip to content

Commit 2b8ff58

Browse files
committed
chore: upgrade typescript
1 parent 63d9f02 commit 2b8ff58

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"tslint-eslint-rules": "^5.4.0",
5151
"tslint-react": "^3.6.0",
5252
"tslint-sonarts": "^1.9.0",
53-
"typescript": "3.1.6",
53+
"typescript": "^3.3.3",
5454
"webpack": "^4.29.5",
5555
"webpack-cli": "^3.2.3",
5656
"webpack-dev-server": "^3.1.14"

src/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export type RestrictArray<T> = T extends any[] ? T : []
22
export type VoidAsNull<T> = T extends void ? null : T
3+
export type Not<P, T, F> = P extends false ? T : F

src/use-event-callback.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useState } from 'react'
22
import { Observable, BehaviorSubject, Subject, noop } from 'rxjs'
33

4-
import { RestrictArray, VoidAsNull } from './type'
4+
import { RestrictArray, VoidAsNull, Not } from './type'
55

66
export type EventCallbackState<EventValue, State, Inputs = void> = [
77
(val: EventValue) => void,
@@ -12,13 +12,15 @@ export type ReturnedState<EventValue, State, Inputs> = [
1212
EventCallbackState<EventValue, State, Inputs>[1][0]
1313
]
1414

15-
export type EventCallback<EventValue, State, Inputs> = Inputs extends void
16-
? (eventSource$: Observable<EventValue>, state$: Observable<State>) => Observable<State>
17-
: (
18-
eventSource$: Observable<EventValue>,
19-
inputs$: Observable<RestrictArray<Inputs>>,
20-
state$: Observable<State>,
21-
) => Observable<State>
15+
export type EventCallback<EventValue, State, Inputs> = Not<
16+
Inputs extends void ? true : false,
17+
(
18+
eventSource$: Observable<EventValue>,
19+
inputs$: Observable<RestrictArray<Inputs>>,
20+
state$: Observable<State>,
21+
) => Observable<State>,
22+
(eventSource$: Observable<EventValue>, state$: Observable<State>) => Observable<State>
23+
>
2224

2325
export function useEventCallback<EventValue>(
2426
callback: EventCallback<EventValue, void, void>,

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6835,10 +6835,10 @@ typedarray@^0.0.6:
68356835
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
68366836
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
68376837

6838-
typescript@3.1.6:
6839-
version "3.1.6"
6840-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.6.tgz#b6543a83cfc8c2befb3f4c8fba6896f5b0c9be68"
6841-
integrity sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==
6838+
typescript@^3.3.3:
6839+
version "3.3.3"
6840+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.3.tgz#f1657fc7daa27e1a8930758ace9ae8da31403221"
6841+
integrity sha512-Y21Xqe54TBVp+VDSNbuDYdGw0BpoR/Q6wo/+35M8PAU0vipahnyduJWirxxdxjsAkS7hue53x2zp8gz7F05u0A==
68426842

68436843
uglify-js@3.4.x, uglify-js@^3.1.4:
68446844
version "3.4.9"

0 commit comments

Comments
 (0)