mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 12:15:34 -06:00
Rewrite inaccessible "this" to containing class/interface in declaration files
This commit is contained in:
parent
41f8aade8e
commit
31eebbf9ea
@ -1606,7 +1606,12 @@ namespace ts {
|
||||
: (<IntrinsicType>type).intrinsicName);
|
||||
}
|
||||
else if (type.flags & TypeFlags.ThisType) {
|
||||
writer.writeKeyword(inObjectTypeLiteral ? "any" : "this");
|
||||
if (inObjectTypeLiteral && globalFlags & TypeFormatFlags.RewriteInaccessibleThis) {
|
||||
writeType((<TypeParameter>type).constraint, flags);
|
||||
}
|
||||
else {
|
||||
writer.writeKeyword("this");
|
||||
}
|
||||
}
|
||||
else if (type.flags & TypeFlags.Reference) {
|
||||
writeTypeReference(<TypeReference>type, flags);
|
||||
@ -14674,17 +14679,17 @@ namespace ts {
|
||||
? getTypeOfSymbol(symbol)
|
||||
: unknownType;
|
||||
|
||||
getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags);
|
||||
getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags | TypeFormatFlags.RewriteInaccessibleThis);
|
||||
}
|
||||
|
||||
function writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) {
|
||||
let signature = getSignatureFromDeclaration(signatureDeclaration);
|
||||
getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags);
|
||||
getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags | TypeFormatFlags.RewriteInaccessibleThis);
|
||||
}
|
||||
|
||||
function writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) {
|
||||
let type = getTypeOfExpression(expr);
|
||||
getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags);
|
||||
getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags | TypeFormatFlags.RewriteInaccessibleThis);
|
||||
}
|
||||
|
||||
function hasGlobalName(name: string): boolean {
|
||||
|
||||
@ -1509,6 +1509,7 @@ namespace ts {
|
||||
WriteTypeArgumentsOfSignature = 0x00000020, // Write the type arguments instead of type parameters of the signature
|
||||
InElementType = 0x00000040, // Writing an array or union element type
|
||||
UseFullyQualifiedType = 0x00000080, // Write out the fully qualified type name (eg. Module.Type, instead of Type)
|
||||
RewriteInaccessibleThis = 0x00000100, // Rewrite references to inaccessible "this"
|
||||
}
|
||||
|
||||
export const enum SymbolFormatFlags {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user