File tree Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ describe('createEffect()', () => {
47
47
expectSnippet ( `
48
48
const effect = createEffect(() => ({ foo: 'a' }), { dispatch: false });
49
49
` ) . toFail (
50
- / T y p e ' { f o o : s t r i n g ; } ' i s n o t a s s i g n a b l e t o t y p e ' O b s e r v a b l e < u n k n o w n > | ( ( ...a r g s : a n y [ ] ) = > O b s e r v a b l e < u n k n o w n > ) ' ./
50
+ / T y p e ' { f o o : s t r i n g ; } ' i s n o t a s s i g n a b l e t o t y p e ' O b s e r v a b l e < { } > | ( ( ...a r g s : a n y [ ] ) = > O b s e r v a b l e < { } > ) ' ./
51
51
) ;
52
52
} ) ;
53
53
} ) ;
Original file line number Diff line number Diff line change @@ -8,10 +8,8 @@ interface CreateEffectMetadata {
8
8
[ CREATE_EFFECT_METADATA_KEY ] : EffectConfig ;
9
9
}
10
10
11
- type DispatchType < T > = T extends { dispatch : infer U } ? U : unknown ;
12
- type ObservableReturnType < T > = T extends false
13
- ? Observable < unknown >
14
- : Observable < Action > ;
11
+ type DispatchType < T > = T extends { dispatch : infer U } ? U : true ;
12
+ type ObservableType < T , OriginalType > = T extends false ? OriginalType : Action ;
15
13
/**
16
14
* @description
17
15
* Creates an effect from an `Observable` and an `EffectConfig`.
@@ -46,9 +44,9 @@ type ObservableReturnType<T> = T extends false
46
44
*/
47
45
export function createEffect <
48
46
C extends EffectConfig ,
49
- T extends DispatchType < C > ,
50
- O extends ObservableReturnType < T > ,
51
- R extends O | ( ( ...args : any [ ] ) => O )
47
+ DT extends DispatchType < C > ,
48
+ OT extends ObservableType < DT , OT > ,
49
+ R extends Observable < OT > | ( ( ...args : any [ ] ) => Observable < OT > )
52
50
> ( source : ( ) => R , config ?: Partial < C > ) : R & CreateEffectMetadata {
53
51
const effect = source ( ) ;
54
52
const value : EffectConfig = {
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ export interface EffectConfig {
13
13
resubscribeOnError ?: boolean ;
14
14
}
15
15
16
- export const DEFAULT_EFFECT_CONFIG : Required < EffectConfig > = {
16
+ export const DEFAULT_EFFECT_CONFIG : Readonly < Required < EffectConfig > > = {
17
17
dispatch : true ,
18
18
resubscribeOnError : true ,
19
19
} ;
You can’t perform that action at this time.
0 commit comments