Skip to content

Commit

Permalink
fix inference for contravariant type-parameters (#4220)
Browse files Browse the repository at this point in the history
  • Loading branch information
KhraksMamtsov authored Jan 9, 2025
1 parent c640d77 commit 734af82
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-rocks-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

fix inference for contravariant type-parameters
6 changes: 3 additions & 3 deletions packages/effect/src/Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ export declare namespace Layer {
*/
export interface Any {
readonly [LayerTypeId]: {
readonly _ROut: any
readonly _E: any
readonly _RIn: any
readonly _ROut: Types.Contravariant<never>
readonly _E: Types.Covariant<any>
readonly _RIn: Types.Covariant<any>
}
}
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/ManagedRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export declare namespace ManagedRuntime {
* @category type-level
* @since 3.4.0
*/
export type Error<T extends ManagedRuntime<any, any>> = [T] extends [ManagedRuntime<infer _R, infer E>] ? E : never
export type Error<T extends ManagedRuntime<never, any>> = [T] extends [ManagedRuntime<infer _R, infer E>] ? E : never
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/effect/src/Predicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export declare namespace Predicate {
* @since 3.6.0
* @category type-level
*/
export type Any = Predicate<any>
export type Any = Predicate<never>
}

/**
Expand Down Expand Up @@ -842,7 +842,7 @@ export const struct: {
const keys = Object.keys(fields)
return (a: Record<string, unknown>) => {
for (const key of keys) {
if (!fields[key](a[key])) {
if (!fields[key](a[key] as never)) {
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export declare namespace Runtime {
* @since 3.12.0
* @category Type Extractors
*/
export type Context<T extends Runtime<any>> = [T] extends [Runtime<infer R>] ? R : never
export type Context<T extends Runtime<never>> = [T] extends [Runtime<infer R>] ? R : never
}

/**
Expand Down

0 comments on commit 734af82

Please sign in to comment.