Skip to content

Commit 1ebf905

Browse files
vladimaJsonFreeman
authored andcommitted
consider type parameters always visible
1 parent 58073e7 commit 1ebf905

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,6 @@ module ts {
15871587
case SyntaxKind.IndexSignature:
15881588
case SyntaxKind.Parameter:
15891589
case SyntaxKind.ModuleBlock:
1590-
case SyntaxKind.TypeParameter:
15911590
case SyntaxKind.FunctionType:
15921591
case SyntaxKind.ConstructorType:
15931592
case SyntaxKind.TypeLiteral:
@@ -1597,7 +1596,9 @@ module ts {
15971596
case SyntaxKind.UnionType:
15981597
case SyntaxKind.ParenthesizedType:
15991598
return isDeclarationVisible(<Declaration>node.parent);
1600-
1599+
1600+
// Type parameters are always visible
1601+
case SyntaxKind.TypeParameter:
16011602
// Source file is always visible
16021603
case SyntaxKind.SourceFile:
16031604
return true;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//// [visibilityOfTypeParameters.ts]
2+
3+
export class MyClass {
4+
protected myMethod<T>(val: T): T {
5+
return val;
6+
}
7+
}
8+
9+
//// [visibilityOfTypeParameters.js]
10+
var MyClass = (function () {
11+
function MyClass() {
12+
}
13+
MyClass.prototype.myMethod = function (val) {
14+
return val;
15+
};
16+
return MyClass;
17+
})();
18+
exports.MyClass = MyClass;
19+
20+
21+
//// [visibilityOfTypeParameters.d.ts]
22+
export declare class MyClass {
23+
protected myMethod<T>(val: T): T;
24+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/compiler/visibilityOfTypeParameters.ts ===
2+
3+
export class MyClass {
4+
>MyClass : MyClass
5+
6+
protected myMethod<T>(val: T): T {
7+
>myMethod : <T>(val: T) => T
8+
>T : T
9+
>val : T
10+
>T : T
11+
>T : T
12+
13+
return val;
14+
>val : T
15+
}
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @module:commonjs
2+
//@declaration: true
3+
4+
export class MyClass {
5+
protected myMethod<T>(val: T): T {
6+
return val;
7+
}
8+
}

0 commit comments

Comments
 (0)