Skip to content

TypeScript: DeepPartial breaks when using unknown #3368

@OliverJAsh

Description

@OliverJAsh

Repro:

type State = {
  bar: unknown;
};

declare let preloadedState: State;

declare const reducer: Reducer<State>;
createStore(
  reducer,
  // Unexpected type error:
  /* Argument of type 'State' is not assignable to parameter of type 'DeepPartial<State>'.
  Types of property 'bar' are incompatible.
    Type 'unknown' is not assignable to type 'DeepPartial<unknown> | undefined'.
      Type 'unknown' is not assignable to type 'DeepPartial<unknown>'. */
  preloadedState,
);

type StateDP = DeepPartial<State>;
declare let stateDP: StateDP;
// Unexpected type error:
// Type 'State' is not assignable to type 'DeepPartial<State>'
stateDP = preloadedState;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions