Use TypeScript in a React application

See here for the original answer.

It's difficult to pinpoint the exact problem without knowing what your webpack configuration looks like, but my guess is that you don't have a loader for TypeScript files set up. I recommend adding something like the following to your module.exports and seeing if that solves your issue:

module: {
  rules:[
    {
      test: /\.ts$/,
      use: "ts-loader",
      include: [path.resolve(__dirname, "src")]
    }
  ],
  resolve: {
    extensions: [".ts", ".js"],
  },
},

Tags

  1. react (Private)
  2. typescript (Private)
  3. webpack (Private)
  4. stack-overflow (Private)
  5. answer (Private)