Skip to content

Commit

Permalink
Merge pull request #45 from PrefectHQ/export-create-actions-return-type
Browse files Browse the repository at this point in the history
Feature: Export return type for createActions utility
  • Loading branch information
pleek91 authored Mar 31, 2022
2 parents 73bcc0f + 434f218 commit e3c8f7a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@prefecthq/vue-compositions",
"private": false,
"version": "0.1.20",
"version": "0.1.21",
"description": "A collection of reusable vue compositions.",
"main": "index.ts",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions src/subscribe/createActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ type AnyFunction = (...args: any[]) => any
type Callable<T> = keyof {
[P in keyof T as T[P] extends AnyFunction ? P : never]: T[P]
}
type OnlyCallable<T> = Pick<T, Callable<T>>
export type CreateActions<T> = Pick<T, Callable<T>>

// we do specifically want any here. unknown breaks this for classes
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function createActions<T extends Record<string, any>>(context: T): OnlyCallable<T> {
export function createActions<T extends Record<string, any>>(context: T): CreateActions<T> {
const objectPrototypeKeys = Reflect.ownKeys(Object.prototype)
const actions: Record<string, unknown> = {}
let prototype = Reflect.getPrototypeOf(context)
Expand All @@ -33,5 +33,5 @@ export function createActions<T extends Record<string, any>>(context: T): OnlyCa
prototype = Reflect.getPrototypeOf(prototype)
}

return actions as Required<OnlyCallable<T>>
return actions as Required<CreateActions<T>>
}

0 comments on commit e3c8f7a

Please sign in to comment.