type: fix typescript error (#44769)

This commit is contained in:
lijianan 2023-09-12 09:57:24 +08:00 committed by GitHub
parent 4f7655ce31
commit bcf7c924e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,8 +122,10 @@ async function printLog() {
const text = `${message} ${body}`; const text = `${message} ${body}`;
const match = text.match(/#\d+/g); const match = text.match(/#\d+/g);
const prs = (match || []).map((pr) => pr.slice(1));
const validatePRs = []; const prs = match?.map((pr) => pr.slice(1)) || [];
const validatePRs: PR[] = [];
console.log( console.log(
`[${i + 1}/${logs.all.length}]`, `[${i + 1}/${logs.all.length}]`,
@ -135,26 +137,24 @@ async function printLog() {
const pr = prs[j]; const pr = prs[j];
// Use jquery to get full html page since it don't need auth token // Use jquery to get full html page since it don't need auth token
let res: any; let res: Response | undefined;
let html: string | undefined;
let tryTimes = 0; let tryTimes = 0;
const timeout = 30000; const timeout = 30000;
let html: HTMLElement | undefined;
const fetchPullRequest = async () => { const fetchPullRequest = async () => {
try { try {
res = await new Promise((resolve, reject) => { res = await new Promise<Response>((resolve, reject) => {
setTimeout(() => { setTimeout(() => {
reject(new Error(`Fetch timeout of ${timeout}ms exceeded`)); reject(new Error(`Fetch timeout of ${timeout}ms exceeded`));
}, timeout); }, timeout);
fetch(`https://github.com/ant-design/ant-design/pull/${pr}`) fetch(`https://github.com/ant-design/ant-design/pull/${pr}`)
.then((response: Response) => { .then((response) => {
response.text().then((htmlRes) => { response.text().then((htmlRes) => {
html = htmlRes; html = htmlRes;
resolve(response); resolve(response);
}); });
}) })
.catch((error) => { .catch(reject);
reject(error);
});
}); });
} catch (err) { } catch (err) {
tryTimes++; tryTimes++;
@ -224,11 +224,11 @@ async function printLog() {
console.log('\n', chalk.green('Done. Here is the log:')); console.log('\n', chalk.green('Done. Here is the log:'));
function printPR(lang: string, postLang: (str?: string) => string) { function printPR(lang: string, postLang: (str: string) => string) {
prList.forEach((entity) => { prList.forEach((entity) => {
const { pr, author, hash, title } = entity; const { pr, author, hash, title } = entity;
if (pr) { if (pr) {
const str = postLang(entity[lang as keyof PR]); const str = postLang(entity[lang as keyof PR]!);
let icon = ''; let icon = '';
if (str.toLowerCase().includes('fix') || str.includes('修复')) { if (str.toLowerCase().includes('fix') || str.includes('修复')) {
icon = '🐞'; icon = '🐞';