From c2986891f6aac87cec98232735945af756e6643f Mon Sep 17 00:00:00 2001 From: Yusuke Sakurai Date: Fri, 7 Feb 2020 16:23:38 +0900 Subject: remove non-null assertion operator from std (part1) (#3900) --- std/fs/expand_glob.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'std/fs/expand_glob.ts') diff --git a/std/fs/expand_glob.ts b/std/fs/expand_glob.ts index 7e575a123..656852ebb 100644 --- a/std/fs/expand_glob.ts +++ b/std/fs/expand_glob.ts @@ -9,6 +9,7 @@ import { normalize } from "../path/mod.ts"; import { WalkInfo, walk, walkSync } from "./walk.ts"; +import { assert } from "../testing/mod.ts"; const { ErrorKind, cwd, stat, statSync } = Deno; type ErrorKind = Deno.ErrorKind; type DenoError = Deno.DenoError; @@ -80,7 +81,9 @@ export async function* expandGlob( let fixedRoot = winRoot != undefined ? winRoot : "/"; while (segments.length > 0 && !isGlob(segments[0])) { - fixedRoot = joinGlobs([fixedRoot, segments.shift()!], globOptions); + const seg = segments.shift(); + assert(seg != null); + fixedRoot = joinGlobs([fixedRoot, seg], globOptions); } let fixedRootInfo: WalkInfo; @@ -182,7 +185,9 @@ export function* expandGlobSync( let fixedRoot = winRoot != undefined ? winRoot : "/"; while (segments.length > 0 && !isGlob(segments[0])) { - fixedRoot = joinGlobs([fixedRoot, segments.shift()!], globOptions); + const seg = segments.shift(); + assert(seg != null); + fixedRoot = joinGlobs([fixedRoot, seg], globOptions); } let fixedRootInfo: WalkInfo; -- cgit v1.2.3