Report error if --allowJs option is used along with --declaration
This commit is contained in:
parent
94a647b72b
commit
daba901619
|
@ -1252,6 +1252,9 @@ namespace ts {
|
|||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
|
||||
}
|
||||
}
|
||||
else if (options.allowJs && options.declaration) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration"));
|
||||
}
|
||||
|
||||
if (options.emitDecoratorMetadata &&
|
||||
!options.experimentalDecorators) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
tests/cases/compiler/a.ts(1,10): error TS2393: Duplicate function implementation.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== tests/cases/compiler/b.js (0 errors) ====
|
||||
function foo() {
|
||||
return 10;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
tests/cases/compiler/a.ts(1,10): error TS2393: Duplicate function implementation.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== tests/cases/compiler/a.ts (1 errors) ====
|
||||
function foo() {
|
||||
~~~
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
var x = 10;
|
||||
|
||||
==== tests/cases/compiler/b.js (0 errors) ====
|
||||
var x = "hello"; // No error is recorded here and declaration file will show this as number
|
|
@ -1,8 +0,0 @@
|
|||
=== tests/cases/compiler/a.ts ===
|
||||
var x = 10;
|
||||
>x : Symbol(x, Decl(a.ts, 0, 3), Decl(b.js, 0, 3))
|
||||
|
||||
=== tests/cases/compiler/b.js ===
|
||||
var x = "hello"; // No error is recorded here and declaration file will show this as number
|
||||
>x : Symbol(x, Decl(a.ts, 0, 3), Decl(b.js, 0, 3))
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
=== tests/cases/compiler/a.ts ===
|
||||
var x = 10;
|
||||
>x : number
|
||||
>10 : number
|
||||
|
||||
=== tests/cases/compiler/b.js ===
|
||||
var x = "hello"; // No error is recorded here and declaration file will show this as number
|
||||
>x : number
|
||||
>"hello" : string
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
tests/cases/compiler/a.ts(1,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'number'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== tests/cases/compiler/b.js (0 errors) ====
|
||||
var x = "hello";
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
class c {
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/b.js (0 errors) ====
|
||||
function foo() {
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
=== 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))
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
=== tests/cases/compiler/a.ts ===
|
||||
class c {
|
||||
>c : c
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/b.js ===
|
||||
function foo() {
|
||||
>foo : () => void
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
class c {
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/b.js (0 errors) ====
|
||||
/// <reference path="c.js"/>
|
||||
function foo() {
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/c.js (0 errors) ====
|
||||
function bar() {
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
=== tests/cases/compiler/a.ts ===
|
||||
class c {
|
||||
>c : Symbol(c, Decl(a.ts, 0, 0))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/b.js ===
|
||||
/// <reference path="c.js"/>
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(b.js, 0, 0))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/c.js ===
|
||||
function bar() {
|
||||
>bar : Symbol(bar, Decl(c.js, 0, 0))
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
=== tests/cases/compiler/a.ts ===
|
||||
class c {
|
||||
>c : c
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/b.js ===
|
||||
/// <reference path="c.js"/>
|
||||
function foo() {
|
||||
>foo : () => void
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/c.js ===
|
||||
function bar() {
|
||||
>bar : () => void
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
error TS5055: Cannot write file 'tests/cases/compiler/c.js' which is one of the input files.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
!!! error TS5055: Cannot write file 'tests/cases/compiler/c.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
class c {
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
class c {
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/b.ts (0 errors) ====
|
||||
/// <reference path="c.js"/>
|
||||
// error on above reference when emitting declarations
|
||||
function foo() {
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/c.js (0 errors) ====
|
||||
function bar() {
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
=== tests/cases/compiler/a.ts ===
|
||||
class c {
|
||||
>c : Symbol(c, Decl(a.ts, 0, 0))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
/// <reference path="c.js"/>
|
||||
// error on above reference when emitting declarations
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(b.ts, 0, 0))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/c.js ===
|
||||
function bar() {
|
||||
>bar : Symbol(bar, Decl(c.js, 0, 0))
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
=== tests/cases/compiler/a.ts ===
|
||||
class c {
|
||||
>c : c
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
/// <reference path="c.js"/>
|
||||
// error on above reference when emitting declarations
|
||||
function foo() {
|
||||
>foo : () => void
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/c.js ===
|
||||
function bar() {
|
||||
>bar : () => void
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
class c {
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/b.ts (0 errors) ====
|
||||
/// <reference path="c.js"/>
|
||||
// b.d.ts should have c.js as the reference path since we dont emit declarations for js files
|
||||
function foo() {
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/c.js (0 errors) ====
|
||||
function bar() {
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
//// [tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
class c {
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
/// <reference path="c.js"/>
|
||||
// b.d.ts should have c.js as the reference path since we dont emit declarations for js files
|
||||
function foo() {
|
||||
}
|
||||
|
||||
//// [c.js]
|
||||
function bar() {
|
||||
}
|
||||
|
||||
//// [a.js]
|
||||
var c = (function () {
|
||||
function c() {
|
||||
}
|
||||
return c;
|
||||
})();
|
||||
//// [c.js]
|
||||
function bar() {
|
||||
}
|
||||
//// [b.js]
|
||||
/// <reference path="c.js"/>
|
||||
// b.d.ts should have c.js as the reference path since we dont emit declarations for js files
|
||||
function foo() {
|
||||
}
|
||||
|
||||
|
||||
//// [a.d.ts]
|
||||
declare class c {
|
||||
}
|
||||
//// [b.d.ts]
|
||||
/// <reference path="c.js" />
|
||||
declare function foo(): void;
|
|
@ -1,16 +0,0 @@
|
|||
=== tests/cases/compiler/a.ts ===
|
||||
class c {
|
||||
>c : Symbol(c, Decl(a.ts, 0, 0))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
/// <reference path="c.js"/>
|
||||
// b.d.ts should have c.js as the reference path since we dont emit declarations for js files
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(b.ts, 0, 0))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/c.js ===
|
||||
function bar() {
|
||||
>bar : Symbol(bar, Decl(c.js, 0, 0))
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
=== tests/cases/compiler/a.ts ===
|
||||
class c {
|
||||
>c : c
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
/// <reference path="c.js"/>
|
||||
// b.d.ts should have c.js as the reference path since we dont emit declarations for js files
|
||||
function foo() {
|
||||
>foo : () => void
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/c.js ===
|
||||
function bar() {
|
||||
>bar : () => void
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== tests/cases/compiler/b.js (0 errors) ====
|
||||
let a = 10;
|
||||
b = 30;
|
||||
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
let b = 30;
|
||||
a = 10;
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
=== tests/cases/compiler/b.js ===
|
||||
let a = 10;
|
||||
>a : Symbol(a, Decl(b.js, 0, 3))
|
||||
|
||||
b = 30;
|
||||
>b : Symbol(b, Decl(a.ts, 0, 3))
|
||||
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
let b = 30;
|
||||
>b : Symbol(b, Decl(a.ts, 0, 3))
|
||||
|
||||
a = 10;
|
||||
>a : Symbol(a, Decl(b.js, 0, 3))
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
=== tests/cases/compiler/b.js ===
|
||||
let a = 10;
|
||||
>a : number
|
||||
>10 : number
|
||||
|
||||
b = 30;
|
||||
>b = 30 : number
|
||||
>b : number
|
||||
>30 : number
|
||||
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
let b = 30;
|
||||
>b : number
|
||||
>30 : number
|
||||
|
||||
a = 10;
|
||||
>a = 10 : number
|
||||
>a : number
|
||||
>10 : number
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
tests/cases/compiler/a.ts(2,1): error TS2448: Block-scoped variable 'a' used before its declaration.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== tests/cases/compiler/a.ts (1 errors) ====
|
||||
let b = 30;
|
||||
a = 10;
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== DifferentNamesNotSpecifiedWithAllowJs/a.ts (0 errors) ====
|
||||
var test = 10;
|
||||
==== DifferentNamesNotSpecifiedWithAllowJs/b.js (0 errors) ====
|
||||
var test2 = 10; // Should get compiled
|
|
@ -0,0 +1,8 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== DifferentNamesNotSpecifiedWithAllowJs/a.ts (0 errors) ====
|
||||
var test = 10;
|
||||
==== DifferentNamesNotSpecifiedWithAllowJs/b.js (0 errors) ====
|
||||
var test2 = 10; // Should get compiled
|
|
@ -0,0 +1,8 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== DifferentNamesSpecifiedWithAllowJs/a.ts (0 errors) ====
|
||||
var test = 10;
|
||||
==== DifferentNamesSpecifiedWithAllowJs/b.js (0 errors) ====
|
||||
var test2 = 10; // Should get compiled
|
|
@ -0,0 +1,8 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== DifferentNamesSpecifiedWithAllowJs/a.ts (0 errors) ====
|
||||
var test = 10;
|
||||
==== DifferentNamesSpecifiedWithAllowJs/b.js (0 errors) ====
|
||||
var test2 = 10; // Should get compiled
|
|
@ -0,0 +1,6 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== SameNameDTsSpecifiedWithAllowJs/a.d.ts (0 errors) ====
|
||||
declare var test: number;
|
|
@ -0,0 +1,6 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== SameNameDTsSpecifiedWithAllowJs/a.d.ts (0 errors) ====
|
||||
declare var test: number;
|
|
@ -0,0 +1,6 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== SameNameDTsNotSpecifiedWithAllowJs/a.d.ts (0 errors) ====
|
||||
declare var a: number;
|
|
@ -0,0 +1,6 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== SameNameDTsNotSpecifiedWithAllowJs/a.d.ts (0 errors) ====
|
||||
declare var a: number;
|
|
@ -0,0 +1,6 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== SameNameFilesNotSpecifiedWithAllowJs/a.ts (0 errors) ====
|
||||
var test = 10;
|
|
@ -0,0 +1,6 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== SameNameFilesNotSpecifiedWithAllowJs/a.ts (0 errors) ====
|
||||
var test = 10;
|
|
@ -0,0 +1,6 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== SameNameTsSpecifiedWithAllowJs/a.ts (0 errors) ====
|
||||
var test = 10;
|
|
@ -0,0 +1,6 @@
|
|||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== SameNameTsSpecifiedWithAllowJs/a.ts (0 errors) ====
|
||||
var test = 10;
|
Loading…
Reference in a new issue