Skip to content

Commit d622cb5

Browse files
authored
Merge pull request #1739 from reduxjs/typescript-port
2 parents 2c7ef25 + e326d6f commit d622cb5

Some content is hidden

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

77 files changed

+22841
-64999
lines changed

.babelrc.js

+26-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
11
const { NODE_ENV, BABEL_ENV } = process.env
22
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs'
3-
const loose = true
43

54
module.exports = {
6-
presets: [['@babel/env', { loose, modules: false }]],
5+
presets: [
6+
[
7+
'@babel/preset-env',
8+
{
9+
targets: {
10+
esmodules: true,
11+
},
12+
// Use the equivalent of `babel-preset-modules`
13+
bugfixes: true,
14+
modules: false,
15+
loose: true,
16+
},
17+
],
18+
'@babel/preset-typescript',
19+
],
720
plugins: [
821
['@babel/proposal-decorators', { legacy: true }],
9-
['@babel/proposal-object-rest-spread', { loose }],
1022
'@babel/transform-react-jsx',
11-
cjs && ['@babel/transform-modules-commonjs', { loose }],
23+
['@babel/plugin-proposal-class-properties', { loose: true }],
24+
['@babel/plugin-proposal-private-methods', { loose: true }],
25+
['@babel/plugin-proposal-private-property-in-object', { loose: true }],
26+
cjs && ['@babel/transform-modules-commonjs'],
1227
[
1328
'@babel/transform-runtime',
1429
{
1530
useESModules: !cjs,
1631
version: require('./package.json').dependencies[
1732
'@babel/runtime'
18-
].replace(/^[^0-9]*/, '')
19-
}
20-
]
21-
].filter(Boolean)
33+
].replace(/^[^0-9]*/, ''),
34+
},
35+
],
36+
].filter(Boolean),
37+
assumptions: {
38+
enumerableModuleMeta: true,
39+
},
2240
}

.codesandbox/ci.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sandboxes": ["vanilla", "vanilla-ts"],
3+
"node": "14",
4+
"buildCommand": "build",
5+
"packages": ["."]
6+
}

.eslintrc

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
{
2-
"parser": "babel-eslint",
2+
"parser": "@typescript-eslint/parser",
33
"extends": [
44
"eslint:recommended",
55
"plugin:import/recommended",
66
"plugin:react/recommended",
77
"plugin:prettier/recommended"
8+
// "plugin:@typescript-eslint/recommended"
89
],
910
"settings": {
1011
"react": {
1112
"version": "detect"
13+
},
14+
"import/ignore": ["react-native"],
15+
"import/resolver": {
16+
"node": {
17+
"extensions": [".js", ".ts", ".tsx"]
18+
}
1219
}
1320
},
1421
"parserOptions": {
@@ -29,10 +36,14 @@
2936
"react/jsx-uses-react": 1,
3037
"react/jsx-no-undef": 2,
3138
"react/jsx-wrap-multilines": 2,
32-
"react/no-string-refs": 0
39+
"react/no-string-refs": 0,
40+
"no-unused-vars": "off",
41+
"@typescript-eslint/no-unused-vars": ["error"],
42+
"no-redeclare": "off",
43+
"@typescript-eslint/no-redeclare": ["error"]
3344
},
34-
"plugins": [
35-
"import",
36-
"react"
37-
]
45+
"plugins": ["@typescript-eslint", "import", "react"],
46+
"globals": {
47+
"JSX": true
48+
}
3849
}

.github/workflows/test.yml

+73-22
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,90 @@ name: Tests
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master, typescript-port]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master, typescript-port]
88

99
jobs:
1010
build:
1111
name: Test Suite
1212
runs-on: ubuntu-latest
1313

1414
steps:
15+
- name: Set up Node
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: 14.x
1519

16-
- name: Set up Node
17-
uses: actions/setup-node@v1
18-
with:
19-
node-version: 14.x
20+
- name: Checkout code
21+
uses: actions/checkout@v2
2022

21-
- name: Checkout code
22-
uses: actions/checkout@v2
23+
- name: Cache dependencies
24+
uses: actions/cache@v2
25+
with:
26+
path: .yarn/cache
27+
key: yarn-${{ hashFiles('yarn.lock') }}
28+
restore-keys: yarn-
2329

24-
- name: Cache dependencies
25-
uses: actions/cache@v2
26-
with:
27-
path: ~/.npm
28-
key: ${{ runner.OS }}-npm-${{ hashFiles('**/package-lock.json') }}
29-
restore-keys: |
30-
${{ runner.OS }}-npm-
31-
${{ runner.OS }}-
30+
- name: Install dependencies
31+
run: yarn install
3232

33-
- name: Install dependencies
34-
run: npm ci
33+
- name: Run test suite
34+
run: yarn test
3535

36-
- name: Run test suite
37-
run: npm test
36+
- name: Collect coverage
37+
run: yarn coverage
3838

39-
- name: Collect coverage
40-
run: npm run coverage
39+
test-types:
40+
name: Test Types with TypeScript ${{ matrix.ts }}
41+
42+
needs: [build]
43+
runs-on: ubuntu-latest
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
node: ['14.x']
48+
ts: ['3.9', '4.0', '4.1', '4.2', '4.3', 'next']
49+
steps:
50+
- name: Checkout repo
51+
uses: actions/checkout@v2
52+
53+
- name: Use node ${{ matrix.node }}
54+
uses: actions/setup-node@v1
55+
with:
56+
node-version: ${{ matrix.node }}
57+
58+
- uses: actions/cache@v2
59+
with:
60+
path: .yarn/cache
61+
key: yarn-${{ hashFiles('yarn.lock') }}
62+
restore-keys: yarn-
63+
64+
- name: Install deps
65+
run: yarn install
66+
67+
- name: Install TypeScript ${{ matrix.ts }}
68+
run: yarn add typescript@${{ matrix.ts }}
69+
70+
# - uses: actions/download-artifact@v2
71+
# with:
72+
# name: package
73+
# path: packages/toolkit
74+
75+
# - name: Install build artifact
76+
# run: yarn add ./package.tgz
77+
78+
# - run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./jest.config.js ./src/tests/*.* ./src/query/tests/*.*
79+
80+
# - name: "@ts-ignore stuff that didn't exist pre-4.1 in the tests"
81+
# if: ${{ matrix.ts < 4.1 }}
82+
# run: sed -i -e 's/@pre41-ts-ignore/@ts-ignore/' -e '/pre41-remove-start/,/pre41-remove-end/d' ./src/tests/*.* ./src/query/tests/*.ts*
83+
84+
# - name: 'disable strictOptionalProperties'
85+
# if: ${{ matrix.ts == 'next' }}
86+
# run: sed -i -e 's|//\(.*strictOptionalProperties.*\)$|\1|' tsconfig.base.json
87+
88+
- name: Test types
89+
run: |
90+
yarn tsc --version
91+
yarn type-tests

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@ dist
33
lib
44
coverage
55
es
6+
temp/
7+
react-redux-*/
8+
9+
.cache
10+
.yarnrc
11+
.yarn/*
12+
!.yarn/patches
13+
!.yarn/releases
14+
!.yarn/plugins
15+
!.yarn/sdks
16+
!.yarn/versions
17+
.pnp.*
18+
*.tgz
19+
20+
.yalc
21+
yalc.lock
22+
yalc.sig
623

724
lib/core/metadata.js
825
lib/core/MetadataBlog.js
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
name: `@yarnpkg/plugin-compat`,
3+
factory: (require) => {
4+
// we are not using PNP and want to use `typescript@next` in CI without hassle
5+
// dummy implementation to override the built-in version of this plugin
6+
// can be dropped once we switch to yarn 3
7+
return {}
8+
},
9+
}

.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

+29
Large diffs are not rendered by default.

.yarn/releases/yarn-berry.cjs

+55
Large diffs are not rendered by default.

.yarnrc.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
nodeLinker: node-modules
2+
3+
plugins:
4+
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
5+
spec: '@yarnpkg/plugin-workspace-tools'
6+
- path: .yarn/plugins/@yarnpkg/plugin-compat.cjs
7+
spec: '@yarnpkg/plugin-compat'
8+
9+
yarnPath: .yarn/releases/yarn-berry.cjs

CONTRIBUTING.md

+28-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Contributing
2-
We are open to, and grateful for, any contributions made by the community. By contributing to React Redux, you agree to abide by the [code of conduct](https://github.com/reduxjs/react-redux/blob/master/CODE_OF_CONDUCT.md).
2+
3+
We are open to, and grateful for, any contributions made by the community. By contributing to React Redux, you agree to abide by the [code of conduct](https://github.com/reduxjs/react-redux/blob/master/CODE_OF_CONDUCT.md).
34

45
Please review the [Redux Style Guide](https://redux.js.org/style-guide/style-guide) in the Redux docs to keep track of our best practices.
56

67
## Reporting Issues and Asking Questions
8+
79
Before opening an issue, please search the [issue tracker](https://github.com/reduxjs/react-redux/issues) to make sure your issue hasn't already been reported.
810

911
Please ask any general and implementation specific questions on [Stack Overflow with a Redux tag](http://stackoverflow.com/questions/tagged/redux?sort=votes&pageSize=50) for support.
@@ -13,43 +15,56 @@ Please ask any general and implementation specific questions on [Stack Overflow
1315
Visit the [Issue tracker](https://github.com/reduxjs/react-redux/issues) to find a list of open issues that need attention.
1416

1517
Fork, then clone the repo:
18+
1619
```
1720
git clone https://github.com/your-username/react-redux.git
1821
```
1922

23+
This repository uses Yarn v2 to manage packages. You'll need to have Yarn v1.22 installed globally on your system first, as Yarn v2 depends on that being available first. Install dependencies with:
24+
25+
```
26+
yarn install
27+
```
28+
2029
### Building
2130

2231
Running the `build` task will create both a CommonJS module-per-module build and a UMD build.
32+
2333
```
24-
npm run build
34+
yarn build
2535
```
2636

2737
To create just a CommonJS module-per-module build:
38+
2839
```
29-
npm run build:lib
40+
yarn build:lib
3041
```
3142

3243
To create just a UMD build:
44+
3345
```
34-
npm run build:umd
35-
npm run build:umd:min
46+
yarn build:umd
47+
yarn build:umd:min
3648
```
3749

3850
### Testing and Linting
3951

4052
To run the tests:
53+
4154
```
42-
npm run test
55+
yarn test
4356
```
4457

4558
To continuously watch and run tests, run the following:
59+
4660
```
47-
npm test -- --watch
61+
yarn test --watch
4862
```
4963

5064
To perform linting with `eslint`, run the following:
65+
5166
```
52-
npm run lint
67+
yarn lint
5368
```
5469

5570
### New Features
@@ -58,11 +73,11 @@ Please open an issue with a proposal for a new feature or refactoring before sta
5873

5974
## Submitting Changes
6075

61-
* Open a new issue in the [Issue tracker](https://github.com/reduxjs/react-redux/issues).
62-
* Fork the repo.
63-
* Create a new feature branch based off the `master` branch.
64-
* Make sure all tests pass and there are no linting errors.
65-
* Submit a pull request, referencing any issues it addresses.
76+
- Open a new issue in the [Issue tracker](https://github.com/reduxjs/react-redux/issues).
77+
- Fork the repo.
78+
- Create a new feature branch based off the `master` branch.
79+
- Make sure all tests pass and there are no linting errors.
80+
- Submit a pull request, referencing any issues it addresses.
6681

6782
Please try to keep your pull request focused in scope and avoid including unrelated commits.
6883

0 commit comments

Comments
 (0)