Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(store): remove typings that are incompatible with TS 2.7 #853

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ $ npm install @ngxs/store@dev
* Fix: Performance improved reading the name of the state from the parameter [#826](https://github.com/ngxs/store/pull/826)
* Fix: Log group not closed on error [#831](https://github.com/ngxs/store/pull/831)
* Fix: Websocket Plugin - server/network error triggered close should dispatch WebSocketDisconnected [#832](https://github.com/ngxs/store/pull/832)
* Fix: Remove typings introduced since 3.3.4 that were incompatible with TS 2.7 [#853](https://github.com/ngxs/store/pull/853)

## NGXS-Labs

Expand Down
4 changes: 2 additions & 2 deletions packages/hmr-plugin/src/internal/hmr-lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export class HmrLifecycle<T extends NgxsHmrLifeCycle<S>, S> {
private stateEventLoop(callback: HmrCallback<S>): void {
if (!this.storage.existHmrStorage) return;

const appBootstrapped$: Observable<unknown> = this.bootstrap.appBootstrapped$;
const state$: Observable<unknown> = this.context.store.select(state => state);
const appBootstrapped$: Observable<boolean> = this.bootstrap.appBootstrapped$;
const state$: Observable<any> = this.context.store.select(state => state);

appBootstrapped$.subscribe(() => {
let eventId: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/store/operators/src/internals.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type Predicate<T = unknown> = (value?: T) => boolean;
export type Predicate<T = any> = (value?: T) => boolean;
4 changes: 2 additions & 2 deletions packages/store/operators/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ export function isStateOperator<T>(value: T | StateOperator<T>): value is StateO
return typeof value === 'function';
}

export function isUndefined(value: unknown): value is undefined {
export function isUndefined(value: any): value is undefined {
return typeof value === 'undefined';
}

export function isPredicate<T>(value: Predicate<T> | boolean | number): value is Predicate<T> {
return typeof value === 'function';
}

export function isNumber(value: unknown): value is number {
export function isNumber(value: any): value is number {
return typeof value === 'number';
}

Expand Down
4 changes: 1 addition & 3 deletions packages/store/src/internal/internals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ export interface ObjectKeyMap<T> {
[key: string]: T;
}

export interface StateClassWithoutStaticMembers {}

// inspired from https://stackoverflow.com/a/43674389
export interface StateClass<T = StateClassWithoutStaticMembers, U = any> {
export interface StateClass<T = any, U = any> {
[META_KEY]?: MetaDataModel;
[META_OPTIONS_KEY]?: StoreOptions<U>;

Expand Down
6 changes: 3 additions & 3 deletions packages/store/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Store {
* Selects a slice of data from the store.
*/
select<T>(selector: (state: any, ...states: any[]) => T): Observable<T>;
select<T = any>(selector: string | Type<unknown>): Observable<T>;
select<T = any>(selector: string | Type<any>): Observable<T>;
select(selector: any): Observable<any> {
const selectorFn = getSelectorFn(selector);
return this._stateStream.pipe(
Expand All @@ -56,7 +56,7 @@ export class Store {
*/

selectOnce<T>(selector: (state: any, ...states: any[]) => T): Observable<T>;
selectOnce<T = any>(selector: string | Type<unknown>): Observable<T>;
selectOnce<T = any>(selector: string | Type<any>): Observable<T>;
selectOnce(selector: any): Observable<any> {
return this.select(selector).pipe(take(1));
}
Expand All @@ -65,7 +65,7 @@ export class Store {
* Select a snapshot from the state.
*/
selectSnapshot<T>(selector: (state: any, ...states: any[]) => T): T;
selectSnapshot<T = any>(selector: string | Type<unknown>): T;
selectSnapshot<T = any>(selector: string | Type<any>): T;
selectSnapshot(selector: any): any {
const selectorFn = getSelectorFn(selector);
return selectorFn(this._stateStream.getValue());
Expand Down