-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ts): Add full test coverage for TypeScript hook types & fix missi…
…ng overloads (#895) * fix: add apollo-composable type overloads + tests There were a lot of TypeScript edge cases, where calling functions with certain argument options would result in `any` being expressed as a type, or where the variables/options were not strictly requiring the desired inputs. This adds TypeScript function overloads for all hook edge cases so that all types are correct. This does not change any behavior. This also adds almost complete coverage for types, excepting the cases where `strict` is required, or where a failure is expected, which TypeScript does not currently support. See: microsoft/TypeScript#29394 * chore: run type tests on prepublish * chore: code style
- Loading branch information
1 parent
7cc7aba
commit 9b8919e
Showing
17 changed files
with
1,118 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Check if a type is a union, and return true if so, otherwise false. | ||
*/ | ||
export type IsUnion<T, U = T> = U extends any ? ([T] extends [U] ? false : true) : never | ||
|
||
/** | ||
* Extracts an inner type if T has a single key K, otherwise it returns T. | ||
*/ | ||
export type ExtractSingleKey<T, K extends keyof T = keyof T> = IsUnion<K> extends true ? T : T[K] |
Oops, something went wrong.