-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update react types #5237
Update react types #5237
Conversation
Build successful! 🎉 |
@@ -46,7 +46,7 @@ function App() { | |||
{(item: any) => | |||
(<Row key={item.foo} UNSTABLE_childItems={item.childRows}> | |||
{(key) => { | |||
return <Cell>{item[key.toString()]}</Cell>; | |||
return <Cell>{item[key]}</Cell>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested via verdaccio build
see https://github.com/adobe/react-spectrum/pull/5237/commits commit See if we fixed the key issue in the CRA app circle ci build
@@ -3,7 +3,7 @@ import React from "react"; | |||
|
|||
interface SectionProps { | |||
title: string; | |||
children: JSX.Element | JSX.Element[]; | |||
children: React.JSX.Element | React.JSX.Element[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React got rid of the global namespace, but JSX is still in the React namespace, so reference through that
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L3309
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deprecated but not removed. Doesn't really explain why it broke. Any idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It broke between RAC alpha 4 and alpha 5 https://unpkg.com/browse/react-aria-components@1.0.0-alpha.5/dist/
Here's the list of commits between those two versions 5911ed2...7186d21
in alpha 4, we exported using the global namespace which included JSX. in alpha 5, we stopped doing that and started exporting the React namespaced version.
I suspect some parcel or update to types in our own repo which caused us to stop using the global namespace, but I haven't nailed it down yet. Upgrading the types caused it to be marked as deprecated in our own code base, but the problem was already present.
I'm following up with the issue author because I suspect they have multiple copies of react types. I suspect users just need to upgrade their types and dedupe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it "broke" in 1123b0f
we upgraded our react/types from 17 to 18, and it seems as though our type generation is smart enough to find the non-global namespace of JSX and prefer that. I'm not sure where that is in the parcel transformer?
I haven't actually "fixed" it in this PR, I think people have to update themselves which is what I followed up with the issue author to do.
In addition to explicit references to the global JSX (RAC DialogTrigger), we also have many implicit references to it. Any inferred component's return value for instance. So if we wanted to "fix" this by using the global JSX namespace again, we'd need to handle both of these.
@@ -31,7 +31,7 @@ | |||
"copyrights": "babel-node --presets @babel/env ./scripts/addHeaders.js", | |||
"build:icons": "babel-node --presets @babel/env ./scripts/buildIcons.js", | |||
"clean:icons": "babel-node --presets @babel/env ./scripts/cleanIcons.js", | |||
"postinstall": "yarn build:icons && patch-package", | |||
"postinstall": "patch-package && yarn build:icons", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run first so that we can fix lodash types before icons build since they'll fail if the types are bad
@@ -0,0 +1,2 @@ | |||
|
|||
export type Key = string | number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this a good place for the type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd have just put it in collections.d.ts. But if you want to keep it in a new file you'll need a license header.
@@ -76,7 +76,12 @@ const GROUPS = { | |||
}; | |||
|
|||
export function PropTable({component, links, style}) { | |||
let [ungrouped, groups] = groupProps(component.props.properties); | |||
let ungrouped, groups; | |||
if (!component.props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what about the typescript update broke this, but some times we now get 'parameters' instead of just 'props'
@@ -6,6 +6,5 @@ export interface LabeledValueProps extends LabeledValueBaseProps { | |||
/** The value to display. */ | |||
value: string | string[] | number | RangeValue<number> | DateTime | RangeValue<DateTime>, | |||
/** Formatting options for the value. The available options depend on the type passed to the `value` prop. */ | |||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could have gotten rid of these Intl.ListFormatOptions anytime after upgrading ts to v5, may as well remove it here
'no-getByRole-toThrow': noGetByRoleToThrow | ||
'no-getByRole-toThrow': noGetByRoleToThrow, | ||
'no-react-key': noReactKey, | ||
'sort-imports': sortImports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved in here so i could add some tests more easily
} | ||
- | ||
-// Backward compatibility with --target es5 | ||
-declare global { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why lodash has this but I don't think it's needed and it was causing our build to fail because we don't skip lib check
Build successful! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, let's get this in for testing.
Build successful! 🎉 |
Build successful! 🎉 |
# Conflicts: # packages/@react-spectrum/menu/src/ContextualHelpTrigger.tsx # yarn.lock
Build successful! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commenting a review here to merge some newline removals nits, will push a separate commit for the rest
Build successful! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, verified that the new lint rule works as well
looks good aside from the |
Build successful! 🎉 |
# Conflicts: # packages/@react-aria/interactions/stories/useFocusRing.stories.tsx # packages/@react-aria/tag/src/useTagGroup.ts # packages/@react-spectrum/form/stories/Form.stories.tsx # packages/@react-types/autocomplete/src/index.d.ts # yarn.lock
@devongovett fixed |
Build successful! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, verified that the undefined.JSX.Element
are fixed. Looks like you've got some conflicts so I'll approve after those are fixed
# Conflicts: # packages/react-aria-components/src/Collection.tsx # packages/react-aria-components/src/ListBox.tsx # packages/react-aria-components/src/utils.tsx
Build successful! 🎉 |
Build successful! 🎉 |
Build successful! 🎉 |
## API Changes
unknown top level export { type: 'any' } @react-aria/dndDragPreviewProps DragPreviewProps {
- children: (Array<DragItem>) => JSX.Element
+ children: (Array<DragItem>) => React.JSX.Element
} useClipboard DragPreview {
- children: (Array<DragItem>) => JSX.Element
+ children: (Array<DragItem>) => React.JSX.Element
} @react-spectrum/dndDragAndDropOptions DragAndDropOptions {
getItems?: (Set<Key>) => Array<DragItem> = () => []
- renderPreview?: (Set<Key>, Key) => JSX.Element
+ renderPreview?: (Set<Key>, Key) => React.JSX.Element
} it changed:
DragAndDropHooks DragAndDropHooks {
dragAndDropHooks: (DragHooks & DropHooks & {
isVirtualDragging?: () => boolean
- renderPreview?: (Set<Key>, Key) => JSX.Element
+ renderPreview?: (Set<Key>, Key) => React.JSX.Element
})
} it changed:
@react-spectrum/listListView ListView<T extends {}> {
density?: 'compact' | 'regular' | 'spacious' = 'regular'
dragAndDropHooks?: DragAndDropHooks['dragAndDropHooks']
isQuiet?: boolean
loadingState?: LoadingState
onAction?: (Key) => void
overflowMode?: 'truncate' | 'wrap' = 'truncate'
- renderEmptyState?: () => JSX.Element
+ renderEmptyState?: () => React.JSX.Element
} SpectrumListViewProps SpectrumListViewProps<T> {
density?: 'compact' | 'regular' | 'spacious' = 'regular'
dragAndDropHooks?: DragAndDropHooks['dragAndDropHooks']
isQuiet?: boolean
loadingState?: LoadingState
onAction?: (Key) => void
overflowMode?: 'truncate' | 'wrap' = 'truncate'
- renderEmptyState?: () => JSX.Element
+ renderEmptyState?: () => React.JSX.Element
} @react-spectrum/tableColumn TableView<T extends {}> {
density?: 'compact' | 'regular' | 'spacious' = 'regular'
dragAndDropHooks?: DragAndDropHooks['dragAndDropHooks']
isQuiet?: boolean
onAction?: (Key) => void
onResize?: (Map<Key, ColumnSize>) => void
onResizeEnd?: (Map<Key, ColumnSize>) => void
onResizeStart?: (Map<Key, ColumnSize>) => void
overflowMode?: 'wrap' | 'truncate' = 'truncate'
- renderEmptyState?: () => JSX.Element
+ renderEmptyState?: () => React.JSX.Element
} CellProps SpectrumTableProps<T> {
density?: 'compact' | 'regular' | 'spacious' = 'regular'
dragAndDropHooks?: DragAndDropHooks['dragAndDropHooks']
isQuiet?: boolean
onAction?: (Key) => void
onResize?: (Map<Key, ColumnSize>) => void
onResizeEnd?: (Map<Key, ColumnSize>) => void
onResizeStart?: (Map<Key, ColumnSize>) => void
overflowMode?: 'wrap' | 'truncate' = 'truncate'
- renderEmptyState?: () => JSX.Element
+ renderEmptyState?: () => React.JSX.Element
} @react-spectrum/tagTagGroup TagGroup<T extends {}> {
actionLabel?: string
maxRows?: number
onAction?: () => void
- renderEmptyState?: () => JSX.Element
+ renderEmptyState?: () => React.JSX.Element
} SpectrumTagGroupProps SpectrumTagGroupProps<T> {
actionLabel?: string
maxRows?: number
onAction?: () => void
- renderEmptyState?: () => JSX.Element
+ renderEmptyState?: () => React.JSX.Element
} |
Closes #5157
Also handles https://github.com/orgs/adobe/projects/19/views/4?pane=issue&itemId=41163780
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: