diff options
| author | Tetsuharu Ohzeki <tetsuharu.ohzeki@gmail.com> | 2023-06-28 04:03:53 +0900 |
|---|---|---|
| committer | Tetsuharu Ohzeki <tetsuharu.ohzeki@gmail.com> | 2023-07-06 16:17:02 +0900 |
| commit | 72a3883a7128b4eae6f38d6479f33aaaaae4790b (patch) | |
| tree | 60b9d6f755bbefeca335bcbc10d0832abc719c48 /editors/code/src/toolchain.ts | |
| parent | bb35d8fa8ef9de3c8282602b411c40b266dc3a4e (diff) | |
| download | rust-72a3883a7128b4eae6f38d6479f33aaaaae4790b.tar.gz rust-72a3883a7128b4eae6f38d6479f33aaaaae4790b.zip | |
editor/code: Enable `noUncheckedIndexedAccess` ts option
https://www.typescriptlang.org/tsconfig#noUncheckedIndexedAccess
Diffstat (limited to 'editors/code/src/toolchain.ts')
| -rw-r--r-- | editors/code/src/toolchain.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts index 917a1d6b099..b2c0c669db2 100644 --- a/editors/code/src/toolchain.ts +++ b/editors/code/src/toolchain.ts @@ -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 */ |
