Skip to content

Commit

Permalink
chore: add typescript strict mode & supress current warnings (#2817)
Browse files Browse the repository at this point in the history
  • Loading branch information
kopach authored Nov 8, 2024
1 parent 9118250 commit 7500b0d
Show file tree
Hide file tree
Showing 115 changed files with 380 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Design infra team
* @krzotki @Fasosnql @thomsa @radekwarisch
* @krzotki @Fasosnql @radekwarisch
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
"@codesandbox/sandpack-react": "^1.17.0",
"@codesandbox/sandpack-themes": "^1.17.0",
"@floating-ui/react": "^0.21.1",
"@types/jest-axe": "^3.5.9",
"chalk": "4.1.2",
"classnames": "^2.3.2",
"glob": "^7.2.0",
"inquirer": "^8.2.0",
"jscodeshift": "^0.13.1",
"lz-string": "1.4.4",
"meow": "^5.0.0",
"patch-package": "^6.5.1",
"path": "^0.12.7",
Expand Down
1 change: 1 addition & 0 deletions src/axe/testA11y.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {render} from '@testing-library/react';
* ```
*/

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

const hoverStylesheet = hStylesheet.sheet;

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

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

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

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

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

// @ts-expect-error TS7006
const mergeStories: any = module => {
const stories = Object.keys(module)
.filter(
Expand Down
1 change: 1 addition & 0 deletions src/components/accordion/Accordion.chromatic.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +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
const WithTooltip = args => {
const handleChange = () => null;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// @ts-expect-error TS7006
const onButtonClick = e => {
if (isLink && isDisabled) {
return;
Expand Down
1 change: 1 addition & 0 deletions src/components/buttons/ButtonLite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ const ButtonLite = ({
);
}

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

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

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

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

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

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

// @ts-expect-error TS7006
const setValue = (event, chipValue) => {
// @ts-expect-error TS2345
setSelectedValue(getGroupValue(selectedValue, chipValue, multiSelect));
if (onChange) onChange(event, chipValue);
};
Expand Down
1 change: 1 addition & 0 deletions src/components/colors/hex.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-expect-error TS7016
import colors from './colors';
import hex from './hex';

Expand Down
2 changes: 2 additions & 0 deletions src/components/colors/hex.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// @ts-expect-error TS7016
import colors from './colors';

const hex: Record<string, string> = {};

Object.keys(colors).forEach(groupName => {
// @ts-expect-error TS7006
colors[groupName].forEach(color => {
hex[color.variable.slice(1)] = `#${color.hex}`;
});
Expand Down
Loading

0 comments on commit 7500b0d

Please sign in to comment.