Skip to content

Commit 9b249e0

Browse files
snowystingerdevongovettLFDanLu
authored
chore: Ts strict remaining (#7368)
* TS Strict Collections * fix rebase * Start ts strict remaining * GridKeyboardDelegate and review * fix some calculateposition tests * fix calculate tests * fix listkeyboarddelegate * fix more tests * fix calculate position * changes to calculate position * grid aria hooks * aria menu * Virtualizer stuff * aria menus more * last of aria menu and overlay * Stately table * More table * delete pagination, aria select * aria slider and textfield * aria toast * fix extra toast * aria table * remove log * ignore s1 cards * More table and aria virtualizer * more * stately data * more * fix stories * fix tree data * more fixes * RSP slider * more stories * spectrum and aria combobox * Make useAsyncList sort function have a required sortDescriptor * stately fixes * fix toast test * rsp layout and stately tree * rsp menu * rsp overlays * rsp picker * more rsp * remaining rsp and dev * fix lint * update yarnlock * remove ts-ignores * a few more removed ts ignores * fix provider usage * DatePicker * fix tsconfig * remove plugin no longer needed * fix check-examples * Fix some ts-ignores * Fix docs build * turn on verdaccio build * fix accidental defaultkey of null * Toast noop * Make focusStrategy match * fix types for tailwind * Try fixing cra app * fix example apps * Revert "turn on verdaccio build" This reverts commit 3157bf1. * fix tooltip for chromatic * fix for all cases * delete pagination files again * fix lock file --------- Co-authored-by: Devon Govett <[email protected]> Co-authored-by: Daniel Lu <[email protected]>
1 parent 1908374 commit 9b249e0

File tree

387 files changed

+2194
-3114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

387 files changed

+2194
-3114
lines changed

examples/rsp-next-ts-17/components/ReorderableListView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function ReorderableListView() {
2222
// Setup the drag types and associated info for each dragged item.
2323
return {
2424
"custom-app-type-reorder": JSON.stringify(item),
25-
"text/plain": item.name,
25+
"text/plain": item?.name ?? '',
2626
};
2727
});
2828
},

examples/rsp-next-ts/components/ReorderableListView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function ReorderableListView() {
2222
// Setup the drag types and associated info for each dragged item.
2323
return {
2424
"custom-app-type-reorder": JSON.stringify(item),
25-
"text/plain": item.name,
25+
"text/plain": item?.name ?? '',
2626
};
2727
});
2828
},

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"packageManager": "[email protected]",
1111
"scripts": {
12-
"check-types": "tsc && tsc-strict",
12+
"check-types": "tsc",
1313
"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",
1414
"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",
1515
"install-19": "node scripts/react-19-install-prep.mjs && yarn add react@next react-dom@next",
@@ -208,7 +208,6 @@
208208
"tempy": "^0.5.0",
209209
"typescript": "^5.5.0",
210210
"typescript-eslint": "^8.9.0",
211-
"typescript-strict-plugin": "^2.0.0",
212211
"verdaccio": "^5.13.0",
213212
"walk-object": "^4.0.0",
214213
"wsrun": "^5.0.0",

packages/@internationalized/message/src/MessageDictionary.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ function getStringsForLocale(locale: string, strings: LocalizedStrings, defaultL
7676
}
7777

7878
function getLanguage(locale: string) {
79-
// @ts-ignore
8079
if (Intl.Locale) {
81-
// @ts-ignore
8280
return new Intl.Locale(locale).language;
8381
}
8482

packages/@internationalized/number/src/NumberFormatter.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ let formatterCache = new Map<string, Intl.NumberFormat>();
1414

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

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

9491
/** Formats a number range as a string. */
9592
formatRange(start: number, end: number): string {
96-
// @ts-ignore
9793
if (typeof this.numberFormatter.formatRange === 'function') {
98-
// @ts-ignore
9994
return this.numberFormatter.formatRange(start, end);
10095
}
10196

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

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

packages/@internationalized/number/src/NumberParser.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ function getSymbols(locale: string, formatter: Intl.NumberFormat, intlOptions: I
273273

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

307306
function replaceAll(str: string, find: string, replace: string) {
308-
// @ts-ignore
309307
if (str.replaceAll) {
310-
// @ts-ignore
311308
return str.replaceAll(find, replace);
312309
}
313310

packages/@react-aria/autocomplete/test/useSearchAutocomplete.test.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
*/
1212

1313
import {Item} from '@react-stately/collections';
14-
import {ListLayout} from '@react-stately/layout';
1514
import React from 'react';
1615
import {renderHook} from '@react-spectrum/test-utils-internal';
1716
import {useComboBoxState} from '@react-stately/combobox';
@@ -30,11 +29,6 @@ describe('useSearchAutocomplete', function () {
3029
});
3130

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

3933
afterEach(() => {
4034
jest.clearAllMocks();
@@ -45,8 +39,7 @@ describe('useSearchAutocomplete', function () {
4539
label: 'test label',
4640
popoverRef: React.createRef(),
4741
inputRef: React.createRef(),
48-
listBoxRef: React.createRef(),
49-
layout: mockLayout
42+
listBoxRef: React.createRef()
5043
};
5144

5245
let {result} = renderHook(() => useSearchAutocomplete(props, useComboBoxState(defaultProps)));
@@ -73,8 +66,7 @@ describe('useSearchAutocomplete', function () {
7366
inputRef: {
7467
current: document.createElement('input')
7568
},
76-
listBoxRef: React.createRef(),
77-
layout: mockLayout
69+
listBoxRef: React.createRef()
7870
};
7971

8072
let {result: state} = renderHook((props) => useComboBoxState(props), {initialProps: props});

packages/@react-aria/combobox/src/useComboBox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ export function useComboBox<T>(props: AriaComboBoxOptions<T>, state: ComboBoxSta
283283
let lastSection = useRef(sectionKey);
284284
let lastItem = useRef(itemKey);
285285
useEffect(() => {
286-
if (isAppleDevice() && focusedItem != null && itemKey !== lastItem.current) {
286+
if (isAppleDevice() && focusedItem != null && itemKey != null && itemKey !== lastItem.current) {
287287
let isSelected = state.selectionManager.isSelected(itemKey);
288288
let section = sectionKey != null ? state.collection.getItem(sectionKey) : null;
289289
let sectionTitle = section?.['aria-label'] || (typeof section?.rendered === 'string' ? section.rendered : '') || '';

packages/@react-aria/combobox/test/useComboBox.test.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
import {actHook as act, renderHook} from '@react-spectrum/test-utils-internal';
1414
import {Item} from '@react-stately/collections';
15-
import {ListLayout} from '@react-stately/layout';
1615
import React from 'react';
1716
import {useComboBox} from '../';
1817
import {useComboBoxState} from '@react-stately/combobox';
@@ -32,11 +31,6 @@ describe('useComboBox', function () {
3231
});
3332

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

4135
let props = {
4236
label: 'test label',
@@ -51,8 +45,7 @@ describe('useComboBox', function () {
5145
},
5246
listBoxRef: {
5347
current: document.createElement('div')
54-
},
55-
layout: mockLayout
48+
}
5649
};
5750

5851
afterEach(() => {

packages/@react-aria/datepicker/src/useDateRangePicker.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import {AriaButtonProps} from '@react-types/button';
1414
import {AriaDatePickerProps, AriaDateRangePickerProps, DateValue} from '@react-types/datepicker';
1515
import {AriaDialogProps} from '@react-types/dialog';
1616
import {createFocusManager} from '@react-aria/focus';
17+
import {DateRange, RangeCalendarProps} from '@react-types/calendar';
1718
import {DateRangePickerState} from '@react-stately/datepicker';
1819
import {DEFAULT_VALIDATION_RESULT, mergeValidation, privateValidationStateProp} from '@react-stately/form';
1920
import {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';
2021
import {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';
2122
import {focusManagerSymbol, roleSymbol} from './useDateField';
2223
// @ts-ignore
2324
import intlMessages from '../intl/*.json';
24-
import {RangeCalendarProps} from '@react-types/calendar';
2525
import {useDatePickerGroup} from './useDatePickerGroup';
2626
import {useField} from '@react-aria/label';
2727
import {useFocusWithin} from '@react-aria/interactions';
@@ -168,7 +168,7 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
168168
startFieldProps: {
169169
...startFieldProps,
170170
...commonFieldProps,
171-
value: state.value?.start,
171+
value: state.value?.start ?? null,
172172
onChange: start => state.setDateTime('start', start),
173173
autoFocus: props.autoFocus,
174174
name: props.startName,
@@ -186,7 +186,7 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
186186
endFieldProps: {
187187
...endFieldProps,
188188
...commonFieldProps,
189-
value: state.value?.end,
189+
value: state.value?.end ?? null,
190190
onChange: end => state.setDateTime('end', end),
191191
name: props.endName,
192192
[privateValidationStateProp]: {
@@ -204,7 +204,7 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
204204
errorMessageProps,
205205
calendarProps: {
206206
autoFocus: true,
207-
value: state.dateRange,
207+
value: state.dateRange?.start && state.dateRange.end ? state.dateRange as DateRange : null,
208208
onChange: state.setDateRange,
209209
minValue: props.minValue,
210210
maxValue: props.maxValue,

0 commit comments

Comments
 (0)