Skip to content

Commit

Permalink
Use unknown rather than any for BaseController state
Browse files Browse the repository at this point in the history
The BaseController state now uses `unknown` rather than `any` as the
type for state properties. `unknown` is more type-safe than `any` in
cases like this where we don't know what type to expect. See here for
details [1].

This was suggested by @rekmarks during review of #362 [2].

[1]: microsoft/TypeScript#24439
[2]: #362 (comment)
  • Loading branch information
Gudahtt committed Feb 25, 2021
1 parent 6e0b2da commit 51c89d7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/BaseControllerV2.ts
Expand Up @@ -14,7 +14,7 @@ export type Listener<T> = (state: T, patches: Patch[]) => void;
/**
* Controller class that provides state management and subscriptions
*/
export class BaseController<S extends Record<string, any>> {
export class BaseController<S extends Record<string, unknown>> {
private internalState: S;

private internalListeners: Set<Listener<S>> = new Set();
Expand Down

0 comments on commit 51c89d7

Please sign in to comment.