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

43 minutes ago

Minor Changes

  • ef32f11: missedPipeableOpportunity now treats data-first and data-last calls as steps of a nested call chain, not only unary and curried calls.

    Option.map(Option.flatMap(option, f), g)
    // now reported, fixes to
    option.pipe(Option.flatMap(f), Option.map(g))
    
    Layer.fresh(Layer.effect(Cache, makeCache))
    // now reported, fixes to
    makeCache.pipe(Layer.effect(Cache), Layer.fresh)

    pipeableMinArgCount now counts every unary, curried, data-first or data-last call that is not already in a pipe, so with pipeableMinArgCount: 1 a single Effect.map(e, f) is also reported as e.pipe(Effect.map(f)).

    A data-first or data-last call with explicit type arguments is not piped, since the pipe form would drop them, and a data-last call is only piped when its other arguments have no side effects, since the pipe form evaluates its input first.

  • 16d85ae: Add the preferEffectNumber diagnostic (group effectNative, off by default). It reports hand-written numeric code that has a direct effect/Number equivalent: clamps, rounding to N digits, sums and products, increment and decrement callbacks, subtraction comparators, range checks and zero-checked divisions. It also reports n => n++ callbacks, Math.max(...values) and Number()/parseFloat results checked with isNaN.

    // before
    const percent = Math.min(100, Math.max(0, value))
    const total = values.reduce((a, b) => a + b, 0)
    const average = count === 0 ? 0 : total / count
    
    // after the quick fix
    const percent = Num.clamp(value, { minimum: 0, maximum: 100 })
    const total = Num.sumAll(values)
    const average = Opt.getOrElse(Num.divide(total, count), () => 0)

    A rewrite that keeps the behavior is a quick fix that adds any missing import * as Num from "effect/Number" (and Opt, Order) import. A rewrite that may change it (a NaN minimum in a range check, a product with 0 and NaN, reordered effectful operands, untyped or JavaScript operands) is offered as a suggestion whose title says why. Cases whose rewrite would run an effectful operand a different number of times, lose a comment, or cannot tell the clamped value from its bounds get no quick fix.

    Piping flows now also recognize Array.sort(values, order) as a data-first step, and Effect v4 duals typed as an intersection of function types, such as Ref.update(ref, f).

Patch Changes

  • 54fbe02: apiStabilityLeak gives each member of a namespace re-export its own analysis budget. Before, all members of export * as Ns from "./module" shared one budget, so on a large module the later members could run out of it and miss their findings, depending on which files the checker had analyzed first.

    // index.ts
    export * as HttpClient from "./HttpClient.ts"
    // now always reports `HttpClient` exposes `Classifier`, an experimental API,
    // reached through `WithCircuitBreaker.Options`
  • 4d7e1a2: CI: run the heavy Rust and compile jobs on namespace.so runners (namespace-profile-linux-default), as the Effect repository does: Validate tsrs, the Oxlint builds and the perf build. Jobs that run the Go test suite (Validate, Update Upstreams) stay on GitHub-hosted runners, since internal/effecttest peaks near 8GB and does not fit the profile's 4x8 machine. On namespace runners, the setup action caches the pnpm store with nscloud-cache-action.

  • 96f1a61: Speed up the Oxlint type-aware pass (--tsrs-lint and the tsgolint mode) when many Effect rules are enabled. Each Effect rule runs as its own Oxlint rule, and before this change every rule redid the per-file setup: resolving the plugin options and overrides, and scanning the whole file for @effect-diagnostics directives. That setup is now prepared once per file and shared by all Effect rules, and files without any @effect-diagnostics comment skip the directive scan entirely (this also helps the tsc and language-service paths).

    With all Effect rules at error, tsrs CPU time drops by about 37-42% on t3code, opencode and the Effect monorepo, with identical diagnostics (#1104).

  • f8a1f86: Update the TypeScript next tag to typescript@next, which ships typescript-go commit 23091b541b898c22c9695f72b417bdb631261c37, update the TypeScript beta tag to typescript@beta, and update the TypeScript latest tag to typescript@latest.

Don't miss a new tsgo release

NewReleases is sending notifications on new releases.