This repository has been archived by the owner on Apr 20, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix TypeScript declarations. * Another round of fixes * Reverting some of the last fixes This should work the way the previous build was designed to. For anywhere that needs hooks to appear on a Service, you need to include: ```typescript import "feathers-hooks" ``` ...at the top of your file. Then the `Service` and `Application` merged declarations will be present in the file. At least I'm finding that to produce clean TypeScript builds right now.
- Loading branch information
Showing
1 changed file
with
43 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,51 @@ | ||
import * as feathers from 'feathers'; | ||
import * as feathers from "feathers"; | ||
|
||
declare module 'feathers' { | ||
interface Application { | ||
hooks(hooks: hooks.HooksObject): Application; | ||
} | ||
declare function hooks(): () => void; | ||
|
||
interface Service<T extends any> { | ||
before(hooks: hooks.HookMap): Application; | ||
after(hooks: hooks.HookMap): Application; | ||
hooks(hooks: hooks.HooksObject): Application; | ||
} | ||
declare module "feathers" { | ||
interface Service<T> { | ||
before(hooks: hooks.HookMap): Application; | ||
after(hooks: hooks.HookMap): Application; | ||
hooks(hooks: hooks.HooksObject): Application; | ||
} | ||
interface Application { | ||
hooks(hooks: hooks.HooksObject): Application; | ||
} | ||
} | ||
|
||
declare function hooks(): () => void; | ||
|
||
declare namespace hooks { | ||
interface Hook { | ||
<T>(hook: HookProps<T>): Promise<any> | void; | ||
} | ||
|
||
interface HookProps<T> { | ||
app?: feathers.Application; | ||
data?: T; | ||
error?: any; | ||
id?: string | number; | ||
method?: string; | ||
params?: any; | ||
path?: string; | ||
result?: T; | ||
service: feathers.Service<T>; | ||
type: 'before' | 'after' | 'error'; | ||
} | ||
|
||
interface HookMap { | ||
all?: Hook | Hook[]; | ||
find?: Hook | Hook[]; | ||
get?: Hook | Hook[]; | ||
create?: Hook | Hook[]; | ||
update?: Hook | Hook[]; | ||
patch?: Hook | Hook[]; | ||
remove?: Hook | Hook[]; | ||
} | ||
|
||
interface HooksObject { | ||
before?: HookMap; | ||
after?: HookMap; | ||
error?: HookMap; | ||
} | ||
interface Hook { | ||
<T>(hook: HookProps<T>): Promise<any> | void; | ||
} | ||
|
||
interface HookProps<T> { | ||
app?: feathers.Application; | ||
data?: T; | ||
error?: any; | ||
id?: string | number; | ||
method?: string; | ||
params?: any; | ||
path?: string; | ||
result?: T; | ||
service: feathers.Service<T>; | ||
type: "before" | "after" | "error"; | ||
} | ||
|
||
interface HookMap { | ||
all?: Hook | Hook[]; | ||
find?: Hook | Hook[]; | ||
get?: Hook | Hook[]; | ||
create?: Hook | Hook[]; | ||
update?: Hook | Hook[]; | ||
patch?: Hook | Hook[]; | ||
remove?: Hook | Hook[]; | ||
} | ||
|
||
interface HooksObject { | ||
before?: HookMap; | ||
after?: HookMap; | ||
error?: HookMap; | ||
} | ||
} | ||
|
||
export = hooks; |