Skip to content

Commit b3a4d6c

Browse files
alecmevsnowystingeryihuiliao
authored
fix: add optional property types (#6872)
* Fix optional property types * Use vanilla Intl.ResolvedDateTimeFormatOptions * Define DOMProps via HTMLAttributes * add id back into the docs * fix lint --------- Co-authored-by: Robert Snow <[email protected]> Co-authored-by: Yihui Liao <[email protected]>
1 parent bd2ca0b commit b3a4d6c

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

packages/@internationalized/date/src/DateFormatter.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212

1313
let formatterCache = new Map<string, Intl.DateTimeFormat>();
1414

15-
interface ResolvedDateTimeFormatOptions extends Intl.ResolvedDateTimeFormatOptions {
16-
hourCycle?: Intl.DateTimeFormatOptions['hourCycle']
17-
}
18-
1915
interface DateRangeFormatPart extends Intl.DateTimeFormatPart {
2016
source: 'startRange' | 'endRange' | 'shared'
2117
}
@@ -79,8 +75,8 @@ export class DateFormatter implements Intl.DateTimeFormat {
7975
}
8076

8177
/** Returns the resolved formatting options based on the values passed to the constructor. */
82-
resolvedOptions(): ResolvedDateTimeFormatOptions {
83-
let resolvedOptions = this.formatter.resolvedOptions() as ResolvedDateTimeFormatOptions;
78+
resolvedOptions(): Intl.ResolvedDateTimeFormatOptions {
79+
let resolvedOptions = this.formatter.resolvedOptions();
8480
if (hasBuggyResolvedHourCycle()) {
8581
if (!this.resolvedHourCycle) {
8682
this.resolvedHourCycle = getResolvedHourCycle(resolvedOptions.locale, this.options);
@@ -156,10 +152,10 @@ function hasBuggyHour12Behavior() {
156152
let _hasBuggyResolvedHourCycle: boolean | null = null;
157153
function hasBuggyResolvedHourCycle() {
158154
if (_hasBuggyResolvedHourCycle == null) {
159-
_hasBuggyResolvedHourCycle = (new Intl.DateTimeFormat('fr', {
155+
_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat('fr', {
160156
hour: 'numeric',
161157
hour12: false
162-
}).resolvedOptions() as ResolvedDateTimeFormatOptions).hourCycle === 'h12';
158+
}).resolvedOptions().hourCycle === 'h12';
163159
}
164160

165161
return _hasBuggyResolvedHourCycle;

packages/@react-types/shared/src/dom.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export interface DOMProps {
5959
/**
6060
* The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
6161
*/
62-
id?: string
62+
id?: string | undefined
6363
}
6464

6565
export interface FocusableDOMProps extends DOMProps {

0 commit comments

Comments
 (0)