mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Improved service typings. (#35688)
* Updated @feathersjs/socket-commons * Fixed linting errors. * Added type definitions for hook-less service methods. * Revert "Added type definitions for hook-less service methods." This reverts commit 14e8062a57f68b7c338ee092fb3e5cfea9e6f226. See https://github.com/DefinitelyTyped/DefinitelyTyped/pull/34684 * Improved service typings. * Fixed tests. * Fixed lint. * Fixed typo.
This commit is contained in:
parent
1f788aaf30
commit
6c2ae3b20a
@ -33,3 +33,15 @@ app.service('users').hooks({
|
||||
context.dispatch = { test: 'true' };
|
||||
}
|
||||
});
|
||||
|
||||
app.service('users').get(0); // app: Service<User>
|
||||
let x = app.service('user'); // never
|
||||
x = (() => { throw new Error(); })(); // only never can be assigned to never
|
||||
|
||||
const app2 = feathers();
|
||||
app2.service('users').get(0); // app2: Service<any>
|
||||
app2.service('user').get(0); // app2 :Service<any>
|
||||
|
||||
const app3 = feathers<{}>();
|
||||
app3.service('users').get(0); // Service<any>
|
||||
app3.service('user').get(0); // Service<any>
|
||||
|
||||
11
types/feathersjs__feathers/index.d.ts
vendored
11
types/feathersjs__feathers/index.d.ts
vendored
@ -4,9 +4,10 @@
|
||||
// Abraao Alves <https://github.com/AbraaoAlves>
|
||||
// Tim Mensch <https://github.com/TimMensch>
|
||||
// Jordan Tucker <https://github.com/jordanbtucker>
|
||||
// Desmond Koh <https://github.com/deskoh>
|
||||
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
|
||||
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
@ -159,7 +160,7 @@ declare namespace feathers {
|
||||
}
|
||||
|
||||
interface SetupMethod {
|
||||
setup(app: Application, path: string): void;
|
||||
setup(app: Application<any>, path: string): void;
|
||||
}
|
||||
|
||||
interface ServiceOverloads<T> {
|
||||
@ -176,7 +177,7 @@ declare namespace feathers {
|
||||
|
||||
type Service<T> = ServiceOverloads<T> & ServiceAddons<T> & ServiceMethods<T>;
|
||||
|
||||
interface Application<ServiceTypes = any> extends EventEmitter {
|
||||
interface Application<ServiceTypes = {}> extends EventEmitter {
|
||||
get(name: string): any;
|
||||
|
||||
set(name: string, value: any): this;
|
||||
@ -197,9 +198,9 @@ declare namespace feathers {
|
||||
|
||||
service<L extends keyof ServiceTypes>(location: L): Service<ServiceTypes[L]>;
|
||||
|
||||
service(location: string): Service<any>;
|
||||
service(location: string): keyof ServiceTypes extends never ? Service<any> : never;
|
||||
|
||||
use(path: string, service: Partial<ServiceMethods<any> & SetupMethod> | Application, options?: any): this;
|
||||
use(path: string, service: Partial<ServiceMethods<any> & SetupMethod> | Application<any>, options?: any): this;
|
||||
|
||||
version: string;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user