From 075eb40cdd73646b6c349c5ccba8c65c65cd222f Mon Sep 17 00:00:00 2001 From: AlCalzone Date: Wed, 15 Apr 2020 05:31:47 +0200 Subject: [PATCH] [iobroker] add object type "folder" (#43819) --- types/iobroker/index.d.ts | 13 +++++++++++-- types/iobroker/iobroker-tests.ts | 11 +++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/types/iobroker/index.d.ts b/types/iobroker/index.d.ts index 210c17d6cf..0ace066307 100644 --- a/types/iobroker/index.d.ts +++ b/types/iobroker/index.d.ts @@ -183,6 +183,15 @@ declare global { common?: Partial; } + interface FolderObject extends BaseObject { + type: 'folder'; + // Nothing is set in stone here, so start with allowing every property + common: OtherCommon; + } + interface PartialFolderObject extends Partial> { + common?: Partial; + } + interface OtherObject extends BaseObject { type: 'adapter' | 'config' | 'enum' | 'group' | 'host' | 'info' | 'instance' | 'meta' | 'script' | 'user'; common: OtherCommon; @@ -191,7 +200,7 @@ declare global { common?: Partial; } - type Object = StateObject | ChannelObject | DeviceObject | OtherObject; + type Object = StateObject | ChannelObject | DeviceObject | FolderObject | OtherObject; type SettableObjectWorker = Pick> & { _id?: T['_id']; @@ -200,7 +209,7 @@ declare global { // In set[Foreign]Object[NotExists] methods, the ID and acl of the object is optional type SettableObject = SettableObjectWorker; - type PartialObject = PartialStateObject | PartialChannelObject | PartialDeviceObject | PartialOtherObject; + type PartialObject = PartialStateObject | PartialChannelObject | PartialDeviceObject | PartialFolderObject | PartialOtherObject; /** Defines access rights for a single file */ interface FileACL { diff --git a/types/iobroker/iobroker-tests.ts b/types/iobroker/iobroker-tests.ts index 79f4ffd9ff..ce524567e9 100644 --- a/types/iobroker/iobroker-tests.ts +++ b/types/iobroker/iobroker-tests.ts @@ -386,6 +386,17 @@ function repro3() { }); } +const folderObj: ioBroker.FolderObject = { + _id: "id", + type: "folder", + common: { + name: "something", + // any property is allowed + foo: "bar", + }, + native: {}, +}; + // Repro from https://github.com/ioBroker/ioBroker.js-controller/issues/782 // $ExpectError adapter.setState("id", {ack: false});