Skip to content

Commit 05af913

Browse files
committed
Use type alias for controller state rather than interface
The mock controller state in the base controller tests now uses a type alias for the controller state rather than an interface. This was required to get around an incompatibility between `Record<string, unknown>` and interfaces[1]. The `@typescript-eslint/consistent-type-definitions` ESLint rule has been disabled, as this problem will be encountered fairly frequently. [1]: microsoft/TypeScript#15300 (comment)
1 parent 51c89d7 commit 05af913

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Diff for: .eslintrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ module.exports = {
2525
'no-shadow': 'off',
2626
'@typescript-eslint/no-shadow': 'error',
2727
'@typescript-eslint/indent': 'off',
28+
// disabled due to incompatibility with Record<string, unknown>
29+
// See https://github.com/Microsoft/TypeScript/issues/15300#issuecomment-702872440
30+
'@typescript-eslint/consistent-type-definitions': 'off',
2831

2932
// TODO re-enable most of these rules
3033
'@typescript-eslint/no-non-null-assertion': 'off',

Diff for: src/BaseControllerV2.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import * as sinon from 'sinon';
33

44
import { BaseController } from './BaseControllerV2';
55

6-
interface MockControllerState {
6+
type MockControllerState = {
77
count: number;
8-
}
8+
};
99

1010
class MockController extends BaseController<MockControllerState> {
1111
update(callback: (state: Draft<MockControllerState>) => void | MockControllerState) {

0 commit comments

Comments
 (0)