Skip to content

Commit c759305

Browse files
authored
Feat: updated playground to TS@3.1 and all dependencies with types (#123)
1 parent 34798e4 commit c759305

File tree

13 files changed

+7671
-6005
lines changed

13 files changed

+7671
-6005
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ jspm_packages
3737
.node_repl_history
3838

3939
temp/
40+
playground/dist

README.md

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -287,56 +287,51 @@ export class StatefulCounter extends React.Component<StatefulCounterProps, State
287287
```tsx
288288
import * as React from 'react';
289289

290-
export interface StatefulCounterWithDefaultProps {
290+
type Props = Readonly<{
291291
label: string;
292-
initialCount?: number;
293-
}
294-
295-
interface DefaultProps {
296-
readonly initialCount: number;
297-
}
292+
initialCount: number;
293+
}>;
298294

299-
interface State {
300-
readonly count: number;
301-
}
295+
type State = Readonly<{
296+
count: number;
297+
}>;
302298

303-
export const StatefulCounterWithDefault: React.ComponentClass<StatefulCounterWithDefaultProps> =
304-
class extends React.Component<StatefulCounterWithDefaultProps & DefaultProps> {
305-
// to make defaultProps strictly typed we need to explicitly declare their type
306-
// @see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11640
307-
static defaultProps: DefaultProps = {
308-
initialCount: 0,
309-
};
299+
export class StatefulCounterWithDefault extends React.Component<Props, State> {
300+
static defaultProps = {
301+
initialCount: 0,
302+
};
310303

311-
readonly state: State = {
312-
count: this.props.initialCount,
313-
};
304+
readonly state: State = {
305+
count: this.props.initialCount,
306+
};
314307

315-
componentWillReceiveProps({ initialCount }: StatefulCounterWithDefaultProps) {
316-
if (initialCount != null && initialCount !== this.props.initialCount) {
317-
this.setState({ count: initialCount });
318-
}
308+
componentWillReceiveProps({ initialCount }: Props) {
309+
if (initialCount != null && initialCount !== this.props.initialCount) {
310+
this.setState({ count: initialCount });
319311
}
312+
}
320313

321-
handleIncrement = () => {
322-
this.setState({ count: this.state.count + 1 });
323-
}
314+
handleIncrement = () => {
315+
this.setState({ count: this.state.count + 1 });
316+
};
324317

325-
render() {
326-
const { handleIncrement } = this;
327-
const { label } = this.props;
328-
const { count } = this.state;
318+
render() {
319+
const { handleIncrement } = this;
320+
const { label } = this.props;
321+
const { count } = this.state;
329322

330-
return (
331-
<div>
332-
<span>{label}: {count} </span>
333-
<button type="button" onClick={handleIncrement}>
334-
{`Increment`}
335-
</button>
336-
</div>
337-
);
338-
}
339-
};
323+
return (
324+
<div>
325+
<span>
326+
{label}: {count}{' '}
327+
</span>
328+
<button type="button" onClick={handleIncrement}>
329+
{`Increment`}
330+
</button>
331+
</div>
332+
);
333+
}
334+
}
340335

341336
```
342337
@@ -1244,7 +1239,6 @@ export const SFCCounterConnectedVerbose =
12441239
"no-submodule-imports": [true, "@src", "rxjs"],
12451240
"no-this-assignment": [true, { "allow-destructuring": true }],
12461241
"no-trailing-whitespace": true,
1247-
"no-unused-variable": [true, "react"],
12481242
"object-literal-sort-keys": false,
12491243
"object-literal-shorthand": false,
12501244
"one-variable-per-declaration": [false],
@@ -1479,7 +1473,6 @@ declare module 'rxjs/Subject' {
14791473
// typings/modules.d.ts
14801474
declare module 'Types';
14811475
declare module 'react-test-renderer';
1482-
declare module 'enzyme';
14831476

14841477
```
14851478

README_SOURCE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@ export const SFCCounterConnectedVerbose =
536536
"no-submodule-imports": [true, "@src", "rxjs"],
537537
"no-this-assignment": [true, { "allow-destructuring": true }],
538538
"no-trailing-whitespace": true,
539-
"no-unused-variable": [true, "react"],
540539
"object-literal-sort-keys": false,
541540
"object-literal-shorthand": false,
542541
"one-variable-per-declaration": [false],

package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
2-
"devDependencies": {
3-
"@types/node": "8.5.1",
4-
"all-contributors-cli": "5.4.0"
5-
},
6-
"scripts": {
7-
"ci-check": "npm run readme:generate",
8-
"readme:generate": "node generate-readme",
9-
"contributors:add": "all-contributors add",
10-
"contributors:generate": "all-contributors generate"
11-
}
2+
"devDependencies": {
3+
"@types/node": "8.5.1",
4+
"all-contributors-cli": "5.4.0"
5+
},
6+
"scripts": {
7+
"ci-check": "npm run readme:generate && npm run check-git-clean",
8+
"check-git-clean": "if output=$(git status --porcelain) && [ -z '$output' ]; then echo 'Success!'; else echo '\n>>> Please check CONTRIBUTING.md to learn how to properly amend README.md <<<\n'; fi",
9+
"readme:generate": "node generate-readme",
10+
"contributors:add": "all-contributors add",
11+
"contributors:generate": "all-contributors generate"
12+
}
1213
}

playground/jest.config.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
"tsConfigFile": "./tsconfig.json"
1515
}
1616
},
17-
"setupFiles": [
18-
"./jest.stubs.js"
19-
],
20-
"setupTestFrameworkScriptFile": "./jest.tests.js"
17+
"setupFiles": ["./jest.stubs.js"],
18+
"testURL": "http://localhost/"
2119
}

playground/jest.tests.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)