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

Commit 6013c21

Browse files
removed implicit any in lots of places
1 parent 077efc1 commit 6013c21

File tree

15 files changed

+48
-32
lines changed

15 files changed

+48
-32
lines changed

src/SqlStreamStoreBrowser.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import theme from './theme';
1717
import { HalLink, HalLinks } from './types';
1818
import { mediaTypes } from './utils';
1919

20-
const getSelfAlias = links =>
20+
const getSelfAlias = (links: HalLinks) =>
2121
Object.keys(links)
2222
.flatMap(rel => links[rel])
23-
.filter(({ rel }) => rel.indexOf('streamStore:') === 0)
23+
.filter(({ rel }) => rel && rel.indexOf('streamStore:') === 0)
2424
.filter(
2525
({ rel, href }) =>
2626
!!links.self.filter(link => link.href === href).length,
@@ -62,7 +62,11 @@ const onNavigate = (link: HalLink, authorization: string | undefined) =>
6262
link.href.indexOf('#') === -1 &&
6363
actions.get.request.next({ link, headers: { authorization } });
6464

65-
const initialNavigation = ({ authorization }) =>
65+
const initialNavigation = ({
66+
authorization,
67+
}: {
68+
authorization: string | undefined;
69+
}) =>
6670
onNavigate(
6771
{ href: window.location.href, type: mediaTypes.any },
6872
authorization,

src/components/AuthorizationProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { ReactNode, StatelessComponent } from 'react';
1+
import React, { ComponentType, ReactNode, StatelessComponent } from 'react';
22
import getDisplayName from './getDisplayName';
33

44
const { Consumer, Provider } = React.createContext<string | undefined>(
@@ -14,8 +14,8 @@ const AuthorizationProvider: StatelessComponent<{
1414

1515
export default AuthorizationProvider;
1616

17-
const withAuthorization = () => WrappedComponent => {
18-
const Component = props => (
17+
const withAuthorization = () => (WrappedComponent: ComponentType) => {
18+
const Component = (props: any) => (
1919
<Consumer>
2020
{authorization => (
2121
<WrappedComponent {...props} authorization={authorization} />

src/components/HyperMediaControls/Dialog.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ import {
55
DialogContent,
66
DialogTitle,
77
Slide,
8+
Theme,
89
withStyles,
910
WithStyles,
1011
} from '@material-ui/core';
11-
import React, { PureComponent, StatelessComponent } from 'react';
12-
1312
import { SlideProps } from '@material-ui/core/Slide';
13+
import React, { FormEvent, PureComponent, StatelessComponent } from 'react';
1414
import { HalLink } from '../../types';
1515
import RelIcon from '../RelIcon';
1616
import HelpButton from './HelpButton';
1717
import RelButton from './RelButton';
18-
const styles = theme => ({
18+
19+
const styles = (theme: Theme) => ({
1920
button: {
2021
margin: theme.spacing.unit,
2122
},
@@ -53,7 +54,7 @@ export default withStyles(styles)(
5354
open: false,
5455
});
5556

56-
_onSubmit = e => {
57+
_onSubmit = (e: FormEvent) => {
5758
const { onSubmit } = this.props;
5859

5960
e.preventDefault();

src/components/HyperMediaControls/FormButton.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { PureComponent } from 'react';
1+
import React, { FormEvent, PureComponent } from 'react';
22
import { SchemaForm } from 'react-schema-form';
33
import { HalLink, NavigatableProps } from '../../types';
44
import { withAuthorization } from '../AuthorizationProvider';
@@ -11,12 +11,12 @@ const mapper = {
1111
uuid: UuidField,
1212
};
1313

14-
const getValue = value => {
14+
const getValue = (value: FormEvent<HTMLInputElement>) => {
1515
if (typeof value === 'object') {
1616
try {
17-
return JSON.parse(value.target.value);
17+
return JSON.parse(value.currentTarget.value);
1818
} catch (e) {
19-
return value.target.value;
19+
return value.currentTarget.value;
2020
}
2121
}
2222

@@ -60,7 +60,7 @@ class FormButton extends PureComponent<
6060
}
6161
};
6262

63-
_onModelChange = (key, value) => {
63+
_onModelChange = (key: string, value: FormEvent<HTMLInputElement>) => {
6464
const { model, ...state } = this.state;
6565
this.setState({
6666
...state,

src/components/HyperMediaControls/HelpButton.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ const getCurie = (rel: string, curies: HalLink[]): HalLink => {
1717
const [prefix, rest] = rel.split(':', 2);
1818

1919
return !rest || rest.indexOf(':') !== -1
20-
? { href: rel }
20+
? { href: rel, rel }
2121
: curies
2222
.filter(({ name }) => name === prefix)
2323
.map(({ href, ...link }) => ({
2424
...link,
2525
href: uriTemplate
2626
.parse(decodeURI(href))
2727
.expand({ rel: rest }),
28-
}))[0] || { href: rel };
28+
}))[0] || { href: rel, rel };
2929
};
3030

3131
interface DocumentationProps {
@@ -88,8 +88,7 @@ class HelpButton extends PureComponent<HelpButtonProps, HelpButtonState> {
8888
disabled: false,
8989
...getCurie(rel, curies),
9090
});
91-
state = {
92-
curies: [],
91+
state: HelpButtonState = {
9392
disabled: true,
9493
documentation: '',
9594
href: '',

src/components/HyperMediaControls/LinkButton.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { PropTypes, TextField } from '@material-ui/core';
2-
import React, { PureComponent, StatelessComponent } from 'react';
2+
import React, {
3+
FormEventHandler,
4+
PureComponent,
5+
StatelessComponent,
6+
} from 'react';
37
import uriTemplate from 'uri-template';
48
import { HalLink, NavigatableProps } from '../../types';
59
import { preventDefault } from '../../utils';
@@ -27,10 +31,14 @@ const TemplatedLinkButton: StatelessComponent<
2731
> {
2832
state = {};
2933

30-
_onChange = variable => ({ target }) =>
34+
_onChange = (
35+
variable: string,
36+
): FormEventHandler<
37+
HTMLTextAreaElement | HTMLInputElement | HTMLSelectElement
38+
> => ({ currentTarget }) =>
3139
this.setState({
3240
...this.state,
33-
[variable]: target.value,
41+
[variable]: currentTarget.value,
3442
});
3543

3644
render() {

src/components/HyperMediaControls/RelButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Button } from '@material-ui/core';
22
import { ButtonProps } from '@material-ui/core/Button';
3-
import { SvgIconProps } from '@material-ui/core/SvgIcon';
4-
import React, { ReactNode, StatelessComponent } from 'react';
3+
import React, { StatelessComponent } from 'react';
54
import RelIcon from '../RelIcon';
65

76
interface RelButtonProps {

src/components/HyperMediaControls/UuidField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { SpaceBar } from '../Icons';
66
import { FormInputProps } from './reactSchemaForms';
77

88
class UuidField extends React.PureComponent<FormInputProps> {
9-
constructor(props) {
9+
constructor(props: FormInputProps) {
1010
super(props);
1111

1212
const { model, form, setDefault } = this.props;

src/components/RelIcon.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SvgIconProps } from '@material-ui/core/SvgIcon';
2-
import { createElement, ReactElement, StatelessComponent } from 'react';
2+
import { createElement, StatelessComponent } from 'react';
33
import { rels } from '../stream-store';
44
import {
55
ChevronLeft,

src/components/StreamBrowser.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
List,
44
ListItem,
55
ListItemText,
6+
Theme,
67
Typography,
78
WithStyles,
89
withStyles,
@@ -12,7 +13,7 @@ import rels from '../stream-store/rels';
1213
import { HalResource } from '../types';
1314
import Hyperlink from './Hyperlink';
1415

15-
const styles = theme => ({
16+
const styles = (theme: Theme) => ({
1617
browser: {
1718
padding: theme.spacing.unit * 2.5,
1819
},
@@ -36,7 +37,9 @@ const StreamBrowser: ComponentType<StreamBrowserProps> = withStyles(styles)(
3637
) : streams.length ? (
3738
<List>
3839
{streams.map(({ _links }) => (
39-
<ListItem>
40+
<ListItem
41+
key={_links[rels.self].map(({ href }) => href)[0]}
42+
>
4043
<ListItemText>
4144
<Hyperlink _links={_links} rel={rels.feed} />
4245
</ListItemText>

0 commit comments

Comments
 (0)