Skip to content

Commit 66d8b95

Browse files
authored
Ensure all scripts are checked, fix errors (microsoft#50326)
1 parent 15f7b6f commit 66d8b95

16 files changed

+51
-42
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ scripts/produceLKG.js
5454
scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
5555
scripts/generateLocalizedDiagnosticMessages.js
5656
scripts/request-pr-review.js
57+
scripts/errorCheck.js
5758
scripts/*.js.map
5859
scripts/typings/
5960
coverage/

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
},
3131
"devDependencies": {
3232
"@octokit/rest": "latest",
33+
"@types/async": "latest",
3334
"@types/chai": "latest",
3435
"@types/convert-source-map": "latest",
3536
"@types/fs-extra": "^9.0.13",

scripts/authors.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import fs = require("fs");
2-
import path = require("path");
3-
import childProcess = require("child_process");
1+
import * as fs from "fs";
2+
import * as path from "path";
3+
import * as childProcess from "child_process";
44

55
interface Author {
66
displayNames: string[];
@@ -120,10 +120,10 @@ namespace Commands {
120120
const authors: { name: string, email: string, knownAuthor?: Author }[] = [];
121121
const {output: [error, stdout, stderr]} = childProcess.spawnSync(`git`, ["shortlog", "-se", ...specs], { cwd: path.resolve(__dirname, "../") });
122122
if (error) {
123-
console.log(stderr.toString());
123+
console.log(stderr!.toString());
124124
}
125125
else {
126-
const output = stdout.toString();
126+
const output = stdout!.toString();
127127
const lines = output.split("\n");
128128
lines.forEach(line => {
129129
if (line) {

scripts/configureLanguageServiceBuild.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference types="node"/>
22
import { normalize, dirname, join } from "path";
33
import { readFileSync, writeFileSync, unlinkSync, existsSync } from "fs";
4-
import assert = require("assert");
4+
import * as assert from "assert";
55
import { execSync } from "child_process";
66
const args = process.argv.slice(2);
77

@@ -10,11 +10,11 @@ const args = process.argv.slice(2);
1010
*/
1111
interface PackageJson {
1212
name: string;
13-
bin: {};
13+
bin?: {};
1414
main: string;
1515
scripts: {
16-
prepare: string
17-
postpublish: string
16+
prepare?: string
17+
postpublish?: string
1818
}
1919
}
2020

scripts/configurePrerelease.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="node"/>
22
import { normalize, relative } from "path";
3-
import assert = require("assert");
3+
import * as assert from "assert";
44
import { readFileSync, writeFileSync } from "fs";
55

66
/**

scripts/errorCheck.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const fs = require("fs");
2-
const async = require("async");
3-
const glob = require("glob");
1+
import * as fs from "fs";
2+
import * as async from "async";
3+
import * as glob from "glob";
44

55
fs.readFile("src/compiler/diagnosticMessages.json", "utf-8", (err, data) => {
66
if (err) {
@@ -25,7 +25,7 @@ fs.readFile("src/compiler/diagnosticMessages.json", "utf-8", (err, data) => {
2525
fs.readFile(baseDir + f, "utf-8", (err, baseline) => {
2626
if (err) throw err;
2727

28-
let g: string[];
28+
let g: RegExpExecArray | null;
2929
while (g = errRegex.exec(baseline)) {
3030
const errCode = +g[1];
3131
const msg = keys.filter(k => messages[k].code === errCode)[0];
@@ -53,7 +53,7 @@ fs.readFile("src/compiler/diagnosticMessages.json", "utf-8", (err, data) => {
5353
fs.readFile("src/compiler/diagnosticInformationMap.generated.ts", "utf-8", (err, data) => {
5454
const errorRegexp = /\s(\w+): \{ code/g;
5555
const errorNames: string[] = [];
56-
let errMatch: string[];
56+
let errMatch: RegExpExecArray | null;
5757
while (errMatch = errorRegexp.exec(data)) {
5858
errorNames.push(errMatch[1]);
5959
}

scripts/failed-tests.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Mocha = require("mocha");
1+
import * as Mocha from "mocha";
22

33
export = FailedTestsReporter;
44

scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function copyFileSync(source: string, destination: string) {
4646
fs.writeFileSync(destination, text);
4747
}
4848

49-
function importDefinitelyTypedTest(tscPath: string, rwcTestPath: string, testCaseName: string, testFiles: string[], responseFile: string) {
49+
function importDefinitelyTypedTest(tscPath: string, rwcTestPath: string, testCaseName: string, testFiles: string[], responseFile: string | undefined) {
5050
let cmd = "node " + tscPath + " --module commonjs " + testFiles.join(" ");
5151
if (responseFile) {
5252
cmd += " @" + responseFile;
@@ -122,7 +122,7 @@ function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, defini
122122

123123
const tsFiles: string[] = [];
124124
const testFiles: string[] = [];
125-
let paramFile: string;
125+
let paramFile: string | undefined;
126126

127127
for (const filePath of files.map(f => path.join(directoryPath, f))) {
128128
if (filePathEndsWith(filePath, ".ts")) {

scripts/open-cherry-pick-pr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
/// <reference types="node" />
44

55
import { Octokit } from "@octokit/rest";
6-
const {runSequence} = require("./run-sequence");
7-
import fs = require("fs");
8-
import path = require("path");
6+
import { runSequence } from "./run-sequence";
7+
import * as fs from "fs";
8+
import * as path from "path";
99

1010
const userName = process.env.GH_USERNAME;
1111
const reviewers = process.env.REQUESTING_USER ? [process.env.REQUESTING_USER] : ["weswigham", "RyanCavanaugh"];

scripts/open-user-pr.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/// <reference lib="es2015.promise" />
33
// Must reference esnext.asynciterable lib, since octokit uses AsyncIterable internally
44
import { Octokit } from "@octokit/rest";
5-
const {runSequence} = require("./run-sequence");
5+
import { runSequence } from "./run-sequence";
66

77
const userName = process.env.GH_USERNAME || "typescript-bot";
88
const reviewers = process.env.REQUESTING_USER ? [process.env.REQUESTING_USER] : ["weswigham", "sandersn", "RyanCavanaugh"];
@@ -22,7 +22,7 @@ runSequence([
2222
["node", ["./node_modules/gulp/bin/gulp.js", "baseline-accept"]], // accept baselines
2323
["git", ["checkout", "-b", branchName]], // create a branch
2424
["git", ["add", "."]], // Add all changes
25-
["git", ["commit", "-m", `"Update user baselines${+process.env.SOURCE_ISSUE === 33716 ? " +cc @sandersn" : ""}"`]], // Commit all changes (ping nathan if we would post to CI thread)
25+
["git", ["commit", "-m", `"Update user baselines${+process.env.SOURCE_ISSUE! === 33716 ? " +cc @sandersn" : ""}"`]], // Commit all changes (ping nathan if we would post to CI thread)
2626
["git", ["push", "--set-upstream", "fork", branchName, "-f"]] // push the branch
2727
]);
2828

scripts/processDiagnosticMessages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import path = require("path");
2-
import fs = require("fs");
1+
import * as path from "path";
2+
import * as fs from "fs";
33

44
interface DiagnosticDetails {
55
category: string;

scripts/produceLKG.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/// <reference types="node" />
22

3-
import childProcess = require("child_process");
4-
import fs = require("fs-extra");
5-
import path = require("path");
6-
import glob = require("glob");
3+
import * as childProcess from "child_process";
4+
import * as fs from "fs-extra";
5+
import * as path from "path";
6+
import * as glob from "glob";
77

88
const root = path.join(__dirname, "..");
99
const source = path.join(root, "built/local");

scripts/request-pr-review.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/// <reference lib="esnext.asynciterable" />
22
/// <reference lib="es2015.promise" />
3-
import octokit = require("@octokit/rest");
4-
import Octokit = octokit.Octokit;
5-
import minimist = require("minimist");
3+
import { Octokit } from "@octokit/rest";
4+
import * as minimist from "minimist";
65

76
const options = minimist(process.argv.slice(2), {
87
boolean: ["help"],
@@ -70,4 +69,4 @@ options:
7069
-h --help Prints this help message.
7170
`);
7271
return process.exit(exitCode);
73-
}
72+
}

scripts/run-sequence.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { SpawnSyncOptions } from "child_process";
2+
3+
export function runSequence(tasks: [string, string[]][], opts?: SpawnSyncOptions): string;

scripts/tsconfig.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,5 @@
1111
"lib": ["es6", "scripthost"],
1212
},
1313

14-
"include": [
15-
"generateLocalizedDiagnosticMessages.ts",
16-
"processDiagnosticMessages.ts",
17-
"configurePrerelease.ts",
18-
"buildProtocol.ts",
19-
"produceLKG.ts",
20-
"word2md.ts",
21-
"request-pr-review.ts"
22-
]
14+
"include": ["*.ts"]
2315
}

0 commit comments

Comments
 (0)