Skip to content
This repository was archived by the owner on Nov 18, 2024. It is now read-only.

Commit 4d36cf5

Browse files
committed
more types
1 parent c43caa6 commit 4d36cf5

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

src/api/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ type CallApiParams = {
1616
apiState: ApiState;
1717
};
1818

19+
type CallApiResponse = object | { error: Error };
20+
1921
type Headers = {
2022
[name: string]: string;
2123
};
@@ -25,7 +27,7 @@ export const callApi = async ({
2527
endpoint,
2628
method = HttpMethod.GET,
2729
version = 'v4',
28-
}: CallApiParams): Promise<object | { error: Error }> => {
30+
}: CallApiParams): Promise<CallApiResponse> => {
2931
if (!endpoint.startsWith('/')) {
3032
// eslint-disable-next-line no-param-reassign
3133
endpoint = `/${endpoint}`;
@@ -63,7 +65,9 @@ export const callApi = async ({
6365
}
6466
};
6567

66-
export const logOutFromServer = async (apiState: ApiState) => {
68+
export const logOutFromServer = async (
69+
apiState: ApiState,
70+
): Promise<CallApiResponse> => {
6771
return callApi({
6872
apiState,
6973
endpoint: 'accounts/session',

src/components/App/index.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { shallow } from 'enzyme';
2+
import { ShallowWrapper, shallow } from 'enzyme';
33
import { Store } from 'redux';
44

55
import styles from './styles.module.scss';
@@ -17,7 +17,7 @@ describe(__filename, () => {
1717
const render = ({
1818
store = configureStore(),
1919
authToken = 'some-token',
20-
}: RenderParams = {}) => {
20+
}: RenderParams = {}): ShallowWrapper => {
2121
// TODO: Use shallowUntilTarget()
2222
// https://github.com/mozilla/addons-code-manager/issues/15
2323
const root = shallow(<App authToken={authToken} />, {

src/components/App/index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ class AppBase extends React.Component<Props, State> {
4242
};
4343
}
4444

45-
componentDidMount() {
45+
componentDidMount(): void {
4646
const { authToken, dispatch } = this.props;
4747

4848
if (authToken) {
4949
dispatch(apiActions.setAuthToken({ authToken }));
5050
}
5151
}
5252

53-
async componentDidUpdate(prevProps: Props) {
53+
async componentDidUpdate(prevProps: Props): Promise<void> {
5454
const { apiState } = this.props;
5555

5656
if (
@@ -69,7 +69,7 @@ class AppBase extends React.Component<Props, State> {
6969
}
7070
}
7171

72-
logOut = async () => {
72+
logOut = async (): Promise<void> => {
7373
const { apiState } = this.props;
7474

7575
this.setState({ isLoggingOut: true });
@@ -79,13 +79,15 @@ class AppBase extends React.Component<Props, State> {
7979
this.setState({ profile: null, isLoggingOut: false });
8080
};
8181

82-
handleToggleClick = (event: React.SyntheticEvent<HTMLButtonElement>) => {
82+
handleToggleClick = (
83+
event: React.SyntheticEvent<HTMLButtonElement>,
84+
): void => {
8385
const { dispatch } = this.props;
8486
event.preventDefault();
8587
dispatch(exampleActions.toggle());
8688
};
8789

88-
render() {
90+
render(): React.ReactNode {
8991
const { toggledOn } = this.props;
9092
const { profile, isLoggingOut } = this.state;
9193

src/components/LoginButton/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { Button } from 'react-bootstrap';
44
import styles from './styles.module.scss';
55

66
export class LoginButtonBase extends React.Component {
7-
getFxaURL() {
7+
getFxaURL(): string {
88
const fxaConfig = process.env.REACT_APP_FXA_CONFIG;
99

1010
return `/api/v4/accounts/login/start/?config=${fxaConfig}&to=/`;
1111
}
1212

13-
render() {
13+
render(): React.ReactNode {
1414
return (
1515
<Button href={this.getFxaURL()} className={styles.link}>
1616
Log in

0 commit comments

Comments
 (0)