From c4b9845ebb812a3c75a8c2e8cb311c2c8e939356 Mon Sep 17 00:00:00 2001 From: Niels Becker Date: Fri, 20 Mar 2020 12:41:14 +0100 Subject: [PATCH] add missing types --- templates/typescript-class.ts.hbs | 8 ++++---- types.d.ts | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/templates/typescript-class.ts.hbs b/templates/typescript-class.ts.hbs index 5e6e3d8..2c771a3 100644 --- a/templates/typescript-class.ts.hbs +++ b/templates/typescript-class.ts.hbs @@ -42,14 +42,14 @@ export class {{className $.name}} extends EventEmitter { } // forward all signals - this.on("newListener", (event, listener) => { + this.on("newListener", (event: string, listener: (...args: any[]) => void) => { if(event === "PropertiesChanged" && this.listenerCount('PropertiesChanged') === 0) { this.propertiesDBusInterface.on('PropertiesChanged', forwardPropertyChange); } else { this.thisDBusInterface.on(event, listener); } }); - this.on("removeListener", (event, listener) => { + this.on("removeListener", (event: string, listener: (...args: any[]) => void) => { if(event === "PropertiesChanged" && this.listenerCount('PropertiesChanged') === 0) { this.propertiesDBusInterface.removeListener('PropertiesChanged', forwardPropertyChange); } else { @@ -75,7 +75,7 @@ export class {{className $.name}} extends EventEmitter { {{#each property}} //@property({ name: '{{$.name}}', signature: '{{$.type}}', access: {{accessConst $.access}} }){{#ifeq $.access "read"}} public {{$.name}}(): Promise<{{tsType $.type}}> { - return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}'){{#unlesseq $.type "v"}}.then((variant) => variant.value){{/unlesseq}}; + return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}'){{#unlesseq $.type "v"}}.then((variant: DBus.Variant) => variant.value){{/unlesseq}}; }{{/ifeq}}{{#ifeq $.access "write"}} public {{$.name}}(value: {{tsType $.type}}): Promise { return this.propertiesDBusInterface.Set(this.dbusInterfaceName, '{{$.name}}', {{#ifeq $.type "v"}}value{{else}}new DBus.Variant("{{$.type}}", value){{/ifeq}}); @@ -86,7 +86,7 @@ export class {{className $.name}} extends EventEmitter { if(value !== undefined) { return this.propertiesDBusInterface.Set(this.dbusInterfaceName, '{{$.name}}', {{#ifeq $.type "v"}}value{{else}}new DBus.Variant("{{$.type}}", value){{/ifeq}}); } else { - return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}'){{#unlesseq $.type "v"}}.then((variant) => variant.value){{/unlesseq}}; + return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}'){{#unlesseq $.type "v"}}.then((variant: DBus.Variant) => variant.value){{/unlesseq}}; } }{{/ifeq}} diff --git a/types.d.ts b/types.d.ts index b257787..067ef61 100644 --- a/types.d.ts +++ b/types.d.ts @@ -53,6 +53,8 @@ declare module 'dbus-next' { export class Variant { signature: string; value: T; + constructor(); + constructor(signatur: string, value: T); } export class DBusError extends Error { type: string; @@ -96,8 +98,7 @@ declare module 'dbus-next' { } export class MessageBus { - getProxyObject(name: string, path: string): Promise; - getProxyObject(name: string, path: string, xml: string): Promise; + getProxyObject(name: string, path: string, xml?: string): Promise; disconnect(): void; export(path: ObjectPath, interface: interface.Interface): void; @@ -133,6 +134,7 @@ declare module 'dbus-next' { busAddress?: string; } + export function setBigIntCompat(state: boolean): void; export function systemBus(): MessageBus; export function sessionBus(options?: BusOptions): MessageBus; }