Skip to content

Commit d089a04

Browse files
committed
Added missing externs for DurationFormat
1 parent 96955a7 commit d089a04

7 files changed

Lines changed: 107 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Added missing externs for `DurationFormat` and `DurationFormatOptions` not yet in https://github.com/google/closure-compiler/blob/master/externs/browser/intl.js
13+
1014
## [2.4.7] - 2026-02-03
1115

1216
### Added

intl/src/main/java/org/jboss/elemento/intl/DateTimeFormat.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import elemental2.core.JsArray;
1919
import elemental2.core.JsDate;
20+
import jsinterop.annotations.JsConstructor;
2021
import jsinterop.annotations.JsOverlay;
2122
import jsinterop.annotations.JsType;
2223
import jsinterop.base.JsArrayLike;
@@ -100,7 +101,7 @@ public static DateTimeFormat dateTimeFormat(Locale[] locales, DateTimeFormatOpti
100101

101102
// ------------------------------------------------------ instance
102103

103-
DateTimeFormat(Object locale, DateTimeFormatOptions options) {}
104+
@JsConstructor DateTimeFormat(Object locale, DateTimeFormatOptions options) {}
104105
public native String format(JsDate date);
105106
public native JsArray<JsPropertyMap<String>> formatToParts(JsDate date);
106107
public native String formatRange(JsDate start, JsDate end);

intl/src/main/java/org/jboss/elemento/intl/DurationFormat.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.jboss.elemento.intl;
1717

1818
import elemental2.core.JsArray;
19+
import jsinterop.annotations.JsConstructor;
1920
import jsinterop.annotations.JsOverlay;
2021
import jsinterop.annotations.JsType;
2122
import jsinterop.base.JsArrayLike;
@@ -100,7 +101,7 @@ public static DurationFormat durationFormat(Locale[] locales, DurationFormatOpti
100101

101102
// ------------------------------------------------------ instance
102103

103-
DurationFormat(Object locale, DurationFormatOptions options) {}
104+
@JsConstructor DurationFormat(Object locale, DurationFormatOptions options) {}
104105
public native String format(Duration duration);
105106
public native JsArray<JsPropertyMap<String>> formatToParts(Duration duration);
106107
public native JsPropertyMap<String> resolvedOptions();

intl/src/main/java/org/jboss/elemento/intl/ListFormat.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.jboss.elemento.intl;
1717

1818
import elemental2.core.JsArray;
19+
import jsinterop.annotations.JsConstructor;
1920
import jsinterop.annotations.JsOverlay;
2021
import jsinterop.annotations.JsType;
2122
import jsinterop.base.JsArrayLike;
@@ -100,7 +101,7 @@ public static ListFormat listFormat(Locale[] locales, ListFormatOptions options)
100101

101102
// ------------------------------------------------------ instance
102103

103-
ListFormat(Object locale, ListFormatOptions options) {}
104+
@JsConstructor ListFormat(Object locale, ListFormatOptions options) {}
104105
public native String format(JsArray<String> list);
105106
public native JsArray<JsPropertyMap<String>> formatToParts(JsArray<String> list);
106107
public native JsPropertyMap<String> resolvedOptions();

intl/src/main/java/org/jboss/elemento/intl/NumberFormat.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.jboss.elemento.intl;
1717

1818
import elemental2.core.JsArray;
19+
import jsinterop.annotations.JsConstructor;
1920
import jsinterop.annotations.JsOverlay;
2021
import jsinterop.annotations.JsType;
2122
import jsinterop.base.JsArrayLike;
@@ -100,7 +101,7 @@ public static NumberFormat numberFormat(Locale[] locales, NumberFormatOptions op
100101

101102
// ------------------------------------------------------ instance
102103

103-
NumberFormat(Object locale, NumberFormatOptions options) {}
104+
@JsConstructor NumberFormat(Object locale, NumberFormatOptions options) {}
104105
public native String format(double number);
105106
public native JsArray<JsPropertyMap<String>> formatToParts(double number);
106107
public native String formatRange(double start, double end);

intl/src/main/java/org/jboss/elemento/intl/RelativeTimeFormat.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.jboss.elemento.intl;
1717

1818
import elemental2.core.JsArray;
19+
import jsinterop.annotations.JsConstructor;
1920
import jsinterop.annotations.JsOverlay;
2021
import jsinterop.annotations.JsType;
2122
import jsinterop.base.JsArrayLike;
@@ -99,7 +100,7 @@ public static RelativeTimeFormat relativeTimeFormat(Locale[] locales, RelativeTi
99100

100101
// ------------------------------------------------------ instance
101102

102-
RelativeTimeFormat(Object locale, RelativeTimeFormatOptions options) {}
103+
@JsConstructor RelativeTimeFormat(Object locale, RelativeTimeFormatOptions options) {}
103104
public native String format(double value, String unit);
104105
// @formatter:off
105106

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// noinspection BadExpressionStatementJS,JSUnusedGlobalSymbols,SpellCheckingInspection,ES6ConvertVarToLetConst,JSCommentMatchesSignature
2+
3+
/*
4+
* Copyright 2023 Red Hat
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* @fileoverview Missing Intl externs not yet in https://github.com/google/closure-compiler/blob/master/externs/browser/intl.js
21+
* @externs
22+
*/
23+
24+
/**
25+
* @constructor
26+
* @param {string|Array<string>=} locales
27+
* @param {{
28+
* localeMatcher: (string|undefined),
29+
* numberingSystem: (string|undefined),
30+
* style: (string|undefined),
31+
* years: (string|undefined),
32+
* yearsDisplay: (string|undefined),
33+
* months: (string|undefined),
34+
* monthsDisplay: (string|undefined),
35+
* weeks: (string|undefined),
36+
* weeksDisplay: (string|undefined),
37+
* days: (string|undefined),
38+
* daysDisplay: (string|undefined),
39+
* hours: (string|undefined),
40+
* hoursDisplay: (string|undefined),
41+
* minutes: (string|undefined),
42+
* minutesDisplay: (string|undefined),
43+
* seconds: (string|undefined),
44+
* secondsDisplay: (string|undefined),
45+
* milliseconds: (string|undefined),
46+
* millisecondsDisplay: (string|undefined),
47+
* microseconds: (string|undefined),
48+
* microsecondsDisplay: (string|undefined),
49+
* nanoseconds: (string|undefined),
50+
* nanosecondsDisplay: (string|undefined),
51+
* fractionDigits: (number|undefined)
52+
* }=}
53+
* options
54+
*/
55+
Intl.DurationFormat = function (locales, options) {
56+
};
57+
58+
/**
59+
* @param {Array<string>} locales
60+
* @param {{localeMatcher: (string|undefined)}=} options
61+
* @return {Array<string>}
62+
*/
63+
Intl.DurationFormat.supportedLocalesOf = function(locales, options) {};
64+
65+
/**
66+
* @param {{
67+
* years: (number|undefined),
68+
* months: (number|undefined),
69+
* weeks: (number|undefined),
70+
* days: (number|undefined),
71+
* hours: (number|undefined),
72+
* minutes: (number|undefined),
73+
* seconds: (number|undefined),
74+
* milliseconds: (number|undefined),
75+
* microseconds: (number|undefined),
76+
* nanoseconds: (number|undefined),
77+
* }=}
78+
* duration
79+
* @return {string}
80+
*/
81+
Intl.DurationFormat.prototype.format = function(num) {};
82+
83+
/**
84+
* @param {number} num
85+
* @return {!Array<{type: string, value: string}>}
86+
* @see http://www.ecma-international.org/ecma-402/#sec-intl.numberformat.prototype.formattoparts
87+
*/
88+
Intl.DurationFormat.prototype.formatToParts = function(num) {};
89+
90+
/**
91+
* @return {{locale: string, numberingSystem: string, style: string, fractionDigits: number }}
92+
*/
93+
Intl.DurationFormat.prototype.resolvedOptions = function() {};

0 commit comments

Comments
 (0)