Skip to content
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

[items] Fix type def issues due to private method in Item class #394

Merged
merged 1 commit into from
Nov 3, 2024
Merged
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
2 changes: 2 additions & 0 deletions build/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Change this to match your project
"include": ["../src/**/*.js"],
"exclude": [
"../src/helpers.js",
"../src/index.js",
"../test/**",
"../coverage/**",
"../dist/**",
Expand Down
8 changes: 4 additions & 4 deletions src/items/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,11 @@ class Item {
* Calculates the toggled state of this Item.
* For Items like Color and Dimmer, getStateAs(OnOffType) is used and the toggle calculated of that.
*
* @private
* @ignore
* @returns the toggled state (e.g. 'OFF' if the Item is 'ON')
* @throws error if the Item is uninitialized or is a type that doesn't make sense to toggle
*/
#getToggleState () {
getToggleState () {
if (this.isUninitialized) {
throw Error('Cannot toggle uninitialized Items');
}
Expand Down Expand Up @@ -366,7 +366,7 @@ class Item {
if (this.type === 'Contact') {
throw Error('Cannot command Contact Items');
}
this.sendCommand(this.#getToggleState());
this.sendCommand(this.getToggleState());
}

/**
Expand All @@ -375,7 +375,7 @@ class Item {
* @throws error if the Item is uninitialized or a type that cannot be toggled
*/
postToggleUpdate () {
this.postUpdate(this.#getToggleState());
this.postUpdate(this.getToggleState());
}

/**
Expand Down
10 changes: 9 additions & 1 deletion types/items/items.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ export class Item {
* @return {boolean} true if the command was sent, false otherwise
*/
sendDecreaseCommand(value: number | Quantity | HostState): boolean;
/**
* Calculates the toggled state of this Item.
* For Items like Color and Dimmer, getStateAs(OnOffType) is used and the toggle calculated of that.
*
* @ignore
* @returns the toggled state (e.g. 'OFF' if the Item is 'ON')
* @throws error if the Item is uninitialized or is a type that doesn't make sense to toggle
*/
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
/**
* Sends a command to flip the Item's state (e.g. if it is 'ON' an 'OFF' command is sent).
* @throws error if the Item is uninitialized or a type that cannot be toggled or commanded
Expand Down Expand Up @@ -317,7 +326,6 @@ export class Item {
*/
removeTags(...tagNames: string[]): void;
toString(): any;
#private;
}
import metadata = require("./metadata/metadata");
import TimeSeries = require("./time-series");
Expand Down
2 changes: 1 addition & 1 deletion types/items/items.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/items/metadata/itemchannellink.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type Item = {
sendCommandIfDifferent(value: any): boolean;
sendIncreaseCommand(value: any): boolean;
sendDecreaseCommand(value: any): boolean;
"__#6@#getToggleState"(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
sendToggleCommand(): void;
postToggleUpdate(): void;
postUpdate(value: any): void;
Expand Down
2 changes: 1 addition & 1 deletion types/items/metadata/metadata.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type Item = {
sendCommandIfDifferent(value: any): boolean;
sendIncreaseCommand(value: any): boolean;
sendDecreaseCommand(value: any): boolean;
"__#6@#getToggleState"(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
sendToggleCommand(): void;
postToggleUpdate(): void;
postUpdate(value: any): void;
Expand Down
2 changes: 1 addition & 1 deletion types/quantity.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type Item = {
sendCommandIfDifferent(value: any): boolean;
sendIncreaseCommand(value: any): boolean;
sendDecreaseCommand(value: any): boolean;
"__#6@#getToggleState"(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
sendToggleCommand(): void;
postToggleUpdate(): void;
postUpdate(value: any): void;
Expand Down
2 changes: 1 addition & 1 deletion types/rules/operation-builder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type Item = {
sendCommandIfDifferent(value: any): boolean;
sendIncreaseCommand(value: any): boolean;
sendDecreaseCommand(value: any): boolean;
"__#6@#getToggleState"(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF"; /** @private */
sendToggleCommand(): void;
postToggleUpdate(): void;
postUpdate(value: any): void;
Expand Down
2 changes: 1 addition & 1 deletion types/rules/operation-builder.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/triggers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type Item = {
sendCommandIfDifferent(value: any): boolean;
sendIncreaseCommand(value: any): boolean;
sendDecreaseCommand(value: any): boolean;
"__#6@#getToggleState"(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
sendToggleCommand(): void;
postToggleUpdate(): void;
postUpdate(value: any): void;
Expand Down
Loading