Skip to content

Commit

Permalink
Merge pull request #1739 from reduxjs/typescript-port
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Jul 28, 2021
2 parents 2c7ef25 + e326d6f commit d622cb5
Show file tree
Hide file tree
Showing 77 changed files with 22,841 additions and 64,999 deletions.
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

0 comments on commit d622cb5

Please sign in to comment.