From 712759ce5e85e91020b81cea8c3daa08d8d2cddf Mon Sep 17 00:00:00 2001 From: Desmond Koh Date: Mon, 1 Jul 2019 23:30:18 +0800 Subject: [PATCH] Export SOCKET_KEY from feathersjs/socket.io (#36099) * 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. * fix: Handle multiple dependent keys * Updated header * fix lint errors * fix lint errors * Added SOCKET_KEY export. * Updated header. * Removed unecessary imports. --- .../feathersjs__socketio-tests.ts | 4 +++- types/feathersjs__socketio/index.d.ts | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/types/feathersjs__socketio/feathersjs__socketio-tests.ts b/types/feathersjs__socketio/feathersjs__socketio-tests.ts index 2e99e19f23..e40ec10897 100644 --- a/types/feathersjs__socketio/feathersjs__socketio-tests.ts +++ b/types/feathersjs__socketio/feathersjs__socketio-tests.ts @@ -1,5 +1,5 @@ import feathers, { Application } from '@feathersjs/feathers'; -import feathersSocketIO from '@feathersjs/socketio'; +import feathersSocketIO, { SOCKET_KEY } from '@feathersjs/socketio'; const app: Application = feathers(); @@ -8,3 +8,5 @@ app.configure(feathersSocketIO(io => {})); app.configure(feathersSocketIO({}, io => {})); app.configure(feathersSocketIO(1337, io => {})); app.configure(feathersSocketIO(1337, {}, io => {})); + +const key = SOCKET_KEY; diff --git a/types/feathersjs__socketio/index.d.ts b/types/feathersjs__socketio/index.d.ts index 94d926911e..67fca942ad 100644 --- a/types/feathersjs__socketio/index.d.ts +++ b/types/feathersjs__socketio/index.d.ts @@ -1,12 +1,19 @@ // Type definitions for @feathersjs/socketio 3.0 // Project: https://feathersjs.com // Definitions by: Jan Lohage +// Desmond Koh // Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript // TypeScript Version: 2.8 -/// -import SocketIO = require("socket.io"); +import * as io from 'socket.io'; -export default function feathersSocketIO(callback?: (io: SocketIO.Server) => void): () => void; -export default function feathersSocketIO(options: number | SocketIO.ServerOptions, callback?: (io: SocketIO.Server) => void): () => void; -export default function feathersSocketIO(port: number, options?: SocketIO.ServerOptions, callback?: (io: SocketIO.Server) => void): () => void; +declare const socketio: FeathersSocketIO; +export = socketio; + +interface FeathersSocketIO { + (callback?: (io: io.Server) => void): () => void; + (options: number | io.ServerOptions, callback?: (io: io.Server) => void): () => void; + (port: number, options?: io.ServerOptions, callback?: (io: io.Server) => void): () => void; + readonly SOCKET_KEY: unique symbol; + default: FeathersSocketIO; +}