mirror of
https://github.com/github/codeql-action.git
synced 2026-04-26 16:58:47 +00:00
Rename keys and entries helpers and update docs
This commit is contained in:
Generated
+4
-2
@@ -88590,7 +88590,7 @@ async function asyncSome(array, predicate) {
|
||||
const results = await Promise.all(array.map(predicate));
|
||||
return results.some((result) => result);
|
||||
}
|
||||
function entriesTyped(object) {
|
||||
function unsafeEntriesInvariant(object) {
|
||||
return Object.entries(object);
|
||||
}
|
||||
|
||||
@@ -93485,7 +93485,9 @@ async function uploadSarif(logger, features, checkoutPath, sarifPath, category)
|
||||
sarifPath
|
||||
);
|
||||
const uploadResults = {};
|
||||
for (const [analysisKind, sarifFiles] of entriesTyped(sarifGroups)) {
|
||||
for (const [analysisKind, sarifFiles] of unsafeEntriesInvariant(
|
||||
sarifGroups
|
||||
)) {
|
||||
const analysisConfig = getAnalysisConfig(analysisKind);
|
||||
uploadResults[analysisKind] = await uploadSpecifiedFiles(
|
||||
sarifFiles,
|
||||
|
||||
+4
-2
@@ -2,7 +2,7 @@ import * as analyses from "./analyses";
|
||||
import { FeatureEnablement } from "./feature-flags";
|
||||
import { Logger } from "./logging";
|
||||
import * as upload_lib from "./upload-lib";
|
||||
import { entriesTyped } from "./util";
|
||||
import { unsafeEntriesInvariant } from "./util";
|
||||
|
||||
// Maps analysis kinds to SARIF IDs.
|
||||
export type UploadSarifResults = Partial<
|
||||
@@ -33,7 +33,9 @@ export async function uploadSarif(
|
||||
);
|
||||
|
||||
const uploadResults: UploadSarifResults = {};
|
||||
for (const [analysisKind, sarifFiles] of entriesTyped(sarifGroups)) {
|
||||
for (const [analysisKind, sarifFiles] of unsafeEntriesInvariant(
|
||||
sarifGroups,
|
||||
)) {
|
||||
const analysisConfig = analyses.getAnalysisConfig(analysisKind);
|
||||
uploadResults[analysisKind] = await upload_lib.uploadSpecifiedFiles(
|
||||
sarifFiles,
|
||||
|
||||
+16
-6
@@ -1288,16 +1288,26 @@ 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>>(
|
||||
/** Like `Object.keys`, but typed so that the elements of the resulting array have the
|
||||
* same type as the keys of the input object. Note that this may not be sound if the input
|
||||
* object has been cast to `T` from a subtype of `T` and contains additional keys that
|
||||
* are not represented by `keyof T`.
|
||||
*/
|
||||
export function unsafeKeysInvariant<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>>(
|
||||
/** Like `Object.entries`, but typed so that the key elements of the result have the
|
||||
* same type as the keys of the input object. Note that this may not be sound if the input
|
||||
* object has been cast to `T` from a subtype of `T` and contains additional keys that
|
||||
* are not represented by `keyof T`.
|
||||
*/
|
||||
export function unsafeEntriesInvariant<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]>]>;
|
||||
): Array<[keyof T, Exclude<T[keyof T], undefined>]> {
|
||||
return Object.entries(object) as Array<
|
||||
[keyof T, Exclude<T[keyof T], undefined>]
|
||||
>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user