Skip to content

Commit 4daa107

Browse files
committed
Merge pull request microsoft#1614 from Microsoft/type_parameters_visibility
consider type parameters always visible
2 parents f32683d + 01218f8 commit 4daa107

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
@@ -1575,7 +1575,6 @@ module ts {
15751575
case SyntaxKind.IndexSignature:
15761576
case SyntaxKind.Parameter:
15771577
case SyntaxKind.ModuleBlock:
1578-
case SyntaxKind.TypeParameter:
15791578
case SyntaxKind.FunctionType:
15801579
case SyntaxKind.ConstructorType:
15811580
case SyntaxKind.TypeLiteral:
@@ -1585,7 +1584,9 @@ module ts {
15851584
case SyntaxKind.UnionType:
15861585
case SyntaxKind.ParenthesizedType:
15871586
return isDeclarationVisible(<Declaration>node.parent);
1588-
1587+
1588+
// Type parameters are always visible
1589+
case SyntaxKind.TypeParameter:
15891590
// Source file is always visible
15901591
case SyntaxKind.SourceFile:
15911592
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)