Skip to content

Commit

Permalink
Replace custom NoInfer type with the native NoInfer type from Typ… (
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti authored and mikearnaldi committed Apr 16, 2024
1 parent 9a3bd47 commit e7e1bbe
Show file tree
Hide file tree
Showing 37 changed files with 55 additions and 72 deletions.
5 changes: 5 additions & 0 deletions .changeset/tidy-news-serve.md
@@ -0,0 +1,5 @@
---
"effect": minor
---

Replaced custom `NoInfer` type with the native `NoInfer` type from TypeScript 5.4
4 changes: 2 additions & 2 deletions packages/effect/dtslint/Either.ts
Expand Up @@ -120,7 +120,7 @@ declare const error$arrayOfStrings: Either.Either<Array<string>, Error>
pipe(
error$arrayOfStrings,
Either.filterOrLeft(ReadonlyArray.isNonEmptyArray, (
_s // $ExpectType string[]
_s // $ExpectType NoInfer<string[]>
) => "b" as const)
)

Expand All @@ -130,7 +130,7 @@ declare const error$readonlyArrayOfStrings: Either.Either<ReadonlyArray<string>,
pipe(
error$readonlyArrayOfStrings,
Either.filterOrLeft(ReadonlyArray.isNonEmptyReadonlyArray, (
_s // $ExpectType readonly string[]
_s // $ExpectType NoInfer<readonly string[]>
) => "b" as const)
)

Expand Down
4 changes: 2 additions & 2 deletions packages/effect/dtslint/Struct.ts
Expand Up @@ -122,7 +122,7 @@ pipe(symbolStruct, S.pick(asym, bsym))
// $ExpectType { [asym]?: number; [bsym]?: number; }
pipe(symbolNumberRecord, S.pick(asym, bsym))

// $ExpectType { 1: string; 2: number; }
// $ExpectType { 2: number; 1: string; }
pipe(numberStruct, S.pick(1, 2))

// @ts-expect-error
Expand All @@ -134,7 +134,7 @@ S.pick(4)(numberStruct)
// $ExpectType { [x: number]: unknown; }
S.pick(4 as number)(numberStruct)

// $ExpectType { 1?: number; 2?: number; }
// $ExpectType { 2?: number; 1?: number; }
pipe(numberNumberRecord, S.pick(1, 2))

// $ExpectType { ab?: number; aa?: number; }
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Cause.ts
Expand Up @@ -36,7 +36,7 @@ import type { Pipeable } from "./Pipeable.js"
import type { Predicate, Refinement } from "./Predicate.js"
import type * as Sink from "./Sink.js"
import type * as Stream from "./Stream.js"
import type { Covariant, NoInfer } from "./Types.js"
import type { Covariant } from "./Types.js"

/**
* @since 2.0.0
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Chunk.ts
Expand Up @@ -17,7 +17,7 @@ import { pipeArguments } from "./Pipeable.js"
import { hasProperty, type Predicate, type Refinement } from "./Predicate.js"
import * as RA from "./ReadonlyArray.js"
import type { NonEmptyReadonlyArray } from "./ReadonlyArray.js"
import type { Covariant, NoInfer } from "./Types.js"
import type { Covariant } from "./Types.js"

const TypeId: unique symbol = Symbol.for("effect/Chunk") as TypeId

Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Effect.ts
Expand Up @@ -55,7 +55,7 @@ import * as Scheduler from "./Scheduler.js"
import type * as Scope from "./Scope.js"
import type * as Supervisor from "./Supervisor.js"
import type * as Tracer from "./Tracer.js"
import type { Concurrency, Covariant, MergeRecord, NoInfer, NotFunction } from "./Types.js"
import type { Concurrency, Covariant, MergeRecord, NotFunction } from "./Types.js"
import type * as Unify from "./Unify.js"

// -------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Either.ts
Expand Up @@ -12,7 +12,7 @@ import type { Option } from "./Option.js"
import type { Pipeable } from "./Pipeable.js"
import type { Predicate, Refinement } from "./Predicate.js"
import { isFunction } from "./Predicate.js"
import type { Covariant, MergeRecord, NoInfer, NotFunction } from "./Types.js"
import type { Covariant, MergeRecord, NotFunction } from "./Types.js"
import type * as Unify from "./Unify.js"
import * as Gen from "./Utils.js"

Expand Down
1 change: 0 additions & 1 deletion packages/effect/src/Exit.ts
Expand Up @@ -10,7 +10,6 @@ import * as core from "./internal/core.js"
import type * as Option from "./Option.js"
import type { Pipeable } from "./Pipeable.js"
import type { Predicate, Refinement } from "./Predicate.js"
import type { NoInfer } from "./Types.js"
import type * as Unify from "./Unify.js"

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/GroupBy.ts
Expand Up @@ -7,7 +7,7 @@ import type { Predicate } from "./Predicate.js"
import type * as Queue from "./Queue.js"
import type * as Stream from "./Stream.js"
import type * as Take from "./Take.js"
import type { Covariant, NoInfer } from "./Types.js"
import type { Covariant } from "./Types.js"

/**
* @since 2.0.0
Expand Down
1 change: 0 additions & 1 deletion packages/effect/src/HashMap.ts
Expand Up @@ -9,7 +9,6 @@ import * as HM from "./internal/hashMap.js"
import * as _keySet from "./internal/hashMap/keySet.js"
import type { Option } from "./Option.js"
import type { Pipeable } from "./Pipeable.js"
import type { NoInfer } from "./Types.js"

const TypeId: unique symbol = HM.HashMapTypeId as TypeId

Expand Down
1 change: 0 additions & 1 deletion packages/effect/src/HashSet.ts
Expand Up @@ -7,7 +7,6 @@ import type { Inspectable } from "./Inspectable.js"
import * as HS from "./internal/hashSet.js"
import type { Pipeable } from "./Pipeable.js"
import type { Predicate, Refinement } from "./Predicate.js"
import type { NoInfer } from "./Types.js"

const TypeId: unique symbol = HS.HashSetTypeId as TypeId

Expand Down
1 change: 0 additions & 1 deletion packages/effect/src/List.ts
Expand Up @@ -33,7 +33,6 @@ import type { Pipeable } from "./Pipeable.js"
import { pipeArguments } from "./Pipeable.js"
import { hasProperty, type Predicate, type Refinement } from "./Predicate.js"
import * as ReadonlyArray from "./ReadonlyArray.js"
import type { NoInfer } from "./Types.js"

/**
* Represents an immutable linked list of elements of type `A`.
Expand Down
4 changes: 2 additions & 2 deletions packages/effect/src/Logger.ts
Expand Up @@ -183,12 +183,12 @@ export const map: {
export const batched: {
<Output, R>(
window: DurationInput,
f: (messages: Array<Types.NoInfer<Output>>) => Effect<void, never, R>
f: (messages: Array<NoInfer<Output>>) => Effect<void, never, R>
): <Message>(self: Logger<Message, Output>) => Effect<Logger<Message, void>, never, R | Scope>
<Message, Output, R>(
self: Logger<Message, Output>,
window: DurationInput,
f: (messages: Array<Types.NoInfer<Output>>) => Effect<void, never, R>
f: (messages: Array<NoInfer<Output>>) => Effect<void, never, R>
): Effect<Logger<Message, void>, never, Scope | R>
} = fiberRuntime.batchedLogger

Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Option.ts
Expand Up @@ -14,7 +14,7 @@ import type { Order } from "./Order.js"
import * as order from "./Order.js"
import type { Pipeable } from "./Pipeable.js"
import type { Predicate, Refinement } from "./Predicate.js"
import type { Covariant, NoInfer, NotFunction } from "./Types.js"
import type { Covariant, NotFunction } from "./Types.js"
import type * as Unify from "./Unify.js"
import * as Gen from "./Utils.js"

Expand Down
1 change: 0 additions & 1 deletion packages/effect/src/ReadonlyArray.ts
Expand Up @@ -20,7 +20,6 @@ import type { Predicate, Refinement } from "./Predicate.js"
import { isBoolean } from "./Predicate.js"
import * as ReadonlyRecord from "./ReadonlyRecord.js"
import * as Tuple from "./Tuple.js"
import type { NoInfer } from "./Types.js"

/**
* @category type lambdas
Expand Down
1 change: 0 additions & 1 deletion packages/effect/src/ReadonlyRecord.ts
Expand Up @@ -11,7 +11,6 @@ import type { Equivalence } from "./Equivalence.js"
import { dual, identity } from "./Function.js"
import type { TypeLambda } from "./HKT.js"
import * as Option from "./Option.js"
import type { NoInfer } from "./Types.js"

/**
* @category models
Expand Down
8 changes: 4 additions & 4 deletions packages/effect/src/RequestResolver.ts
Expand Up @@ -187,13 +187,13 @@ export const around: {
*/
export const aroundRequests: {
<A, A2, R2, X, R3>(
before: (requests: ReadonlyArray<Types.NoInfer<A>>) => Effect.Effect<A2, never, R2>,
after: (requests: ReadonlyArray<Types.NoInfer<A>>, _: A2) => Effect.Effect<X, never, R3>
before: (requests: ReadonlyArray<NoInfer<A>>) => Effect.Effect<A2, never, R2>,
after: (requests: ReadonlyArray<NoInfer<A>>, _: A2) => Effect.Effect<X, never, R3>
): <R>(self: RequestResolver<A, R>) => RequestResolver<A, R2 | R3 | R>
<A, R, A2, R2, X, R3>(
self: RequestResolver<A, R>,
before: (requests: ReadonlyArray<Types.NoInfer<A>>) => Effect.Effect<A2, never, R2>,
after: (requests: ReadonlyArray<Types.NoInfer<A>>, _: A2) => Effect.Effect<X, never, R3>
before: (requests: ReadonlyArray<NoInfer<A>>) => Effect.Effect<A2, never, R2>,
after: (requests: ReadonlyArray<NoInfer<A>>, _: A2) => Effect.Effect<X, never, R3>
): RequestResolver<A, R | R2 | R3>
} = internal.aroundRequests

Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/STM.ts
Expand Up @@ -14,7 +14,7 @@ import * as stm from "./internal/stm/stm.js"
import type * as Option from "./Option.js"
import type { Pipeable } from "./Pipeable.js"
import type { Predicate, Refinement } from "./Predicate.js"
import type { Covariant, MergeRecord, NoInfer } from "./Types.js"
import type { Covariant, MergeRecord } from "./Types.js"
import type * as Unify from "./Unify.js"

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/SortedSet.ts
Expand Up @@ -14,7 +14,7 @@ import { pipeArguments } from "./Pipeable.js"
import type { Predicate } from "./Predicate.js"
import { hasProperty } from "./Predicate.js"
import * as RBT from "./RedBlackTree.js"
import type { Invariant, NoInfer } from "./Types.js"
import type { Invariant } from "./Types.js"

const TypeId: unique symbol = Symbol.for("effect/SortedSet")

Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Stream.ts
Expand Up @@ -29,7 +29,7 @@ import type * as Emit from "./StreamEmit.js"
import type * as HaltStrategy from "./StreamHaltStrategy.js"
import type * as Take from "./Take.js"
import type * as Tracer from "./Tracer.js"
import type { Covariant, MergeRecord, NoInfer } from "./Types.js"
import type { Covariant, MergeRecord } from "./Types.js"
import type * as Unify from "./Unify.js"

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Trie.ts
Expand Up @@ -20,7 +20,7 @@ import type { Inspectable } from "./Inspectable.js"
import * as TR from "./internal/trie.js"
import type { Option } from "./Option.js"
import type { Pipeable } from "./Pipeable.js"
import type { Covariant, NoInfer } from "./Types.js"
import type { Covariant } from "./Types.js"

const TypeId: unique symbol = TR.TrieTypeId as TypeId

Expand Down
8 changes: 0 additions & 8 deletions packages/effect/src/Types.ts
Expand Up @@ -170,14 +170,6 @@ export type Mutable<T> = {
-readonly [P in keyof T]: T[P]
}

/**
* Avoid inference on a specific parameter
*
* @since 2.0.0
* @category models
*/
export type NoInfer<A> = [A][A extends any ? 0 : never]

/**
* Invariant helper.
*
Expand Down
1 change: 0 additions & 1 deletion packages/effect/src/internal/cause.ts
Expand Up @@ -13,7 +13,6 @@ import { hasProperty, isFunction } from "../Predicate.js"
import type { Predicate, Refinement } from "../Predicate.js"
import * as ReadonlyArray from "../ReadonlyArray.js"
import type { ParentSpan, Span } from "../Tracer.js"
import type { NoInfer } from "../Types.js"
import { getBugErrorMessage } from "./errors.js"
import * as OpCodes from "./opCodes/cause.js"

Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/core-effect.ts
Expand Up @@ -25,7 +25,7 @@ import * as ReadonlyArray from "../ReadonlyArray.js"
import * as Ref from "../Ref.js"
import type * as runtimeFlagsPatch from "../RuntimeFlagsPatch.js"
import * as Tracer from "../Tracer.js"
import type { MergeRecord, NoInfer } from "../Types.js"
import type { MergeRecord } from "../Types.js"
import * as internalCause from "./cause.js"
import { clockTag } from "./clock.js"
import * as core from "./core.js"
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/core.ts
Expand Up @@ -35,7 +35,7 @@ import type * as RuntimeFlags from "../RuntimeFlags.js"
import * as RuntimeFlagsPatch from "../RuntimeFlagsPatch.js"
import type * as Scope from "../Scope.js"
import type * as Tracer from "../Tracer.js"
import type { NoInfer, NotFunction } from "../Types.js"
import type { NotFunction } from "../Types.js"
import * as _blockedRequests from "./blockedRequests.js"
import * as internalCause from "./cause.js"
import * as deferred from "./deferred.js"
Expand Down
1 change: 0 additions & 1 deletion packages/effect/src/internal/dataSource.ts
Expand Up @@ -7,7 +7,6 @@ import { dual, pipe } from "../Function.js"
import * as RA from "../ReadonlyArray.js"
import type * as Request from "../Request.js"
import type * as RequestResolver from "../RequestResolver.js"
import type { NoInfer } from "../Types.js"
import * as core from "./core.js"
import { invokeWithInterrupt, zipWithOptions } from "./fiberRuntime.js"
import { complete } from "./request.js"
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/fiberRuntime.ts
Expand Up @@ -41,7 +41,7 @@ import { currentScheduler, type Scheduler } from "../Scheduler.js"
import type * as Scope from "../Scope.js"
import type * as Supervisor from "../Supervisor.js"
import type * as Tracer from "../Tracer.js"
import type { Concurrency, NoInfer } from "../Types.js"
import type { Concurrency } from "../Types.js"
import * as _RequestBlock from "./blockedRequests.js"
import * as internalCause from "./cause.js"
import * as clock from "./clock.js"
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/groupBy.ts
Expand Up @@ -13,7 +13,7 @@ import * as Queue from "../Queue.js"
import * as Ref from "../Ref.js"
import type * as Stream from "../Stream.js"
import type * as Take from "../Take.js"
import type { MergeRecord, NoInfer } from "../Types.js"
import type { MergeRecord } from "../Types.js"
import * as channel from "./channel.js"
import * as channelExecutor from "./channel/channelExecutor.js"
import * as core from "./core-stream.js"
Expand Down
1 change: 0 additions & 1 deletion packages/effect/src/internal/hashMap.ts
Expand Up @@ -7,7 +7,6 @@ import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js"
import * as Option from "../Option.js"
import { pipeArguments } from "../Pipeable.js"
import { hasProperty } from "../Predicate.js"
import type { NoInfer } from "../Types.js"
import { fromBitmap, hashFragment, toBitmap } from "./hashMap/bitwise.js"
import { SIZE } from "./hashMap/config.js"
import * as Node from "./hashMap/node.js"
Expand Down
1 change: 0 additions & 1 deletion packages/effect/src/internal/hashSet.ts
Expand Up @@ -7,7 +7,6 @@ import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js"
import { pipeArguments } from "../Pipeable.js"
import type { Predicate, Refinement } from "../Predicate.js"
import { hasProperty } from "../Predicate.js"
import type { NoInfer } from "../Types.js"
import * as HM from "./hashMap.js"

const HashSetSymbolKey = "effect/HashSet"
Expand Down
11 changes: 5 additions & 6 deletions packages/effect/src/internal/schedule.ts
Expand Up @@ -18,7 +18,6 @@ import type * as Schedule from "../Schedule.js"
import * as ScheduleDecision from "../ScheduleDecision.js"
import * as Interval from "../ScheduleInterval.js"
import * as Intervals from "../ScheduleIntervals.js"
import type * as Types from "../Types.js"
import * as internalCause from "./cause.js"
import * as effect from "./core-effect.js"
import * as core from "./core.js"
Expand Down Expand Up @@ -1903,7 +1902,7 @@ export const retry_combined: {
self: Effect.Effect<A, E, R>
) => Effect.Retry.Return<R, E, A, O>
<B, E, R1>(
policy: Schedule.Schedule<B, Types.NoInfer<E>, R1>
policy: Schedule.Schedule<B, NoInfer<E>, R1>
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R1 | R>
<A, E, R, O extends Effect.Retry.Options<E>>(
self: Effect.Effect<A, E, R>,
Expand Down Expand Up @@ -1949,13 +1948,13 @@ export const retry_combined: {
/** @internal */
export const retryOrElse_Effect = dual<
<A1, E, R1, A2, E2, R2>(
policy: Schedule.Schedule<A1, Types.NoInfer<E>, R1>,
orElse: (e: Types.NoInfer<E>, out: A1) => Effect.Effect<A2, E2, R2>
policy: Schedule.Schedule<A1, NoInfer<E>, R1>,
orElse: (e: NoInfer<E>, out: A1) => Effect.Effect<A2, E2, R2>
) => <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | A2, E2, R | R1 | R2>,
<A, E, R, A1, R1, A2, E2, R2>(
self: Effect.Effect<A, E, R>,
policy: Schedule.Schedule<A1, Types.NoInfer<E>, R1>,
orElse: (e: Types.NoInfer<E>, out: A1) => Effect.Effect<A2, E2, R2>
policy: Schedule.Schedule<A1, NoInfer<E>, R1>,
orElse: (e: NoInfer<E>, out: A1) => Effect.Effect<A2, E2, R2>
) => Effect.Effect<A | A2, E2, R | R1 | R2>
>(3, (self, policy, orElse) =>
core.flatMap(
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/stm/stm.ts
Expand Up @@ -12,7 +12,7 @@ import type { Predicate, Refinement } from "../../Predicate.js"
import * as predicate from "../../Predicate.js"
import * as RA from "../../ReadonlyArray.js"
import type * as STM from "../../STM.js"
import type { MergeRecord, NoInfer } from "../../Types.js"
import type { MergeRecord } from "../../Types.js"
import * as effectCore from "../core.js"
import * as SingleShotGen from "../singleShotGen.js"
import * as core from "./core.js"
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/stream.ts
Expand Up @@ -31,7 +31,7 @@ import * as HaltStrategy from "../StreamHaltStrategy.js"
import type * as Take from "../Take.js"
import type * as Tracer from "../Tracer.js"
import * as Tuple from "../Tuple.js"
import type { MergeRecord, NoInfer } from "../Types.js"
import type { MergeRecord } from "../Types.js"
import * as channel from "./channel.js"
import * as channelExecutor from "./channel/channelExecutor.js"
import * as MergeStrategy from "./channel/mergeStrategy.js"
Expand Down
1 change: 0 additions & 1 deletion packages/effect/src/internal/trie.ts
Expand Up @@ -7,7 +7,6 @@ import type * as Ordering from "../Ordering.js"
import { pipeArguments } from "../Pipeable.js"
import { hasProperty } from "../Predicate.js"
import type * as TR from "../Trie.js"
import type { NoInfer } from "../Types.js"

const TrieSymbolKey = "effect/Trie"

Expand Down

0 comments on commit e7e1bbe

Please sign in to comment.