Improve type safety by using more specific function types
This commit is contained in:
parent
2e69043274
commit
d8f549d6d8
9 changed files with 21 additions and 14 deletions
|
|
@ -1,10 +1,15 @@
|
|||
import * as core from "@actions/core";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import { getConfig } from "./config-utils";
|
||||
import { Config, getConfig } from "./config-utils";
|
||||
import { getActionsLogger } from "./logging";
|
||||
|
||||
export async function run(uploadSarifDebugArtifact: Function) {
|
||||
export async function run(
|
||||
uploadSarifDebugArtifact: (
|
||||
config: Config,
|
||||
outputDir: string,
|
||||
) => Promise<void>,
|
||||
) {
|
||||
const logger = getActionsLogger();
|
||||
|
||||
const config = await getConfig(actionsUtil.getTemporaryDirectory(), logger);
|
||||
|
|
|
|||
|
|
@ -233,14 +233,14 @@ export interface BetterResolveLanguagesOutput {
|
|||
export interface ResolveQueriesOutput {
|
||||
byLanguage: {
|
||||
[language: string]: {
|
||||
[queryPath: string]: {};
|
||||
[queryPath: string]: object;
|
||||
};
|
||||
};
|
||||
noDeclaredLanguage: {
|
||||
[queryPath: string]: {};
|
||||
[queryPath: string]: object;
|
||||
};
|
||||
multipleDeclaredLanguages: {
|
||||
[queryPath: string]: {};
|
||||
[queryPath: string]: object;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ function createConfigFile(inputFileContents: string, tmpDir: string): string {
|
|||
return configFilePath;
|
||||
}
|
||||
|
||||
type GetContentsResponse = { content?: string } | Array<{}>;
|
||||
type GetContentsResponse = { content?: string } | object[];
|
||||
|
||||
function mockGetContents(
|
||||
content: GetContentsResponse,
|
||||
|
|
|
|||
|
|
@ -1065,7 +1065,7 @@ function createRegistriesBlock(registries: RegistryConfigWithCredentials[]): {
|
|||
*/
|
||||
export async function wrapEnvironment(
|
||||
env: Record<string, string | undefined>,
|
||||
operation: Function,
|
||||
operation: () => Promise<void>,
|
||||
) {
|
||||
// Remember the original env
|
||||
const oldEnv = { ...process.env };
|
||||
|
|
|
|||
|
|
@ -163,9 +163,12 @@ export async function tryUploadSarifIfRunFailed(
|
|||
}
|
||||
|
||||
export async function run(
|
||||
uploadDatabaseBundleDebugArtifact: Function,
|
||||
uploadLogsDebugArtifact: Function,
|
||||
printDebugLogs: Function,
|
||||
uploadDatabaseBundleDebugArtifact: (
|
||||
config: Config,
|
||||
logger: Logger,
|
||||
) => Promise<void>,
|
||||
uploadLogsDebugArtifact: (config: Config) => Promise<void>,
|
||||
printDebugLogs: (config: Config) => Promise<void>,
|
||||
config: Config,
|
||||
repositoryNwo: RepositoryNwo,
|
||||
features: FeatureEnablement,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue