Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Ts strict remaining #7368

Merged
merged 78 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
3fb5134
TS Strict Collections
snowystinger Jun 18, 2024
22be104
fix rebase
snowystinger Oct 14, 2024
076a444
Start ts strict remaining
snowystinger Nov 13, 2024
a93d832
GridKeyboardDelegate and review
snowystinger Nov 13, 2024
74da9e1
fix some calculateposition tests
snowystinger Nov 13, 2024
d5cddec
fix calculate tests
snowystinger Nov 13, 2024
bdd0d56
fix listkeyboarddelegate
snowystinger Nov 13, 2024
7fd3794
fix more tests
snowystinger Nov 13, 2024
d01db08
fix calculate position
snowystinger Nov 13, 2024
3082d45
changes to calculate position
snowystinger Nov 13, 2024
40280db
grid aria hooks
snowystinger Nov 14, 2024
437e149
aria menu
snowystinger Nov 14, 2024
b2d1dab
Virtualizer stuff
devongovett Nov 14, 2024
d044ab6
aria menus more
snowystinger Nov 14, 2024
1426b32
last of aria menu and overlay
snowystinger Nov 14, 2024
23c5d69
Stately table
devongovett Nov 14, 2024
4869010
More table
devongovett Nov 14, 2024
fe6085d
delete pagination, aria select
snowystinger Nov 14, 2024
94aaed3
Merge branch 'ts-strict-remaining' of github.com:adobe/react-spectrum…
snowystinger Nov 14, 2024
eb72f15
Merge remote-tracking branch 'origin/ts-strict-collections' into ts-s…
devongovett Nov 14, 2024
16b5222
Merge branch 'ts-strict-remaining' of github.com:adobe/react-spectrum…
devongovett Nov 14, 2024
4e74ee5
aria slider and textfield
snowystinger Nov 14, 2024
71d64f1
Merge branch 'ts-strict-remaining' of github.com:adobe/react-spectrum…
snowystinger Nov 14, 2024
5358fba
aria toast
snowystinger Nov 14, 2024
263f82e
fix extra toast
snowystinger Nov 14, 2024
888831c
aria table
devongovett Nov 14, 2024
63c0810
remove log
devongovett Nov 14, 2024
09b1fe9
ignore s1 cards
snowystinger Nov 14, 2024
cf38578
More table and aria virtualizer
devongovett Nov 14, 2024
a1e9813
Merge branch 'ts-strict-remaining' of github.com:adobe/react-spectrum…
devongovett Nov 14, 2024
56e546c
more
devongovett Nov 14, 2024
d7337b5
stately data
snowystinger Nov 14, 2024
237335c
Merge branch 'ts-strict-remaining' of github.com:adobe/react-spectrum…
snowystinger Nov 14, 2024
00c783f
more
devongovett Nov 14, 2024
41b7baa
Merge branch 'ts-strict-remaining' of github.com:adobe/react-spectrum…
devongovett Nov 14, 2024
fc7b4b8
fix stories
snowystinger Nov 14, 2024
edade00
fix tree data
snowystinger Nov 14, 2024
f8338fb
more fixes
devongovett Nov 14, 2024
7ce464f
RSP slider
devongovett Nov 14, 2024
6d57e1c
more stories
devongovett Nov 14, 2024
bca4ce2
spectrum and aria combobox
snowystinger Nov 14, 2024
538101f
Make useAsyncList sort function have a required sortDescriptor
devongovett Nov 14, 2024
260224c
stately fixes
snowystinger Nov 14, 2024
075abbb
Merge branch 'ts-strict-remaining' of github.com:adobe/react-spectrum…
snowystinger Nov 14, 2024
4aeb49d
fix toast test
snowystinger Nov 14, 2024
b5b5386
rsp layout and stately tree
snowystinger Nov 14, 2024
5a52728
rsp menu
snowystinger Nov 14, 2024
8a560f7
rsp overlays
snowystinger Nov 14, 2024
ea62db8
rsp picker
snowystinger Nov 14, 2024
fe0874d
more rsp
snowystinger Nov 14, 2024
e33a452
remaining rsp and dev
snowystinger Nov 14, 2024
ce380e7
fix lint
snowystinger Nov 14, 2024
a1d8374
update yarnlock
snowystinger Nov 14, 2024
438b2a9
remove ts-ignores
snowystinger Nov 14, 2024
ef751c0
a few more removed ts ignores
snowystinger Nov 14, 2024
5b4526a
fix provider usage
snowystinger Nov 14, 2024
84b1b77
DatePicker
devongovett Nov 14, 2024
9891c84
fix tsconfig
snowystinger Nov 14, 2024
6fe9e20
remove plugin no longer needed
snowystinger Nov 15, 2024
5b44ff4
fix check-examples
devongovett Nov 15, 2024
384b69b
Fix some ts-ignores
devongovett Nov 15, 2024
52d1c45
Fix docs build
devongovett Nov 15, 2024
3157bf1
turn on verdaccio build
snowystinger Nov 15, 2024
9495780
fix accidental defaultkey of null
snowystinger Nov 15, 2024
c187bca
Toast noop
devongovett Nov 15, 2024
44c475d
Merge branch 'ts-strict-remaining' of github.com:adobe/react-spectrum…
devongovett Nov 15, 2024
9617eff
Make focusStrategy match
devongovett Nov 15, 2024
35d3950
fix types for tailwind
snowystinger Nov 15, 2024
e255e85
Merge branch 'ts-strict-remaining' of github.com:adobe/react-spectrum…
snowystinger Nov 15, 2024
523f653
Try fixing cra app
snowystinger Nov 15, 2024
edf8774
fix example apps
snowystinger Nov 15, 2024
dc60cbd
Revert "turn on verdaccio build"
snowystinger Nov 15, 2024
50e51b7
fix tooltip for chromatic
snowystinger Nov 15, 2024
b2d482e
fix for all cases
snowystinger Nov 15, 2024
c04133a
Merge branch 'main' of github.com:adobe/react-spectrum into ts-strict…
LFDanLu Nov 18, 2024
6aea7fd
Merge branch 'main' into ts-strict-remaining
snowystinger Nov 18, 2024
9f7b4f5
delete pagination files again
snowystinger Nov 18, 2024
f7422ee
fix lock file
snowystinger Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion examples/rsp-next-ts-17/components/ReorderableListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function ReorderableListView() {
// Setup the drag types and associated info for each dragged item.
return {
"custom-app-type-reorder": JSON.stringify(item),
"text/plain": item.name,
"text/plain": item?.name ?? '',
};
});
},
Expand Down
2 changes: 1 addition & 1 deletion examples/rsp-next-ts/components/ReorderableListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function ReorderableListView() {
// Setup the drag types and associated info for each dragged item.
return {
"custom-app-type-reorder": JSON.stringify(item),
"text/plain": item.name,
"text/plain": item?.name ?? '',
};
});
},
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"packageManager": "[email protected]",
"scripts": {
"check-types": "tsc && tsc-strict",
"check-types": "tsc",
"install-16": "node scripts/react-16-install-prep.mjs && yarn add react@^16.8.0 react-dom@^16.8.0 @testing-library/react@^12 @testing-library/react-hooks@^8 @testing-library/dom@^8 react-test-renderer@^16.9.0 && node scripts/oldReactSupport.mjs",
"install-17": "node scripts/react-17-install-prep.mjs && yarn add react@^17 react-dom@^17 @testing-library/react@^12 @testing-library/react-hooks@^8 @testing-library/dom@^8 react-test-renderer@^16.9.0 && node scripts/oldReactSupport.mjs",
"install-19": "node scripts/react-19-install-prep.mjs && yarn add react@next react-dom@next",
Expand Down Expand Up @@ -208,7 +208,6 @@
"tempy": "^0.5.0",
"typescript": "^5.5.0",
"typescript-eslint": "^8.9.0",
"typescript-strict-plugin": "^2.0.0",
"verdaccio": "^5.13.0",
"walk-object": "^4.0.0",
"wsrun": "^5.0.0",
Expand Down
2 changes: 0 additions & 2 deletions packages/@internationalized/message/src/MessageDictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ function getStringsForLocale(locale: string, strings: LocalizedStrings, defaultL
}

function getLanguage(locale: string) {
// @ts-ignore
if (Intl.Locale) {
// @ts-ignore
return new Intl.Locale(locale).language;
}

Expand Down
7 changes: 0 additions & 7 deletions packages/@internationalized/number/src/NumberFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ let formatterCache = new Map<string, Intl.NumberFormat>();

let supportsSignDisplay = false;
try {
// @ts-ignore
supportsSignDisplay = (new Intl.NumberFormat('de-DE', {signDisplay: 'exceptZero'})).resolvedOptions().signDisplay === 'exceptZero';
// eslint-disable-next-line no-empty
} catch {}

let supportsUnit = false;
try {
// @ts-ignore
supportsUnit = (new Intl.NumberFormat('de-DE', {style: 'unit', unit: 'degree'})).resolvedOptions().style === 'unit';
// eslint-disable-next-line no-empty
} catch {}
Expand Down Expand Up @@ -87,15 +85,12 @@ export class NumberFormatter implements Intl.NumberFormat {
/** Formats a number to an array of parts such as separators, digits, punctuation, and more. */
formatToParts(value: number): Intl.NumberFormatPart[] {
// TODO: implement signDisplay for formatToParts
// @ts-ignore
return this.numberFormatter.formatToParts(value);
}

/** Formats a number range as a string. */
formatRange(start: number, end: number): string {
// @ts-ignore
if (typeof this.numberFormatter.formatRange === 'function') {
// @ts-ignore
return this.numberFormatter.formatRange(start, end);
}

Expand All @@ -109,9 +104,7 @@ export class NumberFormatter implements Intl.NumberFormat {

/** Formats a number range as an array of parts. */
formatRangeToParts(start: number, end: number): NumberRangeFormatPart[] {
// @ts-ignore
if (typeof this.numberFormatter.formatRangeToParts === 'function') {
// @ts-ignore
return this.numberFormatter.formatRangeToParts(start, end);
}

Expand Down
3 changes: 0 additions & 3 deletions packages/@internationalized/number/src/NumberParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ function getSymbols(locale: string, formatter: Intl.NumberFormat, intlOptions: I

// Safari does not support the signDisplay option, but our number parser polyfills it.
// If no plus sign was returned, but the original options contained signDisplay, default to the '+' character.
// @ts-ignore
if (!plusSign && (originalOptions?.signDisplay === 'exceptZero' || originalOptions?.signDisplay === 'always')) {
plusSign = '+';
}
Expand Down Expand Up @@ -305,9 +304,7 @@ function getSymbols(locale: string, formatter: Intl.NumberFormat, intlOptions: I
}

function replaceAll(str: string, find: string, replace: string) {
// @ts-ignore
if (str.replaceAll) {
// @ts-ignore
return str.replaceAll(find, replace);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/

import {Item} from '@react-stately/collections';
import {ListLayout} from '@react-stately/layout';
import React from 'react';
import {renderHook} from '@react-spectrum/test-utils-internal';
import {useComboBoxState} from '@react-stately/combobox';
Expand All @@ -30,11 +29,6 @@ describe('useSearchAutocomplete', function () {
});

let defaultProps = {items: [{id: 1, name: 'one'}], children: (props) => <Item>{props.name}</Item>};
let {result} = renderHook(() => useComboBoxState(defaultProps));
let mockLayout = new ListLayout({
rowHeight: 40
});
mockLayout.collection = result.current.collection;

afterEach(() => {
jest.clearAllMocks();
Expand All @@ -45,8 +39,7 @@ describe('useSearchAutocomplete', function () {
label: 'test label',
popoverRef: React.createRef(),
inputRef: React.createRef(),
listBoxRef: React.createRef(),
layout: mockLayout
listBoxRef: React.createRef()
};

let {result} = renderHook(() => useSearchAutocomplete(props, useComboBoxState(defaultProps)));
Expand All @@ -73,8 +66,7 @@ describe('useSearchAutocomplete', function () {
inputRef: {
current: document.createElement('input')
},
listBoxRef: React.createRef(),
layout: mockLayout
listBoxRef: React.createRef()
};

let {result: state} = renderHook((props) => useComboBoxState(props), {initialProps: props});
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-aria/combobox/src/useComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export function useComboBox<T>(props: AriaComboBoxOptions<T>, state: ComboBoxSta
let lastSection = useRef(sectionKey);
let lastItem = useRef(itemKey);
useEffect(() => {
if (isAppleDevice() && focusedItem != null && itemKey !== lastItem.current) {
if (isAppleDevice() && focusedItem != null && itemKey != null && itemKey !== lastItem.current) {
let isSelected = state.selectionManager.isSelected(itemKey);
let section = sectionKey != null ? state.collection.getItem(sectionKey) : null;
let sectionTitle = section?.['aria-label'] || (typeof section?.rendered === 'string' ? section.rendered : '') || '';
Expand Down
9 changes: 1 addition & 8 deletions packages/@react-aria/combobox/test/useComboBox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import {actHook as act, renderHook} from '@react-spectrum/test-utils-internal';
import {Item} from '@react-stately/collections';
import {ListLayout} from '@react-stately/layout';
import React from 'react';
import {useComboBox} from '../';
import {useComboBoxState} from '@react-stately/combobox';
Expand All @@ -32,11 +31,6 @@ describe('useComboBox', function () {
});

let defaultProps = {items: [{id: 1, name: 'one'}], children: (props) => <Item>{props.name}</Item>};
let {result} = renderHook(() => useComboBoxState(defaultProps));
let mockLayout = new ListLayout({
rowHeight: 40
});
mockLayout.collection = result.current.collection;

let props = {
label: 'test label',
Expand All @@ -51,8 +45,7 @@ describe('useComboBox', function () {
},
listBoxRef: {
current: document.createElement('div')
},
layout: mockLayout
}
};

afterEach(() => {
Expand Down
8 changes: 4 additions & 4 deletions packages/@react-aria/datepicker/src/useDateRangePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import {AriaButtonProps} from '@react-types/button';
import {AriaDatePickerProps, AriaDateRangePickerProps, DateValue} from '@react-types/datepicker';
import {AriaDialogProps} from '@react-types/dialog';
import {createFocusManager} from '@react-aria/focus';
import {DateRange, RangeCalendarProps} from '@react-types/calendar';
import {DateRangePickerState} from '@react-stately/datepicker';
import {DEFAULT_VALIDATION_RESULT, mergeValidation, privateValidationStateProp} from '@react-stately/form';
import {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';
import {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';
import {focusManagerSymbol, roleSymbol} from './useDateField';
// @ts-ignore
import intlMessages from '../intl/*.json';
import {RangeCalendarProps} from '@react-types/calendar';
import {useDatePickerGroup} from './useDatePickerGroup';
import {useField} from '@react-aria/label';
import {useFocusWithin} from '@react-aria/interactions';
Expand Down Expand Up @@ -168,7 +168,7 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
startFieldProps: {
...startFieldProps,
...commonFieldProps,
value: state.value?.start,
value: state.value?.start ?? null,
onChange: start => state.setDateTime('start', start),
autoFocus: props.autoFocus,
name: props.startName,
Expand All @@ -186,7 +186,7 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
endFieldProps: {
...endFieldProps,
...commonFieldProps,
value: state.value?.end,
value: state.value?.end ?? null,
onChange: end => state.setDateTime('end', end),
name: props.endName,
[privateValidationStateProp]: {
Expand All @@ -204,7 +204,7 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
errorMessageProps,
calendarProps: {
autoFocus: true,
value: state.dateRange,
value: state.dateRange?.start && state.dateRange.end ? state.dateRange as DateRange : null,
onChange: state.setDateRange,
minValue: props.minValue,
maxValue: props.maxValue,
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-aria/dnd/src/DragPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {flushSync} from 'react-dom';
import React, {ForwardedRef, JSX, useEffect, useImperativeHandle, useRef, useState} from 'react';

export interface DragPreviewProps {
children: (items: DragItem[]) => JSX.Element
children: (items: DragItem[]) => JSX.Element | null
}

function DragPreview(props: DragPreviewProps, ref: ForwardedRef<DragPreviewRenderer | null>) {
Expand Down
7 changes: 4 additions & 3 deletions packages/@react-aria/dnd/src/useDroppableCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface DroppableCollectionResult {

interface DroppingState {
collection: Collection<Node<unknown>>,
focusedKey: Key,
focusedKey: Key | null,
selectedKeys: Set<Key>,
target: DropTarget,
draggingKeys: Set<Key | null | undefined>,
Expand Down Expand Up @@ -273,6 +273,7 @@ export function useDroppableCollection(props: DroppableCollectionOptions, state:
}
}
} else if (
prevFocusedKey != null &&
state.selectionManager.focusedKey === prevFocusedKey &&
isInternal &&
target.type === 'item' &&
Expand All @@ -293,7 +294,7 @@ export function useDroppableCollection(props: DroppableCollectionOptions, state:
// Also show the focus ring if the focused key is not selected, e.g. in case of a reorder.
state.selectionManager.setFocusedKey(target.key);
setInteractionModality('keyboard');
} else if (!state.selectionManager.isSelected(state.selectionManager.focusedKey)) {
} else if (state.selectionManager.focusedKey != null && !state.selectionManager.isSelected(state.selectionManager.focusedKey)) {
setInteractionModality('keyboard');
}

Expand Down Expand Up @@ -533,7 +534,7 @@ export function useDroppableCollection(props: DroppableCollectionOptions, state:

// If the focused key is a cell, get the parent item instead.
// For now, we assume that individual cells cannot be dropped on.
let item = localState.state.collection.getItem(key);
let item = key != null ? localState.state.collection.getItem(key) : null;
if (item?.type === 'cell') {
key = item.parentKey;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-aria/dnd/stories/DraggableCollection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function DraggableCollectionExample(props) {

function DraggableCollection(props) {
let ref = React.useRef<HTMLDivElement>(null);
let state = useListState(props);
let state = useListState<ItemValue>(props);
let gridState = useGridState({
selectionMode: 'multiple',
collection: React.useMemo(() => new GridCollection<ItemValue>({
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-aria/dnd/stories/dnd.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ function DraggableCollectionExample(props) {
function DraggableCollection(props) {
let {isDisabled} = props;
let ref = React.useRef<HTMLDivElement>(null);
let state = useListState(props);
let state = useListState<ItemValue>(props);
let gridState = useGridState({
...props,
selectionMode: 'multiple',
Expand Down
Loading