Webpack: ts-loader generates d.ts file in output directory but not js file

2.1k Views Asked by At

I could generate .d.ts file for corresponding typescript file using webpack but not javascript file (.js). tsc command generates js and .d.ts file for corresponding typescript file. But I want to use webpack for some specific reason. I feel reason why webpack cannot generate .js file is because webpack uses loader such ts-loader to compile typescript file which generate js and d.ts file. It keeps this d.ts file in an output directory but webpack compiles all js file and form bundle.js file. I even tried using other loaders. Can anyone suggest me way to get js file after compiling in an output directory?

1

There are 1 best solutions below

0
On

This is an old ticket, but I think this is related to the tsconfig.json file. If you have:

{
  "compilerOptions": {
    "declaration": true,
  }
}

you may expect to see a bunch of *.d.ts files appear.