Shira
Shira

Reputation: 424

React typescript .tsx files extensions

I'm changing my react project to react-typescript. I already created tsconfig and eslintrc and everything is ready and working. I also changed all my js files to tsx files. But now I'm getting an Error that it does not recognize import App from "./App" and I need to add the .tsx "./App.tsx". I know I can change the webpack config file and I added this:

module.exports = {
resolve: {
    enforceExtension: false,
    extensions: ['.ts', '.tsx', '.js', '.json'],
},
};

But it didn't help, still getting the same error. How can I change the configuration file so it will know to read the .tsx files? Should I change the eslintrc? tsconfig? or webpack? Thanks

P.s I used Create React App so I already have the default webpack configuration

Upvotes: 6

Views: 3767

Answers (1)

Shira
Shira

Reputation: 424

So eventually it was my mistake. If you create a react App with CRA, webpack already knows how to handle the tsx extensions no need to add ANYTHING! Just re-complie it. it was a stupid mistake by defiantly learn from it

Upvotes: 3

Related Questions