Skip to content

Commit

Permalink
Merge pull request #1 from ifritzler/fix-typescript-keyof-issue
Browse files Browse the repository at this point in the history
Ensure Type Accuracy in updateSignal Method
  • Loading branch information
Alan-TheGentleman authored May 18, 2024
2 parents c59f1cc + 802cf11 commit 079705e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gentleman-agnostic-signals",
"version": "0.0.4",
"version": "0.0.5",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"description": "",
Expand Down
2 changes: 1 addition & 1 deletion src/init.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SignalsManager } from "./signals_manager";

let signalsManager: SignalsManager<any>;
export type SignalsState<T = {}> = { [K in keyof T]: any };
export type SignalsState<T = {}> = { [K in keyof T]: T[K] };

export function initSignalsManager<T extends SignalsState<T>>(
defaultState: T,
Expand Down
4 changes: 2 additions & 2 deletions src/signals_manager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Signal, SignalsAdapter, SignalsDomain } from "./domain";

export class SignalsManager<T extends { [K in keyof T]: any }> {
export class SignalsManager<T extends { [K in keyof T]: T[K] }> {
signalsCollection = new Map<keyof T, Signal<T[keyof T]>>();
signalsAdapter: SignalsAdapter<T>;

Expand All @@ -27,7 +27,7 @@ export class SignalsManager<T extends { [K in keyof T]: any }> {
return foundSignal;
}

updateSignal(key: keyof T, payload: T[keyof T]) {
updateSignal<K extends keyof T>(key: K, payload: T[K]) {
const foundSignal = this.getSignal(key);

this.signalsAdapter.updateSignal(foundSignal, payload);
Expand Down

0 comments on commit 079705e

Please sign in to comment.