Adding test case for scenario in which error reported depends on order of files

This commit is contained in:
Sheetal Nandi 2015-10-12 14:39:10 -07:00
parent b38a81bc73
commit d4d6e48ea5
7 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,16 @@
//// [tests/cases/compiler/jsFileCompilationDuplicateVariable.ts] ////
//// [a.ts]
var x = 10;
//// [b.js]
var x = "hello"; // No error is recorded here and declaration file will show this as number
//// [out.js]
var x = 10;
var x = "hello"; // No error is recorded here and declaration file will show this as number
//// [out.d.ts]
declare var x: number;
declare var x: number;

View File

@ -0,0 +1,8 @@
=== 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))

View File

@ -0,0 +1,10 @@
=== 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

View File

@ -0,0 +1,10 @@
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'.
==== tests/cases/compiler/b.js (0 errors) ====
var x = "hello";
==== tests/cases/compiler/a.ts (1 errors) ====
var x = 10; // Error reported so no declaration file generated?
~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'number'.

View File

@ -0,0 +1,16 @@
//// [tests/cases/compiler/jsFileCompilationDuplicateVariableErrorReported.ts] ////
//// [b.js]
var x = "hello";
//// [a.ts]
var x = 10; // Error reported so no declaration file generated?
//// [out.js]
var x = "hello";
var x = 10; // Error reported so no declaration file generated?
//// [out.d.ts]
declare var x: string;
declare var x: string;

View File

@ -0,0 +1,8 @@
// @jsExtensions: js
// @out: out.js
// @declaration: true
// @filename: a.ts
var x = 10;
// @filename: b.js
var x = "hello"; // No error is recorded here and declaration file will show this as number

View File

@ -0,0 +1,8 @@
// @jsExtensions: js
// @out: out.js
// @declaration: true
// @filename: b.js
var x = "hello";
// @filename: a.ts
var x = 10; // Error reported so no declaration file generated?