Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(_tools): prepare for noUncheckedIndexedAccess #4442

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading