Skip to content

Commit

Permalink
Reference option types as Partial<T> in arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
André Wachter committed Nov 13, 2017
1 parent 131445a commit be9936c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ interface AssembleOptions {
importHook: (filePath: string, type: 'idl', callback: Callback<object>) => void;
}

export function assembleProtocol(filePath: string, opts: AssembleOptions, callback: Callback<object>): void;
export function assembleProtocol(filePath: string, opts: Partial<AssembleOptions>, callback: Callback<object>): void;
export function assembleProtocol(filePath: string, callback: Callback<object>): void;
export function createFileDecoder(fileName: string, codecs?: CodecOptions): Decoder;
export function createFileDecoder(fileName: string, codecs?: Partial<CodecOptions>): Decoder;
export function createFileEncoder(filePath: string, schema: any, options?: any): Encoder;
export function discoverProtocol(transport: Service.Transport, options: any, callback: Callback<any>): void;
export function discoverProtocol(transport: Service.Transport, callback: Callback<any>): void;
export function extractFileHeader(filePath: string, options?: any): void;
export function parse(schemaOrProtocolIdl: string, options?: any): Service.Protocol | Type.Type; // TODO
export function readProtocol(protocolIdl: string, options?: ReaderOptions): Service.Protocol;
export function readProtocol(protocolIdl: string, options?: Partial<ReaderOptions>): Service.Protocol;
export function readSchema(schemaIdl: string, options?: Partial<ReaderOptions>): Schema;
// TODO streams
// TODO types
Expand Down Expand Up @@ -107,8 +107,8 @@ export namespace Service {
}

interface Service {
createClient(options?: ClientOptions): Client;
createServer(options?: ServerOptions): Server;
createClient(options?: Partial<ClientOptions>): Client;
createServer(options?: Partial<ServerOptions>): Server;
message(name: string): any;
type(name: string): any;
}
Expand All @@ -129,22 +129,22 @@ export namespace Service {
readonly service: Service;
// on<message>()
activeChannels(): ServerChannel[];
createChannel(transport: Transport, options?: ChannelCreateOptions): ServerChannel;
createChannel(transport: Transport, options?: Partial<ChannelCreateOptions>): ServerChannel;
onMessage<T>(name: string, handler: (arg1: any, callback: Callback<T>) => void): this;
remoteProtocols(): Protocol[];
use(...args: any[]): this;
}

interface Client extends EventEmitter {
activeChannels(): ClientChannel[];
createChannel(transport: Transport, options?: ChannelCreateOptions): ClientChannel;
destroyChannels(options?: ChannelDestroyOptions): void;
createChannel(transport: Transport, options?: Partial<ChannelCreateOptions>): ClientChannel;
destroyChannels(options?: Partial<ChannelDestroyOptions>): void;
emitMessage<T>(name: string, req: any, options?: any, callback?: Callback<T>): void // TODO
remoteProtocols(): Protocol[];
use(...args: any[]): this;
}

function compatible(client: Client, server: Server): boolean;
function forProtocol(protocol: Protocol): Service;
function forProtocol(protocol: Protocol, options: any): Service;
function isService(obj: any): boolean;
}

0 comments on commit be9936c

Please sign in to comment.