Skip to content
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

Integrate TypeScript port #1739

Merged
merged 31 commits into from Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a8c84d2
Use babel for typescript compilation with minimal changes (#1738)
chuckdries Jun 25, 2021
4f9c3b8
Convert Context/Provider/Subscription to Typescript (#1742)
Vannevelj Jun 26, 2021
76ed07f
Converts a few hooks & helpers to Typescript (#1743)
Vannevelj Jun 29, 2021
1c677c2
Run these through Prettier
timdorr Jun 29, 2021
0150161
Remove comments and extraneous options from tsconfig
timdorr Jun 29, 2021
d56c262
Fix lint errors and run through prettier
timdorr Jun 29, 2021
c3764dd
Convert reactBatchedUpdates to TypeScript (#1746)
AlexMunoz Jun 30, 2021
a5c4916
[TS-prototype]: convert verifySubselectors to TS #1737 (#1748)
FaberVitale Jun 30, 2021
7dcd152
Refactor: move d.ts file (#1749)
AlexMunoz Jun 30, 2021
0cece74
chore(mapStateToProps): port to typescript (#1745)
tony-go Jul 2, 2021
c8ee01e
Assorted TS updates (#1750)
markerikson Jul 2, 2021
5a11915
Convert package management to Yarn v2 (#1751)
markerikson Jul 3, 2021
9249108
Improve CI setup (#1752)
markerikson Jul 3, 2021
b1d384b
Add first version of types for useSelector hook (#1753)
lindskogen Jul 6, 2021
50018ca
Update Babel config for modern output (#1754)
markerikson Jul 6, 2021
fad30d6
Rewrite Subscription as a closure factory for byte shaving (#1755)
markerikson Jul 6, 2021
3a243ff
Add typescript definitions for mergeProps module (#1756)
lindskogen Jul 6, 2021
b8a118a
Convert connect components and logic to TS (with caveats) (#1758)
markerikson Jul 7, 2021
147f178
chore(mapDispatchToProps): port to typescript (#1760)
tony-go Jul 8, 2021
17ddf9d
Convert entry file to ts (#1759)
myNameIsDu Jul 8, 2021
918e7e9
Consolidate entry points (#1761)
markerikson Jul 8, 2021
2c08811
Add API Extractor setup (#1764)
markerikson Jul 9, 2021
cb93374
Rework connect types and add type test setup (#1766)
markerikson Jul 9, 2021
f1201de
Refactor/test hooks (#1767)
myNameIsDu Jul 13, 2021
cc63d0c
refactor: transform test/components/hooks to tsx (#1769)
myNameIsDu Jul 15, 2021
1f4d970
chore: modify jest config, ts-jest => 26.xx.xx, tsconfig'include add …
myNameIsDu Jul 19, 2021
19ccf75
refactor: transform test/components/Provider => ts (#1772)
myNameIsDu Jul 20, 2021
64a6e3a
refactor: transform test/integration/dynamic-reducers.spec => ts (#1774)
myNameIsDu Jul 21, 2021
8f5b8c3
pref: kill ugly writing (#1775)
myNameIsDu Jul 21, 2021
9e6793a
refactor: transform test/integration/server-rendering => ts (#1776)
myNameIsDu Jul 23, 2021
e326d6f
Merge branch 'master' into typescript-port
markerikson Jul 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 26 additions & 8 deletions .babelrc.js
@@ -1,22 +1,40 @@
const { NODE_ENV, BABEL_ENV } = process.env
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs'
const loose = true

module.exports = {
presets: [['@babel/env', { loose, modules: false }]],
presets: [
[
'@babel/preset-env',
{
targets: {
esmodules: true,
},
// Use the equivalent of `babel-preset-modules`
bugfixes: true,
modules: false,
loose: true,
},
],
'@babel/preset-typescript',
],
plugins: [
['@babel/proposal-decorators', { legacy: true }],
['@babel/proposal-object-rest-spread', { loose }],
'@babel/transform-react-jsx',
cjs && ['@babel/transform-modules-commonjs', { loose }],
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-proposal-private-methods', { loose: true }],
['@babel/plugin-proposal-private-property-in-object', { loose: true }],
cjs && ['@babel/transform-modules-commonjs'],
[
'@babel/transform-runtime',
{
useESModules: !cjs,
version: require('./package.json').dependencies[
'@babel/runtime'
].replace(/^[^0-9]*/, '')
}
]
].filter(Boolean)
].replace(/^[^0-9]*/, ''),
},
],
].filter(Boolean),
assumptions: {
enumerableModuleMeta: true,
},
}
6 changes: 6 additions & 0 deletions .codesandbox/ci.json
@@ -0,0 +1,6 @@
{
"sandboxes": ["vanilla", "vanilla-ts"],
"node": "14",
"buildCommand": "build",
"packages": ["."]
}
23 changes: 17 additions & 6 deletions .eslintrc
@@ -1,14 +1,21 @@
{
"parser": "babel-eslint",
"parser": "@typescript-eslint/parser",
"extends": [
"eslint:recommended",
"plugin:import/recommended",
"plugin:react/recommended",
"plugin:prettier/recommended"
// "plugin:@typescript-eslint/recommended"
],
"settings": {
"react": {
"version": "detect"
},
"import/ignore": ["react-native"],
"import/resolver": {
"node": {
"extensions": [".js", ".ts", ".tsx"]
}
}
},
"parserOptions": {
Expand All @@ -29,10 +36,14 @@
"react/jsx-uses-react": 1,
"react/jsx-no-undef": 2,
"react/jsx-wrap-multilines": 2,
"react/no-string-refs": 0
"react/no-string-refs": 0,
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"],
"no-redeclare": "off",
"@typescript-eslint/no-redeclare": ["error"]
},
"plugins": [
"import",
"react"
]
"plugins": ["@typescript-eslint", "import", "react"],
"globals": {
"JSX": true
}
}
95 changes: 73 additions & 22 deletions .github/workflows/test.yml
Expand Up @@ -2,39 +2,90 @@ name: Tests

on:
push:
branches: [ master ]
branches: [master, typescript-port]
pull_request:
branches: [ master ]
branches: [master, typescript-port]

jobs:
build:
name: Test Suite
runs-on: ubuntu-latest

steps:
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Checkout code
uses: actions/checkout@v2

- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: .yarn/cache
key: yarn-${{ hashFiles('yarn.lock') }}
restore-keys: yarn-

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-npm-
${{ runner.OS }}-
- name: Install dependencies
run: yarn install

- name: Install dependencies
run: npm ci
- name: Run test suite
run: yarn test

- name: Run test suite
run: npm test
- name: Collect coverage
run: yarn coverage

- name: Collect coverage
run: npm run coverage
test-types:
name: Test Types with TypeScript ${{ matrix.ts }}

needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['14.x']
ts: ['3.9', '4.0', '4.1', '4.2', '4.3', 'next']
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Use node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- uses: actions/cache@v2
with:
path: .yarn/cache
key: yarn-${{ hashFiles('yarn.lock') }}
restore-keys: yarn-

- name: Install deps
run: yarn install

- name: Install TypeScript ${{ matrix.ts }}
run: yarn add typescript@${{ matrix.ts }}

# - uses: actions/download-artifact@v2
# with:
# name: package
# path: packages/toolkit

# - name: Install build artifact
# run: yarn add ./package.tgz

# - run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./jest.config.js ./src/tests/*.* ./src/query/tests/*.*

# - name: "@ts-ignore stuff that didn't exist pre-4.1 in the tests"
# if: ${{ matrix.ts < 4.1 }}
# run: sed -i -e 's/@pre41-ts-ignore/@ts-ignore/' -e '/pre41-remove-start/,/pre41-remove-end/d' ./src/tests/*.* ./src/query/tests/*.ts*

# - name: 'disable strictOptionalProperties'
# if: ${{ matrix.ts == 'next' }}
# run: sed -i -e 's|//\(.*strictOptionalProperties.*\)$|\1|' tsconfig.base.json

- name: Test types
run: |
yarn tsc --version
yarn type-tests
17 changes: 17 additions & 0 deletions .gitignore
Expand Up @@ -3,6 +3,23 @@ dist
lib
coverage
es
temp/
react-redux-*/

.cache
.yarnrc
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*
*.tgz

.yalc
yalc.lock
yalc.sig

lib/core/metadata.js
lib/core/MetadataBlog.js
Expand Down
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-compat.cjs
@@ -0,0 +1,9 @@
module.exports = {
name: `@yarnpkg/plugin-compat`,
factory: (require) => {
// we are not using PNP and want to use `typescript@next` in CI without hassle
// dummy implementation to override the built-in version of this plugin
// can be dropped once we switch to yarn 3
return {}
},
}
29 changes: 29 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions .yarn/releases/yarn-berry.cjs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .yarnrc.yml
@@ -0,0 +1,9 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'
- path: .yarn/plugins/@yarnpkg/plugin-compat.cjs
spec: '@yarnpkg/plugin-compat'

yarnPath: .yarn/releases/yarn-berry.cjs
41 changes: 28 additions & 13 deletions CONTRIBUTING.md
@@ -1,9 +1,11 @@
# Contributing
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).

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).

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.

## Reporting Issues and Asking Questions

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.

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.
Expand All @@ -13,43 +15,56 @@ Please ask any general and implementation specific questions on [Stack Overflow
Visit the [Issue tracker](https://github.com/reduxjs/react-redux/issues) to find a list of open issues that need attention.

Fork, then clone the repo:

```
git clone https://github.com/your-username/react-redux.git
```

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:

```
yarn install
```

### Building

Running the `build` task will create both a CommonJS module-per-module build and a UMD build.

```
npm run build
yarn build
```

To create just a CommonJS module-per-module build:

```
npm run build:lib
yarn build:lib
```

To create just a UMD build:

```
npm run build:umd
npm run build:umd:min
yarn build:umd
yarn build:umd:min
```

### Testing and Linting

To run the tests:

```
npm run test
yarn test
```

To continuously watch and run tests, run the following:

```
npm test -- --watch
yarn test --watch
```

To perform linting with `eslint`, run the following:

```
npm run lint
yarn lint
```

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

## Submitting Changes

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

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

Expand Down