-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#1936] Migrate repo-sorter.js to typescript #2052
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b16439b
Migrate repo-sorter.js to typescript
jq1836 f5adc38
Remove any type in checkKeyAndGetValue
jq1836 ca7fd78
Merge branch 'master' into 1936-migrate-repo-sorter
jq1836 b10e08f
Apply generics to remove any cast
jq1836 93c4856
Merge branch '1936-migrate-repo-sorter' of https://github.com/jq1836/…
jq1836 d913ad1
Remove cypress downloads file
jq1836 ce8ba5e
Merge branch 'master' into 1936-migrate-repo-sorter
chan-j-d File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See if it is possible to use generics here.
Else disable eslint for this line using
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @ckcherry23, I have experimented with making use of generics over here and it seems like there is no real need for generics (although I have left a function that uses generics for general use). All that is needed would be casting the
key
string into akeyof User
. However, this causes the problem of handling invalid keys and values that are notComparablePrimitive
, i.e.string | number
to resurface (it was being suppressed due to theany
typecast previously used). I have tried to handle these cases, but am unsure whether such behavior is appropriate (details below). Do let me know if the current behavior is not as intended.Details of behavior
key
that is not valid or simply if a key is not provided to the function,checkKeyAndGetValue
will return undefined, which will be caught in thegetComparablePrimitive
function's guard clause, resulting in an empty string being returned.key
that is associated with a value that is not aComparablePrimitive
, i.e. not astring | number
, is provided to the function, it is caught in thegetComparablePrimitive
function's guard clause, also resulting in an empty string being returned.User
being sorted to the front. If allUser
s in theUser[]
result in an empty string, no sorting occurs.