From e2ec165c87388041342988f6d82c17511903c454 Mon Sep 17 00:00:00 2001 From: Yitzchok Gottlieb Date: Wed, 29 Nov 2017 13:26:37 -0500 Subject: [PATCH 1/5] Add jschannel --- types/jschannel/index.d.ts | 46 ++++++++++++++++++++++++++++++ types/jschannel/jschannel-tests.ts | 0 types/jschannel/tsconfig.json | 22 ++++++++++++++ types/jschannel/tslint.json | 1 + 4 files changed, 69 insertions(+) create mode 100644 types/jschannel/index.d.ts create mode 100644 types/jschannel/jschannel-tests.ts create mode 100644 types/jschannel/tsconfig.json create mode 100644 types/jschannel/tslint.json diff --git a/types/jschannel/index.d.ts b/types/jschannel/index.d.ts new file mode 100644 index 0000000000..13946e83ee --- /dev/null +++ b/types/jschannel/index.d.ts @@ -0,0 +1,46 @@ +// Type definitions for jschannel 1.0.2 +// Project: https://github.com/yochannah/jschannel +// Definitions by: Yitzchok Gottlieb +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +export as namespace Channel; + +export function build(config: ChannelConfiguration): MessagingChannel; + +interface MessagingChannel { + unbind: (method: string, doNotPublish?: boolean) => boolean; + bind: (method: string, callback?: (transaction: MessageTransaction, params: any) => void, doNotPublish?: boolean) => MessagingChannel; + call: (message: Message) => void; + notify: (message: Message) => void; + destroy: () => void; +} + +export interface Message { + method: string; + success?: (result: any) => void; + params?: any; + timeout?: number; + error?: (error: any, message: string) => void; +} + +export interface ChannelConfiguration { + window: any; + origin: string; + scope: string; + debugOutput?: boolean; + postMessageObserver?: (origin: string, message: Message) => void; + gotMessageObserver?: (origin: string, message: Message) => void; + onReady?: (channel: MessagingChannel) => void; + reconnect?: boolean; + publish?: boolean; + remote?: string | ReadonlyArray; +} + +export interface MessageTransaction { + delayReturn: (delay: boolean) => boolean; + complete: (result: any) => void; + error: (error: any, message: string) => void; + invoke: (callbackName: string, params: any) => void; + completed: () => boolean; +} diff --git a/types/jschannel/jschannel-tests.ts b/types/jschannel/jschannel-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/jschannel/tsconfig.json b/types/jschannel/tsconfig.json new file mode 100644 index 0000000000..96fdb53367 --- /dev/null +++ b/types/jschannel/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", + "jschannel-tests.ts" + ] +} diff --git a/types/jschannel/tslint.json b/types/jschannel/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/jschannel/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From de11c43c2ca552c1ccbd8b7afb416ba7ff6620d0 Mon Sep 17 00:00:00 2001 From: Yitzchok Gottlieb Date: Wed, 29 Nov 2017 15:40:27 -0500 Subject: [PATCH 2/5] Set strictFunctionTypes --- types/jschannel/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/jschannel/tsconfig.json b/types/jschannel/tsconfig.json index 96fdb53367..83727a281c 100644 --- a/types/jschannel/tsconfig.json +++ b/types/jschannel/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 847d1575c244daab4531beb4c6f757568f860bf6 Mon Sep 17 00:00:00 2001 From: Yitzchok Gottlieb Date: Wed, 29 Nov 2017 16:40:57 -0500 Subject: [PATCH 3/5] Fix version --- types/jschannel/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jschannel/index.d.ts b/types/jschannel/index.d.ts index 13946e83ee..285cff37b9 100644 --- a/types/jschannel/index.d.ts +++ b/types/jschannel/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jschannel 1.0.2 +// Type definitions for jschannel 1.0 // Project: https://github.com/yochannah/jschannel // Definitions by: Yitzchok Gottlieb // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From fa7f52df8beaac56068b84078399df45dcc97c3f Mon Sep 17 00:00:00 2001 From: Yitzchok Gottlieb Date: Wed, 29 Nov 2017 16:41:04 -0500 Subject: [PATCH 4/5] Export interface --- types/jschannel/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jschannel/index.d.ts b/types/jschannel/index.d.ts index 285cff37b9..42145531ea 100644 --- a/types/jschannel/index.d.ts +++ b/types/jschannel/index.d.ts @@ -8,7 +8,7 @@ export as namespace Channel; export function build(config: ChannelConfiguration): MessagingChannel; -interface MessagingChannel { +export interface MessagingChannel { unbind: (method: string, doNotPublish?: boolean) => boolean; bind: (method: string, callback?: (transaction: MessageTransaction, params: any) => void, doNotPublish?: boolean) => MessagingChannel; call: (message: Message) => void; From 5d8c5e2a4f58c5e0b825c77517dacde78d94bbd6 Mon Sep 17 00:00:00 2001 From: Yitzchok Gottlieb Date: Wed, 29 Nov 2017 16:41:24 -0500 Subject: [PATCH 5/5] Add test content --- types/jschannel/jschannel-tests.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/jschannel/jschannel-tests.ts b/types/jschannel/jschannel-tests.ts index e69de29bb2..eabd150bf2 100644 --- a/types/jschannel/jschannel-tests.ts +++ b/types/jschannel/jschannel-tests.ts @@ -0,0 +1,3 @@ +import { build } from 'jschannel'; + +build({ window: null, origin: "*", scope: "testScope"});