Skip to content

Commit

Permalink
Switch from create-react-app-typescript to create-react-app proper
Browse files Browse the repository at this point in the history
Now that `create-react-app` supports typescript, just use it instead of `create-react-app-typescript`, following the guide at https://vincenttunru.com/migrate-create-react-app-typescript-to-create-react-app/. Upgrading typescript caught an errorr in `index.d.ts`, sort of.
  • Loading branch information
ianobermiller committed Dec 7, 2018
1 parent 2675faf commit 0e9791f
Show file tree
Hide file tree
Showing 7 changed files with 8,140 additions and 5,688 deletions.
16 changes: 9 additions & 7 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@
"license": "MIT",
"private": true,
"dependencies": {
"@types/jest": "^23.3.10",
"@types/node": "^10.12.12",
"emotion": "^9.2.12",
"react": "^16.7.0-alpha.2",
"react-dom": "^16.7.0-alpha.2",
"react-scripts-ts": "3.1.0",
"react-scripts": "^2.1.1",
"redux": "^4.0.1"
},
"scripts": {
"start": "react-scripts-ts start",
"build": "react-scripts-ts build",
"test": "react-scripts-ts test --env=jsdom",
"eject": "react-scripts-ts eject"
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"@types/react": "^16.7.13",
"@types/react-dom": "^16.0.5",
"typescript": "^3.1.3"
"@types/react-dom": "^16.0.11",
"typescript": "^3.2.2"
}
}
6,932 changes: 4,086 additions & 2,846 deletions example/yarn.lock

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"npm": ">=5"
},
"scripts": {
"test": "cross-env CI=1 react-scripts-ts test --env=jsdom",
"test:watch": "react-scripts-ts test --env=jsdom",
"test": "react-scripts test --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"prettier": "prettier --config .prettierrc --write \"{src,example}/**/*.{js,ts,tsx}\"",
"build": "rollup -c",
"start": "rollup -c -w",
Expand All @@ -29,17 +29,16 @@
"redux": "^4.0.1"
},
"devDependencies": {
"@types/jest": "^23.1.5",
"@types/jest": "^23.3.10",
"@types/react": "^16.7.13",
"@types/react-dom": "^16.0.5",
"@types/react-dom": "^16.0.11",
"babel-core": "^6.26.3",
"babel-runtime": "^6.26.0",
"cross-env": "^5.1.4",
"gh-pages": "^2.0.1",
"prettier": "^1.14.3",
"react": "^16.7.0-alpha.2",
"react-dom": "^16.7.0-alpha.2",
"react-scripts-ts": "^3.1.0",
"redux": "^4.0.1",
"rollup": "^0.66.6",
"rollup-plugin-babel": "^4.0.3",
Expand All @@ -49,9 +48,13 @@
"rollup-plugin-peer-deps-external": "^2.2.0",
"rollup-plugin-typescript2": "^0.17.2",
"rollup-plugin-url": "^2.0.1",
"typescript": "^3.1.3"
"typescript": "^3.2.2"
},
"files": [
"dist"
]
],
"dependencies": {
"@types/node": "^10.12.12",
"react-scripts": "^2.1.1"
}
}
6 changes: 2 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import {createContext, useContext, useEffect, useRef, useState} from 'react';
import {Action, Dispatch, Store} from 'redux';
import shallowEqual from './shallowEqual';

export const StoreContext: React.Context<Store<any> | null> = createContext(
null,
);
export const StoreContext = createContext<Store<any> | null>(null);

const CONTEXT_ERROR_MESSAGE =
'redux-react-hook requires your Redux store to ' +
Expand Down Expand Up @@ -49,7 +47,7 @@ export function useMappedState<TState, TResult>(
// state. This way we can compare with the previous version to know if
// the component should re-render. Otherwise, we'd have pass derivedState
// in the array of memoization paramaters to the second useEffect below,
// which would cause it to unsubscribe and resubscribe from Redux everytime
// which would cause it to unsubscribe and resubscribe from Redux every time
// the state changes.
const lastRenderedDerivedState = useRef(derivedState);
// Set the last mapped state after rendering.
Expand Down
1 change: 1 addition & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
11 changes: 9 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"lib": ["es6", "dom", "es2016", "es2017"],
"sourceMap": true,
"allowJs": false,
"jsx": "react",
"jsx": "preserve",
"declaration": true,
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
Expand All @@ -16,7 +16,14 @@
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"noUnusedParameters": true
"noUnusedParameters": true,
"skipLibCheck": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"resolveJsonModule": true,
"isolatedModules": false,
"noEmit": true
},
"include": ["src"],
"exclude": ["node_modules", "build", "dist", "example", "rollup.config.js"]
Expand Down
Loading

0 comments on commit 0e9791f

Please sign in to comment.