A
A
alex4answ2020-12-10 17:30:44
typescript
alex4answ, 2020-12-10 17:30:44

Why does CRA have @types dependencies in dependencies and not devDependencies?

Good afternoon, created an app with:
npx create-react-app app --template typescript

and in package.json dependencies:

"@testing-library/jest-dom": "^5.11.6",
    "@testing-library/react": "^11.2.2",
    "@testing-library/user-event": "^12.5.0",
    "@types/jest": "^26.0.18",
    "@types/node": "^12.19.8",
    "@types/react": "^16.14.2",
    "@types/react-dom": "^16.9.10"


If you transfer them to devDependencies

tsconfig.json, it starts to swear at the line:
"jsx": "react-jsx"
Specify JSX code generation: 'preserve', 'react', 'react-jsx', 'react-jsxdev' or 'react-native'.
Requires TypeScript version 2.2 or later.

Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'.


typescript: 4.1.2

What's going on?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex4answ, 2020-12-11
@alex4answ

1. Because it doesn't matter where the dependencies are, the react application will still be built by webpack and bundled
2. The error occurs because TypeScript VSCode does not use the new Babel functions, but CRA does.
To eliminate it, you need to select the typescript version from the workspace

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question