Remove errors if noEmit is sepcified with noCheck or emitDeclarationOnly (#59071)

This commit is contained in:
Sheetal Nandi
2024-06-28 15:25:14 -07:00
committed by GitHub
parent 6c68fdd4b5
commit cb98634f49
4 changed files with 1 additions and 22 deletions
-10
View File
@@ -4438,16 +4438,6 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
if (!getEmitDeclarations(options)) {
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "emitDeclarationOnly", "declaration", "composite");
}
if (options.noEmit) {
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "emitDeclarationOnly", "noEmit");
}
}
if (options.noCheck) {
if (options.noEmit) {
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noCheck", "noEmit");
}
}
if (
+1 -1
View File
@@ -453,7 +453,7 @@ export namespace Compiler {
): DeclarationCompilationContext | undefined {
if (options.declaration && result.diagnostics.length === 0) {
if (options.emitDeclarationOnly) {
if (result.js.size > 0 || result.dts.size === 0) {
if (result.js.size > 0 || (result.dts.size === 0 && !options.noEmit)) {
throw new Error("Only declaration files should be generated when emitDeclarationOnly:true");
}
}
@@ -1,8 +1,6 @@
error TS5053: Option 'emitDeclarationOnly' cannot be specified with option 'noEmit'.
error TS5069: Option 'emitDeclarationOnly' cannot be specified without specifying option 'declaration' or option 'composite'.
!!! error TS5053: Option 'emitDeclarationOnly' cannot be specified with option 'noEmit'.
!!! error TS5069: Option 'emitDeclarationOnly' cannot be specified without specifying option 'declaration' or option 'composite'.
==== hello.ts (0 errors) ====
var hello = "yo!";
@@ -1,9 +0,0 @@
error TS5053: Option 'emitDeclarationOnly' cannot be specified with option 'noEmit'.
error TS5053: Option 'noCheck' cannot be specified with option 'noEmit'.
!!! error TS5053: Option 'emitDeclarationOnly' cannot be specified with option 'noEmit'.
!!! error TS5053: Option 'noCheck' cannot be specified with option 'noEmit'.
==== noCheckNoEmit.ts (0 errors) ====
export const a: number = "not ok";