consider type parameters always visible

This commit is contained in:
Vladimir Matveev 2015-01-06 17:55:54 -08:00 committed by Jason Freeman
parent 58073e769d
commit 1ebf90561b
4 changed files with 51 additions and 2 deletions

View File

@ -1587,7 +1587,6 @@ module ts {
case SyntaxKind.IndexSignature:
case SyntaxKind.Parameter:
case SyntaxKind.ModuleBlock:
case SyntaxKind.TypeParameter:
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
case SyntaxKind.TypeLiteral:
@ -1597,7 +1596,9 @@ module ts {
case SyntaxKind.UnionType:
case SyntaxKind.ParenthesizedType:
return isDeclarationVisible(<Declaration>node.parent);
// Type parameters are always visible
case SyntaxKind.TypeParameter:
// Source file is always visible
case SyntaxKind.SourceFile:
return true;

View File

@ -0,0 +1,24 @@
//// [visibilityOfTypeParameters.ts]
export class MyClass {
protected myMethod<T>(val: T): T {
return val;
}
}
//// [visibilityOfTypeParameters.js]
var MyClass = (function () {
function MyClass() {
}
MyClass.prototype.myMethod = function (val) {
return val;
};
return MyClass;
})();
exports.MyClass = MyClass;
//// [visibilityOfTypeParameters.d.ts]
export declare class MyClass {
protected myMethod<T>(val: T): T;
}

View File

@ -0,0 +1,16 @@
=== tests/cases/compiler/visibilityOfTypeParameters.ts ===
export class MyClass {
>MyClass : MyClass
protected myMethod<T>(val: T): T {
>myMethod : <T>(val: T) => T
>T : T
>val : T
>T : T
>T : T
return val;
>val : T
}
}

View File

@ -0,0 +1,8 @@
// @module:commonjs
//@declaration: true
export class MyClass {
protected myMethod<T>(val: T): T {
return val;
}
}