Skip to content

Commit f7731e2

Browse files
Merge pull request #3344 from github/robertbrignull/correct-types
Use correct types where possible instead of any
2 parents f4edc6e + 478d416 commit f7731e2

File tree

7 files changed

+16
-10
lines changed

7 files changed

+16
-10
lines changed

extensions/ql-vscode/scripts/add-fields-to-scenarios.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { pathExists, readJson, writeJson } from "fs-extra";
1515
import { resolve, relative } from "path";
1616

1717
import type { Octokit } from "@octokit/core";
18+
import type { EndpointDefaults } from "@octokit/types";
1819
import type { RestEndpointMethodTypes } from "@octokit/rest";
1920
import { throttling } from "@octokit/plugin-throttling";
2021

@@ -42,7 +43,7 @@ const octokit = new MyOctokit({
4243
throttle: {
4344
onRateLimit: (
4445
retryAfter: number,
45-
options: any,
46+
options: EndpointDefaults,
4647
octokit: Octokit,
4748
): boolean => {
4849
octokit.log.warn(
@@ -53,7 +54,7 @@ const octokit = new MyOctokit({
5354
},
5455
onSecondaryRateLimit: (
5556
_retryAfter: number,
56-
options: any,
57+
options: EndpointDefaults,
5758
octokit: Octokit,
5859
): void => {
5960
octokit.log.warn(

extensions/ql-vscode/scripts/source-map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ type WorkflowRunListItem = {
243243
async function replaceAsync(
244244
str: string,
245245
regex: RegExp,
246-
replacer: (substring: string, ...args: any[]) => Promise<string>,
246+
replacer: (substring: string, ...args: string[]) => Promise<string>,
247247
) {
248248
const promises: Array<Promise<string>> = [];
249249
str.replace(regex, (match, ...args) => {

extensions/ql-vscode/src/common/text-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function convertNonPrintableChars(label: string | undefined) {
1717
* If the label contains certain non-printable characters, loop through each
1818
* character and replace it with the cooresponding unicode control label.
1919
*/
20-
const convertedLabelArray: any[] = [];
20+
const convertedLabelArray: string[] = [];
2121
for (let i = 0; i < label.length; i++) {
2222
const labelCheck = label.codePointAt(i)!;
2323
if (labelCheck <= CONTROL_CODE) {

extensions/ql-vscode/src/common/vscode/multi-cancellation-token.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class MultiCancellationToken implements CancellationToken {
1616
return this.tokens.some((t) => t.isCancellationRequested);
1717
}
1818

19-
onCancellationRequested<T>(listener: (e: T) => any): Disposable {
19+
onCancellationRequested<T>(listener: (e: T) => void): Disposable {
2020
return new DisposableObject(
2121
...this.tokens.map((t) => t.onCancellationRequested(listener)),
2222
);

extensions/ql-vscode/src/databases/code-search-api.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { BaseLogger } from "../common/logging";
66
import { AppOctokit } from "../common/octokit";
77
import type { ProgressCallback } from "../common/vscode/progress";
88
import { UserCancellationException } from "../common/vscode/progress";
9+
import type { EndpointDefaults } from "@octokit/types";
910

1011
export async function getCodeSearchRepositories(
1112
query: string,
@@ -54,14 +55,17 @@ async function provideOctokitWithThrottling(
5455
const octokit = new MyOctokit({
5556
auth,
5657
throttle: {
57-
onRateLimit: (retryAfter: number, options: any): boolean => {
58+
onRateLimit: (retryAfter: number, options: EndpointDefaults): boolean => {
5859
void logger.log(
5960
`Rate Limit detected for request ${options.method} ${options.url}. Retrying after ${retryAfter} seconds!`,
6061
);
6162

6263
return true;
6364
},
64-
onSecondaryRateLimit: (_retryAfter: number, options: any): void => {
65+
onSecondaryRateLimit: (
66+
_retryAfter: number,
67+
options: EndpointDefaults,
68+
): void => {
6569
void logger.log(
6670
`Secondary Rate Limit detected for request ${options.method} ${options.url}`,
6771
);

extensions/ql-vscode/src/databases/database-fetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ export async function convertGithubNwoToDatabaseUrl(
590590
repo,
591591
});
592592

593-
const languages = response.data.map((db: any) => db.language);
593+
const languages = response.data.map((db) => db.language);
594594

595595
if (!language || !languages.includes(language)) {
596596
language = await promptForLanguage(languages, progress);

extensions/ql-vscode/src/local-queries/quick-query.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { getErrorMessage } from "../common/helpers-pure";
1414
import { FALLBACK_QLPACK_FILENAME, getQlPackFilePath } from "../common/ql";
1515
import type { App } from "../common/app";
1616
import type { ExtensionApp } from "../common/vscode/vscode-app";
17+
import type { QlPackFile } from "../packaging/qlpack-file";
1718

1819
const QUICK_QUERIES_DIR_NAME = "quick-queries";
1920
const QUICK_QUERY_QUERY_NAME = "quick-query.ql";
@@ -125,7 +126,7 @@ export async function displayQuickQuery(
125126

126127
// Only rewrite the qlpack file if the database has changed
127128
if (shouldRewrite) {
128-
const quickQueryQlpackYaml: any = {
129+
const quickQueryQlpackYaml: QlPackFile = {
129130
name: "vscode/quick-query",
130131
version: "1.0.0",
131132
dependencies: {
@@ -175,6 +176,6 @@ async function checkShouldRewrite(
175176
if (!(await pathExists(qlPackFile))) {
176177
return true;
177178
}
178-
const qlPackContents: any = load(await readFile(qlPackFile, "utf8"));
179+
const qlPackContents = load(await readFile(qlPackFile, "utf8")) as QlPackFile;
179180
return !qlPackContents.dependencies?.[newDependency];
180181
}

0 commit comments

Comments
 (0)