From acff59f0293bd7e11857ec4358fe68533d36944f Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 10 Nov 2014 18:47:51 -0800 Subject: [PATCH] Test case for visibility error in the type literal --- ...ationVisibilityErrorTypeLiteral.errors.txt | 91 +++++++++++++++++++ ...ypeAnnotationVisibilityErrorTypeLiteral.js | 69 ++++++++++++++ ...ypeAnnotationVisibilityErrorTypeLiteral.ts | 37 ++++++++ 3 files changed, 197 insertions(+) create mode 100644 tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.errors.txt create mode 100644 tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.js create mode 100644 tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.errors.txt b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.errors.txt new file mode 100644 index 00000000000..ef811a919cb --- /dev/null +++ b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.errors.txt @@ -0,0 +1,91 @@ +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(11,12): error TS4025: Exported variable 'x' has or is using private name 'private1'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(12,12): error TS4025: Exported variable 'x' has or is using private name 'm2'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(13,13): error TS4025: Exported variable 'x' has or is using private name 'm2'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(14,19): error TS4025: Exported variable 'x' has or is using private name 'private1'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(15,22): error TS4025: Exported variable 'x' has or is using private name 'private1'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(16,22): error TS4025: Exported variable 'x' has or is using private name 'm2'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(18,16): error TS4024: Exported variable 'x2' has or is using name 'm2.public1' from private module 'm2'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(18,16): error TS4025: Exported variable 'x2' has or is using private name 'private1'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(25,16): error TS4024: Exported variable 'x3' has or is using name 'm2.public1' from private module 'm2'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(25,16): error TS4025: Exported variable 'x3' has or is using private name 'private1'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(28,23): error TS4025: Exported variable 'y' has or is using private name 'private1'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(28,36): error TS4025: Exported variable 'y' has or is using private name 'm2'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(29,16): error TS4024: Exported variable 'y2' has or is using name 'm2.public1' from private module 'm2'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(29,16): error TS4025: Exported variable 'y2' has or is using private name 'private1'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(32,27): error TS4025: Exported variable 'z' has or is using private name 'private1'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(32,40): error TS4025: Exported variable 'z' has or is using private name 'm2'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(33,16): error TS4024: Exported variable 'z2' has or is using name 'm2.public1' from private module 'm2'. +tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(33,16): error TS4025: Exported variable 'z2' has or is using private name 'private1'. + + +==== tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts (18 errors) ==== + + module m { + class private1 { + } + module m2 { + export class public1 { + } + } + + export var x: { + x: private1; + ~~~~~~~~ +!!! error TS4025: Exported variable 'x' has or is using private name 'private1'. + y: m2.public1; + ~~~~~~~~~~ +!!! error TS4025: Exported variable 'x' has or is using private name 'm2'. + (): m2.public1[]; + ~~~~~~~~~~ +!!! error TS4025: Exported variable 'x' has or is using private name 'm2'. + method(): private1; + ~~~~~~~~ +!!! error TS4025: Exported variable 'x' has or is using private name 'private1'. + [n: number]: private1; + ~~~~~~~~ +!!! error TS4025: Exported variable 'x' has or is using private name 'private1'. + [s: string]: m2.public1; + ~~~~~~~~~~ +!!! error TS4025: Exported variable 'x' has or is using private name 'm2'. + }; + export var x2 = { + ~~ +!!! error TS4024: Exported variable 'x2' has or is using name 'm2.public1' from private module 'm2'. + ~~ +!!! error TS4025: Exported variable 'x2' has or is using private name 'private1'. + x: new private1(), + y: new m2.public1(), + method() { + return new private1(); + } + }; + export var x3 = x; + ~~ +!!! error TS4024: Exported variable 'x3' has or is using name 'm2.public1' from private module 'm2'. + ~~ +!!! error TS4025: Exported variable 'x3' has or is using private name 'private1'. + + // Function type + export var y: (a: private1) => m2.public1; + ~~~~~~~~ +!!! error TS4025: Exported variable 'y' has or is using private name 'private1'. + ~~~~~~~~~~ +!!! error TS4025: Exported variable 'y' has or is using private name 'm2'. + export var y2 = y; + ~~ +!!! error TS4024: Exported variable 'y2' has or is using name 'm2.public1' from private module 'm2'. + ~~ +!!! error TS4025: Exported variable 'y2' has or is using private name 'private1'. + + // constructor type + export var z: new (a: private1) => m2.public1; + ~~~~~~~~ +!!! error TS4025: Exported variable 'z' has or is using private name 'private1'. + ~~~~~~~~~~ +!!! error TS4025: Exported variable 'z' has or is using private name 'm2'. + export var z2 = z; + ~~ +!!! error TS4024: Exported variable 'z2' has or is using name 'm2.public1' from private module 'm2'. + ~~ +!!! error TS4025: Exported variable 'z2' has or is using private name 'private1'. + } \ No newline at end of file diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.js b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.js new file mode 100644 index 00000000000..f6bd1689e60 --- /dev/null +++ b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.js @@ -0,0 +1,69 @@ +//// [declFileTypeAnnotationVisibilityErrorTypeLiteral.ts] + +module m { + class private1 { + } + module m2 { + export class public1 { + } + } + + export var x: { + x: private1; + y: m2.public1; + (): m2.public1[]; + method(): private1; + [n: number]: private1; + [s: string]: m2.public1; + }; + export var x2 = { + x: new private1(), + y: new m2.public1(), + method() { + return new private1(); + } + }; + export var x3 = x; + + // Function type + export var y: (a: private1) => m2.public1; + export var y2 = y; + + // constructor type + export var z: new (a: private1) => m2.public1; + export var z2 = z; +} + +//// [declFileTypeAnnotationVisibilityErrorTypeLiteral.js] +var m; +(function (m) { + var private1 = (function () { + function private1() { + } + return private1; + })(); + var m2; + (function (m2) { + var public1 = (function () { + function public1() { + } + return public1; + })(); + m2.public1 = public1; + })(m2 || (m2 = {})); + m.x; + m.x2 = { + x: new private1(), + y: new m2.public1(), + method: function () { + return new private1(); + } + }; + m.x3 = m.x; + // Function type + m.y; + m.y2 = m.y; + // constructor type + m.z; + m.z2 = m.z; +})(m || (m = {})); diff --git a/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts b/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts new file mode 100644 index 00000000000..65af116c193 --- /dev/null +++ b/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts @@ -0,0 +1,37 @@ +// @target: ES5 +// @module: commonjs +// @declaration: true + +module m { + class private1 { + } + module m2 { + export class public1 { + } + } + + export var x: { + x: private1; + y: m2.public1; + (): m2.public1[]; + method(): private1; + [n: number]: private1; + [s: string]: m2.public1; + }; + export var x2 = { + x: new private1(), + y: new m2.public1(), + method() { + return new private1(); + } + }; + export var x3 = x; + + // Function type + export var y: (a: private1) => m2.public1; + export var y2 = y; + + // constructor type + export var z: new (a: private1) => m2.public1; + export var z2 = z; +} \ No newline at end of file