Skip to content

Commit

Permalink
remove one @ts-ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Oct 7, 2022
1 parent a59a2f2 commit fe60528
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
19 changes: 15 additions & 4 deletions script/utilities/flattenObject.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
/**
* flattenObject
* @description turns a nested object into a one-dimensional object and joins names with dots
* @param obj
* @param prefix
* @returns flattend objects
*/
export const flattenObject = (obj: any, prefix: string = "") =>
// @ts-ignore
Object.keys(obj).reduce((acc, k) => {
const pre = prefix.length ? prefix + '.' : '';
if (typeof obj[k] === 'object') Object.assign(acc, flattenObject(obj[k], pre + k));
// @ts-ignore
else acc[pre + k] = obj[k];
if (typeof obj[k] === 'object') {
// purposly mutating acc
Object.assign(acc, flattenObject(obj[k], pre + k));
}
else {
// @ts-ignore: implicit any
acc[pre + k] = obj[k];
}
return acc;
}, {})
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2098,9 +2098,9 @@
"mime-types" "^2.1.12"

"fs-extra@^10.0.0":
"integrity" "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag=="
"resolved" "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz"
"version" "10.0.1"
"integrity" "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ=="
"resolved" "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz"
"version" "10.1.0"
dependencies:
"graceful-fs" "^4.2.0"
"jsonfile" "^6.0.1"
Expand Down

0 comments on commit fe60528

Please sign in to comment.