Skip to content

Commit f604243

Browse files
authored
Merge pull request #809 from integer32llc/ts-type-errors
2 parents 45be552 + e3c8669 commit f604243

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+224
-265
lines changed

ui/frontend/.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ module.exports = {
2222
'no-trailing-spaces': 'error',
2323
'quotes': ['error', 'single'],
2424

25+
'@typescript-eslint/ban-ts-comment': ['error', {
26+
'ts-ignore': 'allow-with-description',
27+
}],
2528
'@typescript-eslint/explicit-function-return-type': 'off',
2629
'@typescript-eslint/indent': ['error', 2],
2730
'@typescript-eslint/no-explicit-any': 'off',

ui/frontend/AdvancedOptionsMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { State } from './reducers';
88
import * as selectors from './selectors';
99
import { Backtrace, Edition } from './types';
1010

11-
const AdvancedOptionsMenu: React.SFC = () => {
11+
const AdvancedOptionsMenu: React.FC = () => {
1212
const isEditionDefault = useSelector(selectors.isEditionDefault);
1313
const edition = useSelector((state: State) => state.configuration.edition);
1414
const isBacktraceSet = useSelector(selectors.getBacktraceSet);

ui/frontend/BuildMenu.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const useDispatchAndClose = (action: () => actions.ThunkAction, close: () => voi
2727
);
2828
}
2929

30-
const BuildMenu: React.SFC<BuildMenuProps> = props => {
30+
const BuildMenu: React.FC<BuildMenuProps> = props => {
3131
const isHirAvailable = useSelector(selectors.isHirAvailable);
3232
const isWasmAvailable = useSelector(selectors.isWasmAvailable);
3333

@@ -75,14 +75,14 @@ const BuildMenu: React.SFC<BuildMenuProps> = props => {
7575
);
7676
};
7777

78-
const HirAside: React.SFC = () => (
78+
const HirAside: React.FC = () => (
7979
<MenuAside>
8080
Note: HIR currently requires using the Nightly channel, selecting this
8181
option will switch to Nightly.
8282
</MenuAside>
8383
);
8484

85-
const WasmAside: React.SFC = () => (
85+
const WasmAside: React.FC = () => (
8686
<MenuAside>
8787
Note: WASM currently requires using the Nightly channel, selecting this
8888
option will switch to Nightly.

ui/frontend/ButtonMenuItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface ButtonMenuItemProps extends Button {
1010
name: string;
1111
}
1212

13-
const ButtonMenuItem: React.SFC<ButtonMenuItemProps> = ({ name, children, ...props }) => (
13+
const ButtonMenuItem: React.FC<ButtonMenuItemProps> = ({ name, children, ...props }) => (
1414
<MenuItem>
1515
<button className={styles.container} {...props}>
1616
<div className={styles.name} data-test-id="button-menu-item__name">{name}</div>

ui/frontend/ChannelMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface ChannelMenuProps {
1515
close: () => void;
1616
}
1717

18-
const ChannelMenu: React.SFC<ChannelMenuProps> = props => {
18+
const ChannelMenu: React.FC<ChannelMenuProps> = props => {
1919
const channel = useSelector((state: State) => state.configuration.channel);
2020
const stableVersion = useSelector(selectors.stableVersionText);
2121
const betaVersion = useSelector(selectors.betaVersionText);
@@ -63,7 +63,7 @@ const ChannelMenu: React.SFC<ChannelMenuProps> = props => {
6363
);
6464
};
6565

66-
const Desc: React.SFC<{}> = ({ children }) => (
66+
const Desc: React.FC<{}> = ({ children }) => (
6767
<p className={styles.description}>{children}</p>
6868
);
6969

ui/frontend/ConfigElement.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface EitherProps extends ConfigElementProps {
1414
onChange: (_: string) => any;
1515
}
1616

17-
export const Either: React.SFC<EitherProps> =
17+
export const Either: React.FC<EitherProps> =
1818
({ id, a, b, aLabel = a, bLabel = b, value, onChange, ...rest }) => (
1919
<ConfigElement {...rest}>
2020
<div className={styles.toggle}>
@@ -41,7 +41,7 @@ interface SelectProps extends ConfigElementProps {
4141
onChange: (_: string) => any;
4242
}
4343

44-
export const Select: React.SFC<SelectProps> = ({ value, onChange, children, ...rest }) => (
44+
export const Select: React.FC<SelectProps> = ({ value, onChange, children, ...rest }) => (
4545
<ConfigElement {...rest}>
4646
<select className={styles.select} value={value} onChange={e => onChange(e.target.value)}>
4747
{children}
@@ -55,7 +55,7 @@ interface ConfigElementProps {
5555
aside?: JSX.Element,
5656
}
5757

58-
const ConfigElement: React.SFC<ConfigElementProps> = ({ name, isNotDefault, aside, children }) => (
58+
const ConfigElement: React.FC<ConfigElementProps> = ({ name, isNotDefault, aside, children }) => (
5959
<MenuItem>
6060
<div className={styles.container}>
6161
<span className={isNotDefault ? styles.notDefault : styles.name}>{name}</span>

ui/frontend/ConfigMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const MONACO_THEMES = [
2525
'vs', 'vs-dark', 'vscode-dark-plus',
2626
];
2727

28-
const ConfigMenu: React.SFC<ConfigMenuProps> = () => {
28+
const ConfigMenu: React.FC<ConfigMenuProps> = () => {
2929
const keybinding = useSelector((state: State) => state.configuration.ace.keybinding);
3030
const aceTheme = useSelector((state: State) => state.configuration.ace.theme);
3131
const monacoTheme = useSelector((state: State) => state.configuration.monaco.theme);

ui/frontend/Header.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { useAppDispatch } from './configureStore';
1818

1919
import styles from './Header.module.css';
2020

21-
const Header: React.SFC = () => (
21+
const Header: React.FC = () => (
2222
<div data-test-id="header" className={styles.container}>
2323
<HeaderSet id="build">
2424
<SegmentedButtonSet>
@@ -60,11 +60,11 @@ interface HeaderSetProps {
6060
id: string;
6161
}
6262

63-
const HeaderSet: React.SFC<HeaderSetProps> = ({ id, children }) => (
63+
const HeaderSet: React.FC<HeaderSetProps> = ({ id, children }) => (
6464
<div className={id == 'channel-mode' ? styles.setChannelMode : styles.set}>{children}</div>
6565
);
6666

67-
const ExecuteButton: React.SFC = () => {
67+
const ExecuteButton: React.FC = () => {
6868
const executionLabel = useSelector(selectors.getExecutionLabel);
6969

7070
const dispatch = useAppDispatch();
@@ -79,7 +79,7 @@ const ExecuteButton: React.SFC = () => {
7979
);
8080
};
8181

82-
const BuildMenuButton: React.SFC = () => {
82+
const BuildMenuButton: React.FC = () => {
8383
const Button = React.forwardRef<HTMLButtonElement, { toggle: () => void }>(({ toggle }, ref) => (
8484
<SegmentedButton title="Select what to build" ref={ref} onClick={toggle}>
8585
<HeaderButton icon={<MoreOptionsIcon />} />
@@ -90,7 +90,7 @@ const BuildMenuButton: React.SFC = () => {
9090
return <PopButton Button={Button} Menu={BuildMenu} />;
9191
};
9292

93-
const ModeMenuButton: React.SFC = () => {
93+
const ModeMenuButton: React.FC = () => {
9494
const label = useSelector(selectors.getModeLabel);
9595

9696
const Button = React.forwardRef<HTMLButtonElement, { toggle: () => void }>(({ toggle }, ref) => (
@@ -103,7 +103,7 @@ const ModeMenuButton: React.SFC = () => {
103103
return <PopButton Button={Button} Menu={ModeMenu} />;
104104
};
105105

106-
const ChannelMenuButton: React.SFC = () => {
106+
const ChannelMenuButton: React.FC = () => {
107107
const label = useSelector(selectors.getChannelLabel);
108108

109109
const Button = React.forwardRef<HTMLButtonElement, { toggle: () => void }>(({ toggle }, ref) => (
@@ -116,7 +116,7 @@ const ChannelMenuButton: React.SFC = () => {
116116
return <PopButton Button={Button} Menu={ChannelMenu} />;
117117
}
118118

119-
const AdvancedOptionsMenuButton: React.SFC = () => {
119+
const AdvancedOptionsMenuButton: React.FC = () => {
120120
const advancedOptionsSet = useSelector(selectors.getAdvancedOptionsSet);
121121

122122
const Button = React.forwardRef<HTMLButtonElement, { toggle: () => void }>(({ toggle }, ref) => (
@@ -129,7 +129,7 @@ const AdvancedOptionsMenuButton: React.SFC = () => {
129129
return <PopButton Button={Button} Menu={AdvancedOptionsMenu} />;
130130
}
131131

132-
const ShareButton: React.SFC = () => {
132+
const ShareButton: React.FC = () => {
133133
const dispatch = useAppDispatch();
134134
const gistSave = useCallback(() => dispatch(actions.performGistSave()), [dispatch]);
135135

@@ -141,7 +141,7 @@ const ShareButton: React.SFC = () => {
141141
};
142142

143143

144-
const ToolsMenuButton: React.SFC = () => {
144+
const ToolsMenuButton: React.FC = () => {
145145
const Button = React.forwardRef<HTMLButtonElement, { toggle: () => void }>(({ toggle }, ref) => (
146146
<SegmentedButton title="Run extra tools on the source code" ref={ref} onClick={toggle}>
147147
<HeaderButton isExpandable>Tools</HeaderButton>
@@ -152,7 +152,7 @@ const ToolsMenuButton: React.SFC = () => {
152152
return <PopButton Button={Button} Menu={ToolsMenu} />;
153153
};
154154

155-
const ConfigMenuButton: React.SFC = () => {
155+
const ConfigMenuButton: React.FC = () => {
156156
const Button = React.forwardRef<HTMLButtonElement, { toggle: () => void }>(({ toggle }, ref) => (
157157
<SegmentedButton title="Show the configuration options" ref={ref} onClick={toggle}>
158158
<HeaderButton icon={<ConfigIcon />} isExpandable>Config</HeaderButton>
@@ -163,7 +163,7 @@ const ConfigMenuButton: React.SFC = () => {
163163
return <PopButton Button={Button} Menu={ConfigMenu} />;
164164
};
165165

166-
const HelpButton: React.SFC = () => (
166+
const HelpButton: React.FC = () => (
167167
<SegmentedLink title="View help" action={actions.navigateToHelp}>
168168
<HeaderButton icon={<HelpIcon />} />
169169
</SegmentedLink>

ui/frontend/HeaderButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface HeaderButtonProps {
1111
isExpandable?: boolean;
1212
}
1313

14-
const HeaderButton: React.SFC<HeaderButtonProps> = ({ bold, icon, rightIcon, isExpandable, children }) => {
14+
const HeaderButton: React.FC<HeaderButtonProps> = ({ bold, icon, rightIcon, isExpandable, children }) => {
1515
const c = [styles.container];
1616

1717
if (bold) { c.push(styles.bold); }

ui/frontend/Help.tsx

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ fn main() {
7575
println!("{}", a_loop());
7676
}`;
7777

78-
const Help: React.SFC = () => {
78+
const Help: React.FC = () => {
7979
return (
8080
<section className={styles.container}>
8181
<h1>The Rust Playground</h1>
8282
<Link action={actions.navigateToIndex}>Return to the playground</Link>
8383

84-
<LinkableSection id="about" header="About" level={H2}>
84+
<LinkableSection id="about" header="About" level="h2">
8585
<p>
8686
The playground is an <a href={REPO_URL}>open source project</a>.
8787
If you have any suggestions for features, issues with the
@@ -107,8 +107,8 @@ const Help: React.SFC = () => {
107107
</p>
108108
</LinkableSection>
109109

110-
<LinkableSection id="features" header="Features" level={H2}>
111-
<LinkableSection id="features-crates" header="Crates" level={H3}>
110+
<LinkableSection id="features" header="Features" level="h2">
111+
<LinkableSection id="features-crates" header="Crates" level="h3">
112112
<p>
113113
The playground provides the top 100 most downloaded crates
114114
from <a href={CRATES_IO_URL}>crates.io</a>, the crates from
@@ -126,7 +126,7 @@ const Help: React.SFC = () => {
126126
</p>
127127
</LinkableSection>
128128

129-
<LinkableSection id="features-formatting" header="Formatting code" level={H3}>
129+
<LinkableSection id="features-formatting" header="Formatting code" level="h3">
130130
<p>
131131
<a href={RUSTFMT_URL}>rustfmt</a> is a tool for formatting Rust code
132132
according to the Rust style guidelines. Click on the <strong>Format</strong>
@@ -137,7 +137,7 @@ const Help: React.SFC = () => {
137137
<Example code={RUSTFMT_EXAMPLE} />
138138
</LinkableSection>
139139

140-
<LinkableSection id="features-linting" header="Linting code" level={H3}>
140+
<LinkableSection id="features-linting" header="Linting code" level="h3">
141141
<p>
142142
<a href={CLIPPY_URL}>Clippy</a> is a collection of lints to catch common
143143
mistakes and improve your Rust code. Click on the <strong>Clippy</strong>
@@ -149,7 +149,7 @@ const Help: React.SFC = () => {
149149
<Example code={CLIPPY_EXAMPLE} />
150150
</LinkableSection>
151151

152-
<LinkableSection id="features-miri" header="Checking code for undefined behavior" level={H3}>
152+
<LinkableSection id="features-miri" header="Checking code for undefined behavior" level="h3">
153153
<p>
154154
<a href={MIRI_URL}>Miri</a> is an interpreter for Rust’s mid-level intermediate
155155
representation (MIR) and can be used to detect certain kinds of undefined behavior
@@ -160,7 +160,7 @@ const Help: React.SFC = () => {
160160
<Example code={MIRI_EXAMPLE} />
161161
</LinkableSection>
162162

163-
<LinkableSection id="features-sharing" header="Sharing code" level={H3}>
163+
<LinkableSection id="features-sharing" header="Sharing code" level="h3">
164164
<p>
165165
Once you have some code worth saving or sharing, click on the
166166
{' '}
@@ -171,7 +171,7 @@ const Help: React.SFC = () => {
171171
</p>
172172
</LinkableSection>
173173

174-
<LinkableSection id="features-linking" header="Linking to the playground with initial code" level={H3}>
174+
<LinkableSection id="features-linking" header="Linking to the playground with initial code" level="h3">
175175
<p>
176176
If you have a web page with Rust code that you’d like to
177177
show in action, you can link to the playground with the
@@ -183,7 +183,7 @@ const Help: React.SFC = () => {
183183
<pre className={styles.code}><code>{LINK_EXAMPLE}</code></pre>
184184
</LinkableSection>
185185

186-
<LinkableSection id="features-tests" header="Executing tests" level={H3}>
186+
<LinkableSection id="features-tests" header="Executing tests" level="h3">
187187
<p>
188188
If your code contains the <Code>#[test]</Code> attribute and does not
189189
contain a <Code>main</Code> method, <Code>cargo test</Code> will be
@@ -193,7 +193,7 @@ const Help: React.SFC = () => {
193193
<Example code={TEST_EXAMPLE} />
194194
</LinkableSection>
195195

196-
<LinkableSection id="features-library" header="Compiling as a library" level={H3}>
196+
<LinkableSection id="features-library" header="Compiling as a library" level="h3">
197197
<p>
198198
If your code contains the <Code>#![crate_type=&quot;lib&quot;]</Code> attribute,
199199
{' '}
@@ -204,7 +204,7 @@ const Help: React.SFC = () => {
204204
<Example code={LIBRARY_EXAMPLE} />
205205
</LinkableSection>
206206

207-
<LinkableSection id="features-output-formats" header="Output formats" level={H3}>
207+
<LinkableSection id="features-output-formats" header="Output formats" level="h3">
208208
<p>
209209
Instead of executing the code, you can also see intermediate
210210
output of the compiler as x86_64 assembly, LLVM IR, Rust MIR, or
@@ -217,7 +217,7 @@ const Help: React.SFC = () => {
217217
<Example code={OUTPUT_EXAMPLE} />
218218
</LinkableSection>
219219

220-
<LinkableSection id="features-modes" header="Compilation modes" level={H3}>
220+
<LinkableSection id="features-modes" header="Compilation modes" level="h3">
221221
<p>
222222
Rust has two primary compilation modes: <strong>Debug</strong> and
223223
{' '}
@@ -232,7 +232,7 @@ const Help: React.SFC = () => {
232232
</p>
233233
</LinkableSection>
234234

235-
<LinkableSection id="features-channels" header="Rust channels" level={H3}>
235+
<LinkableSection id="features-channels" header="Rust channels" level="h3">
236236
<p>
237237
Rust releases new <strong>stable</strong> versions every 6
238238
weeks. Between these stable releases, <strong>beta</strong> versions of the
@@ -247,7 +247,7 @@ const Help: React.SFC = () => {
247247
</p>
248248
</LinkableSection>
249249

250-
<LinkableSection id="features-customization" header="Customization" level={H3}>
250+
<LinkableSection id="features-customization" header="Customization" level="h3">
251251
<p>
252252
The <a href={ACE_URL}>Ajax.org Cloud9 Editor (Ace)</a> is used to
253253
provide a better interface for editing code. Ace comes with
@@ -265,7 +265,7 @@ const Help: React.SFC = () => {
265265
</p>
266266
</LinkableSection>
267267

268-
<LinkableSection id="features-persistence" header="Persistence" level={H3}>
268+
<LinkableSection id="features-persistence" header="Persistence" level="h3">
269269
<p>
270270
The most recently entered code will be automatically saved in your browser’s
271271
{' '}
@@ -280,7 +280,7 @@ const Help: React.SFC = () => {
280280
</LinkableSection>
281281
</LinkableSection>
282282

283-
<LinkableSection id="limitations" header="Limitations" level={H2}>
283+
<LinkableSection id="limitations" header="Limitations" level="h2">
284284
<p>
285285
To prevent the playground from being used to attack other computers and
286286
to ensure it is available for everyone to use, some limitations
@@ -316,10 +316,7 @@ const Help: React.SFC = () => {
316316
);
317317
};
318318

319-
const H2: React.SFC = ({ children }) => <h2>{children}</h2>;
320-
const H3: React.SFC = ({ children }) => <h3>{children}</h3>;
321-
322-
const LinkableSection: React.SFC<LinkableSectionProps> = ({
319+
const LinkableSection: React.FC<LinkableSectionProps> = ({
323320
id, header, level: Level, children,
324321
}) => (
325322
<div id={id}>
@@ -335,10 +332,10 @@ const LinkableSection: React.SFC<LinkableSectionProps> = ({
335332
interface LinkableSectionProps {
336333
id: string;
337334
header: string;
338-
level: (ChildrenProps) => JSX.Element;
335+
level: React.ElementType;
339336
}
340337

341-
const Code: React.SFC = ({ children }) => (
338+
const Code: React.FC = ({ children }) => (
342339
<code className={styles.code}>{children}</code>
343340
);
344341

0 commit comments

Comments
 (0)