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

refactor: replace ts-expect-error with ts-ignore #2819

Merged
merged 1 commit into from
Nov 8, 2024
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
2 changes: 1 addition & 1 deletion src/axe/testA11y.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {render} from '@testing-library/react';
* ```
*/

// @ts-expect-error TS7006
// @ts-ignore TS7006
export default async function testA11y(node, axeOptions?) {
const container = React.isValidElement(node)
? render(node, axeOptions).container
Expand Down
12 changes: 6 additions & 6 deletions src/chromatic/HoverStyle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ const applyHoverStates = (

const hoverStylesheet = hStylesheet.sheet;

// @ts-expect-error TS18047
// @ts-ignore TS18047
if (!hoverStylesheet.cssRules || hoverStylesheet.cssRules.length !== 0) {
return;
}

const insertUnhoveredRule = (unhoveredSelector: string) => {
if (unhoveredSelector) {
// @ts-expect-error TS18047
// @ts-ignore TS18047
hoverStylesheet.insertRule(
unhoveredSelector,
// @ts-expect-error TS18047
// @ts-ignore TS18047
hoverStylesheet.cssRules.length
);
}
Expand All @@ -72,7 +72,7 @@ const applyHoverStates = (
if (conditionText) {
Array.from((rule as CSSGroupingRule).cssRules).forEach(r => {
insertUnhoveredRule(
// @ts-expect-error TS2345
// @ts-ignore TS2345
generateUnhoveredSelector(
r as CSSStyleRule,
hoverContainerId,
Expand All @@ -82,7 +82,7 @@ const applyHoverStates = (
});
} else {
insertUnhoveredRule(
// @ts-expect-error TS2345
// @ts-ignore TS2345
generateUnhoveredSelector(rule as CSSStyleRule, hoverContainerId)
);
}
Expand All @@ -103,7 +103,7 @@ const HoverStyle = ({
const hoverContainerId = 'hover-container';

React.useEffect(() => {
// @ts-expect-error TS2345
// @ts-ignore TS2345
applyHoverStates(hoverContainerId, styleheetRef.current);
}, []);

Expand Down
4 changes: 2 additions & 2 deletions src/chromatic/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const generateChromaticStory: any = (
const storyName = !isNew && storyToHover;

return (
// @ts-expect-error TS2322
// @ts-ignore TS2322
<HoverStyle storyName={storyName} key={storyName || i}>
<HoverStory {...module.default.args} {...HoverStory.args} />
</HoverStyle>
Expand All @@ -37,7 +37,7 @@ export const generateChromaticStory: any = (
);
};

// @ts-expect-error TS7006
// @ts-ignore TS7006
const mergeStories: any = module => {
const stories = Object.keys(module)
.filter(
Expand Down
2 changes: 1 addition & 1 deletion src/components/accordion/Accordion.chromatic.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const copy = {
"Now your family member just needs to open the link and hit 'accept'. If they aren't already on Brainly",
};

// @ts-expect-error TS7006
// @ts-ignore TS7006
const WithTooltip = args => {
const handleChange = () => null;

Expand Down
2 changes: 1 addition & 1 deletion src/components/accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const Accordion = ({
const wrapper = wrapperRef.current;

function handleKeyDown(event: KeyboardEvent) {
// @ts-expect-error TS7053
// @ts-ignore TS7053
const key = KEY_CODES[event.keyCode];

if (['space', 'enter'].includes(key)) {
Expand Down
18 changes: 9 additions & 9 deletions src/components/action-list/ActionList.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ describe('ActionList', () => {
);
const root = actionList.container.firstElementChild;

// @ts-expect-error TS18047
// @ts-ignore TS18047
expect(root.classList.contains('sg-actions-list')).toEqual(true);
});

it('to-right', () => {
const actionList = render(<ActionList direction={DIRECTION.TO_RIGHT} />);
const root = actionList.container.firstElementChild;

// @ts-expect-error TS18047
// @ts-ignore TS18047
expect(root.classList.contains('sg-actions-list--to-right')).toEqual(true);
});

it('to-top', () => {
const actionList = render(<ActionList toTop />);
const root = actionList.container.firstElementChild;

// @ts-expect-error TS18047
// @ts-ignore TS18047
expect(root.classList.contains('sg-actions-list--to-top')).toEqual(true);
});

it('baseline', () => {
const actionList = render(<ActionList align={ALIGNMENT.BASELINE} />);
const root = actionList.container.firstElementChild;

// @ts-expect-error TS18047
// @ts-ignore TS18047
expect(root.classList.contains('sg-actions-list--align-baseline')).toEqual(
true
);
Expand All @@ -52,7 +52,7 @@ describe('ActionList', () => {
const actionList = render(<ActionList direction={DIRECTION.CENTERED} />);
const root = actionList.container.firstElementChild;

// @ts-expect-error TS18047
// @ts-ignore TS18047
expect(root.classList.contains('sg-actions-list--centered')).toEqual(true);
});

Expand All @@ -62,7 +62,7 @@ describe('ActionList', () => {
);
const root = actionList.container.firstElementChild;

// @ts-expect-error TS18047
// @ts-ignore TS18047
expect(root.classList.contains('sg-actions-list--space-between')).toEqual(
true
);
Expand All @@ -74,7 +74,7 @@ describe('ActionList', () => {
);
const root = actionList.container.firstElementChild;

// @ts-expect-error TS18047
// @ts-ignore TS18047
expect(root.classList.contains('sg-actions-list--space-around')).toEqual(
true
);
Expand All @@ -86,7 +86,7 @@ describe('ActionList', () => {
);
const root = actionList.container.firstElementChild;

// @ts-expect-error TS18047
// @ts-ignore TS18047
expect(root.classList.contains('sg-actions-list--space-evenly')).toEqual(
true
);
Expand All @@ -96,7 +96,7 @@ describe('ActionList', () => {
const actionList = render(<ActionList noWrap />);
const root = actionList.container.firstElementChild;

// @ts-expect-error TS18047
// @ts-ignore TS18047
expect(root.classList.contains('sg-actions-list--no-wrap')).toEqual(true);
});
});
24 changes: 12 additions & 12 deletions src/components/action-list/ActionListHole.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('<ActionListHole />', () => {
);

expect(
// @ts-expect-error TS18047
// @ts-ignore TS18047
actionListHole.container.firstElementChild.classList.contains(
'sg-actions-list__hole'
)
Expand All @@ -27,7 +27,7 @@ describe('<ActionListHole />', () => {
);

expect(
// @ts-expect-error TS18047
// @ts-ignore TS18047
actionListHole.container.firstElementChild.classList.contains(
'sg-actions-list__hole--container'
)
Expand All @@ -39,7 +39,7 @@ describe('<ActionListHole />', () => {
);

expect(
// @ts-expect-error TS18047
// @ts-ignore TS18047
actionListHole.container.firstElementChild.classList.contains(
'sg-actions-list__hole--no-spacing'
)
Expand All @@ -51,7 +51,7 @@ describe('<ActionListHole />', () => {
);

expect(
// @ts-expect-error TS18047
// @ts-ignore TS18047
actionListHole.container.firstElementChild.classList.contains(
'sg-actions-list__hole--space-bellow'
)
Expand All @@ -63,7 +63,7 @@ describe('<ActionListHole />', () => {
);

expect(
// @ts-expect-error TS18047
// @ts-ignore TS18047
actionListHole.container.firstElementChild.classList.contains(
'sg-actions-list__hole--no-shrink'
)
Expand All @@ -73,7 +73,7 @@ describe('<ActionListHole />', () => {
const actionListHole = render(<ActionListHole grow>test</ActionListHole>);

expect(
// @ts-expect-error TS18047
// @ts-ignore TS18047
actionListHole.container.firstElementChild.classList.contains(
'sg-actions-list__hole--grow'
)
Expand All @@ -83,7 +83,7 @@ describe('<ActionListHole />', () => {
const actionListHole = render(<ActionListHole toEnd>test</ActionListHole>);

expect(
// @ts-expect-error TS18047
// @ts-ignore TS18047
actionListHole.container.firstElementChild.classList.contains(
'sg-actions-list__hole--to-end'
)
Expand All @@ -95,7 +95,7 @@ describe('<ActionListHole />', () => {
);

expect(
// @ts-expect-error TS18047
// @ts-ignore TS18047
actionListHole.container.firstElementChild.classList.contains(
'sg-actions-list__hole--to-right'
)
Expand All @@ -107,7 +107,7 @@ describe('<ActionListHole />', () => {
);

expect(
// @ts-expect-error TS18047
// @ts-ignore TS18047
actionListHole.container.firstElementChild.classList.contains(
'sg-actions-list__hole--to-right'
)
Expand All @@ -121,7 +121,7 @@ describe('<ActionListHole />', () => {
);

expect(
// @ts-expect-error TS18047
// @ts-ignore TS18047
actionListHole.container.firstElementChild.classList.contains(
'sg-actions-list__hole--spaced-small'
)
Expand All @@ -135,7 +135,7 @@ describe('<ActionListHole />', () => {
);

expect(
// @ts-expect-error TS18047
// @ts-ignore TS18047
actionListHole.container.firstElementChild.classList.contains(
'sg-actions-list__hole--spaced-xsmall'
)
Expand All @@ -147,7 +147,7 @@ describe('<ActionListHole />', () => {
);

expect(
// @ts-expect-error TS18047
// @ts-ignore TS18047
actionListHole.container.firstElementChild.classList.contains(
'sg-actions-list__hole--equal-width'
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/box/Box.chromatic.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
responsivePropsStoryLabel,
} from '../../chromatic/utils';

// @ts-expect-error TS7006
// @ts-ignore TS7006
export const ResponsiveProps = args => {
return (
<div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/buttons/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ const Button = React.forwardRef(
ico = <span className={iconClass}>{icon}</span>;
}

// @ts-expect-error TS7006
// @ts-ignore TS7006
const onButtonClick = e => {
if (isLink && isDisabled) {
return;
Expand All @@ -386,7 +386,7 @@ const Button = React.forwardRef(
className={btnClass}
href={href}
disabled={isDisabled}
// @ts-expect-error generics while using React.forwardRef
// @ts-ignore generics while using React.forwardRef
ref={ref}
target={target}
aria-label={ariaLabel}
Expand Down
2 changes: 1 addition & 1 deletion src/components/buttons/ButtonLite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const ButtonLite = ({
);
}

// @ts-expect-error TS7006
// @ts-ignore TS7006
const onButtonClick = e => {
if (isLink && isDisabled) {
return;
Expand Down
6 changes: 3 additions & 3 deletions src/components/card-interactive/CardCheckbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const CardCheckboxRoot = React.forwardRef<
};

const onInputChange = React.useCallback(
// @ts-expect-error TS7006
// @ts-ignore TS7006
e => {
if (!isControlled) {
setIsChecked(val => !val);
Expand All @@ -189,9 +189,9 @@ export const CardCheckboxRoot = React.forwardRef<
<CardCheckboxContext.Provider
value={{
checked: isChecked,
// @ts-expect-error TS2322
// @ts-ignore TS2322
indeterminate,
// @ts-expect-error TS2322
// @ts-ignore TS2322
disabled,
}}
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/card-interactive/CardRadio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const CardRadio = React.forwardRef<HTMLInputElement, CardRadioPropsType>(
<CardRadioContext.Provider
value={{
checked: isChecked,
// @ts-expect-error TS2322
// @ts-ignore TS2322
disabled,
}}
>
Expand Down
4 changes: 2 additions & 2 deletions src/components/chip/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ const Chip = ({

const isControlled = checked !== undefined || isWithinChipGroup;
const isChecked = isControlled
? // @ts-expect-error TS2345
? // @ts-ignore TS2345
checked ?? isCheckedWithinGroup(chipGroupContext.groupValue, value)
: undefined;

// @ts-expect-error TS7006
// @ts-ignore TS7006
const onInputChange = e => {
if (isWithinChipGroup) {
chipGroupContext.onChipChange(e, value);
Expand Down
2 changes: 1 addition & 1 deletion src/components/chip/ChipGroup.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {testA11y} from '../../axe';
const chips = ['option-a', 'option-b'];

describe('<ChipGroup />', () => {
// @ts-expect-error TS7006
// @ts-ignore TS7006
const renderChipGroup = props =>
render(
<ChipGroup {...props} name="chipgroup">
Expand Down
8 changes: 4 additions & 4 deletions src/components/chip/ChipGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const getGroupValue = (
) => {
if (multiSelect) {
if (Array.isArray(currentValue)) {
// @ts-expect-error TS2345
// @ts-ignore TS2345
return currentValue.includes(toggledValue)
? currentValue.filter(v => v !== toggledValue)
: [...currentValue, toggledValue];
Expand Down Expand Up @@ -123,13 +123,13 @@ const ChipGroup = ({
const [selectedValue, setSelectedValue] = React.useState(value || null);

React.useEffect(() => {
// @ts-expect-error TS2345
// @ts-ignore TS2345
setSelectedValue(value);
}, [value]);

// @ts-expect-error TS7006
// @ts-ignore TS7006
const setValue = (event, chipValue) => {
// @ts-expect-error TS2345
// @ts-ignore TS2345
setSelectedValue(getGroupValue(selectedValue, chipValue, multiSelect));
if (onChange) onChange(event, chipValue);
};
Expand Down
Loading
Loading