-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[🔥AUDIT🔥] [rg.audit.3] Fix keys typing (#620)
🖍 _This is an audit!_ 🖍 ## Summary: This updates the typing of the `keys` function to match better with our expected usage. Issue: FEI-4960 ## Test plan: `yarn typecheck` Also built the types and tried them in webapp to verify they now work as we would want. Author: somewhatabstract Auditors: #typescript, #frontend-infra Required Reviewers: Approved By: Checks: ⏭ dependabot, ⌛ gerald, ⌛ Prime node_modules cache for primary configuration (ubuntu-latest, 16.x), ⌛ Analyze (javascript) Pull Request URL: #620
- Loading branch information
1 parent
d0c21c7
commit b28725a
Showing
3 changed files
with
8 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/wonder-stuff-core": patch | ||
--- | ||
|
||
Fix the typing for the `key` function |
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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
/** | ||
* Return an array of the enumerable keys of an object. | ||
* | ||
* @param {$ReadOnly<interface {[string]: mixed}>} obj The object for which the values are | ||
* @param {object} obj The object for which the values are | ||
* to be returned. | ||
* @returns {Array<$Keys<O>>} An array of the enumerable keys of an object. | ||
*/ | ||
// NOTE(kevinb): This type was copied from TypeScript's library definitions. | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export function keys(obj: {}): string[] { | ||
return Object.keys(obj); | ||
export function keys<O extends object>(obj: O): Array<keyof O> { | ||
return Object.keys(obj) as Array<keyof O>; | ||
} |