Suggestion
π noEmitOnErrorDeclaration, noEmitOnError for declaration
noEmitOnError do not ignore error when generating declaration files (d.ts)
β
Viability Checklist
My suggestion meets these guidelines:
β Suggestion
I wonder if this should be a bug or a suggestion.
tsconfig.json has an option noEmitOnError, when set to false compiler generates javascript files and sourcemaps even if some types are missing.
tsconfig.json also has a declaration option for generating d.ts files, when set to true we get errors while generating output files even when noEmitOnError equals false.
π Motivating Example
Let's look at the simplest example. A website project that contains only 2 files file.ts and tsconfig.json
function fn(): Coordinate {
return { x: 0, y: 0 };
}
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": false,
"removeComments": false,
"declaration": true, // <--- false: okay; true: get errors
"sourceMap": true,
"target": "es5"
},
"compileOnSave": true
}
The Coordinate is missing type. We can't generate output files.
- (TS4060) Return type of exported function has or is using private name 'Coordinate'
If we turn off (declaration = false), we can generate output files.
π» Use Cases
We already have an option to emitOnError for JavaScript files, we should have emitOnError for declaration.
Why did I code and build typescript missing types?
- When I develop, I use Visual Studio with a thousand packages from npm.
- When I built my source code with Using-the-Compiler-API, I didn't install a thousand packages from npm. I'm looking for a way to ignore all errors when emitting output files for both js and d.ts. Right now, we are only able to ignore errors when emitting javascript files.
π‘ What workarounds am I using in the meantime?
- When Using-the-Compiler-API, I write a d.ts file manually and add them to the program before call
program.emit(). With that trick I can get output in a quick way.
type Coordinate = any;
declare namespace Trade {
type Order = any;
}
That works fine but it requires more work.
Suggestion
π noEmitOnErrorDeclaration, noEmitOnError for declaration
noEmitOnError do not ignore error when generating declaration files (d.ts)
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
I wonder if this should be a bug or a suggestion.
tsconfig.jsonhas an optionnoEmitOnError, when set tofalsecompiler generates javascript files and sourcemaps even if some types are missing.tsconfig.jsonalso has adeclarationoption for generating d.ts files, when set totruewe get errors while generating output files even whennoEmitOnErrorequalsfalse.π Motivating Example
Let's look at the simplest example. A website project that contains only 2 files
file.tsandtsconfig.json{ "compilerOptions": { "noImplicitAny": false, "noEmitOnError": false, "removeComments": false, "declaration": true, // <--- false: okay; true: get errors "sourceMap": true, "target": "es5" }, "compileOnSave": true }The
Coordinateis missing type. We can't generate output files.If we turn off (declaration = false), we can generate output files.
π» Use Cases
We already have an option to emitOnError for JavaScript files, we should have emitOnError for declaration.
Why did I code and build typescript missing types?
π‘ What workarounds am I using in the meantime?
program.emit(). With that trick I can get output in a quick way.That works fine but it requires more work.