fix a ton of typescript errors

This commit is contained in:
Eduard Heimbuch
2020-01-08 13:40:07 +01:00
parent 15a9a5b09b
commit a43ffacf03
41 changed files with 229 additions and 311 deletions

View File

@@ -1,5 +1,6 @@
import React from "react";
import { connect } from "react-redux";
import { compose } from "redux";
import { WithTranslation, withTranslation } from "react-i18next";
import { History } from "history";
import { User } from "@scm-manager/ui-types";
@@ -46,7 +47,7 @@ class CreateUser extends React.Component<Props> {
}
}
const mapDispatchToProps = dispatch => {
const mapDispatchToProps = (dispatch: any) => {
return {
addUser: (link: string, user: User, callback?: () => void) => {
dispatch(createUser(link, user, callback));
@@ -57,7 +58,7 @@ const mapDispatchToProps = dispatch => {
};
};
const mapStateToProps = (state, ownProps) => {
const mapStateToProps = (state: any) => {
const loading = isCreateUserPending(state);
const error = getCreateUserFailure(state);
const usersLink = getUsersLink(state);
@@ -68,7 +69,4 @@ const mapStateToProps = (state, ownProps) => {
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(withTranslation("users")(CreateUser));
export default compose(connect(mapStateToProps, mapDispatchToProps), withTranslation("users"))(CreateUser);

View File

@@ -1,5 +1,6 @@
import React from "react";
import { connect } from "react-redux";
import { compose } from "redux";
import { withRouter } from "react-router-dom";
import { WithTranslation, withTranslation } from "react-i18next";
import { History } from "history";
@@ -72,7 +73,7 @@ class DeleteUser extends React.Component<Props> {
}
}
const mapStateToProps = (state, ownProps) => {
const mapStateToProps = (state: any, ownProps: Props) => {
const loading = isDeleteUserPending(state, ownProps.user.name);
const error = getDeleteUserFailure(state, ownProps.user.name);
return {
@@ -81,7 +82,7 @@ const mapStateToProps = (state, ownProps) => {
};
};
const mapDispatchToProps = dispatch => {
const mapDispatchToProps = (dispatch: any) => {
return {
deleteUser: (user: User, callback?: () => void) => {
dispatch(deleteUser(user, callback));
@@ -89,7 +90,4 @@ const mapDispatchToProps = dispatch => {
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(withRouter(withTranslation("users")(DeleteUser)));
export default compose(connect(mapStateToProps, mapDispatchToProps), withRouter, withTranslation("users"))(DeleteUser);

View File

@@ -7,6 +7,7 @@ import { User } from "@scm-manager/ui-types";
import { modifyUser, isModifyUserPending, getModifyUserFailure, modifyUserReset } from "../modules/users";
import { History } from "history";
import { ErrorNotification } from "@scm-manager/ui-components";
import { compose } from "redux";
type Props = {
loading: boolean;
@@ -47,7 +48,7 @@ class EditUser extends React.Component<Props> {
}
}
const mapStateToProps = (state, ownProps) => {
const mapStateToProps = (state: any, ownProps: Props) => {
const loading = isModifyUserPending(state, ownProps.user.name);
const error = getModifyUserFailure(state, ownProps.user.name);
return {
@@ -56,7 +57,7 @@ const mapStateToProps = (state, ownProps) => {
};
};
const mapDispatchToProps = dispatch => {
const mapDispatchToProps = (dispatch: any) => {
return {
modifyUser: (user: User, callback?: () => void) => {
dispatch(modifyUser(user, callback));
@@ -67,7 +68,4 @@ const mapDispatchToProps = dispatch => {
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(withRouter(EditUser));
export default compose(connect(mapStateToProps, mapDispatchToProps), withRouter)(EditUser);

View File

@@ -95,7 +95,7 @@ class SingleUser extends React.Component<Props> {
}
}
const mapStateToProps = (state, ownProps) => {
const mapStateToProps = (state: any, ownProps: Props) => {
const name = ownProps.match.params.name;
const user = getUserByName(state, name);
const loading = isFetchUserPending(state, name);
@@ -110,7 +110,7 @@ const mapStateToProps = (state, ownProps) => {
};
};
const mapDispatchToProps = dispatch => {
const mapDispatchToProps = (dispatch: any) => {
return {
fetchUserByName: (link: string, name: string) => {
dispatch(fetchUserByName(link, name));
@@ -118,7 +118,4 @@ const mapDispatchToProps = dispatch => {
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(withTranslation("users")(SingleUser));
export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("users")(SingleUser));

View File

@@ -1,6 +1,7 @@
import React from "react";
import { connect } from "react-redux";
import { WithTranslation, withTranslation } from "react-i18next";
import { RouteComponentProps } from "react-router-dom";
import { History } from "history";
import { User, PagedCollection } from "@scm-manager/ui-types";
import {
@@ -23,22 +24,23 @@ import {
} from "../modules/users";
import { UserTable } from "./../components/table";
type Props = WithTranslation & {
users: User[];
loading: boolean;
error: Error;
canAddUsers: boolean;
list: PagedCollection;
page: number;
usersLink: string;
type Props = RouteComponentProps &
WithTranslation & {
users: User[];
loading: boolean;
error: Error;
canAddUsers: boolean;
list: PagedCollection;
page: number;
usersLink: string;
// context objects
history: History;
location: any;
// context objects
history: History;
location: any;
// dispatch functions
fetchUsersByPage: (link: string, page: number, filter?: string) => void;
};
// dispatch functions
fetchUsersByPage: (link: string, page: number, filter?: string) => void;
};
class Users extends React.Component<Props> {
componentDidMount() {
@@ -100,7 +102,7 @@ class Users extends React.Component<Props> {
}
}
const mapStateToProps = (state, ownProps) => {
const mapStateToProps = (state: any, ownProps: Props) => {
const { match } = ownProps;
const users = getUsersFromState(state);
const loading = isFetchUsersPending(state);
@@ -121,7 +123,7 @@ const mapStateToProps = (state, ownProps) => {
};
};
const mapDispatchToProps = dispatch => {
const mapDispatchToProps = (dispatch: any) => {
return {
fetchUsersByPage: (link: string, page: number, filter?: string) => {
dispatch(fetchUsersByPage(link, page, filter));
@@ -129,7 +131,4 @@ const mapDispatchToProps = dispatch => {
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(withTranslation("users")(Users));
export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("users")(Users));