Skip to content

Commit d8f549d

Browse files
committed
Improve type safety by using more specific function types
1 parent 2e69043 commit d8f549d

9 files changed

+21
-14
lines changed

.eslintrc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
// "temporarily downgraded during transition to eslint
5252
"files": "**",
5353
"rules": {
54-
"@typescript-eslint/ban-types": "off",
5554
"@typescript-eslint/explicit-module-boundary-types": "off",
5655
"@typescript-eslint/no-explicit-any": "off",
5756
"@typescript-eslint/no-unsafe-assignment": "off",

lib/analyze-action-post-helper.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action-post-helper.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/analyze-action-post-helper.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import * as core from "@actions/core";
22

33
import * as actionsUtil from "./actions-util";
4-
import { getConfig } from "./config-utils";
4+
import { Config, getConfig } from "./config-utils";
55
import { getActionsLogger } from "./logging";
66

7-
export async function run(uploadSarifDebugArtifact: Function) {
7+
export async function run(
8+
uploadSarifDebugArtifact: (
9+
config: Config,
10+
outputDir: string,
11+
) => Promise<void>,
12+
) {
813
const logger = getActionsLogger();
914

1015
const config = await getConfig(actionsUtil.getTemporaryDirectory(), logger);

src/codeql.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,14 @@ export interface BetterResolveLanguagesOutput {
233233
export interface ResolveQueriesOutput {
234234
byLanguage: {
235235
[language: string]: {
236-
[queryPath: string]: {};
236+
[queryPath: string]: object;
237237
};
238238
};
239239
noDeclaredLanguage: {
240-
[queryPath: string]: {};
240+
[queryPath: string]: object;
241241
};
242242
multipleDeclaredLanguages: {
243-
[queryPath: string]: {};
243+
[queryPath: string]: object;
244244
};
245245
}
246246

src/config-utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function createConfigFile(inputFileContents: string, tmpDir: string): string {
8181
return configFilePath;
8282
}
8383

84-
type GetContentsResponse = { content?: string } | Array<{}>;
84+
type GetContentsResponse = { content?: string } | object[];
8585

8686
function mockGetContents(
8787
content: GetContentsResponse,

src/config-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ function createRegistriesBlock(registries: RegistryConfigWithCredentials[]): {
10651065
*/
10661066
export async function wrapEnvironment(
10671067
env: Record<string, string | undefined>,
1068-
operation: Function,
1068+
operation: () => Promise<void>,
10691069
) {
10701070
// Remember the original env
10711071
const oldEnv = { ...process.env };

src/init-action-post-helper.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,12 @@ export async function tryUploadSarifIfRunFailed(
163163
}
164164

165165
export async function run(
166-
uploadDatabaseBundleDebugArtifact: Function,
167-
uploadLogsDebugArtifact: Function,
168-
printDebugLogs: Function,
166+
uploadDatabaseBundleDebugArtifact: (
167+
config: Config,
168+
logger: Logger,
169+
) => Promise<void>,
170+
uploadLogsDebugArtifact: (config: Config) => Promise<void>,
171+
printDebugLogs: (config: Config) => Promise<void>,
169172
config: Config,
170173
repositoryNwo: RepositoryNwo,
171174
features: FeatureEnablement,

0 commit comments

Comments
 (0)