Skip to content

Commit 4453cdc

Browse files
committed
For empty objects, prefer no type assertions or as never
- `never` is assignable to all types
1 parent 93a997b commit 4453cdc

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

packages/base-controller/src/BaseControllerV1.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ export class BaseControllerV1<C extends BaseConfig, S extends BaseState> {
3636
/**
3737
* Default options used to configure this controller
3838
*/
39-
defaultConfig: C = {} as C;
39+
defaultConfig: C = {} as never;
4040

4141
/**
4242
* Default state set on this controller
4343
*/
44-
defaultState: S = {} as S;
44+
defaultState: S = {} as never;
4545

4646
/**
4747
* Determines if listeners are notified of state changes
@@ -70,10 +70,7 @@ export class BaseControllerV1<C extends BaseConfig, S extends BaseState> {
7070
* @param config - Initial options used to configure this controller.
7171
* @param state - Initial state to set on this controller.
7272
*/
73-
constructor(config: Partial<C> = {} as C, state: Partial<S> = {} as S) {
74-
// Use assign since generics can't be spread: https://git.io/vpRhY
75-
this.initialState = state as S;
76-
this.initialConfig = config as C;
73+
constructor(config: Partial<C> = {}, state: Partial<S> = {}) {
7774
}
7875

7976
/**

0 commit comments

Comments
 (0)