Skip to content

Commit 0ec2f5e

Browse files
authored
[items] Fix type def issues due to private method in Item class (#394)
Private methods are not supported by .d.ts type declarations, so do not use them! Refs #392. Signed-off-by: Florian Hotze <[email protected]>
1 parent 1c7399b commit 0ec2f5e

10 files changed

+22
-12
lines changed

build/tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Change this to match your project
33
"include": ["../src/**/*.js"],
44
"exclude": [
5+
"../src/helpers.js",
6+
"../src/index.js",
57
"../test/**",
68
"../coverage/**",
79
"../dist/**",

src/items/items.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,11 @@ class Item {
334334
* Calculates the toggled state of this Item.
335335
* For Items like Color and Dimmer, getStateAs(OnOffType) is used and the toggle calculated of that.
336336
*
337-
* @private
337+
* @ignore
338338
* @returns the toggled state (e.g. 'OFF' if the Item is 'ON')
339339
* @throws error if the Item is uninitialized or is a type that doesn't make sense to toggle
340340
*/
341-
#getToggleState () {
341+
getToggleState () {
342342
if (this.isUninitialized) {
343343
throw Error('Cannot toggle uninitialized Items');
344344
}
@@ -366,7 +366,7 @@ class Item {
366366
if (this.type === 'Contact') {
367367
throw Error('Cannot command Contact Items');
368368
}
369-
this.sendCommand(this.#getToggleState());
369+
this.sendCommand(this.getToggleState());
370370
}
371371

372372
/**
@@ -375,7 +375,7 @@ class Item {
375375
* @throws error if the Item is uninitialized or a type that cannot be toggled
376376
*/
377377
postToggleUpdate () {
378-
this.postUpdate(this.#getToggleState());
378+
this.postUpdate(this.getToggleState());
379379
}
380380

381381
/**

types/items/items.d.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@ export class Item {
267267
* @return {boolean} true if the command was sent, false otherwise
268268
*/
269269
sendDecreaseCommand(value: number | Quantity | HostState): boolean;
270+
/**
271+
* Calculates the toggled state of this Item.
272+
* For Items like Color and Dimmer, getStateAs(OnOffType) is used and the toggle calculated of that.
273+
*
274+
* @ignore
275+
* @returns the toggled state (e.g. 'OFF' if the Item is 'ON')
276+
* @throws error if the Item is uninitialized or is a type that doesn't make sense to toggle
277+
*/
278+
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
270279
/**
271280
* Sends a command to flip the Item's state (e.g. if it is 'ON' an 'OFF' command is sent).
272281
* @throws error if the Item is uninitialized or a type that cannot be toggled or commanded
@@ -317,7 +326,6 @@ export class Item {
317326
*/
318327
removeTags(...tagNames: string[]): void;
319328
toString(): any;
320-
#private;
321329
}
322330
import metadata = require("./metadata/metadata");
323331
import TimeSeries = require("./time-series");

types/items/items.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

types/items/metadata/itemchannellink.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type Item = {
3333
sendCommandIfDifferent(value: any): boolean;
3434
sendIncreaseCommand(value: any): boolean;
3535
sendDecreaseCommand(value: any): boolean;
36-
"__#6@#getToggleState"(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
36+
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
3737
sendToggleCommand(): void;
3838
postToggleUpdate(): void;
3939
postUpdate(value: any): void;

types/items/metadata/metadata.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export type Item = {
2424
sendCommandIfDifferent(value: any): boolean;
2525
sendIncreaseCommand(value: any): boolean;
2626
sendDecreaseCommand(value: any): boolean;
27-
"__#6@#getToggleState"(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
27+
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
2828
sendToggleCommand(): void;
2929
postToggleUpdate(): void;
3030
postUpdate(value: any): void;

types/quantity.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export type Item = {
3737
sendCommandIfDifferent(value: any): boolean;
3838
sendIncreaseCommand(value: any): boolean;
3939
sendDecreaseCommand(value: any): boolean;
40-
"__#6@#getToggleState"(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
40+
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
4141
sendToggleCommand(): void;
4242
postToggleUpdate(): void;
4343
postUpdate(value: any): void;

types/rules/operation-builder.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type Item = {
3333
sendCommandIfDifferent(value: any): boolean;
3434
sendIncreaseCommand(value: any): boolean;
3535
sendDecreaseCommand(value: any): boolean;
36-
"__#6@#getToggleState"(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
36+
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF"; /** @private */
3737
sendToggleCommand(): void;
3838
postToggleUpdate(): void;
3939
postUpdate(value: any): void;

types/rules/operation-builder.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

types/triggers.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type Item = {
3333
sendCommandIfDifferent(value: any): boolean;
3434
sendIncreaseCommand(value: any): boolean;
3535
sendDecreaseCommand(value: any): boolean;
36-
"__#6@#getToggleState"(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
36+
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
3737
sendToggleCommand(): void;
3838
postToggleUpdate(): void;
3939
postUpdate(value: any): void;

0 commit comments

Comments
 (0)