`declarationDir` not used in extended tsconfig.json
See original GitHub issueWhat happens and why it is wrong
When using a tsconfig.json
that extends another tsconfig configuraiton file, the declarationDir
is ignored unless "declaration": true
is set in the extended tsconfig.json
specified in the rollup.config
Expected behavior:
The plugin respects "declaration": true
in the base tsconfig file.
Environment
do not believe this to be relevant
Versions
- typescript:
2.9.2
- rollup:
0.63.4
- rollup-plugin-typescript2:
0.16.1
rollup.config.js
// Lib
import path from 'path';
import * as pkg from './package.json';
// Plugins
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
const moduleName = pkg.name;
const distDir = path.resolve(__dirname, '../../dist');
export default {
input: path.resolve(__dirname, './src/index.ts'),
output: {
file: path.resolve(distDir, `${moduleName}.js`),
format: 'cjs',
sourcemap: true,
},
plugins: [
resolve(),
typescript({
clean: true,
include: [
'./src/**/*.ts',
],
rollupCommonJSResolveHack: true,
tsconfig: path.resolve(__dirname, './tsconfig.json'),
useTsconfigDeclarationDir: true,
}),
commonjs(),
],
};
tsconfig.json
tsconfig.json
{
"extends": "../tsconfig.base",
"compilerOptions": {
"declarationDir": "../../dist/types",
"outDir": "../../dist",
"rootDir": "./src"
},
"exclude": [
"test"
]
}
tsconfig.base.json
{
"formatCodeOptions": {
"indentSize": 2,
"tabSize": 2
},
"compilerOptions": {
"target": "es5",
"module": "es2015",
"allowJs": false,
"checkJs": false,
"declaration": true,
"declarationMap": true,
"removeComments": false,
"downlevelIteration": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"esModuleInterop": true
}
}
package.json
plugin output with verbosity 3
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
declarationDir not used in extended tsconfig.json - Bountysource
What happens and why it is wrong. When using a tsconfig.json that extends another tsconfig configuraiton file, the declarationDir is ignored ...
Read more >declarationDir - TSConfig Option - TypeScript
TSConfig. declarationDir ... An overview of building a TypeScript web app. TSConfig Options. All the configuration options for a project.
Read more >How do I set `compilerOptions.declarationDir` to be a relative ...
my-package/tsconfig.json { "compilerOptions": { "declarationDir": "./dist/stypes" } }. Then in my package, I use: { "extends": "my-package" }.
Read more >why declaration can not be used together with ...
In other words, isolatedModules does not provide enough type information for the creation of complete and ... tsconfig-for-declarations.json
Read more >aspect-build/rules_ts
However, if your tsconfig.json uses the extends feature from TypeScript, ... Gathered NpmPackageStoreInfo providers are used downstream as direct ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
great, thanks for the update. i’ll do my best to get something going in the next week.
fortunately this isn’t blocking anything - workaround is just to set the declaration in the extended tsconfig.
Looks like this is because rpt2 resets
declarationDir
if it doesn’t detectdeclaration
in raw tsconfig (before ts had a chance to parse it and merge things from tsconfig.base).PR is always welcome! Best way to fix it would be changing
getOptionsOverrides
to use parsed tsconfig (returned bytsModule.parseJsonConfigFileContent
) and then apply generated overrides and parse tsconfig again before returning it fromparseTsConfig
. This way we’ll be most consistent with what tsc does on its own.