dotansimha / dotansimha/graphql-code-generator
`Exact<T>` doesn't do anything
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Describe the bug**
The `Exact` utility type that is included in generated TS code doesn't seem to do what it's intended to do. In fact it doesn't seem to do anything at all.
This example sums it up:
```ts
type Exact = {
[K in keyof T]: T[K];
};
type Foo = { x: number };
const notExactlyFoo = { x: 1, y: 1 };
// object literal with extra property is not assignable to Exact
const a: Exact = { x: 1, y: 1 }; // ts error
// object *variable* with extra property *is* assignable to Exact
const b: Exact = notExactlyFoo; // no ts error
// using just `Foo` instead of `Exact` has the same effect
const c: Foo = { x: 1, y: 1 }; // tsc error
const d: Foo = notExactlyFoo; // no ts error
```
**To Reproduce**
[CodeSandbox Link](https://codesandbox.io/s/unruffled-stallman-b0evl)
[Playground Link](https://www.typescriptlang.org/play?ssl=1&ssc=1&pln=18&pc=1#code/C4TwDgpgBAogHgQwMbADwBUoTsCA7AEwGcoBvKAbQGsIQAuKI4AJwEs8BzAXQYFc8qeAPYB3PFAC+APigBeMgCgolANJR2UGiCEAzKOh76KKrgG4FE8wtCQoAMSFC5ZKHAZ5eAWwBGEZpKskITwmKGFgeGRgABsQByd5cjcoAEYAGih6VICFBQB6PKghbwArCBQoaNZcZgRoqBFqgAssHFqoMGYhSGZQdRJwqAQiIlYOPARvaOhgJ0iUVHipBSCQ4CGGebQl5ySGdMz9gKhcgqLS8vWAKgA3BDZJ6auG5taWBA6unr6r1iJn4ajcaPGZzRALJYrYKhbybcHbRwyeThLaxeJWM68UacKAlLHrAAG8QJ6jWEAQBCKegJW0WiJJTWGUGATWgRAQnmgEB0OkuULWUCQDHiu1c+wyWRSx35oQIwsczhR8LRjnMQA)
**Expected behavior**
I would expect `Exact` to be a `T` that has no extra properties. I made a mild assumption that this is what it's intended to do. Please correct me if I'm wrong!
**Environment:**
N/A
**Additional context**
This realization came from [this thread on Reddit](https://www.reddit.com/r/typescript/comments/i8vxz2/is_there_an_exactt_advanced_type_something_that/g1b5fdr/?context=3).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.