Skip to content

Commit 6fee6cb

Browse files
authored
Fix clients cannot resolve some types (2nd try) (#544)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
1 parent fb82965 commit 6fee6cb

4 files changed

Lines changed: 97 additions & 63 deletions

File tree

build/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
// Change this to match your project
3-
"include": ["../src/**/*.js", "../src/globals.d.ts"],
3+
"include": ["../src/**/*.js", "../src/globals.d.ts", "../src/java.d.ts"],
44
"exclude": [
55
"../src/helpers.js",
66
"../src/index.js",

src/globals.d.ts

Lines changed: 6 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,15 @@
1-
declare global {
2-
/**
3-
* Native Java Class Object (instance of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Class.html java.lang.Class})
4-
*/
5-
type JavaClass = object;
6-
/**
7-
* Native Java BigDecimal (instance of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/math/BigDecimal.html java.math.BigDecimal})
8-
*/
9-
type JavaBigDecimal = object;
10-
/**
11-
* Native Java Set Object (instance of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html java.util.Set})
12-
*/
13-
type JavaSet = object;
14-
/**
15-
* Native Java List Object (instance of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html java.util.List})
16-
*/
17-
type JavaList = object;
18-
/**
19-
* Native Java Map Object (implementation of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html java.util.Map})
20-
*/
21-
type JavaMap = object;
22-
/**
23-
* Native Java Instant Object (instance of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Instant.html java.time.Instant})
24-
*/
25-
type JavaInstant = object;
26-
/**
27-
* Native Java ZonedDateTime Object (instance of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/ZonedDateTime.html java.time.ZonedDateTime})
28-
*/
29-
type JavaZonedDateTime = object;
30-
/**
31-
* Native Java openHAB State (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/types/state org.openhab.core.types.State})
32-
*/
33-
type HostState = object;
34-
/**
35-
* Native Java openHAB Item (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/items/item org.openhab.core.items.Item})
36-
*/
37-
type HostItem = object;
38-
/**
39-
* Native Javea openHAB Rule (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/automation/rule org.openhab.core.automation.Rule})
40-
*/
41-
type HostRule = object;
42-
/**
43-
* Native Java openHAB Trigger (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/automation/trigger org.openhab.core.automation.Trigger})
44-
*/
45-
type HostTrigger = object;
46-
/**
47-
* Native Java openHAB Thing (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/thing/thing org.openhab.core.thing.Thing})
48-
*/
49-
type HostThing = object;
50-
/**
51-
* Native Java openHAB GroupFunction (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/items/groupfunction org.openhab.core.items.GroupFunction})
52-
*/
53-
type HostGroupFunction = object;
54-
/**
55-
* Native Java openHAB QuantityType (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/library/types/quantitytype org.openhab.core.library.types.QuantityType})
56-
*/
57-
type QuantityType = object;
1+
/// <reference path="./java.d.ts" />
582

3+
declare global {
594
namespace items {
605
type Item = InstanceType<typeof import('./items/items').Item>;
616
type ItemConfig = import('./items/items').ItemConfig;
627
type ItemMetadata = InstanceType<typeof import('./items/metadata').ItemMetadata>;
638
type TimeSeries = InstanceType<typeof import('./items/time-series')>;
64-
type ItemPersistence = InstanceType<typeof import('./items/item-persistence')>;
65-
type ItemSemantics = InstanceType<typeof import('./items/item-semantics')>;
66-
type PersistedItem = InstanceType<typeof import('./items/item-persistence').PersistedItem>;
67-
type PersistedState = InstanceType<typeof import('./items/item-persistence').PersistedState>;
9+
type ItemPersistence = InstanceType<typeof import('./items/items').ItemPersistence>;
10+
type ItemSemantics = InstanceType<typeof import('./items/items').ItemSemantics>;
11+
type PersistedItem = InstanceType<typeof import('./items/items').PersistedItem>;
12+
type PersistedState = InstanceType<typeof import('./items/items').PersistedState>;
6813
}
6914

7015
namespace time {

src/java.d.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
declare global {
2+
/**
3+
* Native Java Class Object (instance of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Class.html java.lang.Class})
4+
*/
5+
type JavaClass = object;
6+
/**
7+
* Native Java BigDecimal (instance of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/math/BigDecimal.html java.math.BigDecimal})
8+
*/
9+
type JavaBigDecimal = object;
10+
/**
11+
* Native Java Set Object (instance of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html java.util.Set})
12+
*/
13+
type JavaSet = object;
14+
/**
15+
* Native Java List Object (instance of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html java.util.List})
16+
*/
17+
type JavaList = object;
18+
/**
19+
* Native Java Map Object (implementation of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html java.util.Map})
20+
*/
21+
type JavaMap = object;
22+
/**
23+
* Native Java Instant Object (instance of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Instant.html java.time.Instant})
24+
*/
25+
type JavaInstant = object;
26+
/**
27+
* Native Java ZonedDateTime Object (instance of {@link https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/ZonedDateTime.html java.time.ZonedDateTime})
28+
*/
29+
type JavaZonedDateTime = object;
30+
/**
31+
* Native Java openHAB State (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/types/state org.openhab.core.types.State})
32+
*/
33+
type HostState = object;
34+
/**
35+
* Native Java openHAB Item (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/items/item org.openhab.core.items.Item})
36+
*/
37+
type HostItem = object;
38+
/**
39+
* Native Java openHAB Rule (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/automation/rule org.openhab.core.automation.Rule})
40+
*/
41+
type HostRule = object;
42+
/**
43+
* Native Java openHAB Trigger (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/automation/trigger org.openhab.core.automation.Trigger})
44+
*/
45+
type HostTrigger = object;
46+
/**
47+
* Native Java openHAB Thing (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/thing/thing org.openhab.core.thing.Thing})
48+
*/
49+
type HostThing = object;
50+
/**
51+
* Native Java openHAB GroupFunction (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/items/groupfunction org.openhab.core.items.GroupFunction})
52+
*/
53+
type HostGroupFunction = object;
54+
/**
55+
* Native Java openHAB QuantityType (instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/library/types/quantitytype org.openhab.core.library.types.QuantityType})
56+
*/
57+
type QuantityType = object;
58+
}
59+
60+
export {}

types/openhab-js.d.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,33 @@
1-
/// <reference path="../src/globals.d.ts" />
1+
/// <reference path="../src/java.d.ts" />
2+
3+
declare global {
4+
namespace items {
5+
type Item = import('./items/items').Item;
6+
type ItemConfig = import('./items/items').ItemConfig;
7+
type ItemMetadata = import('./items/metadata').ItemMetadata;
8+
type TimeSeries = import('./items/time-series');
9+
type ItemPersistence = import('./items/items').ItemPersistence;
10+
type ItemSemantics = import('./items/items').ItemSemantics;
11+
type PersistedItem = InstanceType<typeof import('./items/item-persistence').PersistedItem>;
12+
type PersistedState = InstanceType<typeof import('./items/item-persistence').PersistedState>;
13+
}
14+
15+
namespace time {
16+
type ZonedDateTime = import('@js-joda/core').ZonedDateTime;
17+
type Instant = import('@js-joda/core').Instant;
18+
type Duration = import('@js-joda/core').Duration;
19+
type LocalDateTime = import('@js-joda/core').LocalDateTime;
20+
type LocalTime = import('@js-joda/core').LocalTime;
21+
type LocalDate = import('@js-joda/core').LocalDate;
22+
}
23+
24+
namespace rules {
25+
type RuleCallback = import('./rules/rules').RuleCallback;
26+
type RuleConfig = import('./rules/rules').RuleConfig;
27+
}
28+
29+
type Quantity = import('./quantity').Quantity;
30+
}
231

332
// Manually written type definitions to avoid problems with lazy loading in index.js
433
export const log: typeof import("./log");

0 commit comments

Comments
 (0)