Skip to content

Use unknown rather than any for BaseController state #365

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

Merged
merged 3 commits into from
Feb 25, 2021
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
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ module.exports = {
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/indent': 'off',
// disabled due to incompatibility with Record<string, unknown>
// See https://github.com/Microsoft/TypeScript/issues/15300#issuecomment-702872440
'@typescript-eslint/consistent-type-definitions': 'off',

// TODO re-enable most of these rules
'@typescript-eslint/no-non-null-assertion': 'off',
Expand Down
4 changes: 2 additions & 2 deletions src/BaseControllerV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import * as sinon from 'sinon';

import { BaseController } from './BaseControllerV2';

interface MockControllerState {
type MockControllerState = {
count: number;
}
};

class MockController extends BaseController<MockControllerState> {
update(callback: (state: Draft<MockControllerState>) => void | MockControllerState) {
Expand Down
2 changes: 1 addition & 1 deletion src/BaseControllerV2.ts
Original file line number Diff line number Diff line change
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