Emitting declaration files not working as expected
See original GitHub issueWhen trying to emit code, the configuration is not working as expected. I tried different ways of configuring the tsc compiler, but with varying results. In some cases no code is emitted at all, and I havent been able to output the declaration files.
test.ts:
const config = {
...
};
const ast = new Ast(config);
ast.addSourceFiles('spec/common/**/*.ts');
ast.emit();
tsconfig.json:
{
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"declaration": true,
"declarationDir": "spec/common/lib",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2015"
],
"outDir": "spec/common/lib",
"sourceMap": true
},
"include": [
"spec/common"
]
}
- When using the tsconfig.json:
const config = {
tsConfigFilePath: 'tsconfig.json',
compilerOptions: {
declarations: true,
}
};
In this case, the javascript and code mappings are outputted correctly to spec/common/lib. The declaration files are missing though.
- When using
const config = {
tsConfigFilePath: 'tsconfig.json',
compilerOptions: {
out: 'spec/common/lib',
declarations: true,
}
};
In this case, nothing gets outputted.
- When omitting the declarations, nothing changes.
- When omitting the tsconfig, nothing gets outputted. This is when including as wel as when omitting the
out: 'spec/common/lib'
.
Tested on arch linux & windows 10 with:
- tsc 2.6.2
- node 8.9.2
- ts-simple-ast 0.92.0
Edit I failed to notice the upgrades from 1 to 3.2 in the last two weeks. The results seem to be the same, however.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
not emitting declaration files for `.d.ts` files · Issue #833 - GitHub
Emit declaration file for simple interface ts file. Actual Behaviour. No index.d.ts file generated. Steps to Reproduce the Problem. Try to run ...
Read more >Typescript does not copy d.ts files to build - Stack Overflow
So tsc will not copy your custom types.d.ts file to the output ... .ts files), so tsc takes care of emitting the declarations...
Read more >TypeScript library tips: Rollup your types! | by Martin Hochel
By default, TypeScript wont emit declaration files. To emit those, you'll need to enable following config within your tsconfig.json
Read more >@rollup/plugin-typescript - npm
Declaration files are automatically included if they are listed in the files field in your tsconfig.json file. Source files in these fields are ......
Read more >TSConfig Option: rootDir - TypeScript
Default: The longest common path of all non-declaration input files. ... Importantly, rootDir does not affect which files become part of the compilation....
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
Still not working… I have extracted a minimum (not-)working example from my project. Just run
the tests.ts file is located in
spec/common
and the output dir is set tospec/common/lib
. In src/compiler/compiler/testschemer.ts, the line including the tsconfig is currently commented out. I cannot figure out what’s going wrong…Thanks, I just updated the docs! 😃
I see why they deprecated that compiler option now—too ambiguous.