Merge pull request #3344 from github/robertbrignull/correct-types
Use correct types where possible instead of any
This commit is contained in:
Коммит
f7731e2e12
|
@ -15,6 +15,7 @@ import { pathExists, readJson, writeJson } from "fs-extra";
|
|||
import { resolve, relative } from "path";
|
||||
|
||||
import type { Octokit } from "@octokit/core";
|
||||
import type { EndpointDefaults } from "@octokit/types";
|
||||
import type { RestEndpointMethodTypes } from "@octokit/rest";
|
||||
import { throttling } from "@octokit/plugin-throttling";
|
||||
|
||||
|
@ -42,7 +43,7 @@ const octokit = new MyOctokit({
|
|||
throttle: {
|
||||
onRateLimit: (
|
||||
retryAfter: number,
|
||||
options: any,
|
||||
options: EndpointDefaults,
|
||||
octokit: Octokit,
|
||||
): boolean => {
|
||||
octokit.log.warn(
|
||||
|
@ -53,7 +54,7 @@ const octokit = new MyOctokit({
|
|||
},
|
||||
onSecondaryRateLimit: (
|
||||
_retryAfter: number,
|
||||
options: any,
|
||||
options: EndpointDefaults,
|
||||
octokit: Octokit,
|
||||
): void => {
|
||||
octokit.log.warn(
|
||||
|
|
|
@ -243,7 +243,7 @@ type WorkflowRunListItem = {
|
|||
async function replaceAsync(
|
||||
str: string,
|
||||
regex: RegExp,
|
||||
replacer: (substring: string, ...args: any[]) => Promise<string>,
|
||||
replacer: (substring: string, ...args: string[]) => Promise<string>,
|
||||
) {
|
||||
const promises: Array<Promise<string>> = [];
|
||||
str.replace(regex, (match, ...args) => {
|
||||
|
|
|
@ -17,7 +17,7 @@ export function convertNonPrintableChars(label: string | undefined) {
|
|||
* If the label contains certain non-printable characters, loop through each
|
||||
* character and replace it with the cooresponding unicode control label.
|
||||
*/
|
||||
const convertedLabelArray: any[] = [];
|
||||
const convertedLabelArray: string[] = [];
|
||||
for (let i = 0; i < label.length; i++) {
|
||||
const labelCheck = label.codePointAt(i)!;
|
||||
if (labelCheck <= CONTROL_CODE) {
|
||||
|
|
|
@ -16,7 +16,7 @@ export class MultiCancellationToken implements CancellationToken {
|
|||
return this.tokens.some((t) => t.isCancellationRequested);
|
||||
}
|
||||
|
||||
onCancellationRequested<T>(listener: (e: T) => any): Disposable {
|
||||
onCancellationRequested<T>(listener: (e: T) => void): Disposable {
|
||||
return new DisposableObject(
|
||||
...this.tokens.map((t) => t.onCancellationRequested(listener)),
|
||||
);
|
||||
|
|
|
@ -6,6 +6,7 @@ import type { BaseLogger } from "../common/logging";
|
|||
import { AppOctokit } from "../common/octokit";
|
||||
import type { ProgressCallback } from "../common/vscode/progress";
|
||||
import { UserCancellationException } from "../common/vscode/progress";
|
||||
import type { EndpointDefaults } from "@octokit/types";
|
||||
|
||||
export async function getCodeSearchRepositories(
|
||||
query: string,
|
||||
|
@ -54,14 +55,17 @@ async function provideOctokitWithThrottling(
|
|||
const octokit = new MyOctokit({
|
||||
auth,
|
||||
throttle: {
|
||||
onRateLimit: (retryAfter: number, options: any): boolean => {
|
||||
onRateLimit: (retryAfter: number, options: EndpointDefaults): boolean => {
|
||||
void logger.log(
|
||||
`Rate Limit detected for request ${options.method} ${options.url}. Retrying after ${retryAfter} seconds!`,
|
||||
);
|
||||
|
||||
return true;
|
||||
},
|
||||
onSecondaryRateLimit: (_retryAfter: number, options: any): void => {
|
||||
onSecondaryRateLimit: (
|
||||
_retryAfter: number,
|
||||
options: EndpointDefaults,
|
||||
): void => {
|
||||
void logger.log(
|
||||
`Secondary Rate Limit detected for request ${options.method} ${options.url}`,
|
||||
);
|
||||
|
|
|
@ -590,7 +590,7 @@ export async function convertGithubNwoToDatabaseUrl(
|
|||
repo,
|
||||
});
|
||||
|
||||
const languages = response.data.map((db: any) => db.language);
|
||||
const languages = response.data.map((db) => db.language);
|
||||
|
||||
if (!language || !languages.includes(language)) {
|
||||
language = await promptForLanguage(languages, progress);
|
||||
|
|
|
@ -14,6 +14,7 @@ import { getErrorMessage } from "../common/helpers-pure";
|
|||
import { FALLBACK_QLPACK_FILENAME, getQlPackFilePath } from "../common/ql";
|
||||
import type { App } from "../common/app";
|
||||
import type { ExtensionApp } from "../common/vscode/vscode-app";
|
||||
import type { QlPackFile } from "../packaging/qlpack-file";
|
||||
|
||||
const QUICK_QUERIES_DIR_NAME = "quick-queries";
|
||||
const QUICK_QUERY_QUERY_NAME = "quick-query.ql";
|
||||
|
@ -125,7 +126,7 @@ export async function displayQuickQuery(
|
|||
|
||||
// Only rewrite the qlpack file if the database has changed
|
||||
if (shouldRewrite) {
|
||||
const quickQueryQlpackYaml: any = {
|
||||
const quickQueryQlpackYaml: QlPackFile = {
|
||||
name: "vscode/quick-query",
|
||||
version: "1.0.0",
|
||||
dependencies: {
|
||||
|
@ -175,6 +176,6 @@ async function checkShouldRewrite(
|
|||
if (!(await pathExists(qlPackFile))) {
|
||||
return true;
|
||||
}
|
||||
const qlPackContents: any = load(await readFile(qlPackFile, "utf8"));
|
||||
const qlPackContents = load(await readFile(qlPackFile, "utf8")) as QlPackFile;
|
||||
return !qlPackContents.dependencies?.[newDependency];
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче