Skip to content

Feat: updated playground to TS@3.1 and all dependencies with types #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ jspm_packages
.node_repl_history

temp/
playground/dist
79 changes: 36 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,56 +287,51 @@ export class StatefulCounter extends React.Component<StatefulCounterProps, State
```tsx
import * as React from 'react';

export interface StatefulCounterWithDefaultProps {
type Props = Readonly<{
label: string;
initialCount?: number;
}

interface DefaultProps {
readonly initialCount: number;
}
initialCount: number;
}>;

interface State {
readonly count: number;
}
type State = Readonly<{
count: number;
}>;

export const StatefulCounterWithDefault: React.ComponentClass<StatefulCounterWithDefaultProps> =
class extends React.Component<StatefulCounterWithDefaultProps & DefaultProps> {
// to make defaultProps strictly typed we need to explicitly declare their type
// @see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11640
static defaultProps: DefaultProps = {
initialCount: 0,
};
export class StatefulCounterWithDefault extends React.Component<Props, State> {
static defaultProps = {
initialCount: 0,
};

readonly state: State = {
count: this.props.initialCount,
};
readonly state: State = {
count: this.props.initialCount,
};

componentWillReceiveProps({ initialCount }: StatefulCounterWithDefaultProps) {
if (initialCount != null && initialCount !== this.props.initialCount) {
this.setState({ count: initialCount });
}
componentWillReceiveProps({ initialCount }: Props) {
if (initialCount != null && initialCount !== this.props.initialCount) {
this.setState({ count: initialCount });
}
}

handleIncrement = () => {
this.setState({ count: this.state.count + 1 });
}
handleIncrement = () => {
this.setState({ count: this.state.count + 1 });
};

render() {
const { handleIncrement } = this;
const { label } = this.props;
const { count } = this.state;
render() {
const { handleIncrement } = this;
const { label } = this.props;
const { count } = this.state;

return (
<div>
<span>{label}: {count} </span>
<button type="button" onClick={handleIncrement}>
{`Increment`}
</button>
</div>
);
}
};
return (
<div>
<span>
{label}: {count}{' '}
</span>
<button type="button" onClick={handleIncrement}>
{`Increment`}
</button>
</div>
);
}
}

```

Expand Down Expand Up @@ -1244,7 +1239,6 @@ export const SFCCounterConnectedVerbose =
"no-submodule-imports": [true, "@src", "rxjs"],
"no-this-assignment": [true, { "allow-destructuring": true }],
"no-trailing-whitespace": true,
"no-unused-variable": [true, "react"],
"object-literal-sort-keys": false,
"object-literal-shorthand": false,
"one-variable-per-declaration": [false],
Expand Down Expand Up @@ -1479,7 +1473,6 @@ declare module 'rxjs/Subject' {
// typings/modules.d.ts
declare module 'Types';
declare module 'react-test-renderer';
declare module 'enzyme';

```

Expand Down
1 change: 0 additions & 1 deletion README_SOURCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ export const SFCCounterConnectedVerbose =
"no-submodule-imports": [true, "@src", "rxjs"],
"no-this-assignment": [true, { "allow-destructuring": true }],
"no-trailing-whitespace": true,
"no-unused-variable": [true, "react"],
"object-literal-sort-keys": false,
"object-literal-shorthand": false,
"one-variable-per-declaration": [false],
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"devDependencies": {
"@types/node": "8.5.1",
"all-contributors-cli": "5.4.0"
},
"scripts": {
"ci-check": "npm run readme:generate",
"readme:generate": "node generate-readme",
"contributors:add": "all-contributors add",
"contributors:generate": "all-contributors generate"
}
"devDependencies": {
"@types/node": "8.5.1",
"all-contributors-cli": "5.4.0"
},
"scripts": {
"ci-check": "npm run readme:generate && npm run check-git-clean",
"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",
"readme:generate": "node generate-readme",
"contributors:add": "all-contributors add",
"contributors:generate": "all-contributors generate"
}
}
6 changes: 2 additions & 4 deletions playground/jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
"tsConfigFile": "./tsconfig.json"
}
},
"setupFiles": [
"./jest.stubs.js"
],
"setupTestFrameworkScriptFile": "./jest.tests.js"
"setupFiles": ["./jest.stubs.js"],
"testURL": "http://localhost/"
}
4 changes: 0 additions & 4 deletions playground/jest.tests.js

This file was deleted.

Loading