Skip to content

Commit

Permalink
Specified more types in generic utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
joelalejandro committed Oct 21, 2023
1 parent a491a2d commit 4fce6bd
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/utils/flatten.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Thanks 30 seconds of code...
// https://github.com/30-seconds/30-seconds-of-code#flatten

export default function flatten(arr: any[], depth = 1) {
return arr.reduce((a: any[], v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []);
export default function flatten(arr: unknown[], depth = 1) {
return arr.reduce((a: unknown[], v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []);
}
2 changes: 1 addition & 1 deletion src/utils/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ApplicationHooks, ApplicationInstanceInterface } from "../types";
export const runHookFunctions = async (
appInstance: ApplicationInstanceInterface,
hookType: keyof ApplicationHooks,
parameters: Record<string, any> = {},
parameters: Record<string, unknown> = {},
) => {
for (const hook of appInstance.app.hooks[hookType]) {
try {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/http-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ function urlData(appInstance: ApplicationInstanceInterface, path: string): UrlDa
"(?<relationship>[^\\s/?]+)?(/+)?$",
);

const { resource, id, relationships, relationship } = (path.match(urlRegexp) || {})["groups"] || ({} as any);
const { resource, id, relationships, relationship } =
(path.match(urlRegexp) || ({} as UrlData))["groups"] || ({} as UrlData);

return {
id,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/object.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const isEmptyObject = (obj: any) => obj && Object.keys(obj).length === 0;
const isEmptyObject = (obj: object | undefined) => obj && Object.keys(obj).length === 0;

export { isEmptyObject };
2 changes: 1 addition & 1 deletion src/utils/promise-hash-map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const promiseHashMap = async (hash, callback) => {
const promiseHashMap = async (hash: Record<string, unknown>, callback: (key: string | number) => Promise<unknown>) => {
const keys = Object.keys(hash);
const result = {};

Expand Down

0 comments on commit 4fce6bd

Please sign in to comment.