summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-05-30 14:59:30 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-05-30 08:59:30 -0400
commit50a79584cb12129b3db1ef3e0eb9d0c8b9f20b62 (patch)
treeee9a90a8b8018c03b1e1a6ace07abdaa494ea90d /util
parent80b3c486f6222f65b52eb2eca903b67312e8ce0c (diff)
chore: Implement strict mode (denoland/deno_std#453)
Original: https://github.com/denoland/deno_std/commit/be24677d15494e83eea2e99bfc5ccfdde31cb892
Diffstat (limited to 'util')
-rw-r--r--util/async.ts2
-rw-r--r--util/deep_assign.ts9
2 files changed, 7 insertions, 4 deletions
diff --git a/util/async.ts b/util/async.ts
index 15edb1b42..b737c4cc8 100644
--- a/util/async.ts
+++ b/util/async.ts
@@ -25,7 +25,7 @@ export function deferred<T>(): Deferred<T> {
methods = { resolve, reject };
}
);
- return Object.assign(promise, methods) as Deferred<T>;
+ return Object.assign(promise, methods)! as Deferred<T>;
}
interface TaggedYieldedValue<T> {
diff --git a/util/deep_assign.ts b/util/deep_assign.ts
index 77bf5e9b3..1dfc00a5b 100644
--- a/util/deep_assign.ts
+++ b/util/deep_assign.ts
@@ -1,12 +1,15 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-export function deepAssign(target: object, ...sources: object[]): object {
+export function deepAssign(
+ target: Record<string, unknown>,
+ ...sources: object[]
+): object | undefined {
for (let i = 0; i < sources.length; i++) {
const source = sources[i];
if (!source || typeof source !== `object`) {
return;
}
Object.entries(source).forEach(
- ([key, value]): void => {
+ ([key, value]: [string, unknown]): void => {
if (value instanceof Date) {
target[key] = new Date(value);
return;
@@ -22,7 +25,7 @@ export function deepAssign(target: object, ...sources: object[]): object {
if (typeof target[key] !== `object` || !target[key]) {
target[key] = {};
}
- deepAssign(target[key], value);
+ deepAssign(target[key] as Record<string, unknown>, value!);
}
);
}