mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Handle this in isEntityNameVisible (#49521)
This commit is contained in:
parent
89d05f7131
commit
eb4b8a4d2e
@ -4665,6 +4665,9 @@ namespace ts {
|
||||
if (symbol && symbol.flags & SymbolFlags.TypeParameter && meaning & SymbolFlags.Type) {
|
||||
return { accessibility: SymbolAccessibility.Accessible };
|
||||
}
|
||||
if (!symbol && isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === SymbolAccessibility.Accessible) {
|
||||
return { accessibility: SymbolAccessibility.Accessible };
|
||||
}
|
||||
|
||||
// Verify if the symbol is accessible
|
||||
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
//// [declarationEmitTypeofThisInClass.ts]
|
||||
class Foo {
|
||||
public foo!: string
|
||||
public bar!: typeof this.foo //Public property 'bar' of exported class has or is using private name 'this'.(4031)
|
||||
}
|
||||
|
||||
//// [declarationEmitTypeofThisInClass.js]
|
||||
"use strict";
|
||||
var Foo = /** @class */ (function () {
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
}());
|
||||
|
||||
|
||||
//// [declarationEmitTypeofThisInClass.d.ts]
|
||||
declare class Foo {
|
||||
foo: string;
|
||||
bar: typeof this.foo;
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/declarationEmitTypeofThisInClass.ts ===
|
||||
class Foo {
|
||||
>Foo : Symbol(Foo, Decl(declarationEmitTypeofThisInClass.ts, 0, 0))
|
||||
|
||||
public foo!: string
|
||||
>foo : Symbol(Foo.foo, Decl(declarationEmitTypeofThisInClass.ts, 0, 11))
|
||||
|
||||
public bar!: typeof this.foo //Public property 'bar' of exported class has or is using private name 'this'.(4031)
|
||||
>bar : Symbol(Foo.bar, Decl(declarationEmitTypeofThisInClass.ts, 1, 23))
|
||||
>this.foo : Symbol(Foo.foo, Decl(declarationEmitTypeofThisInClass.ts, 0, 11))
|
||||
>this : Symbol(Foo, Decl(declarationEmitTypeofThisInClass.ts, 0, 0))
|
||||
>foo : Symbol(Foo.foo, Decl(declarationEmitTypeofThisInClass.ts, 0, 11))
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/declarationEmitTypeofThisInClass.ts ===
|
||||
class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
public foo!: string
|
||||
>foo : string
|
||||
|
||||
public bar!: typeof this.foo //Public property 'bar' of exported class has or is using private name 'this'.(4031)
|
||||
>bar : string
|
||||
>this.foo : string
|
||||
>this : this
|
||||
>foo : string
|
||||
}
|
||||
6
tests/cases/compiler/declarationEmitTypeofThisInClass.ts
Normal file
6
tests/cases/compiler/declarationEmitTypeofThisInClass.ts
Normal file
@ -0,0 +1,6 @@
|
||||
// @declaration: true
|
||||
// @strict: true
|
||||
class Foo {
|
||||
public foo!: string
|
||||
public bar!: typeof this.foo //Public property 'bar' of exported class has or is using private name 'this'.(4031)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user