diff --git a/types/burns/burns-tests.ts b/types/burns/burns-tests.ts new file mode 100644 index 0000000000..e1fd41ad09 --- /dev/null +++ b/types/burns/burns-tests.ts @@ -0,0 +1,29 @@ +import burns from 'burns'; + +interface OrderData { + userName: string; + orderId: string; +} + +function handleEverything() { + console.log('Do absolutely nothing! 😄'); +} + +function sendEmail(message: string) { + console.log(message); +} + +function sendOrderShippedEmail(data: OrderData) { + sendEmail(`Hi ${data.userName}, Your order ${data.orderId} has been shipped`); +} + +burns.configure({ + defaultHandler: handleEverything +}); +burns.registerEvents({ + newPurchase: sendOrderShippedEmail +}); +burns.dispatch('newPurchase', { + userName: 'Johnny', + orderId: 'rand' +}); diff --git a/types/burns/index.d.ts b/types/burns/index.d.ts new file mode 100644 index 0000000000..af1d86c9e6 --- /dev/null +++ b/types/burns/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for burns version 2.0.1 +// Project: https://github.com/shalvah/burns +// Definitions by: Timothy Onyiuke +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare const _Burns: Burns; + +export interface Config { + defaultHandler?: any; + broadcaster?: any; + pusher?: any; +} + +export interface ObjectLiteral { + [key: string]: any +} + +declare class Burns { + configure(config?: Config): this; + + registerEvents(newEvents: ObjectLiteral): this; + + dispatch(eventName: string, eventData?: ObjectLiteral, exclude?: { exclude?: any }): this; +} + +export default _Burns; \ No newline at end of file diff --git a/types/burns/tsconfig.json b/types/burns/tsconfig.json new file mode 100644 index 0000000000..45af42852b --- /dev/null +++ b/types/burns/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "burns-tests.ts" + ] +} \ No newline at end of file diff --git a/types/burns/tslint.json b/types/burns/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/burns/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }