Skip to content

Commit

Permalink
chore: update typescript to 5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
snowystinger committed Mar 6, 2025
1 parent 6672a12 commit 9d6cbc4
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 53 deletions.
19 changes: 0 additions & 19 deletions lib/viewTransitions.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
"tailwindcss": "^4.0.0",
"tailwindcss-animate": "^1.0.7",
"tempy": "^0.5.0",
"typescript": "^5.5.0",
"typescript": "^5.8.2",
"typescript-eslint": "^8.9.0",
"verdaccio": "^5.13.0",
"walk-object": "^4.0.0",
Expand Down
29 changes: 18 additions & 11 deletions packages/@react-aria/dnd/src/useDroppableCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,25 @@ export function useDroppableCollection(props: DroppableCollectionOptions, state:
// inserted item. If selection is disabled, then also show the focus ring so there
// is some indication that items were added.
if (state.selectionManager.focusedKey === prevFocusedKey) {
let first = newKeys.keys().next().value;
let item = state.collection.getItem(first);

// If this is a cell, focus the parent row.
if (item?.type === 'cell') {
first = item.parentKey;
}
let first: Key | null | undefined = newKeys.keys().next().value;
if (first != null) {
let item = state.collection.getItem(first);

// If this is a cell, focus the parent row.
// eslint-disable-next-line max-depth
if (item?.type === 'cell') {
first = item.parentKey;
}

state.selectionManager.setFocusedKey(first);
// eslint-disable-next-line max-depth
if (first != null) {
state.selectionManager.setFocusedKey(first);
}

if (state.selectionManager.selectionMode === 'none') {
setInteractionModality('keyboard');
// eslint-disable-next-line max-depth
if (state.selectionManager.selectionMode === 'none') {
setInteractionModality('keyboard');
}
}
}
} else if (
Expand Down Expand Up @@ -335,7 +342,7 @@ export function useDroppableCollection(props: DroppableCollectionOptions, state:
}, 50);
}, [localState, defaultOnDrop, ref, updateFocusAfterDrop]);


useEffect(() => {
return () => {
if (droppingState.current) {
Expand Down
19 changes: 12 additions & 7 deletions packages/@react-aria/grid/src/useGridSelectionAnnouncement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,25 @@ export function useGridSelectionAnnouncement<T>(props: GridSelectionAnnouncement
let messages: string[] = [];

if ((state.selectionManager.selectedKeys.size === 1 && isReplace)) {
if (state.collection.getItem(state.selectionManager.selectedKeys.keys().next().value)) {
let currentSelectionText = getRowText(state.selectionManager.selectedKeys.keys().next().value);
let firstKey = state.selectionManager.selectedKeys.keys().next().value;
if (firstKey != null && state.collection.getItem(firstKey)) {
let currentSelectionText = getRowText(firstKey);
if (currentSelectionText) {
messages.push(stringFormatter.format('selectedItem', {item: currentSelectionText}));
}
}
} else if (addedKeys.size === 1 && removedKeys.size === 0) {
let addedText = getRowText(addedKeys.keys().next().value);
if (addedText) {
messages.push(stringFormatter.format('selectedItem', {item: addedText}));
let firstKey = addedKeys.keys().next().value;
if (firstKey != null) {
let addedText = getRowText(firstKey);
if (addedText) {
messages.push(stringFormatter.format('selectedItem', {item: addedText}));
}
}
} else if (removedKeys.size === 1 && addedKeys.size === 0) {
if (state.collection.getItem(removedKeys.keys().next().value)) {
let removedText = getRowText(removedKeys.keys().next().value);
let firstKey = removedKeys.keys().next().value;
if (firstKey != null && state.collection.getItem(firstKey)) {
let removedText = getRowText(firstKey);
if (removedText) {
messages.push(stringFormatter.format('deselectedItem', {item: removedText}));
}
Expand Down
17 changes: 10 additions & 7 deletions packages/@react-spectrum/s2/src/SegmentedControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,17 @@ export const SegmentedControl = /*#__PURE__*/ forwardRef(function SegmentedContr
if (currentSelectedRef.current) {
prevRef.current = currentSelectedRef?.current.getBoundingClientRect();
}

if (onSelectionChange) {
onSelectionChange(values.values().next().value);
let firstKey = values.values().next().value;
if (firstKey != null) {
onSelectionChange(firstKey);
}
}
};

return (
<ToggleButtonGroup
<ToggleButtonGroup
{...props}
selectedKeys={selectedKey != null ? [selectedKey] : undefined}
defaultSelectedKeys={defaultSelectedKey != null ? [defaultSelectedKey] : undefined}
Expand Down Expand Up @@ -211,7 +214,7 @@ function DefaultSelectionTracker(props: DefaultSelectionTrackProps) {
<Provider
values={[
[InternalSegmentedControlContext, {register: register, prevRef: props.prevRef, currentSelectedRef: props.currentSelectedRef, isJustified: props.isJustified}]
]}>
]}>
{props.children}
</Provider>
);
Expand Down Expand Up @@ -255,15 +258,15 @@ export const SegmentedControlItem = /*#__PURE__*/ forwardRef(function SegmentedC
}, [isSelected, reduceMotion]);

return (
<ToggleButton
<ToggleButton
{...props}
ref={domRef}
ref={domRef}
style={props.UNSAFE_style}
className={renderProps => (props.UNSAFE_className || '') + controlItem({...renderProps, isJustified}, props.styles)} >
{({isSelected, isPressed, isDisabled}) => (
<>
{isSelected && <div className={slider({isDisabled})} ref={currentSelectedRef} />}
<Provider
<Provider
values={[
[IconContext, {
render: centerBaseline({slot: 'icon', styles: style({order: 0, flexShrink: 0})})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface DisclosureGroupState {

/** Whether all items are disabled. */
readonly isDisabled: boolean,

/** A set of keys for items that are expanded. */
readonly expandedKeys: Set<Key>,

Expand All @@ -55,11 +55,14 @@ export function useDisclosureGroupState(props: DisclosureGroupProps): Disclosure
useMemo(() => props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(), [props.defaultExpandedKeys]),
props.onExpandedChange
);

useEffect(() => {
// Ensure only one item is expanded if allowsMultipleExpanded is false.
if (!allowsMultipleExpanded && expandedKeys.size > 1) {
setExpandedKeys(new Set([expandedKeys.values().next().value]));
let firstKey = expandedKeys.values().next().value;
if (firstKey != null) {
setExpandedKeys(new Set([firstKey]));
}
}
});

Expand All @@ -80,7 +83,7 @@ export function useDisclosureGroupState(props: DisclosureGroupProps): Disclosure
} else {
keys = new Set(expandedKeys.has(key) ? [] : [key]);
}

setExpandedKeys(keys);
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-types/shared/src/selection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface SingleSelection {
/** The initial selected key in the collection (uncontrolled). */
defaultSelectedKey?: Key,
/** Handler that is called when the selection changes. */
onSelectionChange?: (key: Key) => void
onSelectionChange?: (key: Key | null) => void
}

export type SelectionMode = 'none' | 'single' | 'multiple';
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/codemods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"devDependencies": {
"@types/jscodeshift": "^0.11.11",
"typescript": "^5.5.0"
"typescript": "^5.8.2"
},
"peerDependencies": {
"react": "^18.0.0 || ^19.0.0-rc.1",
Expand Down
24 changes: 22 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7148,7 +7148,7 @@ __metadata:
jscodeshift: "npm:^0.15.2"
recast: "npm:^0.23.9"
ts-node: "npm:^10.9.2"
typescript: "npm:^5.5.0"
typescript: "npm:^5.8.2"
uuid: "npm:^9.0.1"
peerDependencies:
react: ^18.0.0 || ^19.0.0-rc.1
Expand Down Expand Up @@ -29399,7 +29399,7 @@ __metadata:
tailwindcss: "npm:^4.0.0"
tailwindcss-animate: "npm:^1.0.7"
tempy: "npm:^0.5.0"
typescript: "npm:^5.5.0"
typescript: "npm:^5.8.2"
typescript-eslint: "npm:^8.9.0"
verdaccio: "npm:^5.13.0"
walk-object: "npm:^4.0.0"
Expand Down Expand Up @@ -33316,6 +33316,16 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:^5.8.2":
version: 5.8.2
resolution: "typescript@npm:5.8.2"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/5c4f6fbf1c6389b6928fe7b8fcd5dc73bb2d58cd4e3883f1d774ed5bd83b151cbac6b7ecf11723de56d4676daeba8713894b1e9af56174f2f9780ae7848ec3c6
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A^5.5.0#optional!builtin<compat/typescript>":
version: 5.5.2
resolution: "typescript@patch:typescript@npm%3A5.5.2#optional!builtin<compat/typescript>::version=5.5.2&hash=b45daf"
Expand All @@ -33326,6 +33336,16 @@ __metadata:
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A^5.8.2#optional!builtin<compat/typescript>":
version: 5.8.2
resolution: "typescript@patch:typescript@npm%3A5.8.2#optional!builtin<compat/typescript>::version=5.8.2&hash=b45daf"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/8a6cd29dfb59bd5a978407b93ae0edb530ee9376a5b95a42ad057a6f80ffb0c410489ccd6fe48d1d0dfad6e8adf5d62d3874bbd251f488ae30e11a1ce6dabd28
languageName: node
linkType: hard

"ua-parser-js@npm:0.7.17":
version: 0.7.17
resolution: "ua-parser-js@npm:0.7.17"
Expand Down

0 comments on commit 9d6cbc4

Please sign in to comment.