Skip to content

Commit 63d4359

Browse files
authored
chore: TS update 5.8 (#8061)
1 parent 9fe5629 commit 63d4359

39 files changed

+184
-117
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/buffer.d.ts b/buffer.d.ts
2+
index 5d6c97d6b5d47fd189f795498aefd6b8d7713b7d..b9a22c4634fa6308006ae17d3527ff3c518a789d 100644
3+
--- a/buffer.d.ts
4+
+++ b/buffer.d.ts
5+
@@ -629,7 +629,7 @@ declare module "buffer" {
6+
*/
7+
poolSize: number;
8+
}
9+
- interface Buffer extends Uint8Array {
10+
+ interface Buffer extends Uint8Array<ArrayBuffer> {
11+
/**
12+
* Writes `string` to `buf` at `offset` according to the character encoding in`encoding`. The `length` parameter is the number of bytes to write. If `buf` did
13+
* not contain enough space to fit the entire string, only part of `string` will be

lib/viewTransitions.d.ts

-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,3 @@
1313
interface Document {
1414
startViewTransition(update: (() => void) | {update: () => void, types: string[]}): ViewTransition;
1515
}
16-
17-
interface ViewTransition {
18-
ready: Promise<void>;
19-
finished: Promise<void>;
20-
}

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
"tailwindcss": "^4.0.0",
207207
"tailwindcss-animate": "^1.0.7",
208208
"tempy": "^0.5.0",
209-
"typescript": "^5.5.0",
209+
"typescript": "^5.8.2",
210210
"typescript-eslint": "^8.9.0",
211211
"verdaccio": "^6.0.0",
212212
"walk-object": "^4.0.0",
@@ -234,7 +234,10 @@
234234
"recast": "0.23.6",
235235
"ast-types": "0.16.1",
236236
"svgo": "^3",
237-
"@testing-library/user-event": "patch:@testing-library/user-event@npm%3A14.6.1#~/.yarn/patches/@testing-library-user-event-npm-14.6.1-5da7e1d4e2.patch"
237+
"@testing-library/user-event": "patch:@testing-library/user-event@npm%3A14.6.1#~/.yarn/patches/@testing-library-user-event-npm-14.6.1-5da7e1d4e2.patch",
238+
"@types/node@npm:*": "patch:@types/node@npm%3A20.14.13#~/.yarn/patches/@types-node-npm-20.14.13-41f92d384c.patch",
239+
"@types/node@npm:^18.0.0": "patch:@types/node@npm%3A20.14.13#~/.yarn/patches/@types-node-npm-20.14.13-41f92d384c.patch",
240+
"@types/node@npm:>= 8": "patch:@types/node@npm%3A20.14.13#~/.yarn/patches/@types-node-npm-20.14.13-41f92d384c.patch"
238241
},
239242
"@parcel/transformer-css": {
240243
"cssModules": {

packages/@react-aria/dnd/src/useDroppableCollection.ts

+18-11
Original file line numberDiff line numberDiff line change
@@ -260,18 +260,25 @@ export function useDroppableCollection(props: DroppableCollectionOptions, state:
260260
// inserted item. If selection is disabled, then also show the focus ring so there
261261
// is some indication that items were added.
262262
if (state.selectionManager.focusedKey === prevFocusedKey) {
263-
let first = newKeys.keys().next().value;
264-
let item = state.collection.getItem(first);
265-
266-
// If this is a cell, focus the parent row.
267-
if (item?.type === 'cell') {
268-
first = item.parentKey;
269-
}
263+
let first: Key | null | undefined = newKeys.keys().next().value;
264+
if (first != null) {
265+
let item = state.collection.getItem(first);
266+
267+
// If this is a cell, focus the parent row.
268+
// eslint-disable-next-line max-depth
269+
if (item?.type === 'cell') {
270+
first = item.parentKey;
271+
}
270272

271-
state.selectionManager.setFocusedKey(first);
273+
// eslint-disable-next-line max-depth
274+
if (first != null) {
275+
state.selectionManager.setFocusedKey(first);
276+
}
272277

273-
if (state.selectionManager.selectionMode === 'none') {
274-
setInteractionModality('keyboard');
278+
// eslint-disable-next-line max-depth
279+
if (state.selectionManager.selectionMode === 'none') {
280+
setInteractionModality('keyboard');
281+
}
275282
}
276283
}
277284
} else if (
@@ -337,7 +344,7 @@ export function useDroppableCollection(props: DroppableCollectionOptions, state:
337344
}, 50);
338345
}, [localState, defaultOnDrop, ref, updateFocusAfterDrop]);
339346

340-
347+
341348
useEffect(() => {
342349
return () => {
343350
if (droppingState.current) {

packages/@react-aria/grid/src/useGridSelectionAnnouncement.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,25 @@ export function useGridSelectionAnnouncement<T>(props: GridSelectionAnnouncement
6161
let messages: string[] = [];
6262

6363
if ((state.selectionManager.selectedKeys.size === 1 && isReplace)) {
64-
if (state.collection.getItem(state.selectionManager.selectedKeys.keys().next().value)) {
65-
let currentSelectionText = getRowText(state.selectionManager.selectedKeys.keys().next().value);
64+
let firstKey = state.selectionManager.selectedKeys.keys().next().value;
65+
if (firstKey != null && state.collection.getItem(firstKey)) {
66+
let currentSelectionText = getRowText(firstKey);
6667
if (currentSelectionText) {
6768
messages.push(stringFormatter.format('selectedItem', {item: currentSelectionText}));
6869
}
6970
}
7071
} else if (addedKeys.size === 1 && removedKeys.size === 0) {
71-
let addedText = getRowText(addedKeys.keys().next().value);
72-
if (addedText) {
73-
messages.push(stringFormatter.format('selectedItem', {item: addedText}));
72+
let firstKey = addedKeys.keys().next().value;
73+
if (firstKey != null) {
74+
let addedText = getRowText(firstKey);
75+
if (addedText) {
76+
messages.push(stringFormatter.format('selectedItem', {item: addedText}));
77+
}
7478
}
7579
} else if (removedKeys.size === 1 && addedKeys.size === 0) {
76-
if (state.collection.getItem(removedKeys.keys().next().value)) {
77-
let removedText = getRowText(removedKeys.keys().next().value);
80+
let firstKey = removedKeys.keys().next().value;
81+
if (firstKey != null && state.collection.getItem(firstKey)) {
82+
let removedText = getRowText(firstKey);
7883
if (removedText) {
7984
messages.push(stringFormatter.format('deselectedItem', {item: removedText}));
8085
}

packages/@react-spectrum/calendar/stories/Calendar.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ const calendars = [
209209

210210
function Example(props) {
211211
let [locale, setLocale] = React.useState('');
212-
let [calendar, setCalendar] = React.useState<Key>(calendars[0].key);
212+
let [calendar, setCalendar] = React.useState<Key | null>(calendars[0].key);
213213
let {locale: defaultLocale} = useLocale();
214214

215215
let pref = preferences.find(p => p.locale === locale)!;

packages/@react-spectrum/datepicker/stories/DateField.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export const IsDateUnavailable: DateFieldStory = {
212212
...Default,
213213
args: {
214214
isDateUnavailable: (date) => {
215-
return date.compare(new CalendarDate(1980, 1, 1)) >= 0
215+
return date.compare(new CalendarDate(1980, 1, 1)) >= 0
216216
&& date.compare(new CalendarDate(1980, 1, 8)) <= 0;
217217
},
218218
errorMessage: 'Date unavailable.',
@@ -310,7 +310,7 @@ const calendars = [
310310

311311
function Example(props) {
312312
let [locale, setLocale] = React.useState('');
313-
let [calendar, setCalendar] = React.useState<Key>(calendars[0].key);
313+
let [calendar, setCalendar] = React.useState<Key | null>(calendars[0].key);
314314
let {locale: defaultLocale} = useLocale();
315315

316316
let pref = preferences.find(p => p.locale === locale);

packages/@react-spectrum/datepicker/stories/DatePicker.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ const calendars = [
338338

339339
function Example(props) {
340340
let [locale, setLocale] = React.useState('');
341-
let [calendar, setCalendar] = React.useState<Key>(calendars[0].key);
341+
let [calendar, setCalendar] = React.useState<Key | null>(calendars[0].key);
342342
let {locale: defaultLocale} = useLocale();
343343

344344
let pref = preferences.find(p => p.locale === locale);

packages/@react-spectrum/datepicker/stories/DateRangePicker.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ const calendars = [
238238

239239
function Example(props) {
240240
let [locale, setLocale] = React.useState('');
241-
let [calendar, setCalendar] = React.useState<Key>(calendars[0].key);
241+
let [calendar, setCalendar] = React.useState<Key | null>(calendars[0].key);
242242
let {locale: defaultLocale} = useLocale();
243243

244244
let pref = preferences.find(p => p.locale === locale);

packages/@react-spectrum/form/stories/Form.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ function FormWithControls(props: any = {}) {
482482
let [firstName, setFirstName] = useState('hello');
483483
let [isHunter, setIsHunter] = useState(true);
484484
let [favoritePet, setFavoritePet] = useState('cats');
485-
let [favoriteColor, setFavoriteColor] = useState('green' as Key);
485+
let [favoriteColor, setFavoriteColor] = useState<Key | null>('green');
486486
let [howIFeel, setHowIFeel] = useState('I feel good, o I feel so good!');
487487
let [birthday, setBirthday] = useState<CalendarDate | null>(new CalendarDate(1732, 2, 22));
488488
let [money, setMoney] = useState(50);

packages/@react-spectrum/s2/src/Breadcrumbs.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
DefaultCollectionRenderer,
2121
HeadingContext,
2222
Link,
23+
LinkRenderProps,
2324
Provider,
2425
Breadcrumbs as RACBreadcrumbs
2526
} from 'react-aria-components';
@@ -97,7 +98,7 @@ const wrapper = style<BreadcrumbsStyleProps>({
9798

9899
const InternalBreadcrumbsContext = createContext<Partial<BreadcrumbsProps<any>>>({});
99100

100-
/** Breadcrumbs show hierarchy and navigational context for a users location within an application. */
101+
/** Breadcrumbs show hierarchy and navigational context for a user's location within an application. */
101102
export const Breadcrumbs = /*#__PURE__*/ (forwardRef as forwardRefType)(function Breadcrumbs<T extends object>(props: BreadcrumbsProps<T>, ref: DOMRef<HTMLOListElement>) {
102103
[props, ref] = useSpectrumContextProps(props, ref, BreadcrumbsContext);
103104
let domRef = useDOMRef(ref);
@@ -200,7 +201,7 @@ let HiddenBreadcrumbs = function (props: {listRef: RefObject<HTMLDivElement | nu
200201
);
201202
};
202203

203-
const breadcrumbStyles = style({
204+
const breadcrumbStyles = style<BreadcrumbsStyleProps & {isMenu?: boolean, isCurrent?: boolean}>({
204205
display: 'flex',
205206
alignItems: 'center',
206207
justifyContent: 'start',
@@ -245,7 +246,7 @@ const chevronStyles = style({
245246
}
246247
});
247248

248-
const linkStyles = style({
249+
const linkStyles = style<LinkRenderProps & {size?: 'M' | 'L', isCurrent?: boolean}>({
249250
...focusRing(),
250251
borderRadius: 'sm',
251252
font: 'control',
@@ -255,7 +256,8 @@ const linkStyles = style({
255256
isCurrent: 'neutral',
256257
forcedColors: {
257258
default: 'LinkText',
258-
isDisabled: 'GrayText'
259+
isDisabled: 'GrayText',
260+
isCurrent: 'GrayText'
259261
}
260262
},
261263
transition: 'default',
@@ -337,7 +339,7 @@ export const Breadcrumb = /*#__PURE__*/ (forwardRef as forwardRefType)(function
337339
ping={ping}
338340
referrerPolicy={referrerPolicy}
339341
isDisabled={isDisabled || isCurrent}
340-
className={({isFocused, isFocusVisible, isHovered, isDisabled, isPressed}) => linkStyles({isFocused, isFocusVisible, isHovered, isDisabled, size, isPressed})}>
342+
className={({isFocused, isFocusVisible, isHovered, isDisabled, isPressed}) => linkStyles({isFocused, isFocusVisible, isHovered, isDisabled, size, isPressed, isCurrent})}>
341343
{children}
342344
</Link>
343345
<ChevronIcon

packages/@react-spectrum/s2/src/CloseButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const hoverBackground = {
3939
isStaticColor: 'transparent-overlay-200'
4040
} as const;
4141

42-
const styles = style({
42+
const styles = style<CloseButtonProps & {isHovered: boolean, isFocusVisible: boolean, isPressed: boolean, isStaticColor: boolean}>({
4343
...focusRing(),
4444
...staticColor(),
4545
display: 'flex',

packages/@react-spectrum/s2/src/ComboBox.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
ListBoxSection as AriaListBoxSection,
1717
PopoverProps as AriaPopoverProps,
1818
Button,
19+
ButtonRenderProps,
1920
ContextValue,
2021
InputContext,
2122
ListBox,
@@ -95,7 +96,7 @@ export interface ComboBoxProps<T extends object> extends
9596

9697
export const ComboBoxContext = createContext<ContextValue<Partial<ComboBoxProps<any>>, TextFieldRef>>(null);
9798

98-
const inputButton = style({
99+
const inputButton = style<ButtonRenderProps & {isOpen: boolean, size: 'S' | 'M' | 'L' | 'XL'}>({
99100
display: 'flex',
100101
outlineStyle: 'none',
101102
textAlign: 'center',

packages/@react-spectrum/s2/src/Menu.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
SubmenuTriggerProps as AriaSubmenuTriggerProps,
2424
ContextValue,
2525
DEFAULT_SLOT,
26+
MenuItemRenderProps,
2627
Provider,
2728
Separator,
2829
SeparatorProps
@@ -146,7 +147,7 @@ export let sectionHeading = style({
146147
margin: 0
147148
});
148149

149-
export let menuitem = style({
150+
export let menuitem = style<Omit<MenuItemRenderProps, 'hasSubmenu' | 'isOpen'> & {isFocused: boolean, size: 'S' | 'M' | 'L' | 'XL', isLink?: boolean, hasSubmenu?: boolean, isOpen?: boolean}>({
150151
...focusRing(),
151152
boxSizing: 'border-box',
152153
borderRadius: 'control',
@@ -293,7 +294,7 @@ let value = style({
293294
marginStart: 8
294295
});
295296

296-
let keyboard = style({
297+
let keyboard = style<{size: 'S' | 'M' | 'L' | 'XL', isDisabled: boolean}>({
297298
gridArea: 'keyboard',
298299
marginStart: 8,
299300
font: 'ui',
@@ -305,7 +306,7 @@ let keyboard = style({
305306
isDisabled: 'GrayText'
306307
}
307308
},
308-
background: 'gray-25',
309+
backgroundColor: 'gray-25',
309310
unicodeBidi: 'plaintext'
310311
});
311312

packages/@react-spectrum/s2/src/NumberField.tsx

+4-16
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
NumberField as AriaNumberField,
1717
NumberFieldProps as AriaNumberFieldProps,
1818
ButtonContext,
19+
ButtonRenderProps,
1920
ContextValue,
2021
InputContext,
2122
Text,
@@ -56,7 +57,7 @@ export interface NumberFieldProps extends
5657

5758
export const NumberFieldContext = createContext<ContextValue<Partial<NumberFieldProps>, TextFieldRef>>(null);
5859

59-
const inputButton = style({
60+
const inputButton = style<ButtonRenderProps & {size: 'S' | 'M' | 'L' | 'XL', type: 'decrement' | 'increment'}>({
6061
display: 'flex',
6162
outlineStyle: 'none',
6263
textAlign: 'center',
@@ -69,9 +70,6 @@ const inputButton = style({
6970
L: '[5px]',
7071
XL: '[6px]'
7172
}
72-
},
73-
type: {
74-
decrementStep: 'none'
7573
}
7674
},
7775
borderBottomRadius: {
@@ -82,9 +80,6 @@ const inputButton = style({
8280
L: '[5px]',
8381
XL: '[6px]'
8482
}
85-
},
86-
type: {
87-
incrementStep: 'none'
8883
}
8984
},
9085
alignItems: 'center',
@@ -132,13 +127,6 @@ const inputButton = style({
132127

133128
const iconStyles = style({
134129
flexShrink: 0,
135-
rotate: {
136-
default: 0,
137-
type: {
138-
incrementStep: 270,
139-
decrementStep: 90
140-
}
141-
},
142130
'--iconPrimary': {
143131
type: 'fill',
144132
value: 'currentColor'
@@ -261,7 +249,7 @@ export const NumberField = forwardRef(function NumberField(props: NumberFieldPro
261249
type: 'decrement',
262250
size
263251
})}>
264-
<Dash size={size} className={iconStyles({})} />
252+
<Dash size={size} className={iconStyles} />
265253
</StepButton>
266254
<StepButton
267255
ref={incrementButtonRef}
@@ -272,7 +260,7 @@ export const NumberField = forwardRef(function NumberField(props: NumberFieldPro
272260
type: 'increment',
273261
size
274262
})}>
275-
<Add size={size} className={iconStyles({})} />
263+
<Add size={size} className={iconStyles} />
276264
</StepButton>
277265
</div>}
278266
</FieldGroup>

0 commit comments

Comments
 (0)