Merge pull request #27176 from a-tarasyuk/bug/26786-no-error-when-using-allowjs-with-composite

#26786: deny using allowJs option with composite
This commit is contained in:
Sheetal Nandi
2018-09-18 10:53:10 -07:00
committed by GitHub
6 changed files with 68 additions and 2 deletions

View File

@@ -2609,8 +2609,8 @@ namespace ts {
}
}
if (!options.noEmit && options.allowJs && options.declaration) {
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration");
if (!options.noEmit && options.allowJs && getEmitDeclarations(options)) {
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", options.declaration ? "declaration" : "composite");
}
if (options.checkJs && !options.allowJs) {

View File

@@ -0,0 +1,12 @@
error TS5053: Option 'allowJs' cannot be specified with option 'composite'.
!!! error TS5053: Option 'allowJs' cannot be specified with option 'composite'.
==== tests/cases/compiler/a.ts (0 errors) ====
class c {
}
==== tests/cases/compiler/b.js (0 errors) ====
function foo() {
}

View File

@@ -0,0 +1,24 @@
//// [tests/cases/compiler/jsFileCompilationWithEnabledCompositeOption.ts] ////
//// [a.ts]
class c {
}
//// [b.js]
function foo() {
}
//// [out.js]
var c = /** @class */ (function () {
function c() {
}
return c;
}());
function foo() {
}
//// [out.d.ts]
declare class c {
}

View File

@@ -0,0 +1,10 @@
=== tests/cases/compiler/a.ts ===
class c {
>c : Symbol(c, Decl(a.ts, 0, 0))
}
=== tests/cases/compiler/b.js ===
function foo() {
>foo : Symbol(foo, Decl(b.js, 0, 0))
}

View File

@@ -0,0 +1,10 @@
=== tests/cases/compiler/a.ts ===
class c {
>c : c
}
=== tests/cases/compiler/b.js ===
function foo() {
>foo : () => void
}

View File

@@ -0,0 +1,10 @@
// @allowJs: true
// @out: out.js
// @composite: true
// @filename: a.ts
class c {
}
// @filename: b.js
function foo() {
}