-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
[lodash] Fix GetFieldType indexing for numeric indexes #69457
base: master
Are you sure you want to change the base?
Changes from 1 commit
634ec4e
d8d95a4
884b288
d29d1da
76df931
6d213dc
1f486fc
ff361cc
a7807c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1022,15 +1022,17 @@ declare module "../index" { | |
|
||
type GetIndexedField<T, K> = K extends keyof T | ||
? T[K] | ||
: K extends `${number}` | ||
? 'length' extends keyof T | ||
? number extends T['length'] | ||
? number extends keyof T | ||
? T[number] | ||
: undefined | ||
: K extends `${infer U extends number}` | ||
? "length" extends keyof T | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm having a hard time following this due to inconsistent indentation. I this this line and below should be indented 1 level deeper. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome, thanks for the quick feedback! I'll bump the I'll also adjust the indentation level (for some reason prettier & eslint is acting up for me in the cloned repo). |
||
? number extends T["length"] | ||
? number extends keyof T | ||
? T[number] | ||
: undefined | ||
: undefined | ||
: undefined; | ||
: U extends keyof T | ||
? T[U] | ||
: undefined | ||
: undefined; | ||
|
||
type FieldWithPossiblyUndefined<T, Key> = | ||
| GetFieldType<Exclude<T, undefined>, Key> | ||
|
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.
Does it matter that
"1.23"
and".123"
will work for this? It's fair if it doesn't matter since the previous code did not check against this, but it's possible to verify the result is an integer using this: