Merge pull request #21847 from Yitzchok/master

types for npm package jschannel
This commit is contained in:
Armando Aguirre
2017-11-29 18:32:43 -08:00
committed by GitHub
4 changed files with 73 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
// Type definitions for jschannel 1.0
// Project: https://github.com/yochannah/jschannel
// Definitions by: Yitzchok Gottlieb <https://github.com/yitzchok>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
export as namespace Channel;
export function build(config: ChannelConfiguration): 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;
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<string>;
}
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;
}
+3
View File
@@ -0,0 +1,3 @@
import { build } from 'jschannel';
build({ window: null, origin: "*", scope: "testScope"});
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jschannel-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }