Upgrade ts to the latest version and fix type errors

This commit is contained in:
SleepWalker 2020-05-20 19:59:06 +03:00
parent 2d903f96fc
commit 29326519b8
16 changed files with 37 additions and 37 deletions

View File

@ -163,7 +163,7 @@
"speed-measure-webpack-plugin": "^1.3.3",
"storybook-addon-intl": "^2.4.1",
"style-loader": "~1.2.1",
"typescript": "^3.7.4",
"typescript": "^3.9.3",
"unexpected": "^11.14.0",
"unexpected-sinon": "^10.5.1",
"url-loader": "^4.1.0",

View File

@ -169,7 +169,7 @@ export class AccountSwitcher extends React.Component<Props> {
);
}
onSwitch = (account: Account) => (event: React.MouseEvent) => {
onSwitch = (account: Account) => (event: React.MouseEvent<any>) => {
event.preventDefault();
loader.show();
@ -184,7 +184,7 @@ export class AccountSwitcher extends React.Component<Props> {
.finally(() => loader.hide());
};
onRemove = (account: Account) => (event: React.MouseEvent) => {
onRemove = (account: Account) => (event: React.MouseEvent<any>) => {
event.preventDefault();
event.stopPropagation();

View File

@ -406,7 +406,7 @@ class PanelTransition extends React.PureComponent<Props, State> {
});
};
onGoBack: MouseEventHandler = (event): void => {
onGoBack: MouseEventHandler<HTMLButtonElement> = (event): void => {
event.preventDefault();
authFlow.goBack();
};

View File

@ -680,7 +680,7 @@ function validationErrorsHandler(
repeatUrl?: string,
): (
resp: Resp<{
errors?: Record<string, string>;
errors?: Record<string, string | ValidationError>;
data?: Record<string, any>;
}>,
) => Promise<never> {

View File

@ -11,7 +11,9 @@ import messages from './footerMenu.intl.json';
const FooterMenu: ComponentType = () => {
const dispatch = useDispatch();
const onLanguageSwitcherClick = useCallback<MouseEventHandler>(
const onLanguageSwitcherClick = useCallback<
MouseEventHandler<HTMLAnchorElement>
>(
(event) => {
event.preventDefault();
dispatch(createPopup({ Popup: LanguageSwitcher }));

View File

@ -124,7 +124,7 @@ export default class LanguageList extends React.Component<{
return emptyCaptions[Math.floor(Math.random() * emptyCaptions.length)];
}
onChangeLang(lang: string): MouseEventHandler {
onChangeLang(lang: string): MouseEventHandler<HTMLDivElement> {
return (event) => {
event.preventDefault();

View File

@ -313,7 +313,7 @@ export default class ChangeEmail extends React.Component<Props, State> {
return this.state.activeStep + 1 === STEPS_TOTAL;
}
onSwitchStep = (event: React.MouseEvent) => {
onSwitchStep = (event: React.MouseEvent<HTMLAnchorElement>) => {
event.preventDefault();
this.nextStep();

View File

@ -103,7 +103,7 @@ export class PanelBodyHeader extends React.Component<
);
}
onClose = (event: React.MouseEvent) => {
onClose = (event: React.MouseEvent<HTMLElement>) => {
event.preventDefault();
const { onClose } = this.props;

View File

@ -100,7 +100,7 @@ export default class Dropdown extends FormInputComponent<Props, State> {
});
}
onSelectItem(item: OptionItem): MouseEventHandler {
onSelectItem(item: OptionItem): MouseEventHandler<HTMLDivElement> {
return (event) => {
event.preventDefault();

View File

@ -3,16 +3,16 @@ import { Link } from 'react-router-dom';
import Button from './Button';
export default function LinkButton(
props: React.ComponentProps<typeof Button> &
React.ComponentProps<typeof Link>,
) {
type ButtonProps = React.ComponentProps<typeof Button>;
type LinkProps = React.ComponentProps<typeof Link>;
export default function LinkButton(props: ButtonProps & LinkProps) {
const { to, ...restProps } = props;
return (
<Button
component={(linkProps) => <Link {...linkProps} to={to} />}
{...restProps}
{...(restProps as ButtonProps)}
/>
);
}

View File

@ -14,7 +14,7 @@ function DummyPopup(_props: Record<string, any>) {
describe('<PopupStack />', () => {
it('renders all popup components', () => {
const props = {
const props: any = {
destroy: () => {},
popups: [
{
@ -35,13 +35,13 @@ describe('<PopupStack />', () => {
foo: 'bar',
};
const props = {
const props: any = {
destroy: () => {},
popups: [
{
Popup: (props = { onClose: Function }) => {
Popup: (popupProps = { onClose: Function }) => {
// eslint-disable-next-line
expect(props.onClose, 'to be a', 'function');
expect(popupProps.onClose, 'to be a', 'function');
return <DummyPopup {...expectedProps} />;
},
@ -56,7 +56,7 @@ describe('<PopupStack />', () => {
});
it('should hide popup, when onClose called', () => {
const props = {
const props: any = {
popups: [
{
Popup: DummyPopup,
@ -79,7 +79,7 @@ describe('<PopupStack />', () => {
it('should hide popup, when overlay clicked', () => {
const preventDefault = sinon.stub().named('event.preventDefault');
const props = {
const props: any = {
destroy: sinon.stub().named('props.destroy'),
popups: [
{
@ -97,7 +97,7 @@ describe('<PopupStack />', () => {
});
it('should hide popup on overlay click if disableOverlayClose', () => {
const props = {
const props: any = {
destroy: sinon.stub().named('props.destroy'),
popups: [
{
@ -119,7 +119,7 @@ describe('<PopupStack />', () => {
});
it('should hide popup, when esc pressed', () => {
const props = {
const props: any = {
destroy: sinon.stub().named('props.destroy'),
popups: [
{
@ -138,7 +138,7 @@ describe('<PopupStack />', () => {
});
it('should hide first popup in stack if esc pressed', () => {
const props = {
const props: any = {
destroy: sinon.stub().named('props.destroy'),
popups: [
{
@ -165,7 +165,7 @@ describe('<PopupStack />', () => {
});
it('should NOT hide popup on esc pressed if disableOverlayClose', () => {
const props = {
const props: any = {
destroy: sinon.stub().named('props.destroy'),
popups: [
{

View File

@ -64,7 +64,7 @@ export class PopupStack extends React.Component<Props> {
}
onOverlayClick(popup: PopupConfig) {
return (event: React.MouseEvent) => {
return (event: React.MouseEvent<HTMLDivElement>) => {
if (event.target !== event.currentTarget || popup.disableOverlayClose) {
return;
}

View File

@ -77,7 +77,7 @@ export default class AuthFlow implements AuthContext {
replace: ((path: string) => void) | null;
onReady: () => void;
navigate: (route: string, options: { replace?: boolean }) => void;
currentRequest: Request;
currentRequest: Partial<Request> = {};
oAuthStateRestored = false;
dispatch: (action: Record<string, any>) => void;
getState: () => RootState;

View File

@ -8,12 +8,9 @@ export const SUPPORTED_LANGUAGES = Object.keys(locales);
export const DEFAULT_LANGUAGE = 'en';
function getBrowserPreferredLanguages(): string[] {
return []
.concat(
// @ts-ignore
navigator.languages || [],
)
.concat(navigator.language || []);
return ([] as string[])
.concat(navigator['languages'] || [])
.concat(navigator['language'] || []);
}
function detectLanguage(

View File

@ -11,6 +11,7 @@
"noEmit": true,
"checkJs": true,
"allowJs": true,
"skipLibCheck": true,
"strictNullChecks": true,
"strictPropertyInitialization": false,
"isolatedModules": true,

View File

@ -15665,10 +15665,10 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
typescript@^3.7.4:
version "3.7.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.4.tgz#1743a5ec5fef6a1fa9f3e4708e33c81c73876c19"
integrity sha512-A25xv5XCtarLwXpcDNZzCGvW2D1S3/bACratYBx2sax8PefsFhlYmkQicKHvpYflFS8if4zne5zT5kpJ7pzuvw==
typescript@^3.9.3:
version "3.9.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.3.tgz#d3ac8883a97c26139e42df5e93eeece33d610b8a"
integrity sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==
ua-parser-js@^0.7.18:
version "0.7.21"