Skip to content

Commit 4551064

Browse files
Better typing (#1942)
* Better typing * Fixing tests * Fixing tests
1 parent abcbd14 commit 4551064

File tree

7 files changed

+923
-926
lines changed

7 files changed

+923
-926
lines changed

admin/custom/assets/index-CEFrj8jA.js

Lines changed: 0 additions & 904 deletions
This file was deleted.

admin/custom/assets/index-DxyyYdTq.js

Lines changed: 904 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

admin/custom/customComponents.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build-backend/lib/javascript.d.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ declare global {
844844
min?: number;
845845
/** maximum value */
846846
max?: number;
847-
/** allowed interval for numeric values */
847+
/** the allowed interval for numeric values */
848848
step?: number;
849849
/** unit of the value */
850850
unit?: string;
@@ -1583,6 +1583,10 @@ declare global {
15831583
type: 'state';
15841584
common: StateCommon;
15851585
acl?: StateACL;
1586+
/** The IDs of enums this state is assigned to. For example ["enum.functions.Licht","enum.rooms.Garten"] */
1587+
enumIds?: string[];
1588+
/** The names of enums this state is assigned to. For example ["Licht","Garten"] */
1589+
enumNames?: Array<iobJS.StringOrTranslated>;
15861590
}
15871591

15881592
interface PartialStateObject extends Partial<Omit<StateObject, 'common' | 'acl'>> {
@@ -1663,7 +1667,7 @@ declare global {
16631667
version: string;
16641668
/** Array of blocked versions, each entry represents a semver range */
16651669
blockedVersions: string[];
1666-
/** If true the unsafe perm flag is needed on install */
1670+
/** If true, the unsafe perm flag is needed on install */
16671671
unsafePerm?: boolean;
16681672
/** If given, the packet name differs from the adapter name, e.g. because it is a scoped package */
16691673
packetName?: string;
@@ -1975,6 +1979,7 @@ declare global {
19751979

19761980
interface TypedState<T extends iobJS.StateValue = any> extends iobJS.State {
19771981
val: T;
1982+
notExist?: true;
19781983
}
19791984

19801985
interface AbsentState extends Omit<iobJS.State, 'ack' | 'from' | 'ts' | 'lc'> {
@@ -2234,7 +2239,7 @@ declare global {
22342239
* Otherwise, you need to provide a callback.
22352240
*/
22362241
getState<T extends iobJS.StateValue = any>(callback: GetStateCallback<T>): void;
2237-
getState<T extends iobJS.StateValue = any>(): TypedState<T> | null | undefined;
2242+
getState<T extends iobJS.StateValue = any>(): TypedState<T> | iobJS.AbsentState | null | undefined;
22382243
getStateAsync<T extends iobJS.StateValue = any>(): Promise<
22392244
TypedState<T> | iobJS.AbsentState | null | undefined
22402245
>;

io-package.json

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,6 @@
4040
"Matthias Kleine <info@haus-automatisierung.com>"
4141
],
4242
"news": {
43-
"9.0.10": {
44-
"en": "Added Blockly block to format a numeric value\nFixing some blocks in blockly: cron, time\nAdded new block: \"unconditional return\"\nType definitions for TypeScript were updated\nCorrected bug with deleting of sub-folders",
45-
"de": "Hinzugefügt Blockly Block, um einen numerischen Wert zu formatieren\nEinige Blöcke blockweise fixieren: cron, time\nNeuer Block hinzugefügt: \"bedingungslose Rückkehr\"\nTypdefinitionen für TypeScript wurden aktualisiert\nFehler behoben mit Löschen von Unterordner",
46-
"ru": "Добавлен блок Blockly для форматирования числового значения\nПочинка блоков в блоке: крон, время\nДобавлен новый блок: \"безусловный возврат\"\nОбновлены определения типов для TypeScript\nИсправлена ошибка с удалением подпапок",
47-
"pt": "Adicionado Bloco para formatar um valor numérico\nConsertando alguns blocos em bloco: cron, tempo\nAdicionado novo bloco: \"retorno incondicional\"\nAs definições de tipo para TypeScript foram atualizadas\nErro corrigido com a exclusão de subpastas",
48-
"nl": "Blockly blok toegevoegd om een numerieke waarde te formatteren\nHet repareren van wat blokken in blokjes: cron, tijd\nToegevoegd nieuw blok: \"onvoorwaardelijke terugkeer\"\nTypedefinities voor TypeScript zijn bijgewerkt\nGecorrigeerde bug met verwijderen van submappen",
49-
"fr": "Ajout d'un bloc bloc bloc pour formater une valeur numérique\nCorrection de quelques blocs en bloc : cron, temps\nAjout d'un nouveau bloc : « retour inconditionnel »\nLes définitions de type pour TypeScript ont été mises à jour\nCorrection du bogue avec suppression des sous-dossiers",
50-
"it": "Aggiunto Blockly per formattare un valore numerico\nFissare alcuni blocchi in blocco: cron, tempo\nAggiunto nuovo blocco: \"ritorno incondizionato\"\nLe definizioni di tipo per TypeScript sono state aggiornate\nCorretto bug con cancellazione di sotto-cartelle",
51-
"es": "Añadido Bloqueo bloqueado para formatear un valor numérico\nArreglar algunos bloques en bloque: cron, tiempo\nNuevo bloque añadido: \"retorno incondicional\"\nSe actualizaron las definiciones de tipo para TipoScript\nError corregido con eliminación de subcarpetas",
52-
"pl": "Dodano Blockly bloku do formatu wartości liczbowej\nNaprawianie niektórych bloków w blokowanych: cron, czas\nDodano nowy blok: \"bezwarunkowy powrót\"\nDefinicje typu dla TypeScript zostały zaktualizowane\nPoprawiony błąd z usuwaniem podfolderów",
53-
"uk": "Додано блокнот для форматування числового значення\nВиправлення деяких блоків в блокноті: cron, час\nДодано новий блок: \"безумовне повернення\"\nОновлено тип визначення для TypeScript\nВиправлена помилка з видаленням підпапок",
54-
"zh-cn": "添加块格式化一个数值\n整顿一些街区: cron, time\n新增块:\"无条件返回\"\n更新了 TypeScript 的类型定义\n删除子文件夹纠正错误"
55-
},
5643
"9.0.7": {
5744
"en": "Fixing some blocks in blockly: time, function",
5845
"de": "Einige Blocks blockieren: Zeit, Funktion",

src/lib/javascript.d.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ declare global {
844844
min?: number;
845845
/** maximum value */
846846
max?: number;
847-
/** allowed interval for numeric values */
847+
/** the allowed interval for numeric values */
848848
step?: number;
849849
/** unit of the value */
850850
unit?: string;
@@ -1583,6 +1583,10 @@ declare global {
15831583
type: 'state';
15841584
common: StateCommon;
15851585
acl?: StateACL;
1586+
/** The IDs of enums this state is assigned to. For example ["enum.functions.Licht","enum.rooms.Garten"] */
1587+
enumIds?: string[];
1588+
/** The names of enums this state is assigned to. For example ["Licht","Garten"] */
1589+
enumNames?: Array<iobJS.StringOrTranslated>;
15861590
}
15871591

15881592
interface PartialStateObject extends Partial<Omit<StateObject, 'common' | 'acl'>> {
@@ -1663,7 +1667,7 @@ declare global {
16631667
version: string;
16641668
/** Array of blocked versions, each entry represents a semver range */
16651669
blockedVersions: string[];
1666-
/** If true the unsafe perm flag is needed on install */
1670+
/** If true, the unsafe perm flag is needed on install */
16671671
unsafePerm?: boolean;
16681672
/** If given, the packet name differs from the adapter name, e.g. because it is a scoped package */
16691673
packetName?: string;
@@ -1975,6 +1979,7 @@ declare global {
19751979

19761980
interface TypedState<T extends iobJS.StateValue = any> extends iobJS.State {
19771981
val: T;
1982+
notExist?: true;
19781983
}
19791984

19801985
interface AbsentState extends Omit<iobJS.State, 'ack' | 'from' | 'ts' | 'lc'> {
@@ -2234,7 +2239,7 @@ declare global {
22342239
* Otherwise, you need to provide a callback.
22352240
*/
22362241
getState<T extends iobJS.StateValue = any>(callback: GetStateCallback<T>): void;
2237-
getState<T extends iobJS.StateValue = any>(): TypedState<T> | null | undefined;
2242+
getState<T extends iobJS.StateValue = any>(): TypedState<T> | iobJS.AbsentState | null | undefined;
22382243
getStateAsync<T extends iobJS.StateValue = any>(): Promise<
22392244
TypedState<T> | iobJS.AbsentState | null | undefined
22402245
>;

0 commit comments

Comments
 (0)