Skip to content

Commit

Permalink
feat: use type unknown instead of any
Browse files Browse the repository at this point in the history
  • Loading branch information
gcandal committed Jan 11, 2021
1 parent 469b5c4 commit 61c1687
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 21 deletions.
4 changes: 2 additions & 2 deletions types/base/main.d.ts
@@ -1,3 +1,3 @@
export declare function register(name: string, value: any): void;
export declare function register(name: string, value: unknown): void;
export declare function unregister(name: string): void;
export declare function request(name: string): any;
export declare function request(name: string): unknown;
10 changes: 5 additions & 5 deletions types/data/model.d.ts
@@ -1,16 +1,16 @@
export declare class Model {
static niw<T = Model>(this: { new(): T }): T
static find<T = Model>(this: { new(): T }, params?: Record<string, any>): T[]
static get<T = Model>(this: { new(): T }, params?: Record<string, any>): T
static find<T = Model>(this: { new(): T }, params?: Record<string, unknown>): T[]
static get<T = Model>(this: { new(): T }, params?: Record<string, unknown>): T

constructor(options?: { fill?: boolean })
apply<T = Model>(this: T, model: Record<string, any>): Promise<T>
apply<T = Model>(this: T, model: Record<string, unknown>): Promise<T>
save<T = Model>(this: T): Promise<T>
delete<T = Model>(this: T, options?: {
preDelete?: boolean,
postDelete?: boolean,
beforeCallbacks?: ((self: T, model: Record<string, any>) => void)[],
afterCallbacks?: ((self: T, model: Record<string, any>) => void)[]
beforeCallbacks?: ((self: T, model: Record<string, unknown>) => void)[],
afterCallbacks?: ((self: T, model: Record<string, unknown>) => void)[]
}): Promise<T>

validate(): Promise<void>
Expand Down
2 changes: 1 addition & 1 deletion types/util/assert.d.ts
@@ -1 +1 @@
export declare function verify(condition: boolean, message?: string, code?: number, exception?: any, kwargs?: any): void;
export declare function verify(condition: boolean, message?: string, code?: number, exception?: unknown, kwargs?: unknown): void;
4 changes: 2 additions & 2 deletions types/util/config.d.ts
@@ -1,2 +1,2 @@
export declare function load(names?: Array<string>, path?: string, encoding?: string, force?: boolean, ctx?: any): Promise<void>;
export declare function conf(name: string, fallback?: any, cast?: string, ctx?: any): any;
export declare function load(names?: Array<string>, path?: string, encoding?: string, force?: boolean, ctx?: unknown): Promise<void>;
export declare function conf(name: string, fallback?: unknown, cast?: string, ctx?: unknown): unknown;
4 changes: 2 additions & 2 deletions types/util/data.d.ts
@@ -1,9 +1,9 @@
export declare function getObject(
params: Record<string, any>,
params: Record<string, unknown>,
options: {
alias?: boolean,
page?: boolean,
find?: boolean,
norm?: boolean
}
): Record<string, any>;
): Record<string, unknown>;
41 changes: 32 additions & 9 deletions types/util/validation.d.ts
@@ -1,40 +1,63 @@
export declare function eq<T>(
valueC: T,
message?: string
): (value?: T, ctx?: any) => boolean;
): (value?: T, ctx?: unknown) => boolean;

export declare function gt<T>(
valueC: T,
message?: string
): (value?: T, ctx?: any) => boolean;
): (value?: T, ctx?: unknown) => boolean;

export declare function gte<T>(
valueC: T,
message?: string
): (value?: T, ctx?: any) => boolean;
): (value?: T, ctx?: unknown) => boolean;

export declare function notEmpty(
message?: string
): (value?: string | unknown[], ctx?: any) => boolean;
): (value?: string | unknown[], ctx?: unknown) => boolean;

export declare function isIn<T>(
valueC: T[],
message?: string
): (value?: T, ctx?: any) => boolean;
): (value?: T, ctx?: unknown) => boolean;

export declare function isUpper(
message?: string
): (value?: string, ctx?: unknown) => boolean;

export declare function isLower(
message?: string
): (value?: string, ctx?: unknown) => boolean;

export declare function isSimple(
message?: string
): (value?: string, ctx?: any) => boolean;
): (value?: string, ctx?: unknown) => boolean;

export declare function isEmail(
message?: string
): (value?: string, ctx?: any) => boolean;
): (value?: string, ctx?: unknown) => boolean;

export declare function isUrl(
message?: string
): (value?: string, ctx?: any) => boolean;
): (value?: string, ctx?: unknown) => boolean;

export declare function isRegex(
regex: string,
message?: string
): (value?: string, ctx?: any) => boolean;
): (value?: string, ctx?: unknown) => boolean;

export declare function stringGt(
valueC: number,
message?: string
): (value?: string, ctx?: unknown) => boolean;

export declare function stringLt(
valueC: number,
message?: string
): (value?: string, ctx?: unknown) => boolean;

export declare function stringEq(
valueC: number,
message?: string
): (value?: string, ctx?: unknown) => boolean;

0 comments on commit 61c1687

Please sign in to comment.