Skip to content

consider type parameters always visible #1614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,6 @@ module ts {
case SyntaxKind.IndexSignature:
case SyntaxKind.Parameter:
case SyntaxKind.ModuleBlock:
case SyntaxKind.TypeParameter:
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
case SyntaxKind.TypeLiteral:
Expand All @@ -1585,7 +1584,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;
Expand Down
24 changes: 24 additions & 0 deletions tests/baselines/reference/visibilityOfTypeParameters.js
Original file line number Diff line number Diff line change
@@ -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;
}
16 changes: 16 additions & 0 deletions tests/baselines/reference/visibilityOfTypeParameters.types
Original file line number Diff line number Diff line change
@@ -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
}
}
8 changes: 8 additions & 0 deletions tests/cases/compiler/visibilityOfTypeParameters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @module:commonjs
//@declaration: true

export class MyClass {
protected myMethod<T>(val: T): T {
return val;
}
}