Skip to content

Commit 22284ab

Browse files
alex-okrushkobrandonroberts
authored andcommitted
refactor(store): adjust types to be compatible with TypeScript 2.7 and 2.9 (#1193)
1 parent 97269c0 commit 22284ab

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

modules/effects/src/effects_metadata.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { compose } from '@ngrx/store';
33
const METADATA_KEY = '__@ngrx/effects__';
44

55
export interface EffectMetadata<T> {
6-
propertyName: keyof T;
6+
// Once TS is >= 2.8 replace with <Key extends Extract<keyof T, string>>
7+
propertyName: string;
78
dispatch: boolean;
89
}
910

@@ -29,7 +30,9 @@ function setEffectMetadataEntries<T>(
2930
}
3031

3132
export function Effect<T>({ dispatch = true } = {}): PropertyDecorator {
32-
return function(target: T, propertyName: keyof T) {
33+
// Once TS is >= 2.8 replace with <Key extends Extract<keyof T, string>>
34+
// for propertyName.
35+
return function(target: T, propertyName: string) {
3336
const metadata: EffectMetadata<T> = { propertyName, dispatch };
3437
setEffectMetadataEntries<T>(target, [metadata]);
3538
} as (target: {}, propertyName: string | symbol) => void;
@@ -46,7 +49,9 @@ export function getSourceMetadata<T>(instance: T): Array<EffectMetadata<T>> {
4649
)(instance);
4750
}
4851

49-
export type EffectsMetadata<T> = { [key in keyof T]?: { dispatch: boolean } };
52+
// Once TS is >= 2.8 replace with
53+
// {[key in <Key extends Extract<keyof T, string>>]?: { dispatch: boolean } };
54+
export type EffectsMetadata<T> = { [key: string]: { dispatch: boolean } };
5055

5156
export function getEffectsMetadata<T>(instance: T): EffectsMetadata<T> {
5257
const metadata: EffectsMetadata<T> = {};

0 commit comments

Comments
 (0)