Skip to content

TypeScript type adjustments for Socket and Worker #1414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions typings/socket.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ declare module "socket" {
constructor(options: ListenerOptions);
callback: (this: Listener) => void;
}
type Socket = RawSocket | TCPSocket | UDPSocket;
var Socket: {
new <T extends RawSocketOptions | TCPSocketOptions | UDPSocketOptions>(
dictionary: T
Expand Down
34 changes: 29 additions & 5 deletions typings/worker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,45 @@
*/

declare module "worker" {
export interface Self {
export interface WorkerOptions {
static?: number;
chunk?: {
initial?: number;
incremental?: number;
};
heap?: {
initial?: number;
incremental?: number;
};
stack?: number;
keys?: {
initial?: number;
incremental?: number;
name?: number;
symbol?: number;
};
}

interface MessagePort {
onmessage(message: any): void;
postMessage(message: any): void;
}

class Worker implements Self {
constructor(module: string, options?: object)
terminate(): void;

class Worker implements MessagePort {
constructor(module: string, options?: WorkerOptions)
onmessage(message: any): void;
postMessage(message: any): void;
terminate(): void;
}

export class SharedWorker {
constructor(module: string, options?: object)
get port(): MessagePort
}


export interface Self extends MessagePort {
close(): void;
}

global {
Expand Down