Skip to content

[TS] sample with target: "best common type" problem  #247

@bloadvenro

Description

@bloadvenro
sample({
  target: {} as Unit<{ a: string; b: string }>,
  source: {} as Unit<{ a: string }>, // should not let such assignment
  //////////////////////////////////////////////////////////////////////////////
  ///////////////// types of props below do not affect anything ////////////////     
  //////////////////////////////////////////////////////////////////////////////
  clock: {} as Unit<any>,
});

sample({
  target: {} as Unit<{ a: string; b: string }>,
  fn: () => ({ a: '' }), // should not let such assignment
  //////////////////////////////////////////////////////////////////////////////
  ///////////////// types of props below do not affect anything ////////////////     
  //////////////////////////////////////////////////////////////////////////////
  source: {} as Unit<any>,
  clock: {} as Unit<any>,
});

Last time we faced with the same problem in forward typings.

I'll add NoInfer<T> type suggested by Typescript comminuty and modify inference for each sample overload which includes target.

Metadata

Metadata

Assignees

No one assigned

    Labels

    typingsTypescript public type definitions issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions