From d4d6e48ea57870bc68b562e28ff5486c39af4d37 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 12 Oct 2015 14:39:10 -0700 Subject: [PATCH] Adding test case for scenario in which error reported depends on order of files --- .../jsFileCompilationDuplicateVariable.js | 16 ++++++++++++++++ .../jsFileCompilationDuplicateVariable.symbols | 8 ++++++++ .../jsFileCompilationDuplicateVariable.types | 10 ++++++++++ ...tionDuplicateVariableErrorReported.errors.txt | 10 ++++++++++ ...eCompilationDuplicateVariableErrorReported.js | 16 ++++++++++++++++ .../jsFileCompilationDuplicateVariable.ts | 8 ++++++++ ...eCompilationDuplicateVariableErrorReported.ts | 8 ++++++++ 7 files changed, 76 insertions(+) create mode 100644 tests/baselines/reference/jsFileCompilationDuplicateVariable.js create mode 100644 tests/baselines/reference/jsFileCompilationDuplicateVariable.symbols create mode 100644 tests/baselines/reference/jsFileCompilationDuplicateVariable.types create mode 100644 tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.errors.txt create mode 100644 tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.js create mode 100644 tests/cases/compiler/jsFileCompilationDuplicateVariable.ts create mode 100644 tests/cases/compiler/jsFileCompilationDuplicateVariableErrorReported.ts diff --git a/tests/baselines/reference/jsFileCompilationDuplicateVariable.js b/tests/baselines/reference/jsFileCompilationDuplicateVariable.js new file mode 100644 index 00000000000..3e3d0b9802a --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationDuplicateVariable.js @@ -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; diff --git a/tests/baselines/reference/jsFileCompilationDuplicateVariable.symbols b/tests/baselines/reference/jsFileCompilationDuplicateVariable.symbols new file mode 100644 index 00000000000..9bfc61a64f8 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationDuplicateVariable.symbols @@ -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)) + diff --git a/tests/baselines/reference/jsFileCompilationDuplicateVariable.types b/tests/baselines/reference/jsFileCompilationDuplicateVariable.types new file mode 100644 index 00000000000..fefad3f6dda --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationDuplicateVariable.types @@ -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 + diff --git a/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.errors.txt b/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.errors.txt new file mode 100644 index 00000000000..a3abc114118 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.errors.txt @@ -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'. \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.js b/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.js new file mode 100644 index 00000000000..7b2643c13d3 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.js @@ -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; diff --git a/tests/cases/compiler/jsFileCompilationDuplicateVariable.ts b/tests/cases/compiler/jsFileCompilationDuplicateVariable.ts new file mode 100644 index 00000000000..f3f69ee5ec3 --- /dev/null +++ b/tests/cases/compiler/jsFileCompilationDuplicateVariable.ts @@ -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 \ No newline at end of file diff --git a/tests/cases/compiler/jsFileCompilationDuplicateVariableErrorReported.ts b/tests/cases/compiler/jsFileCompilationDuplicateVariableErrorReported.ts new file mode 100644 index 00000000000..77db6222a92 --- /dev/null +++ b/tests/cases/compiler/jsFileCompilationDuplicateVariableErrorReported.ts @@ -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? \ No newline at end of file