github Effect-TS/tsgo @effect/tsgo@0.74.2

one hour ago

Patch Changes

  • 387dd4f: missedPipeableOpportunity no longer suggests .pipe(...) on values whose pipe method does not take functions, such as a Node.js Readable stream. A receiver is now reported only when some call signature of its pipe accepts one function argument per step of the suggested pipe:

    import { Readable } from "node:stream"
    import { identity } from "effect/Function"
    import * as Option from "effect/Option"
    
    declare const stream: Readable
    
    // before: reported, and the quick fix produced `stream.pipe(identity, Option.some)`, which does not compile
    // after: not reported
    Option.some(identity(stream))
  • 5103cb8: Keep comments when the missedPipeableOpportunity quick fix rewrites nested calls into .pipe(...). Previously every comment inside the rewritten expression was deleted.

    export const direct = identity(
      // Keep this reason with the inner call.
      identity(source)
    )

    now becomes

    export const direct = source.pipe(
    // Keep this reason with the inner call.
    identity, identity)
  • e95239a: missedPipeableOpportunity no longer suggests passing an overloaded function point-free to .pipe. A direct call picks the overload that fits its argument, but in the pipe form the function is passed as a value and TypeScript infers from its last overload, so the suggested fix could fail to type-check or widen the result. A call to an overloaded function (or a dual such as Graph.topo) with no arguments of its own now ends the pipeable run. The calls before it are still reported, and curried calls such as Effect.map(f)(self) are unaffected:

    import { Schema } from "effect"
    
    declare const schema: Schema.Schema<number>
    declare function withTitle<A>(schema: Schema.Schema<A>): Schema.Schema<A>
    declare function jsonOf<A>(schema: Schema.Schema<A>): Schema.Schema<A>
    declare function jsonOf(options: { readonly space: number }): Schema.Schema<unknown>
    
    // before: reported, and the fix produced `schema.pipe(withTitle, jsonOf)`, which does not compile
    // after: not reported
    export const direct = jsonOf(withTitle(schema))
    
    // reported on the run before the overloaded call: `jsonOf(schema.pipe(withTitle, withTitle))`
    export const before = jsonOf(withTitle(withTitle(schema)))
  • 2c3aadc: The togglePipeStyle refactor no longer offers "Rewrite as X.pipe(Y, Z, ...)" when the subject's pipe method does not take the piped functions, such as a Node.js Readable stream. It is offered only when some call signature of the subject's pipe accepts one function argument per piped step, the same check missedPipeableOpportunity uses:

    import { Readable } from "node:stream"
    import { identity, pipe } from "effect/Function"
    import * as Option from "effect/Option"
    
    declare const stream: Readable
    
    // before: offered, and produced `stream.pipe(identity, Option.some)`, which does not compile
    // after: not offered
    pipe(stream, identity, Option.some)

Don't miss a new tsgo release

NewReleases is sending notifications on new releases.