wandb / weave

Weave is a toolkit for developing AI-powered applications, built by Weights & Biases.
https://wandb.me/weave
Apache License 2.0
659 stars 49 forks source link

chore: old type fix in libtypes #2217

Closed tssweeney closed 2 weeks ago

tssweeney commented 2 weeks ago

Running yarn tsc with some node / ts versions causes the following error. This has been happening to me for almost a year now 😮‍💨 ... anyway, this is because the above check of if (convertedType != null) makes convertedType a NonNullable<T> instead of T. However since NonNullable<T> is assignable to T, this fix is satisfactory.

src/components/Panel2/panellib/libtypes.ts:84:11 - error TS2322: Type 'TypedInputHandlerStack<NonNullable<T>, TypedInputHandler<NonNullable<T>>, TypedInputConverter<NonNullable<T>>>[]' is not assignable to type 'TypedInputHandlerStack<T, H, C>[]'.
  Type 'TypedInputHandlerStack<NonNullable<T>, TypedInputHandler<NonNullable<T>>, TypedInputConverter<NonNullable<T>>>' is not assignable to type 'TypedInputHandlerStack<T, H, C>'.
    Type 'TypedInputHandler<NonNullable<T>>' is not assignable to type 'TypedInputHandlerStack<T, H, C>'.
      Type 'TypedInputHandler<NonNullable<T>>' is not assignable to type 'C & { inputType: T; child: TypedInputHandlerStack<T, H, C>; }'.
        Type 'TypedInputHandler<NonNullable<T>>' is not assignable to type 'C'.
          'C' could be instantiated with an arbitrary type which could be unrelated to 'TypedInputHandler<NonNullable<T>>'.

84       let children: Array<TypedInputHandlerStack<T, H, C>> =
             ~~~~~~~~

src/components/Panel2/panellib/libtypes.ts:87:11 - error TS2345: Argument of type 'H[]' is not assignable to parameter of type 'TypedInputHandler<NonNullable<T>>[]'.
  Type 'H' is not assignable to type 'TypedInputHandler<NonNullable<T>>'.
    Type 'TypedInputHandler<T>' is not assignable to type 'TypedInputHandler<NonNullable<T>>'.
      Types of property 'inputType' are incompatible.
        Type 'T' is not assignable to type 'NonNullable<T>'.

87           handlers,
             ~~~~~~~~

Found 2 errors in the same file, starting at: src/components/Panel2/panellib/libtypes.ts:84
circle-job-mirror[bot] commented 2 weeks ago

Preview this PR with FeatureBee: https://beta.wandb.ai/?betaVersion=2d427ca3979272231a69d21e3237a194ff815ed5