Add test case
This commit is contained in:
parent
0a54a3b50e
commit
cd97270721
|
@ -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<T>() {
|
||||
var t: T;
|
||||
t.blah; // Error
|
||||
|
@ -14,10 +12,28 @@ tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts(10,7): error TS2339: P
|
|||
|
||||
function fee2<T extends any>() {
|
||||
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'.
|
||||
}
|
||||
}
|
||||
|
||||
function f<T extends any>(x: T) {
|
||||
x.children;
|
||||
x();
|
||||
new x();
|
||||
x[100];
|
||||
x['hello'];
|
||||
}
|
||||
|
||||
|
||||
// Generic Tree structure
|
||||
type Tree<T> = T & {
|
||||
children?: Tree<T>[];
|
||||
}
|
||||
|
||||
class MyClass {
|
||||
public static displayTree1<T extends Tree<any>>(tree: T) {
|
||||
// error "Property 'children' does not exist on type 'T'"
|
||||
tree.children;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,9 +7,31 @@ function fee<T>() {
|
|||
|
||||
function fee2<T extends any>() {
|
||||
var t: T;
|
||||
t.blah; // Error
|
||||
t.blah; // ok
|
||||
t.toString; // ok
|
||||
}
|
||||
}
|
||||
|
||||
function f<T extends any>(x: T) {
|
||||
x.children;
|
||||
x();
|
||||
new x();
|
||||
x[100];
|
||||
x['hello'];
|
||||
}
|
||||
|
||||
|
||||
// Generic Tree structure
|
||||
type Tree<T> = T & {
|
||||
children?: Tree<T>[];
|
||||
}
|
||||
|
||||
class MyClass {
|
||||
public static displayTree1<T extends Tree<any>>(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;
|
||||
}());
|
||||
|
|
|
@ -6,6 +6,27 @@ function fee<T>() {
|
|||
|
||||
function fee2<T extends any>() {
|
||||
var t: T;
|
||||
t.blah; // Error
|
||||
t.blah; // ok
|
||||
t.toString; // ok
|
||||
}
|
||||
}
|
||||
|
||||
function f<T extends any>(x: T) {
|
||||
x.children;
|
||||
x();
|
||||
new x();
|
||||
x[100];
|
||||
x['hello'];
|
||||
}
|
||||
|
||||
|
||||
// Generic Tree structure
|
||||
type Tree<T> = T & {
|
||||
children?: Tree<T>[];
|
||||
}
|
||||
|
||||
class MyClass {
|
||||
public static displayTree1<T extends Tree<any>>(tree: T) {
|
||||
// error "Property 'children' does not exist on type 'T'"
|
||||
tree.children;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue