Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Use unknown instead of any whenever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
ci7lus committed Jul 11, 2021
1 parent 3d4a307 commit d32a4ea
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ironpipe",
"version": "0.0.6",
"version": "0.0.7",
"author": "ci7lus <[email protected]>",
"description": "TypeScript typed helpers for pipedream.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/component/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type InstanceThis<Props, Methods> = ThisType<
$props: Props
$emit: (
data: ObjectLiteral,
metadata?: ObjectLiteral & { id: any } // metadata requires id
metadata?: ObjectLiteral & { id: unknown } // metadata requires id
) => void
} & Props &
Methods &
Expand Down
10 changes: 5 additions & 5 deletions src/component/pipedream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type ArgEventHttp = {
query: ObjectLiteral
headers: ObjectLiteral
bodyRaw: string
body: any
body: unknown
}

export type PipedreamPropTypes =
Expand All @@ -36,16 +36,16 @@ export type PropDefaultDInterfaceTimer =
| { cron: string }

export type PropReturnDInterfaceHttp = {
respond(options: {
respond<T = unknown>(options: {
status?: number
headers?: ObjectLiteral
body?: any
[key: string]: any
body?: T
[key: string]: unknown
}): void
endpoint: string
}

export type PropReturnDServiceDB = {
get: <T = any>(key: string) => T | undefined
get: <T = unknown>(key: string) => T | undefined
set: <T>(key: string, value: T) => void
}
15 changes: 9 additions & 6 deletions src/component/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ type Prop<T> = PropOptions<T> | PropTypes | string2

type PropTypesDefault = PropDefaultDInterfaceTimer

type PropOptions<T = any> = {
type PropOptions<T = unknown> = {
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[]>) | string[] | any[]
options?:
| ((...args: unknown[]) => string[] | Promise<string[]>)
| string[]
| unknown[]
}

type ConvertPropTypes<T> = T extends null
Expand All @@ -37,15 +40,15 @@ type ConvertPropTypes<T> = T extends null
? PropReturnDInterfaceHttp
: T extends { type: "$.service.db" } | "$.service.db"
? PropReturnDServiceDB
: any
: unknown

type PropOptionalCheck<T> = T extends { optional: true }
? ConvertPropTypes<T> | undefined
: ConvertPropTypes<T>

export type ExtractPropTypes<P> = P extends object
? { [K in keyof P]: PropOptionalCheck<P[K]> }
: { [K in string]: any }
: { [K in string]: unknown }

export type InstancePropsOptions<P = Record<string, unknown>> =
| {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export type ObjectLiteral = { [key: string]: any }
export type ObjectLiteral = { [key: string]: unknown }
export type string2 = string & {}

0 comments on commit d32a4ea

Please sign in to comment.