-
Notifications
You must be signed in to change notification settings - Fork 433
Find, then filter, SARIF files for upload-sarif Action
#3167
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
Changes from 1 commit
fe0376e
13ae3d4
0417531
717d581
63d1b25
056fb86
93711d3
ad086e4
b8c4966
9a0b46a
d25fa60
91a63dc
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 |
|---|---|---|
|
|
@@ -1287,3 +1287,17 @@ export async function asyncSome<T>( | |
| export function isDefined<T>(value: T | null | undefined): value is T { | ||
| return value !== undefined && value !== null; | ||
| } | ||
|
|
||
| /** Like `Object.keys`, but infers the correct key type. */ | ||
| export function keysTyped<T extends Record<string, any>>( | ||
| object: T, | ||
| ): Array<keyof T> { | ||
| return Object.keys(object) as Array<keyof T>; | ||
| } | ||
|
|
||
| /** Like `Object.entries`, but infers the correct key type. */ | ||
| export function entriesTyped<T extends Record<string, any>>( | ||
| object: T, | ||
| ): Array<[keyof T, NonNullable<T[keyof T]>]> { | ||
| return Object.entries(object) as Array<[keyof T, NonNullable<T[keyof T]>]>; | ||
|
||
| } | ||
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.
The
NonNullable<T[keyof T]>is an undocumented refinement that is unsound.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.
You're right. I have been thinking about this a good bit yesterday and I am not entirely sure about the best solution.
I initially thought that maybe using
Exclude<T[keyof T], undefined>instead would be better, but then remembered that we can explicitly set a key toundefinedin which caseObject.entriesstill returns a pair for the key andundefinedas the value.I am now thinking that perhaps it would be better to explicitly filter the results of these functions to exclude
undefinedvalues and keys that don't belong toT?