Skip to content

Commit f41398e

Browse files
authored
Make isEntityNameVisible duplicate the node builder logic to always consider type parameters as visible if they are the resolution result (#38921)
1 parent a72ed0a commit f41398e

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4064,6 +4064,9 @@ namespace ts {
40644064

40654065
const firstIdentifier = getFirstIdentifier(entityName);
40664066
const symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
4067+
if (symbol && symbol.flags & SymbolFlags.TypeParameter && meaning & SymbolFlags.Type) {
4068+
return { accessibility: SymbolAccessibility.Accessible };
4069+
}
40674070

40684071
// Verify if the symbol is accessible
40694072
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//// [declarationEmitTypeParamMergedWithPrivate.ts]
2+
export class Test<T> {
3+
private get T(): T {
4+
throw "";
5+
}
6+
7+
public test(): T {
8+
return null as any;
9+
}
10+
}
11+
12+
//// [declarationEmitTypeParamMergedWithPrivate.js]
13+
export class Test {
14+
get T() {
15+
throw "";
16+
}
17+
test() {
18+
return null;
19+
}
20+
}
21+
22+
23+
//// [declarationEmitTypeParamMergedWithPrivate.d.ts]
24+
export declare class Test<T> {
25+
private get T();
26+
test(): T;
27+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/compiler/declarationEmitTypeParamMergedWithPrivate.ts ===
2+
export class Test<T> {
3+
>Test : Symbol(Test, Decl(declarationEmitTypeParamMergedWithPrivate.ts, 0, 0))
4+
>T : Symbol(T, Decl(declarationEmitTypeParamMergedWithPrivate.ts, 0, 18), Decl(declarationEmitTypeParamMergedWithPrivate.ts, 0, 22))
5+
6+
private get T(): T {
7+
>T : Symbol(T, Decl(declarationEmitTypeParamMergedWithPrivate.ts, 0, 18), Decl(declarationEmitTypeParamMergedWithPrivate.ts, 0, 22))
8+
>T : Symbol(T, Decl(declarationEmitTypeParamMergedWithPrivate.ts, 0, 18), Decl(declarationEmitTypeParamMergedWithPrivate.ts, 0, 22))
9+
10+
throw "";
11+
}
12+
13+
public test(): T {
14+
>test : Symbol(Test.test, Decl(declarationEmitTypeParamMergedWithPrivate.ts, 3, 5))
15+
>T : Symbol(T, Decl(declarationEmitTypeParamMergedWithPrivate.ts, 0, 18), Decl(declarationEmitTypeParamMergedWithPrivate.ts, 0, 22))
16+
17+
return null as any;
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/compiler/declarationEmitTypeParamMergedWithPrivate.ts ===
2+
export class Test<T> {
3+
>Test : Test<T>
4+
5+
private get T(): T {
6+
>T : T
7+
8+
throw "";
9+
>"" : ""
10+
}
11+
12+
public test(): T {
13+
>test : () => T
14+
15+
return null as any;
16+
>null as any : any
17+
>null : null
18+
}
19+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @declaration: true
2+
// @target: es6
3+
export class Test<T> {
4+
private get T(): T {
5+
throw "";
6+
}
7+
8+
public test(): T {
9+
return null as any;
10+
}
11+
}

0 commit comments

Comments
 (0)