diff --git a/types/socketio-wildcard/index.d.ts b/types/socketio-wildcard/index.d.ts new file mode 100644 index 0000000000..3170a27ca5 --- /dev/null +++ b/types/socketio-wildcard/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for socketio-wildcard 2.0 +// Project: https://github.com/hden/socketio-wildcard +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +import EventEmitter = NodeJS.EventEmitter; +import Socket = SocketIO.Socket; +import ClientSocket = SocketIOClient.Socket; + +export = sioWildcard; + +declare function sioWildcard(emitterCtor?: { prototype: typeof EventEmitter.prototype }): (socket: Socket | ClientSocket, next?: (err?: any) => void) => void; diff --git a/types/socketio-wildcard/socketio-wildcard-tests.ts b/types/socketio-wildcard/socketio-wildcard-tests.ts new file mode 100644 index 0000000000..3d479ef3f9 --- /dev/null +++ b/types/socketio-wildcard/socketio-wildcard-tests.ts @@ -0,0 +1,24 @@ +import ioBuilder = require('socket.io'); +const io = ioBuilder(); +import middlewareBuilder = require('socketio-wildcard'); +const middleware = middlewareBuilder(); + +io.use(middleware); + +io.on('connection', (socket) => { + socket.on('*', (packet) => { + // client.emit('foo', 'bar', 'baz') + packet.data === ['foo', 'bar', 'baz']; + }); +}); + +io.listen(8000); + +import clientIo = require('socket.io-client'); +const socket = clientIo('http://localhost'); +import patchBuilder = require('socketio-wildcard'); +const patch = patchBuilder(clientIo.Manager); +patch(socket); + +socket.on('*', () => { +}); diff --git a/types/socketio-wildcard/tsconfig.json b/types/socketio-wildcard/tsconfig.json new file mode 100644 index 0000000000..ee0d3805f4 --- /dev/null +++ b/types/socketio-wildcard/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "socketio-wildcard-tests.ts" + ] +} diff --git a/types/socketio-wildcard/tslint.json b/types/socketio-wildcard/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/socketio-wildcard/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }