Created
February 22, 2017 20:33
-
-
Save richseviora/7479889d210014b57d2d75da2b78ec16 to your computer and use it in GitHub Desktop.
Twilio Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Twilio { | |
Device = { | |
setup: function () { }, | |
ready: function () { }, | |
offline: function () { }, | |
incoming: function () { }, | |
connect: function (params): Twilio.Connection { return null }, | |
error: function () { } | |
} | |
} | |
namespace NodeJS { | |
interface Global { | |
Twilio : { | |
Device : Twilio.IDevice; | |
}; | |
} | |
} | |
beforeEach(() => { | |
Twilio.Device.setup = () => {return null;}; | |
}) | |
test('adds stuff', () => { | |
expect(Twilio.Device).toBeTruthy() | |
expect(Twilio.Device.setup(null, null)).toBeNull() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare namespace Twilio { | |
class Connection { | |
// Constructor does not appear to be available to user. | |
private constructor(); | |
// Add Connection Methods and Properties Here | |
} | |
type DeviceCallback = (device : IDevice) => void; | |
// Not immediately clear if Twilio.Device is a class or not. | |
interface IDevice { | |
setup(token, options); | |
ready(handler: DeviceCallback) : void; | |
offline(handler : DeviceCallback) : void; | |
error(handler : DeviceCallback) : void; | |
incoming(handler); | |
connect(params) : Connection; | |
// Add Remainder of Twilio.Device properties here. | |
} | |
/** | |
* Twilio.Device appears to be a singleton object that | |
* you don't instantiate yourself. You can use | |
* the below to declare its presence. | |
*/ | |
let Device : IDevice; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment