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

feat(react): add react-router-dom types #1762

Merged
merged 1 commit into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export function copyMissingPackages(): void {
'styled-components',
'@types/react',
'@types/react-dom',
'@types/react-router-dom',
'@testing-library',

// For testing webpack config with babel-loader
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@types/react-dom": "^16.8.5",
"@types/webpack": "^4.4.24",
"@types/yargs": "^11.0.0",
"@types/react-router-dom": "4.3.5",
"@typescript-eslint/eslint-plugin": "2.0.0-alpha.4",
"@typescript-eslint/experimental-utils": "2.0.0-alpha.4",
"@typescript-eslint/parser": "2.0.0-alpha.4",
Expand Down
6 changes: 5 additions & 1 deletion packages/react/src/schematics/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
babelPresetReactVersion,
babelPresetTypeScriptVersion,
coreJsVersion,
reactRouterDomVersion,
reactRouterVersion,
regeneratorVersion
} from '../../utils/versions';
Expand Down Expand Up @@ -255,7 +256,10 @@ function addRouting(

insert(host, appPath, addInitialRoutes(appPath, appSource, context));
},
addDepsToPackageJson({ 'react-router-dom': reactRouterVersion }, {})
addDepsToPackageJson(
{ 'react-router-dom': reactRouterVersion },
{ '@types/react-router-dom': reactRouterDomVersion }
)
])
: noop();
}
Expand Down
10 changes: 8 additions & 2 deletions packages/react/src/schematics/component/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import {
insert
} from '@nrwl/workspace/src/utils/ast-utils';
import { CSS_IN_JS_DEPENDENCIES } from '../../utils/styled';
import { reactRouterVersion } from '../../utils/versions';
import {
reactRouterDomVersion,
reactRouterVersion
} from '../../utils/versions';
import { assertValidStyle } from '../../utils/assertion';

interface NormalizedSchema extends Schema {
Expand All @@ -40,7 +43,10 @@ export default function(schema: Schema): Rule {
addStyledModuleDependencies(options),
addExportsToBarrel(options),
options.routing
? addDepsToPackageJson({ 'react-router-dom': reactRouterVersion }, {})
? addDepsToPackageJson(
{ 'react-router-dom': reactRouterVersion },
{ '@types/react-router-dom': reactRouterDomVersion }
)
: noop(),
formatFiles({ skipFormat: false })
]);
Expand Down
10 changes: 8 additions & 2 deletions packages/react/src/schematics/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ import {
addRoute,
findComponentImportPath
} from '../../utils/ast-utils';
import { reactRouterVersion } from '../../utils/versions';
import {
reactRouterDomVersion,
reactRouterVersion
} from '../../utils/versions';
import { assertValidStyle } from '../../utils/assertion';
import { extraEslintDependencies, reactEslintJson } from '../../utils/lint';

Expand Down Expand Up @@ -170,7 +173,10 @@ function updateAppRoutes(
`${componentImportPath}.tsx`
);
return chain([
addDepsToPackageJson({ 'react-router-dom': reactRouterVersion }, {}),
addDepsToPackageJson(
{ 'react-router-dom': reactRouterVersion },
{ '@types/react-router-dom': reactRouterDomVersion }
),
function addBrowserRouterToMain(host: Tree) {
const { content, source } = readComponent(host, options.appMain);
const isRouterPresent = content.match(/react-router-dom/);
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const styledComponentsTypesVersion = '4.1.18';
export const emotionVersion = '10.0.14';
export const domTypesVersion = '16.8.5';
export const reactRouterVersion = '5.0.1';
export const reactRouterDomVersion = '4.3.5';
export const testingLibraryVersion = '8.0.5';
export const babelCoreVersion = '7.5.5';
export const babelPresetEnvVersion = '7.5.5';
Expand Down
22 changes: 22 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,11 @@
"@types/minimatch" "*"
"@types/node" "*"

"@types/history@*":
version "4.7.3"
resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.3.tgz#856c99cdc1551d22c22b18b5402719affec9839a"
integrity sha512-cS5owqtwzLN5kY+l+KgKdRJ/Cee8tlmQoGQuIE9tWnSmS3JMKzmxo2HIAk2wODMifGwO20d62xZQLYz+RLfXmw==

"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#42995b446db9a48a11a07ec083499a860e9138ff"
Expand Down Expand Up @@ -1700,6 +1705,23 @@
dependencies:
"@types/react" "*"

"@types/react-router-dom@4.3.5":
version "4.3.5"
resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-4.3.5.tgz#72f229967690c890d00f96e6b85e9ee5780db31f"
integrity sha512-eFajSUASYbPHg2BDM1G8Btx+YqGgvROPIg6sBhl3O4kbDdYXdFdfrgQFf/pcBuQVObjfT9AL/dd15jilR5DIEA==
dependencies:
"@types/history" "*"
"@types/react" "*"
"@types/react-router" "*"

"@types/react-router@*":
version "5.0.3"
resolved "https://registry.yarnpkg.com/@types/react-router/-/react-router-5.0.3.tgz#855a1606e62de3f4d69ea34fb3c0e50e98e964d5"
integrity sha512-j2Gge5cvxca+5lK9wxovmGPgpVJMwjyu5lTA/Cd6fLGoPq7FXcUE1jFkEdxeyqGGz8VfHYSHCn5Lcn24BzaNKA==
dependencies:
"@types/history" "*"
"@types/react" "*"

"@types/react@*":
version "16.8.23"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.8.23.tgz#ec6be3ceed6353a20948169b6cb4c97b65b97ad2"
Expand Down