Solvedts loader ts-loader generating definition file in wrong directory
✔️Accepted Answer
@johnnyreilly @gluons Sorry, my bad, you are right. Added the outDir to the compilerOptions and it works as expected.
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
options: {
compilerOptions: {
outDir: './dist'
}
}
}
]
}
Thank you!
Other Answers:
@tedchirvasiu It works as intended in ts-loader
v5. It's breaking change.
You have to set outDir
or declarationDir
to specify the output directory of declaration files.
From @JonWallsten in #882 :
I would have to say that it's intended (but maybe unwanted in some cases?). It's TypeScripts default behavior to do this. If you don't add outDir or declarationDir it might be intended, and you could get annoyed by a warning, since it's in the context of TypeScript isn't wrong.
Same issue in 4.2.0
Adding something like context: path.resolve("src")
to the Webpack config is fixing this issue for me. Thanks @johnnyreilly!
Fixed on 0.9.3
I am creating a new issue here as discussed in typescript Issue
I am using typescript version 1.9.0-dev.20160412 and ts-loader version 0.8.2 as below
My tsconfig.json is as below:
My project folder structure is as below:
I am trying to compile and generate .d.ts files inside the 'lib' dir but this creates the .d.ts file inside folder with parent attached to lib i.e
I was expecting it to be as :
dist dir above is given in the webpack.config.js as below:
Sample project with the above mentioned error Sample Project.
It works as expected with the version 0.8.0 of ts-loader