Skip to content

Commit

Permalink
Adds widened has support to ReadonlySet
Browse files Browse the repository at this point in the history
  • Loading branch information
Kadrei committed Feb 24, 2023
1 parent 33af82c commit 0bccc5a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/entrypoints/set-has.d.ts
Expand Up @@ -3,3 +3,7 @@
interface Set<T> {
has(value: T | (TSReset.WidenLiteral<T> & {})): boolean;
}

interface ReadonlySet<T> {
has(value: T | (TSReset.WidenLiteral<T> & {})): boolean;
}
16 changes: 16 additions & 0 deletions src/tests/set-has.ts
Expand Up @@ -15,3 +15,19 @@ doNotExecute(() => {
true,
);
});

doNotExecute(() => {
const set = new Set([1, 2, 3] as const) as ReadonlySet<1 | 2 | 3>;

set.has(4);

set.has(
// @ts-expect-error
"4",
);

set.has(
// @ts-expect-error
true,
);
});

0 comments on commit 0bccc5a

Please sign in to comment.