editor/code: Enable noUncheckedIndexedAccess ts option

https://www.typescriptlang.org/tsconfig#noUncheckedIndexedAccess
This commit is contained in:
Tetsuharu Ohzeki 2023-06-28 04:03:53 +09:00
parent bb35d8fa8e
commit 72a3883a71
14 changed files with 124 additions and 52 deletions

View file

@ -4,6 +4,8 @@ import * as path from "path";
import * as readline from "readline";
import * as vscode from "vscode";
import { execute, log, memoizeAsync } from "./util";
import { unwrapNullable } from "./nullable";
import { unwrapUndefinable } from "./undefinable";
interface CompilationArtifact {
fileName: string;
@ -93,7 +95,8 @@ export class Cargo {
throw new Error("Multiple compilation artifacts are not supported.");
}
return artifacts[0].fileName;
const artifact = unwrapUndefinable(artifacts[0]);
return artifact.fileName;
}
private async runCargo(
@ -142,7 +145,9 @@ export async function getRustcId(dir: string): Promise<string> {
const data = await execute(`${rustcPath} -V -v`, { cwd: dir });
const rx = /commit-hash:\s(.*)$/m;
return rx.exec(data)![1];
const result = unwrapNullable(rx.exec(data));
const first = unwrapUndefinable(result[1]);
return first;
}
/** Mirrors `toolchain::cargo()` implementation */