Effect CommunityEC
Effect Community2y ago
8 replies
Patrick Roza

Implementing Generic Extension with TypeScript Copy Function

How to make this work with generic extends?
declare const copy: <A>(f: (a: NoInfer<A>) => Partial<NoInfer<A>>) => (self: A) => A

type Type = {
  value: string | null
}

const test = <T extends Type>(t: T) => pipe(t, copy(({ value }) => ({ value: value ? value.toUpperCase() : value })))
// Type '{ value: string | null; }' is not assignable to type 'Partial<NoInfer<T>>'.

replacing t: T -> t: Type works
Was this page helpful?