diff options
| author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-05-30 14:59:30 +0200 |
|---|---|---|
| committer | Ryan Dahl <ry@tinyclouds.org> | 2019-05-30 08:59:30 -0400 |
| commit | 50a79584cb12129b3db1ef3e0eb9d0c8b9f20b62 (patch) | |
| tree | ee9a90a8b8018c03b1e1a6ace07abdaa494ea90d /fs/path | |
| parent | 80b3c486f6222f65b52eb2eca903b67312e8ce0c (diff) | |
chore: Implement strict mode (denoland/deno_std#453)
Original: https://github.com/denoland/deno_std/commit/be24677d15494e83eea2e99bfc5ccfdde31cb892
Diffstat (limited to 'fs/path')
| -rw-r--r-- | fs/path/join_test.ts | 9 | ||||
| -rw-r--r-- | fs/path/parse_format_test.ts | 10 | ||||
| -rw-r--r-- | fs/path/resolve_test.ts | 6 | ||||
| -rw-r--r-- | fs/path/utils.ts | 4 | ||||
| -rw-r--r-- | fs/path/win32.ts | 5 |
5 files changed, 20 insertions, 14 deletions
diff --git a/fs/path/join_test.ts b/fs/path/join_test.ts index d82a1b471..2c0f35e48 100644 --- a/fs/path/join_test.ts +++ b/fs/path/join_test.ts @@ -108,18 +108,21 @@ const windowsJoinTests = [ test(function join() { joinTests.forEach(function(p) { - const actual = path.posix.join.apply(null, p[0]); + const _p = p[0] as string[]; + const actual = path.posix.join.apply(null, _p); assertEquals(actual, p[1]); }); }); test(function joinWin32() { joinTests.forEach(function(p) { - const actual = path.win32.join.apply(null, p[0]).replace(backslashRE, "/"); + const _p = p[0] as string[]; + const actual = path.win32.join.apply(null, _p).replace(backslashRE, "/"); assertEquals(actual, p[1]); }); windowsJoinTests.forEach(function(p) { - const actual = path.win32.join.apply(null, p[0]); + const _p = p[0] as string[]; + const actual = path.win32.join.apply(null, _p); assertEquals(actual, p[1]); }); }); diff --git a/fs/path/parse_format_test.ts b/fs/path/parse_format_test.ts index 05327a139..8829891da 100644 --- a/fs/path/parse_format_test.ts +++ b/fs/path/parse_format_test.ts @@ -79,8 +79,8 @@ const unixSpecialCaseFormatTests = [ [{}, ""] ]; -function checkParseFormat(path, paths): void { - paths.forEach(function(p) { +function checkParseFormat(path: any, paths: any): void { + paths.forEach(function(p: Record<string, unknown>[]) { const element = p[0]; const output = path.parse(element); assertEquals(typeof output.root, "string"); @@ -95,8 +95,8 @@ function checkParseFormat(path, paths): void { }); } -function checkSpecialCaseParseFormat(path, testCases): void { - testCases.forEach(function(testCase) { +function checkSpecialCaseParseFormat(path: any, testCases: any): void { + testCases.forEach(function(testCase: Record<string, unknown>[]) { const element = testCase[0]; const expect = testCase[1]; const output = path.parse(element); @@ -106,7 +106,7 @@ function checkSpecialCaseParseFormat(path, testCases): void { }); } -function checkFormat(path, testCases): void { +function checkFormat(path: any, testCases: unknown[][]): void { testCases.forEach(function(testCase) { assertEquals(path.format(testCase[0]), testCase[1]); }); diff --git a/fs/path/resolve_test.ts b/fs/path/resolve_test.ts index 7ee9513c1..606570aad 100644 --- a/fs/path/resolve_test.ts +++ b/fs/path/resolve_test.ts @@ -37,14 +37,16 @@ const posixTests = test(function resolve() { posixTests.forEach(function(p) { - const actual = path.posix.resolve.apply(null, p[0]); + const _p = p[0] as string[]; + const actual = path.posix.resolve.apply(null, _p); assertEquals(actual, p[1]); }); }); test(function resolveWin32() { windowsTests.forEach(function(p) { - const actual = path.win32.resolve.apply(null, p[0]); + const _p = p[0] as string[]; + const actual = path.win32.resolve.apply(null, _p); assertEquals(actual, p[1]); }); }); diff --git a/fs/path/utils.ts b/fs/path/utils.ts index e50cb6d3c..7a4cd7299 100644 --- a/fs/path/utils.ts +++ b/fs/path/utils.ts @@ -49,7 +49,7 @@ export function normalizeString( let code: number; for (let i = 0, len = path.length; i <= len; ++i) { if (i < len) code = path.charCodeAt(i); - else if (isPathSeparator(code)) break; + else if (isPathSeparator(code!)) break; else code = CHAR_FORWARD_SLASH; if (isPathSeparator(code)) { @@ -107,7 +107,7 @@ export function _format( sep: string, pathObject: FormatInputPathObject ): string { - const dir: string | null = pathObject.dir || pathObject.root; + const dir: string | undefined = pathObject.dir || pathObject.root; const base: string = pathObject.base || (pathObject.name || "") + (pathObject.ext || ""); if (!dir) return base; diff --git a/fs/path/win32.ts b/fs/path/win32.ts index 6b906bc7b..d42cc4885 100644 --- a/fs/path/win32.ts +++ b/fs/path/win32.ts @@ -171,7 +171,7 @@ export function normalize(path: string): string { const len = path.length; if (len === 0) return "."; let rootEnd = 0; - let device: string; + let device: string | undefined; let isAbsolute = false; const code = path.charCodeAt(0); @@ -301,7 +301,7 @@ export function join(...paths: string[]): string { const pathsCount = paths.length; if (pathsCount === 0) return "."; - let joined: string; + let joined: string | undefined; let firstPart: string; for (let i = 0; i < pathsCount; ++i) { let path = paths[i]; @@ -329,6 +329,7 @@ export function join(...paths: string[]): string { // path.join('//server', 'share') -> '\\\\server\\share\\') let needsReplace = true; let slashCount = 0; + firstPart = firstPart!; if (isPathSeparator(firstPart.charCodeAt(0))) { ++slashCount; const firstLen = firstPart.length; |
