mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
fix(@feathersjs/various): proper module augmentation, add reexports (#23195)
* fix feathersjs__{authentication-client,express,socket-commons}
* fix feathersjs__authentication-client
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
import feathers from '@feathersjs/feathers';
|
||||
import feathersAuthClient from '@feathersjs/authentication-client';
|
||||
|
||||
// we can't really do much, because the augmentation of @feathersjs/feathers breaks importing it here.
|
||||
const configureFn = feathersAuthClient({});
|
||||
const app = feathers();
|
||||
app.configure(feathersAuthClient());
|
||||
app.authenticate({strategy : 'abcdef'}).then(() => {});
|
||||
app.logout().then(() => {});
|
||||
|
||||
// check if the non-augmented @feathersjs/feathers typings still work
|
||||
app.on('asd', () => {});
|
||||
app.service('asd').get(0).then(() => {});
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
declare module '@feathersjs/feathers' {
|
||||
import {
|
||||
FeathersAuthCredentials,
|
||||
Passport
|
||||
} from '@feathersjs/authentication-client';
|
||||
|
||||
interface Application<ServiceTypes> {
|
||||
authenticate(options?: FeathersAuthCredentials): Promise<any>;
|
||||
|
||||
logout(): Promise<void>;
|
||||
|
||||
passport: Passport;
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
// Definitions by: Abraao Alves <https://github.com/AbraaoAlves>, Jan Lohage <https://github.com/j2L4e>
|
||||
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
|
||||
|
||||
import './feathersjs__feathers';
|
||||
|
||||
export default function feathersAuthClient(config?: FeathersAuthClientConfig): () => void;
|
||||
|
||||
export interface FeathersAuthClientConfig {
|
||||
@@ -62,3 +60,13 @@ export interface Passport {
|
||||
|
||||
getStorage(storage: any): any;
|
||||
}
|
||||
|
||||
declare module '@feathersjs/feathers' {
|
||||
interface Application<ServiceTypes> {
|
||||
authenticate(options?: FeathersAuthCredentials): Promise<any>;
|
||||
|
||||
logout(): Promise<void>;
|
||||
|
||||
passport: Passport;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import feathers, { Application } from '@feathersjs/feathers';
|
||||
import feathersExpress from '@feathersjs/express';
|
||||
import { Application as ExpressApplication } from 'express';
|
||||
import feathersExpress, { original, rest, notFound, errorHandler } from '@feathersjs/express';
|
||||
|
||||
const app: ExpressApplication & Application<{}> = feathersExpress(feathers());
|
||||
const app = feathersExpress(feathers());
|
||||
|
||||
app.configure(rest());
|
||||
app.use(notFound());
|
||||
app.use(errorHandler());
|
||||
|
||||
16
types/feathersjs__express/index.d.ts
vendored
16
types/feathersjs__express/index.d.ts
vendored
@@ -5,6 +5,18 @@
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import { Application as FeathersApplication } from '@feathersjs/feathers';
|
||||
import { Application as ExpressApplication } from 'express';
|
||||
import * as express from 'express';
|
||||
|
||||
export default function feathersExpress<T>(app: FeathersApplication<T>): ExpressApplication & FeathersApplication<T>;
|
||||
export default function feathersExpress<T>(app: FeathersApplication<T>): express.Application & FeathersApplication<T>;
|
||||
|
||||
export function errorHandler(options?: any): express.ErrorRequestHandler;
|
||||
export function notFound(): express.RequestHandler;
|
||||
export const rest: {
|
||||
(): () => void;
|
||||
formatter: express.RequestHandler;
|
||||
};
|
||||
|
||||
/*
|
||||
* Re-export of the express package. Can't be typed properly without just copying everything.
|
||||
**/
|
||||
export const original: any;
|
||||
|
||||
18
types/feathersjs__socket-commons/feathers.d.ts
vendored
18
types/feathersjs__socket-commons/feathers.d.ts
vendored
@@ -1,18 +0,0 @@
|
||||
declare module '@feathersjs/feathers' {
|
||||
import { Channel } from '@feathersjs/socket-commons';
|
||||
import { HookContext } from '@feathersjs/feathers';
|
||||
|
||||
export interface ServiceAddons<T> {
|
||||
publish(callback: (data: T, hook: HookContext<T>) => Channel): this
|
||||
|
||||
publish(event: string, callback: (data: T, hook: HookContext<T>) => Channel): this
|
||||
}
|
||||
|
||||
export interface Application<ServiceTypes = {}> {
|
||||
channel(...names: string[]): Channel;
|
||||
|
||||
publish<T>(callback: (data: T, hook: HookContext<T>) => Channel | Channel[]): Application<ServiceTypes>;
|
||||
|
||||
publish<T>(event: string, callback: (data: T, hook: HookContext<T>) => Channel | Channel[]): Application<ServiceTypes>;
|
||||
}
|
||||
}
|
||||
@@ -1 +1,9 @@
|
||||
const dummy: any = null;
|
||||
import feathers from '@feathersjs/feathers';
|
||||
|
||||
const app = feathers();
|
||||
|
||||
app.channel('abc').send({});
|
||||
|
||||
// check if the non-augmented @feathersjs/feathers typings still work
|
||||
app.on('asd', () => {});
|
||||
app.service('asd').get(0).then(() => {});
|
||||
|
||||
32
types/feathersjs__socket-commons/index.d.ts
vendored
32
types/feathersjs__socket-commons/index.d.ts
vendored
@@ -2,6 +2,34 @@
|
||||
// Project: http://feathersjs.com/
|
||||
// Definitions by: Jan Lohage <https://github.com/j2L4e>
|
||||
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import './socket-commons';
|
||||
import './feathers';
|
||||
import { HookContext } from '@feathersjs/feathers';
|
||||
|
||||
export type Connection = any; // todo: spec connection
|
||||
|
||||
export interface Channel {
|
||||
join(...connections: Connection[]): this;
|
||||
|
||||
leave(...connections: Connection[]): this;
|
||||
|
||||
filter(callback: (connection: Connection) => boolean): Channel;
|
||||
|
||||
send(data: any): this;
|
||||
}
|
||||
|
||||
declare module '@feathersjs/feathers' {
|
||||
interface ServiceAddons<T> {
|
||||
publish(callback: (data: T, hook: HookContext<T>) => Channel): this;
|
||||
|
||||
publish(event: string, callback: (data: T, hook: HookContext<T>) => Channel): this;
|
||||
}
|
||||
|
||||
interface Application<ServiceTypes> {
|
||||
channel(...names: string[]): Channel;
|
||||
|
||||
publish<T>(callback: (data: T, hook: HookContext<T>) => Channel | Channel[]): Application<ServiceTypes>;
|
||||
|
||||
publish<T>(event: string, callback: (data: T, hook: HookContext<T>) => Channel | Channel[]): Application<ServiceTypes>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
declare module '@feathersjs/socket-commons' {
|
||||
export type Connection = any; // todo: spec connection
|
||||
|
||||
export interface Channel {
|
||||
join(...connections: Connection[]): this;
|
||||
|
||||
leave(...connections: Connection[]): this;
|
||||
|
||||
filter(callback: (connection: Connection) => boolean): Channel;
|
||||
|
||||
send(data: any): this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user