-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(types): improve type extraction for namespaced responses and corr…
…ect async iterator types (#637) The `iterator()` function returns an object containing a key of `Symbol.asyncIterator`, which is an object with a `next()` function. Only the top-level has the `Symbol.asyncIterator`, and the `next()` function is not present at the top-level The `GetResultsType<T>` sometimes doesn't return the paginated data and returns the whole data object. For some reason TypeScript sometimes get's confused and returns all the keys in the object in the call `KnownKeysMatching<T["data"], any[]>` In order to remedy that, we remove keys that we know do not contain the data (`"repository_selection" | "total_count" | "incomplete_results"`) and we then always get the data. The `NormalizeResponse<T>` type would return the intersection of the original data from the request and the paginated data. To remedy that, we use `Omit<T, K>` to remove the `data` from the request data and only return the paginated data instead.
- Loading branch information
Showing
4 changed files
with
19 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,5 +58,5 @@ export function iterator( | |
} | ||
}, | ||
}), | ||
}; | ||
} as AsyncIterable<any>; | ||
} |
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