close
Skip to content
This repository was archived by the owner on Sep 4, 2019. It is now read-only.

Update TypeScript definition for service.patch#199

Merged
daffl merged 1 commit into
feathersjs-ecosystem:masterfrom
kfatehi:patch-1
Oct 22, 2017
Merged

Update TypeScript definition for service.patch#199
daffl merged 1 commit into
feathersjs-ecosystem:masterfrom
kfatehi:patch-1

Conversation

@kfatehi

@kfatehi kfatehi commented Sep 20, 2017

Copy link
Copy Markdown
Contributor

Similar to React's setState, the patch function should allow a partial object of a given type, but no extraneous keys thereafter.

Resource: https://github.com/developit/preact/blob/f7834ec9fb7848581c6fbc7833bcbe2f2db9fe61/src/preact.d.ts#L61

Similar to React's `setState`, the `patch` function should allow a partial object of a given type, but no extraneous keys thereafter.

Resource: https://github.com/developit/preact/blob/f7834ec9fb7848581c6fbc7833bcbe2f2db9fe61/src/preact.d.ts#L61
Comment thread index.d.ts
create(data: T, params?: any): Promise<T>;
update(id: string, data: T, params?: any): Promise<T>;
patch(id: string, data: T, params?: any) : Promise<T>;
patch<K extends keyof T>(id: string, data:Pick<T, K>, params?: any) : Promise<T>;

@j2L4e j2L4e Oct 8, 2017

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, would need to be patched in feathers and feathers-reactive too.
Out of curiosity: How is this different from using data: Partial<T>?

edit: this answered my question: https://medium.com/@curtistatewilkinson/typescript-2-1-and-the-power-of-pick-ff433f1e6fb

@daffl
daffl merged commit 1bf6c2d into feathersjs-ecosystem:master Oct 22, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants