From d32a4ea4b59c66cad2be0df6611ca36ebfed5f9e Mon Sep 17 00:00:00 2001 From: ci7lus <7887955+ci7lus@users.noreply.github.com> Date: Sun, 11 Jul 2021 20:57:17 +0900 Subject: [PATCH] Use unknown instead of any whenever possible --- package.json | 2 +- src/component/options.ts | 2 +- src/component/pipedream.ts | 10 +++++----- src/component/props.ts | 15 +++++++++------ src/types.ts | 2 +- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index ad2a38e..31ec485 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ironpipe", - "version": "0.0.6", + "version": "0.0.7", "author": "ci7lus <7887955+ci7lus@users.noreply.github.com>", "description": "TypeScript typed helpers for pipedream.", "repository": { diff --git a/src/component/options.ts b/src/component/options.ts index 94eef59..33301f0 100644 --- a/src/component/options.ts +++ b/src/component/options.ts @@ -5,7 +5,7 @@ export type InstanceThis = ThisType< $props: Props $emit: ( data: ObjectLiteral, - metadata?: ObjectLiteral & { id: any } // metadata requires id + metadata?: ObjectLiteral & { id: unknown } // metadata requires id ) => void } & Props & Methods & diff --git a/src/component/pipedream.ts b/src/component/pipedream.ts index 92b21d7..943d764 100644 --- a/src/component/pipedream.ts +++ b/src/component/pipedream.ts @@ -17,7 +17,7 @@ export type ArgEventHttp = { query: ObjectLiteral headers: ObjectLiteral bodyRaw: string - body: any + body: unknown } export type PipedreamPropTypes = @@ -36,16 +36,16 @@ export type PropDefaultDInterfaceTimer = | { cron: string } export type PropReturnDInterfaceHttp = { - respond(options: { + respond(options: { status?: number headers?: ObjectLiteral - body?: any - [key: string]: any + body?: T + [key: string]: unknown }): void endpoint: string } export type PropReturnDServiceDB = { - get: (key: string) => T | undefined + get: (key: string) => T | undefined set: (key: string, value: T) => void } diff --git a/src/component/props.ts b/src/component/props.ts index 41bd347..c614f96 100644 --- a/src/component/props.ts +++ b/src/component/props.ts @@ -13,14 +13,17 @@ type Prop = PropOptions | PropTypes | string2 type PropTypesDefault = PropDefaultDInterfaceTimer -type PropOptions = { +type PropOptions = { type?: PropTypes | string2 label?: string description?: string - default?: PropTypesDefault | { [key: string]: any } | string | null - propDefinition?: [any, string] + default?: PropTypesDefault | { [key: string]: unknown } | string | null + propDefinition?: [unknown, string] optional?: boolean - options?: ((...args: any) => string[] | Promise) | string[] | any[] + options?: + | ((...args: unknown[]) => string[] | Promise) + | string[] + | unknown[] } type ConvertPropTypes = T extends null @@ -37,7 +40,7 @@ type ConvertPropTypes = T extends null ? PropReturnDInterfaceHttp : T extends { type: "$.service.db" } | "$.service.db" ? PropReturnDServiceDB - : any + : unknown type PropOptionalCheck = T extends { optional: true } ? ConvertPropTypes | undefined @@ -45,7 +48,7 @@ type PropOptionalCheck = T extends { optional: true } export type ExtractPropTypes

= P extends object ? { [K in keyof P]: PropOptionalCheck } - : { [K in string]: any } + : { [K in string]: unknown } export type InstancePropsOptions

> = | { diff --git a/src/types.ts b/src/types.ts index 2941e74..afd0111 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,2 +1,2 @@ -export type ObjectLiteral = { [key: string]: any } +export type ObjectLiteral = { [key: string]: unknown } export type string2 = string & {}