Skip to content

Commit

Permalink
Improve type safety by using more specific function types
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Mercer committed Jun 13, 2024
1 parent 2e69043 commit d8f549d
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 14 deletions.
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
// "temporarily downgraded during transition to eslint
"files": "**",
"rules": {
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
Expand Down
2 changes: 1 addition & 1 deletion lib/analyze-action-post-helper.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/config-utils.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/init-action-post-helper.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/analyze-action-post-helper.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/config-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/config-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
9 changes: 6 additions & 3 deletions src/init-action-post-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d8f549d

Please sign in to comment.