Skip to content

Commit

Permalink
chore(_tools): prepare for noUncheckedIndexedAccess (#4442)
Browse files Browse the repository at this point in the history
  • Loading branch information
iuioiua committed Mar 6, 2024
1 parent 4f8d963 commit 32e4b43
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions _tools/check_circular_submodule_dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ const STABILITY: Record<Mod, DepState> = {
const root = new URL("../", import.meta.url).href;
const deps: Record<string, Dep> = {};

function getSubmoduleNameFromUrl(url: string) {
return url.replace(root, "").split("/")[0];
function getSubmoduleNameFromUrl(url: string): string {
return url.replace(root, "").split("/")[0]!;
}

async function check(
Expand Down Expand Up @@ -270,9 +270,9 @@ function stateToNodeStyle(state: DepState) {
if (Deno.args.includes("--graph")) {
console.log("digraph std_deps {");
for (const mod of Object.keys(deps)) {
const info = deps[mod];
const info = deps[mod]!;
console.log(` ${formatLabel(mod)} ${stateToNodeStyle(info.state)};`);
for (const dep of deps[mod].set) {
for (const dep of info.set) {
console.log(` ${formatLabel(mod)} -> ${dep};`);
}
}
Expand Down
4 changes: 2 additions & 2 deletions _tools/check_doc_imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ function checkCodeBlocks(

if (
["ts", "js", "typescript", "javascript", ""].includes(
language.toLocaleLowerCase(),
language!.toLocaleLowerCase(),
)
) {
checkImportStatements(
codeBlock,
codeBlock!,
filePath,
lineNumber + codeBlockLineNumber,
);
Expand Down
3 changes: 2 additions & 1 deletion _tools/check_licence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ for await (
console.log("Copyright header automatically added to " + path);
}
} else if (
parseInt(match[1]) !== FIRST_YEAR || parseInt(match[2]) !== CURRENT_YEAR
(match[1] && parseInt(match[1]) !== FIRST_YEAR) ||
(match[2] && parseInt(match[2]) !== CURRENT_YEAR)
) {
if (CHECK) {
console.error(`Incorrect copyright year: ${path}`);
Expand Down
8 changes: 4 additions & 4 deletions _tools/convert_to_workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ for (const { specifier, dependencies } of graph.modules) {
continue;
}
const from = relative(cwd, fromFileUrl(specifier)).replaceAll("\\", "/");
const fromPkg = from.split("/")[0];
const fromPkg = from.split("/")[0]!;
for (const dep of dependencies ?? []) {
if (dep.code) {
const to = relative(cwd, fromFileUrl(dep.code.specifier)).replaceAll(
"\\",
"/",
);
const toPkg = to.split("/")[0];
const toPkg = to.split("/")[0]!;
if (fromPkg !== toPkg) {
pkgDeps.get(fromPkg)!.add(toPkg);
}
Expand All @@ -111,7 +111,7 @@ for (const { specifier, dependencies } of graph.modules) {
"\\",
"/",
);
const toPkg = to.split("/")[0];
const toPkg = to.split("/")[0]!;
if (fromPkg !== toPkg) {
pkgDeps.get(fromPkg)!.add(toPkg);
}
Expand Down Expand Up @@ -221,7 +221,7 @@ for await (const entry of walk(cwd)) {
for (const pkg of packages) {
const exportsList = exportsByPackage.get(pkg)!;
let exports;
if (exportsList.length === 1 && exportsList[0][0] === ".") {
if (exportsList.length === 1 && exportsList[0]![0] === ".") {
exports = "./mod.ts";
} else {
exports = Object.fromEntries(exportsList);
Expand Down

0 comments on commit 32e4b43

Please sign in to comment.