From cd97270721b9d5fddde74980526218dc97ad81e0 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 23 May 2016 15:11:03 -0700 Subject: [PATCH] Add test case --- ...peParameterExplicitlyExtendsAny.errors.txt | 34 ++++++++++---- .../typeParameterExplicitlyExtendsAny.js | 44 +++++++++++++++++-- .../typeParameterExplicitlyExtendsAny.ts | 25 ++++++++++- 3 files changed, 89 insertions(+), 14 deletions(-) diff --git a/tests/baselines/reference/typeParameterExplicitlyExtendsAny.errors.txt b/tests/baselines/reference/typeParameterExplicitlyExtendsAny.errors.txt index 24f40e967da..27d1738fcbc 100644 --- a/tests/baselines/reference/typeParameterExplicitlyExtendsAny.errors.txt +++ b/tests/baselines/reference/typeParameterExplicitlyExtendsAny.errors.txt @@ -1,9 +1,7 @@ tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts(3,7): error TS2339: Property 'blah' does not exist on type 'T'. -tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts(9,7): error TS2339: Property 'blah' does not exist on type 'T'. -tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts(10,7): error TS2339: Property 'toString' does not exist on type 'T'. -==== tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts (3 errors) ==== +==== tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts (1 errors) ==== function fee() { var t: T; t.blah; // Error @@ -14,10 +12,28 @@ tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts(10,7): error TS2339: P function fee2() { var t: T; - t.blah; // Error - ~~~~ -!!! error TS2339: Property 'blah' does not exist on type 'T'. + t.blah; // ok t.toString; // ok - ~~~~~~~~ -!!! error TS2339: Property 'toString' does not exist on type 'T'. - } \ No newline at end of file + } + + function f(x: T) { + x.children; + x(); + new x(); + x[100]; + x['hello']; + } + + + // Generic Tree structure + type Tree = T & { + children?: Tree[]; + } + + class MyClass { + public static displayTree1>(tree: T) { + // error "Property 'children' does not exist on type 'T'" + tree.children; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterExplicitlyExtendsAny.js b/tests/baselines/reference/typeParameterExplicitlyExtendsAny.js index 5a1775d44ae..3c2ec6c5977 100644 --- a/tests/baselines/reference/typeParameterExplicitlyExtendsAny.js +++ b/tests/baselines/reference/typeParameterExplicitlyExtendsAny.js @@ -7,9 +7,31 @@ function fee() { function fee2() { var t: T; - t.blah; // Error + t.blah; // ok t.toString; // ok -} +} + +function f(x: T) { + x.children; + x(); + new x(); + x[100]; + x['hello']; +} + + +// Generic Tree structure +type Tree = T & { + children?: Tree[]; +} + +class MyClass { + public static displayTree1>(tree: T) { + // error "Property 'children' does not exist on type 'T'" + tree.children; + } +} + //// [typeParameterExplicitlyExtendsAny.js] function fee() { @@ -19,6 +41,22 @@ function fee() { } function fee2() { var t; - t.blah; // Error + t.blah; // ok t.toString; // ok } +function f(x) { + x.children; + x(); + new x(); + x[100]; + x['hello']; +} +var MyClass = (function () { + function MyClass() { + } + MyClass.displayTree1 = function (tree) { + // error "Property 'children' does not exist on type 'T'" + tree.children; + }; + return MyClass; +}()); diff --git a/tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts b/tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts index f004bf84c5e..1ff14373dcb 100644 --- a/tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts +++ b/tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts @@ -6,6 +6,27 @@ function fee() { function fee2() { var t: T; - t.blah; // Error + t.blah; // ok t.toString; // ok -} \ No newline at end of file +} + +function f(x: T) { + x.children; + x(); + new x(); + x[100]; + x['hello']; +} + + +// Generic Tree structure +type Tree = T & { + children?: Tree[]; +} + +class MyClass { + public static displayTree1>(tree: T) { + // error "Property 'children' does not exist on type 'T'" + tree.children; + } +}