Applied changes to solve several issues about typescript strict mode

This commit is contained in:
Alexander Cerutti
2021-12-23 19:46:29 +01:00
parent ef20bc5a44
commit cf8a467266
6 changed files with 56 additions and 38 deletions

View File

@@ -7,7 +7,7 @@ import type Bundle from "./Bundle";
* @returns
*/
export function processDate(date: Date): string | null {
export function processDate(date: Date): string | undefined {
if (!(date instanceof Date)) {
throw "Invalid date";
}
@@ -84,9 +84,9 @@ export function removeHidden(from: Array<string>): Array<string> {
* @returns
*/
export function cloneRecursive(object: Object) {
const objectCopy = {};
const objectEntries = Object.entries(object);
export function cloneRecursive<T extends Object>(object: T) {
const objectCopy = {} as Record<keyof T, any>;
const objectEntries = Object.entries(object) as [keyof T, T[keyof T]][];
for (let i = 0; i < objectEntries.length; i++) {
const [key, value] = objectEntries[i];