17

I create a react-typescript project using create-react-app. I see that package.json looks like below:

"dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.4.0",
    "@testing-library/user-event": "^7.2.1",
    "@types/jest": "^24.9.1",
    "@types/node": "^12.12.26",
    "@types/react": "^16.9.19",
    "@types/react-dom": "^16.9.5",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-scripts": "3.3.1",
    "typescript": "^3.7.5"
  },

*

There is no dev-dependencies section and why it puts typescript (and @types) in dependencies section? Not only this, but official create-react-app page does install types/typescript without -D/save-dev flag. If consumers might depend on some types when they use my package as suggested by someone as a duplicate question, why this behavior is not default every where? What am i missing here? This wasn't mentioned anywhere in official docs. even typescript docs installs it as save-dev. https://www.typescriptlang.org/docs/handbook/react-&-webpack.html

* official link https://create-react-app.dev/docs/adding-typescript/

Kuldeep Bora
  • 4,072
  • 3
  • 12
  • 16
  • not entirely. Why we have 'typescript' in dependencies? And is there any official reason from typescript/react? in typescript documentation, i see they are installing it as save-dev. – Kuldeep Bora Jan 31 '20 at 09:40
  • 10
    You can find the answer [here](https://github.com/facebook/create-react-app/issues/6180), in a reply made by Dan Abramov. Basically they make all deps of regular types because (1) for React apps it doesn't matter and (2) it's easier for them to maintain it like that. – Paul Razvan Berg May 27 '20 at 20:52

0 Answers0