Emit unqiue symbols with typeof if possible before issuing an error (#21403)

This commit is contained in:
Wesley Wigham
2018-02-28 15:44:12 -08:00
committed by GitHub
parent 7a31192ecb
commit 62185673fd
6 changed files with 79 additions and 1 deletions

View File

@@ -2898,6 +2898,9 @@ namespace ts {
}
if (type.flags & TypeFlags.UniqueESSymbol) {
if (!(context.flags & NodeBuilderFlags.AllowUniqueESSymbolType)) {
if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
return createTypeQueryNode(symbolToName(type.symbol, context, SymbolFlags.Value, /*expectsIdentifier*/ false));
}
if (context.tracker.reportInaccessibleUniqueSymbolError) {
context.tracker.reportInaccessibleUniqueSymbolError();
}

View File

@@ -79,7 +79,7 @@ class TypeWriterWalker {
// Workaround to ensure we output 'C' instead of 'typeof C' for base class expressions
// let type = this.checker.getTypeAtLocation(node);
const type = node.parent && ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) && this.checker.getTypeAtLocation(node.parent) || this.checker.getTypeAtLocation(node);
const typeString = type ? this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation) : "No type information available!";
const typeString = type ? this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.AllowUniqueESSymbolType) : "No type information available!";
return {
line: lineAndCharacter.line,
syntaxKind: node.kind,