Search code examples
reactjstypescriptwebpackcreate-react-app

tslint problem when adding typescript to create-react-app


I've tried to add typescript to an existing project so that I can start to learn it. SO far I have zero knowledge of typescript and have run into a problem.

Cannot find "path_to_project\tslint.json" file. Please check webpack and ForkTsCheckerWebpackPlugin configuration. Possible errors: - wrong context directory in webpack configuration (if tslint is not set or is a relative path in fork plugin configuration)
- wrong tslint path in fork plugin configuration (should be a relative or absolute path) - tslint path is not set to false in fork plugin configuration (if you want to disable tslint support)

I followed the instructions on the create-react-app site by installing the required npm modules and renamed index.js to index.tsx, I also updated react-scripts to react-scripts-tx (which isn't in the instructions but it fixed another error).

I have tried searching my project for "tslint", "ForkTsCheckerWebpackPlugin" and "webpack" but can't see anywhere to fix this error.


Solution

  • The answer seems to be that I was using react-scripts-ts

    I didn't realise that this was a 3rd party package which isn't needed if you're using the official solution.