Skip to content

Commit

Permalink
Suppress Type instantiation is excessively deep and possibly infinite.
Browse files Browse the repository at this point in the history
IDK whether this is good idea since it disturbs code and deceased readability but it fixes annoying error.

refs:
- https://kgtkr.net/blog/2019/04/15/typescript-typelevelprogramming-error-suppression/en
- microsoft/TypeScript#30188
  • Loading branch information
ENvironmentSet committed May 14, 2020
1 parent f1cada9 commit f0466b3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/OpenRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Cons, AnyList, Head, Tail } from './Promoted/List';
import { HKT } from './Primitive/HKT';
import { Stuck } from './Primitive/Stuck';
import { DeriveGeneric, UnInitialized } from './Primitive/UnInitialized';
import { If } from './Promoted/Bool';
import { Eq } from './Promoted/Eq';

type _OpenRecord<record> = object & PhantomTypeParameter<'OpenRecord/record', record>;
Expand Down Expand Up @@ -31,10 +30,9 @@ interface _IsMember extends HKT {
}
export type IsMember<param = UnInitialized> = DeriveGeneric<_IsMember, param>;

//@ts-expect-error
export function insert<
//@TODO: Abstract If<[IsMember<[key, record]>, never, unknown] out constraints
record extends AnyList, key extends PropertyKey, value extends If<[IsMember<[key, record]>, never, unknown]>
record extends AnyList, key extends PropertyKey, value extends (IsMember<[key, record]> extends true ? never : unknown)
>(
key: key,
value: value,
Expand Down Expand Up @@ -83,9 +81,8 @@ interface _Set extends HKT {
}
type Set<param = UnInitialized> = DeriveGeneric<_Set, param>;

//@ts-expect-error
export function set<
record extends AnyList, key extends PropertyKey, value extends If<[IsMember<[key, record]>, unknown, never]>
record extends AnyList, key extends PropertyKey, value extends (IsMember<[key, record]> extends true ? unknown : never)
>(
key: key,
value: value,
Expand Down

0 comments on commit f0466b3

Please sign in to comment.