Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kale-stew committed May 14, 2020
1 parent b755024 commit ae9a945
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 29 deletions.
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"scripts": {
"preversion": "yarn test",
"benchmark": "node benchmark",
"eslint": "eslint \"*.js\" benchmark test",
"eslint": "eslint \"*.js\" \"*.ts\" benchmark test",
"test-browser": "karma start test/browser/karma.conf.js",
"test-browser-ie": "karma start test/browser/karma.conf.ie.js",
"test-node": "mocha \"test/node/*.spec.js\"",
"test-node-cov": "nyc yarn test-node",
"test-ts": "tsc --p test/typescript/index.ts",
"test-tsc": "tsc --target ES5 --noImplicitAny index.d.ts",
"test-ts-types": "tsc --p test/typescript/index.ts",
"test-ts-usage": "tsc --target ES5 --noImplicitAny index.d.ts",
"test": "builder concurrent --buffer eslint test-tsc test-ts test-node-cov test-browser",
"test-ie": "builder concurrent --buffer eslint test-tsc -test-ts test-node-cov test-browser-ie",
"compress": "terser --compress --mangle=\"toplevel:true\" -- index.js",
Expand Down Expand Up @@ -41,6 +41,7 @@
"@babel/preset-env": "^7.7.6",
"@testing-library/dom": "^7.5.1",
"@testing-library/preact": "^1.0.2",
"@types/node": "^14.0.1",
"babel-loader": "^8.0.6",
"benchmark": "^2.1.4",
"builder": "^5.0.0",
Expand All @@ -65,6 +66,7 @@
"nyc": "^14.1.1",
"preact": "^10.4.1",
"react": "^16.3.1",
"react-redux": "^7.2.0",
"react-test-renderer": "^16.13.1",
"shallow-equal-fuzzy": "0.0.2",
"sinon": "^7.5.0",
Expand Down
39 changes: 15 additions & 24 deletions test/typescript/index.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,34 @@
import React from "react";
import { useSelector } from "react-redux";

const equal = require("../..");

type DeepObject = {
any: any;
export const TodoListItem = (props) => {
return;
};

type State = {
any: {
any: any;
};
type ITodo = string;

type IProps = {
todo: ITodo;
};

// State
const selector = (state: State) => {
a: {
b: [1, 2, 3];
}
type IState = {
todos: ITodo[];
};

class TestComponent extends React.Component {
constructor() {
super();
this.useSelector = this.useSelector;
class TestApp extends React.Component<IProps, IState> {
constructor(props) {
super(...props);
}

shouldComponentUpdate(nextProps) {
return !equal(this.props, nextProps);
}

useSelector<TState, TSelected>(
selector: (state: TState) => TSelected,
equalityFn?: (left: TSelected, right: TSelected) => boolean
): TSelected;

this.useSelector(selector); // typed correctly as DeepObject
this.useSelector(selector, equal); // typed as any
todo = useSelector((state) => state.todos[props.id]);

render() {
// ...
return <div>{todo.text}</div>;
}
};
}
27 changes: 25 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,11 @@
"@types/istanbul-lib-coverage" "*"
"@types/istanbul-lib-report" "*"

"@types/node@^14.0.1":
version "14.0.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.1.tgz#5d93e0a099cd0acd5ef3d5bde3c086e1f49ff68c"
integrity sha512-FAYBGwC+W6F9+huFIDtn43cpy7+SzG+atzRiTfdp3inUKL2hXnd4rG8hylJLIh4+hqrQy1P17kvJByE/z825hA==

"@types/testing-library__dom@^6.12.1":
version "6.14.0"
resolved "https://registry.yarnpkg.com/@types/testing-library__dom/-/testing-library__dom-6.14.0.tgz#1aede831cb4ed4a398448df5a2c54b54a365644e"
Expand Down Expand Up @@ -3126,6 +3131,13 @@ hmac-drbg@^1.0.0:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.1"

hoist-non-react-statics@^3.3.0:
version "3.3.2"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
dependencies:
react-is "^16.7.0"

hosted-git-info@^2.1.4:
version "2.8.8"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
Expand Down Expand Up @@ -4780,7 +4792,7 @@ promise-inflight@^1.0.1:
resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3"
integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM=

prop-types@^15.6.2:
prop-types@^15.6.2, prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
Expand Down Expand Up @@ -4911,11 +4923,22 @@ [email protected]:
iconv-lite "0.4.24"
unpipe "1.0.0"

react-is@^16.12.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6:
react-is@^16.12.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6, react-is@^16.9.0:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

react-redux@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-7.2.0.tgz#f970f62192b3981642fec46fd0db18a074fe879d"
integrity sha512-EvCAZYGfOLqwV7gh849xy9/pt55rJXPwmYvI4lilPM5rUT/1NxuuN59ipdBksRVSvz0KInbPnp4IfoXJXCqiDA==
dependencies:
"@babel/runtime" "^7.5.5"
hoist-non-react-statics "^3.3.0"
loose-envify "^1.4.0"
prop-types "^15.7.2"
react-is "^16.9.0"

react-test-renderer@^16.13.1:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.13.1.tgz#de25ea358d9012606de51e012d9742e7f0deabc1"
Expand Down

0 comments on commit ae9a945

Please sign in to comment.