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

Commit 97fd0e6

Browse files
committed
more types
1 parent 0927ca2 commit 97fd0e6

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.test.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
@@ -41,15 +41,15 @@ class AppBase extends React.Component<Props, State> {
4141
};
4242
}
4343

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

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

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

5555
if (
@@ -68,7 +68,7 @@ class AppBase extends React.Component<Props, State> {
6868
}
6969
}
7070

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

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

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

87-
render() {
89+
render(): React.ReactNode {
8890
const { toggledOn } = this.props;
8991
const { profile, isLoggingOut } = this.state;
9092

src/components/LoginButton/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import * as React from 'react';
33
import styles from './styles.module.scss';
44

55
export class LoginButtonBase extends React.Component {
6-
getFxaURL() {
6+
getFxaURL(): string {
77
const fxaConfig = process.env.REACT_APP_FXA_CONFIG;
88

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

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

0 commit comments

Comments
 (0)