dsherret / dsherret/conditional-type-checks

IsExact fails with string enum item and string

Open
#17 1 comment 0 reactions 0 assignees View on GitHub
by design
Dominant language
TypeScript
Stars
450
Forks
18
PR merge metrics
No merged PRs in 30d

Description

Hi,

I can't make `IsExact` work with enums.

```ts
const foo = 'Foo';
enum A {
A1 = 'A1',
A2 = 'A2',
}

export const t1 = [foo, ['A1']] as const;
export type T1 = typeof t1[number];

export type T2 = typeof foo | readonly [A.A1]

assert>(true);
```

In the example above

- `T1` is `"Foo" | readonly ["A1"]`
- `T2` is `"Foo" | readonly [A.A1]`

I presume the issue is that for the type system `"A1"` is not exact to `A.A1`

Edit.
Following [your _another option_ approach](https://stackoverflow.com/a/55046618/1355416) (that doesn't require this library), I can see the origin of the error, which is extremely helpful.

![image](https://user-images.githubusercontent.com/2076221/162426997-719759f7-7cbf-4577-bf83-827b79694800.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.