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: upgrade babel/typescript to support latest features #1172

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"presets": ["@babel/env", "@babel/react", "@babel/preset-typescript"],
"plugins": [
"transform-export-extensions",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-export-default-from"
]
}
19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"release": "./scripts/release.sh"
},
"prettier": {
"singleQuote": true
"singleQuote": true,
"trailingComma": "none"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really care that much, but this keeps the existing behavior that was present before the upgrade to keep things consistent

},
"husky": {
"hooks": {
Expand All @@ -43,14 +44,12 @@
},
"devDependencies": {
"@axe-core/puppeteer": "^4.3.1",
"@babel/core": "^7.4.3",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/plugin-proposal-export-default-from": "^7.2.0",
"@babel/preset-env": "^7.8.4",
"@babel/preset-react": "^7.0.0",
"@babel/preset-stage-0": "^7.0.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really needed anymore

"@babel/preset-typescript": "^7.8.3",
"@babel/register": "^7.4.0",
"@babel/core": "^7.22.10",
"@babel/plugin-proposal-export-default-from": "^7.22.5",
"@babel/preset-env": "^7.22.10",
"@babel/preset-react": "^7.22.5",
"@babel/preset-typescript": "^7.22.5",
"@babel/register": "^7.22.5",
"@fontsource/lato": "^4.5.0",
"@fontsource/pt-mono": "^4.5.0",
"@fontsource/roboto": "^4.5.1",
Expand Down Expand Up @@ -128,7 +127,7 @@
"style-loader": "^0.19.0",
"terser-webpack-plugin": "^5.3.6",
"ts-node": "^10.9.1",
"typescript": "^3.7.5",
"typescript": "~5.0.0",
Copy link
Member Author

@scurker scurker Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prettier yells at you if it's 5.1.0 or greater 🤷

"webpack": "^5.76.0",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1"
Expand Down
1 change: 0 additions & 1 deletion packages/react/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
}
],
"transform-export-extensions",
"@babel/plugin-proposal-class-properties",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now included as part of preset-env

"@babel/plugin-proposal-export-default-from"
]
}
19 changes: 8 additions & 11 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,15 @@
"tslib": "^2.4.0"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

"@babel/core": "^7.9.6",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-export-default-from": "^7.8.3",
"@babel/preset-env": "^7.9.6",
"@babel/preset-react": "^7.9.4",
"@babel/preset-stage-0": "^7.8.3",
"@babel/preset-typescript": "^7.9.0",
"@babel/register": "^7.9.0",
"@babel/core": "^7.22.10",
"@babel/plugin-proposal-export-default-from": "^7.22.5",
"@babel/preset-env": "^7.22.10",
"@babel/preset-react": "^7.22.5",
"@babel/preset-typescript": "^7.22.5",
"@babel/register": "^7.22.5",
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-dynamic-import-vars": "^1.4.2",
"@rollup/plugin-typescript": "^5.0.2",
"@rollup/plugin-typescript": "^11.1.2",
"@svgr/rollup": "^6.1.2",
"@types/classnames": "^2.2.10",
"@types/node": "^17.0.42",
Expand Down Expand Up @@ -78,7 +75,7 @@
"rollup": "^2.23.0",
"sinon": "^10.0.0",
"ts-node": "^10.9.1",
"typescript": "^4.7.3"
"typescript": "~5.0.0"
},
"repository": {
"type": "git",
Expand Down
15 changes: 9 additions & 6 deletions packages/react/src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ const Accordion = ({
const childrenArray = React.Children.toArray(children);

const trigger = childrenArray.find(
child =>
(child) =>
typeof child === 'string' ||
(child as React.ReactElement<any>).type === AccordionTrigger
);
) as unknown as typeof AccordionTrigger;

const panelElement = childrenArray.find(
child =>
(child) =>
typeof child === 'string' ||
(child as React.ReactElement<any>).type === AccordionContent
);
Expand Down Expand Up @@ -96,10 +96,13 @@ const Accordion = ({
<PanelTrigger
iconCollapsed="triangle-right"
iconExpanded="triangle-down"
className={classnames('Accordion__trigger', trigger.props.className)}
className={classnames(
'Accordion__trigger',
(trigger.props as AccordionTriggerProps).className
)}
aria-controls={panelElement.props.id || `${elementId}-panel`}
heading={trigger.props.heading}
{...trigger.props}
heading={(trigger.props as AccordionTriggerProps).heading}
{...(trigger.props as AccordionTriggerProps)}
>
{trigger}
</PanelTrigger>
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/components/FieldWrap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const FieldWrap = React.forwardRef<HTMLElement, Props>(

FieldWrap.displayName = 'FieldWrap';
FieldWrap.propTypes = {
// @ts-expect-error
children: PropTypes.node.isRequired,
className: PropTypes.string,
as: PropTypes.string
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/components/IconButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ IconButton.propTypes = {
as: PropTypes.elementType,
// @ts-expect-error
icon: PropTypes.string.isRequired,
// @ts-expect-error
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently none of these error anymore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The others still error?

label: PropTypes.node.isRequired,
// @ts-expect-error
tooltipPlacement: PropTypes.string,
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/components/LoaderOverlay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ LoaderOverlay.propTypes = {
variant: PropTypes.oneOf(['large', 'small']),
label: PropTypes.string,
focusOnInitialRender: PropTypes.bool,
// @ts-expect-error
children: PropTypes.node
};

Expand Down
1 change: 0 additions & 1 deletion packages/react/src/components/Notice/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const Notice = forwardRef<HTMLDivElement, NoticeProps>(

Notice.displayName = 'Notice';
Notice.propTypes = {
// @ts-expect-error
children: PropTypes.node,
type: PropTypes.oneOf(['caution', 'info', 'danger']),
// @ts-expect-error
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/components/Panel/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const Panel = forwardRef<HTMLElement, PanelProps>(

Panel.displayName = 'Panel';
Panel.propTypes = {
// @ts-expect-error
children: PropTypes.node.isRequired,
// @ts-expect-error
heading: PropTypes.oneOfType([PropTypes.object, PropTypes.node]),
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/components/Panel/PanelContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const PanelContent = forwardRef<HTMLDivElement, PanelContentProps>(
PanelContent.displayName = 'PanelContent';

PanelContent.propTypes = {
//@ts-expect-error
children: PropTypes.node.isRequired,
className: PropTypes.string,
padding: PropTypes.bool
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/components/Panel/PanelHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const PanelHeader = forwardRef<HTMLDivElement, PanelHeaderProps>(
PanelHeader.displayName = 'PanelHeader';

PanelHeader.propTypes = {
//@ts-expect-error
children: PropTypes.node.isRequired,
className: PropTypes.string
};
Expand Down
7 changes: 3 additions & 4 deletions packages/react/src/components/SideBar/SideBarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export interface SideBarItemProps extends React.HTMLAttributes<HTMLLIElement> {
autoClickLink?: boolean;
}

const SideBarItem: React.ComponentType<React.PropsWithChildren<
SideBarItemProps
>> = ({ children, autoClickLink, ...other }) => {
const SideBarItem: React.ComponentType<
React.PropsWithChildren<SideBarItemProps>
> = ({ children, autoClickLink, ...other }) => {
const onClick = (e: React.MouseEvent<HTMLLIElement>) => {
if (!autoClickLink) {
return;
Expand All @@ -31,7 +31,6 @@ SideBarItem.defaultProps = {
autoClickLink: true
};
SideBarItem.propTypes = {
// @ts-expect-error
children: PropTypes.node.isRequired,
autoClickLink: PropTypes.bool
};
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/components/Tabs/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Tab.displayName = 'Tab';
Tab.propTypes = {
target: PropTypes.any.isRequired,
id: PropTypes.string,
// @ts-expect-error
children: PropTypes.node
};

Expand Down
1 change: 0 additions & 1 deletion packages/react/src/components/Tabs/TabPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const TabPanel = forwardRef<HTMLDivElement, TabPanelProps>(
TabPanel.displayName = 'TabPanel';
TabPanel.propTypes = {
id: PropTypes.string,
// @ts-expect-error
children: PropTypes.node,
className: PropTypes.string
};
Expand Down
7 changes: 3 additions & 4 deletions packages/react/src/components/TopBar/TopBarTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ interface TopBarTriggerProps extends React.HTMLAttributes<HTMLLIElement> {
children: React.ReactNode;
}

const TopBarTrigger: React.ComponentType<React.PropsWithChildren<
TopBarTriggerProps
>> = ({ children, className, ...other }) => (
const TopBarTrigger: React.ComponentType<
React.PropsWithChildren<TopBarTriggerProps>
> = ({ children, className, ...other }) => (
<MenuItem
aria-haspopup="true"
className={classNames('TopBar__menu-trigger', className)}
Expand All @@ -20,7 +20,6 @@ const TopBarTrigger: React.ComponentType<React.PropsWithChildren<
);
TopBarTrigger.displayName = 'TopBarTrigger';
TopBarTrigger.propTypes = {
// @ts-expect-error
children: PropTypes.node.isRequired,
className: PropTypes.string
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const TwoColumnPanel = forwardRef<HTMLDivElement, TwoColumnPanelProps>(
const columnRightRef = useRef<HTMLDivElement>(null);

const columnLeft = React.Children.toArray(children).find(
child => (child as React.ReactElement<any>).type === ColumnLeft
(child) => (child as React.ReactElement<any>).type === ColumnLeft
);

const togglePanel = () => {
Expand Down Expand Up @@ -112,7 +112,7 @@ const TwoColumnPanel = forwardRef<HTMLDivElement, TwoColumnPanelProps>(
];
ColumnLeftComponent = cloneElement(
columnLeft,
{ id, ref, tabIndex: -1 },
{ id, ref, tabIndex: -1 } as React.ComponentProps<typeof ColumnLeft>,
children.map((child, index) =>
cloneElement(child as React.ReactElement, {
key: (child as React.ReactElement).key
Expand All @@ -124,7 +124,7 @@ const TwoColumnPanel = forwardRef<HTMLDivElement, TwoColumnPanelProps>(
}

const columnRight = React.Children.toArray(children).find(
child => (child as React.ReactElement<any>).type === ColumnRight
(child) => (child as React.ReactElement<any>).type === ColumnRight
);

let ColumnRightComponent;
Expand Down Expand Up @@ -163,7 +163,7 @@ const TwoColumnPanel = forwardRef<HTMLDivElement, TwoColumnPanelProps>(
];
ColumnRightComponent = cloneElement(
columnRight,
{ ref, tabIndex: -1 },
{ ref, tabIndex: -1 } as React.ComponentProps<typeof ColumnRight>,
children.map((child, index) =>
cloneElement(child as React.ReactElement, {
key: (child as React.ReactElement).key
Expand Down
Loading