Rename symbol.name to escapedName and make name unescaped (#17412)

This commit is contained in:
Andy 2017-07-25 14:22:26 -07:00 committed by GitHub
parent e515151ba4
commit 30d973bdcb
17 changed files with 147 additions and 142 deletions

View file

@ -1649,7 +1649,7 @@ namespace ts {
const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, InternalSymbolName.Type); const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, InternalSymbolName.Type);
addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral);
typeLiteralSymbol.members = createSymbolTable(); typeLiteralSymbol.members = createSymbolTable();
typeLiteralSymbol.members.set(symbol.name, symbol); typeLiteralSymbol.members.set(symbol.escapedName, symbol);
} }
function bindObjectLiteralExpression(node: ObjectLiteralExpression) { function bindObjectLiteralExpression(node: ObjectLiteralExpression) {
@ -2447,14 +2447,14 @@ namespace ts {
// module might have an exported variable called 'prototype'. We can't allow that as // module might have an exported variable called 'prototype'. We can't allow that as
// that would clash with the built-in 'prototype' for the class. // that would clash with the built-in 'prototype' for the class.
const prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype" as __String); const prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype" as __String);
const symbolExport = symbol.exports.get(prototypeSymbol.name); const symbolExport = symbol.exports.get(prototypeSymbol.escapedName);
if (symbolExport) { if (symbolExport) {
if (node.name) { if (node.name) {
node.name.parent = node; node.name.parent = node;
} }
file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], Diagnostics.Duplicate_identifier_0, unescapeLeadingUnderscores(prototypeSymbol.name))); file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], Diagnostics.Duplicate_identifier_0, unescapeLeadingUnderscores(prototypeSymbol.escapedName)));
} }
symbol.exports.set(prototypeSymbol.name, prototypeSymbol); symbol.exports.set(prototypeSymbol.escapedName, prototypeSymbol);
prototypeSymbol.parent = symbol; prototypeSymbol.parent = symbol;
} }

View file

@ -490,7 +490,7 @@ namespace ts {
} }
const builtinGlobals = createSymbolTable(); const builtinGlobals = createSymbolTable();
builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
initializeTypeChecker(); initializeTypeChecker();
@ -567,7 +567,7 @@ namespace ts {
} }
function cloneSymbol(symbol: Symbol): Symbol { function cloneSymbol(symbol: Symbol): Symbol {
const result = createSymbol(symbol.flags, symbol.name); const result = createSymbol(symbol.flags, symbol.escapedName);
result.declarations = symbol.declarations.slice(0); result.declarations = symbol.declarations.slice(0);
result.parent = symbol.parent; result.parent = symbol.parent;
if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration;
@ -935,7 +935,7 @@ namespace ts {
// name of that export default matches. // name of that export default matches.
if (result = moduleExports.get("default" as __String)) { if (result = moduleExports.get("default" as __String)) {
const localSymbol = getLocalSymbolForExportDefault(result); const localSymbol = getLocalSymbolForExportDefault(result);
if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) {
break loop; break loop;
} }
result = undefined; result = undefined;
@ -1385,7 +1385,7 @@ namespace ts {
if (valueSymbol.flags & (SymbolFlags.Type | SymbolFlags.Namespace)) { if (valueSymbol.flags & (SymbolFlags.Type | SymbolFlags.Namespace)) {
return valueSymbol; return valueSymbol;
} }
const result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); const result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName);
result.declarations = concatenate(valueSymbol.declarations, typeSymbol.declarations); result.declarations = concatenate(valueSymbol.declarations, typeSymbol.declarations);
result.parent = valueSymbol.parent || typeSymbol.parent; result.parent = valueSymbol.parent || typeSymbol.parent;
if (valueSymbol.valueDeclaration) result.valueDeclaration = valueSymbol.valueDeclaration; if (valueSymbol.valueDeclaration) result.valueDeclaration = valueSymbol.valueDeclaration;
@ -2042,14 +2042,14 @@ namespace ts {
function trySymbolTable(symbols: SymbolTable) { function trySymbolTable(symbols: SymbolTable) {
// If symbol is directly available by its name in the symbol table // If symbol is directly available by its name in the symbol table
if (isAccessible(symbols.get(symbol.name))) { if (isAccessible(symbols.get(symbol.escapedName))) {
return [symbol]; return [symbol];
} }
// Check if symbol is any of the alias // Check if symbol is any of the alias
return forEachEntry(symbols, symbolFromSymbolTable => { return forEachEntry(symbols, symbolFromSymbolTable => {
if (symbolFromSymbolTable.flags & SymbolFlags.Alias if (symbolFromSymbolTable.flags & SymbolFlags.Alias
&& symbolFromSymbolTable.name !== "export=" && symbolFromSymbolTable.escapedName !== "export="
&& !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) { && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) {
if (!useOnlyExternalAliasing || // We can use any type of alias to get the name if (!useOnlyExternalAliasing || // We can use any type of alias to get the name
// Is this external alias, then use it to name // Is this external alias, then use it to name
@ -2083,7 +2083,7 @@ namespace ts {
let qualify = false; let qualify = false;
forEachSymbolTableInScope(enclosingDeclaration, symbolTable => { forEachSymbolTableInScope(enclosingDeclaration, symbolTable => {
// If symbol of this name is not available in the symbol table we are ok // If symbol of this name is not available in the symbol table we are ok
let symbolFromSymbolTable = symbolTable.get(symbol.name); let symbolFromSymbolTable = symbolTable.get(symbol.escapedName);
if (!symbolFromSymbolTable) { if (!symbolFromSymbolTable) {
// Continue to the next symbol table // Continue to the next symbol table
return false; return false;
@ -2599,7 +2599,7 @@ namespace ts {
function symbolToTypeReferenceName(symbol: Symbol) { function symbolToTypeReferenceName(symbol: Symbol) {
// Unnamed function expressions and arrow functions have reserved names that we don't want to display // Unnamed function expressions and arrow functions have reserved names that we don't want to display
const entityName = symbol.flags & SymbolFlags.Class || !isReservedMemberName(symbol.name) ? symbolToName(symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ false) : createIdentifier(""); const entityName = symbol.flags & SymbolFlags.Class || !isReservedMemberName(symbol.escapedName) ? symbolToName(symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ false) : createIdentifier("");
return entityName; return entityName;
} }
@ -2851,7 +2851,7 @@ namespace ts {
parameterDeclaration.name.kind === SyntaxKind.Identifier ? parameterDeclaration.name.kind === SyntaxKind.Identifier ?
setEmitFlags(getSynthesizedClone(parameterDeclaration.name), EmitFlags.NoAsciiEscaping) : setEmitFlags(getSynthesizedClone(parameterDeclaration.name), EmitFlags.NoAsciiEscaping) :
cloneBindingName(parameterDeclaration.name) : cloneBindingName(parameterDeclaration.name) :
unescapeLeadingUnderscores(parameterSymbol.name); unescapeLeadingUnderscores(parameterSymbol.escapedName);
const questionToken = isOptionalParameter(parameterDeclaration) ? createToken(SyntaxKind.QuestionToken) : undefined; const questionToken = isOptionalParameter(parameterDeclaration) ? createToken(SyntaxKind.QuestionToken) : undefined;
let parameterType = getTypeOfSymbol(parameterSymbol); let parameterType = getTypeOfSymbol(parameterSymbol);
@ -2987,7 +2987,7 @@ namespace ts {
return "(Anonymous function)"; return "(Anonymous function)";
} }
} }
return unescapeLeadingUnderscores(symbol.name); return unescapeLeadingUnderscores(symbol.escapedName);
} }
} }
@ -3071,7 +3071,7 @@ namespace ts {
return "(Anonymous function)"; return "(Anonymous function)";
} }
} }
return unescapeLeadingUnderscores(symbol.name); return unescapeLeadingUnderscores(symbol.escapedName);
} }
function getSymbolDisplayBuilder(): SymbolDisplayBuilder { function getSymbolDisplayBuilder(): SymbolDisplayBuilder {
@ -3283,7 +3283,7 @@ namespace ts {
function writeSymbolTypeReference(symbol: Symbol, typeArguments: Type[], pos: number, end: number, flags: TypeFormatFlags) { function writeSymbolTypeReference(symbol: Symbol, typeArguments: Type[], pos: number, end: number, flags: TypeFormatFlags) {
// Unnamed function expressions and arrow functions have reserved names that we don't want to display // Unnamed function expressions and arrow functions have reserved names that we don't want to display
if (symbol.flags & SymbolFlags.Class || !isReservedMemberName(symbol.name)) { if (symbol.flags & SymbolFlags.Class || !isReservedMemberName(symbol.escapedName)) {
buildSymbolDisplay(symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, flags); buildSymbolDisplay(symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, flags);
} }
if (pos < end) { if (pos < end) {
@ -3534,7 +3534,7 @@ namespace ts {
continue; continue;
} }
if (getDeclarationModifierFlagsFromSymbol(p) & (ModifierFlags.Private | ModifierFlags.Protected)) { if (getDeclarationModifierFlagsFromSymbol(p) & (ModifierFlags.Private | ModifierFlags.Protected)) {
writer.reportPrivateInBaseOfClassExpression(unescapeLeadingUnderscores(p.name)); writer.reportPrivateInBaseOfClassExpression(unescapeLeadingUnderscores(p.escapedName));
} }
} }
const t = getTypeOfSymbol(p); const t = getTypeOfSymbol(p);
@ -4082,11 +4082,11 @@ namespace ts {
names.set(getTextOfPropertyName(name), true); names.set(getTextOfPropertyName(name), true);
} }
for (const prop of getPropertiesOfType(source)) { for (const prop of getPropertiesOfType(source)) {
const inNamesToRemove = names.has(prop.name); const inNamesToRemove = names.has(prop.escapedName);
const isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (ModifierFlags.Private | ModifierFlags.Protected); const isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (ModifierFlags.Private | ModifierFlags.Protected);
const isSetOnlyAccessor = prop.flags & SymbolFlags.SetAccessor && !(prop.flags & SymbolFlags.GetAccessor); const isSetOnlyAccessor = prop.flags & SymbolFlags.SetAccessor && !(prop.flags & SymbolFlags.GetAccessor);
if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) {
members.set(prop.name, prop); members.set(prop.escapedName, prop);
} }
} }
const stringIndexInfo = getIndexInfoOfType(source, IndexKind.String); const stringIndexInfo = getIndexInfoOfType(source, IndexKind.String);
@ -4273,7 +4273,7 @@ namespace ts {
} }
// Use contextual parameter type if one is available // Use contextual parameter type if one is available
let type: Type; let type: Type;
if (declaration.symbol.name === "this") { if (declaration.symbol.escapedName === "this") {
type = getContextualThisParameterType(func); type = getContextualThisParameterType(func);
} }
else { else {
@ -4393,7 +4393,7 @@ namespace ts {
const symbol = createSymbol(flags, text); const symbol = createSymbol(flags, text);
symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors);
symbol.bindingElement = e; symbol.bindingElement = e;
members.set(symbol.name, symbol); members.set(symbol.escapedName, symbol);
}); });
const result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); const result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined);
if (includePatternInType) { if (includePatternInType) {
@ -5323,15 +5323,15 @@ namespace ts {
function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable {
const result = createSymbolTable(); const result = createSymbolTable();
for (const symbol of symbols) { for (const symbol of symbols) {
result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); result.set(symbol.escapedName, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper));
} }
return result; return result;
} }
function addInheritedMembers(symbols: SymbolTable, baseSymbols: Symbol[]) { function addInheritedMembers(symbols: SymbolTable, baseSymbols: Symbol[]) {
for (const s of baseSymbols) { for (const s of baseSymbols) {
if (!symbols.has(s.name)) { if (!symbols.has(s.escapedName)) {
symbols.set(s.name, s); symbols.set(s.escapedName, s);
} }
} }
} }
@ -5833,10 +5833,10 @@ namespace ts {
const members = createSymbolTable(); const members = createSymbolTable();
for (const current of type.types) { for (const current of type.types) {
for (const prop of getPropertiesOfType(current)) { for (const prop of getPropertiesOfType(current)) {
if (!members.has(prop.name)) { if (!members.has(prop.escapedName)) {
const combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name); const combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.escapedName);
if (combinedProp) { if (combinedProp) {
members.set(prop.name, combinedProp); members.set(prop.escapedName, combinedProp);
} }
} }
} }
@ -5866,9 +5866,9 @@ namespace ts {
continue; continue;
} }
for (const { name } of getPropertiesOfType(memberType)) { for (const { escapedName } of getPropertiesOfType(memberType)) {
if (!props.has(name)) { if (!props.has(escapedName)) {
props.set(name, createUnionOrIntersectionProperty(type as UnionType, name)); props.set(escapedName, createUnionOrIntersectionProperty(type as UnionType, escapedName));
} }
} }
} }
@ -6176,7 +6176,7 @@ namespace ts {
if (isObjectLiteralType(type)) { if (isObjectLiteralType(type)) {
const propTypes: Type[] = []; const propTypes: Type[] = [];
for (const prop of getPropertiesOfType(type)) { for (const prop of getPropertiesOfType(type)) {
if (kind === IndexKind.String || isNumericLiteralName(prop.name)) { if (kind === IndexKind.String || isNumericLiteralName(prop.escapedName)) {
propTypes.push(getTypeOfSymbol(prop)); propTypes.push(getTypeOfSymbol(prop));
} }
} }
@ -6353,10 +6353,10 @@ namespace ts {
let paramSymbol = param.symbol; let paramSymbol = param.symbol;
// Include parameter symbol instead of property symbol in the signature // Include parameter symbol instead of property symbol in the signature
if (paramSymbol && !!(paramSymbol.flags & SymbolFlags.Property) && !isBindingPattern(param.name)) { if (paramSymbol && !!(paramSymbol.flags & SymbolFlags.Property) && !isBindingPattern(param.name)) {
const resolvedSymbol = resolveName(param, paramSymbol.name, SymbolFlags.Value, undefined, undefined); const resolvedSymbol = resolveName(param, paramSymbol.escapedName, SymbolFlags.Value, undefined, undefined);
paramSymbol = resolvedSymbol; paramSymbol = resolvedSymbol;
} }
if (i === 0 && paramSymbol.name === "this") { if (i === 0 && paramSymbol.escapedName === "this") {
hasThisParameter = true; hasThisParameter = true;
thisParameter = param.symbol; thisParameter = param.symbol;
} }
@ -6988,11 +6988,11 @@ namespace ts {
} }
const type = getDeclaredTypeOfSymbol(symbol); const type = getDeclaredTypeOfSymbol(symbol);
if (!(type.flags & TypeFlags.Object)) { if (!(type.flags & TypeFlags.Object)) {
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, unescapeLeadingUnderscores(symbol.name)); error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, unescapeLeadingUnderscores(symbol.escapedName));
return arity ? emptyGenericType : emptyObjectType; return arity ? emptyGenericType : emptyObjectType;
} }
if (length((<InterfaceType>type).typeParameters) !== arity) { if (length((<InterfaceType>type).typeParameters) !== arity) {
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, unescapeLeadingUnderscores(symbol.name), arity); error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, unescapeLeadingUnderscores(symbol.escapedName), arity);
return arity ? emptyGenericType : emptyObjectType; return arity ? emptyGenericType : emptyObjectType;
} }
return <ObjectType>type; return <ObjectType>type;
@ -7476,9 +7476,9 @@ namespace ts {
} }
function getLiteralTypeFromPropertyName(prop: Symbol) { function getLiteralTypeFromPropertyName(prop: Symbol) {
return getDeclarationModifierFlagsFromSymbol(prop) & ModifierFlags.NonPublicAccessibilityModifier || startsWith(prop.name as string, "__@") ? return getDeclarationModifierFlagsFromSymbol(prop) & ModifierFlags.NonPublicAccessibilityModifier || startsWith(prop.escapedName as string, "__@") ?
neverType : neverType :
getLiteralType(unescapeLeadingUnderscores(prop.name)); getLiteralType(unescapeLeadingUnderscores(prop.escapedName));
} }
function getLiteralTypeFromPropertyNames(type: Type) { function getLiteralTypeFromPropertyNames(type: Type) {
@ -7723,34 +7723,34 @@ namespace ts {
// we approximate own properties as non-methods plus methods that are inside the object literal // we approximate own properties as non-methods plus methods that are inside the object literal
const isSetterWithoutGetter = rightProp.flags & SymbolFlags.SetAccessor && !(rightProp.flags & SymbolFlags.GetAccessor); const isSetterWithoutGetter = rightProp.flags & SymbolFlags.SetAccessor && !(rightProp.flags & SymbolFlags.GetAccessor);
if (getDeclarationModifierFlagsFromSymbol(rightProp) & (ModifierFlags.Private | ModifierFlags.Protected)) { if (getDeclarationModifierFlagsFromSymbol(rightProp) & (ModifierFlags.Private | ModifierFlags.Protected)) {
skippedPrivateMembers.set(rightProp.name, true); skippedPrivateMembers.set(rightProp.escapedName, true);
} }
else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) {
members.set(rightProp.name, getNonReadonlySymbol(rightProp)); members.set(rightProp.escapedName, getNonReadonlySymbol(rightProp));
} }
} }
for (const leftProp of getPropertiesOfType(left)) { for (const leftProp of getPropertiesOfType(left)) {
if (leftProp.flags & SymbolFlags.SetAccessor && !(leftProp.flags & SymbolFlags.GetAccessor) if (leftProp.flags & SymbolFlags.SetAccessor && !(leftProp.flags & SymbolFlags.GetAccessor)
|| skippedPrivateMembers.has(leftProp.name) || skippedPrivateMembers.has(leftProp.escapedName)
|| isClassMethod(leftProp)) { || isClassMethod(leftProp)) {
continue; continue;
} }
if (members.has(leftProp.name)) { if (members.has(leftProp.escapedName)) {
const rightProp = members.get(leftProp.name); const rightProp = members.get(leftProp.escapedName);
const rightType = getTypeOfSymbol(rightProp); const rightType = getTypeOfSymbol(rightProp);
if (rightProp.flags & SymbolFlags.Optional) { if (rightProp.flags & SymbolFlags.Optional) {
const declarations: Declaration[] = concatenate(leftProp.declarations, rightProp.declarations); const declarations: Declaration[] = concatenate(leftProp.declarations, rightProp.declarations);
const flags = SymbolFlags.Property | (leftProp.flags & SymbolFlags.Optional); const flags = SymbolFlags.Property | (leftProp.flags & SymbolFlags.Optional);
const result = createSymbol(flags, leftProp.name); const result = createSymbol(flags, leftProp.escapedName);
result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, TypeFacts.NEUndefined)]); result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, TypeFacts.NEUndefined)]);
result.leftSpread = leftProp; result.leftSpread = leftProp;
result.rightSpread = rightProp; result.rightSpread = rightProp;
result.declarations = declarations; result.declarations = declarations;
members.set(leftProp.name, result); members.set(leftProp.escapedName, result);
} }
} }
else { else {
members.set(leftProp.name, getNonReadonlySymbol(leftProp)); members.set(leftProp.escapedName, getNonReadonlySymbol(leftProp));
} }
} }
return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo);
@ -7761,7 +7761,7 @@ namespace ts {
return prop; return prop;
} }
const flags = SymbolFlags.Property | (prop.flags & SymbolFlags.Optional); const flags = SymbolFlags.Property | (prop.flags & SymbolFlags.Optional);
const result = createSymbol(flags, prop.name); const result = createSymbol(flags, prop.escapedName);
result.type = getTypeOfSymbol(prop); result.type = getTypeOfSymbol(prop);
result.declarations = prop.declarations; result.declarations = prop.declarations;
result.syntheticOrigin = prop; result.syntheticOrigin = prop;
@ -8078,7 +8078,7 @@ namespace ts {
} }
// Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and
// also transient so that we can just store data on it directly. // also transient so that we can just store data on it directly.
const result = createSymbol(symbol.flags, symbol.name); const result = createSymbol(symbol.flags, symbol.escapedName);
result.checkFlags = CheckFlags.Instantiated; result.checkFlags = CheckFlags.Instantiated;
result.declarations = symbol.declarations; result.declarations = symbol.declarations;
result.parent = symbol.parent; result.parent = symbol.parent;
@ -8495,8 +8495,8 @@ namespace ts {
if (!related) { if (!related) {
if (reportErrors) { if (reportErrors) {
errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible, errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible,
unescapeLeadingUnderscores(sourceParams[i < sourceMax ? i : sourceMax].name), unescapeLeadingUnderscores(sourceParams[i < sourceMax ? i : sourceMax].escapedName),
unescapeLeadingUnderscores(targetParams[i < targetMax ? i : targetMax].name)); unescapeLeadingUnderscores(targetParams[i < targetMax ? i : targetMax].escapedName));
} }
return Ternary.False; return Ternary.False;
} }
@ -8635,17 +8635,17 @@ namespace ts {
if (relation !== undefined) { if (relation !== undefined) {
return relation; return relation;
} }
if (sourceSymbol.name !== targetSymbol.name || !(sourceSymbol.flags & SymbolFlags.RegularEnum) || !(targetSymbol.flags & SymbolFlags.RegularEnum)) { if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & SymbolFlags.RegularEnum) || !(targetSymbol.flags & SymbolFlags.RegularEnum)) {
enumRelation.set(id, false); enumRelation.set(id, false);
return false; return false;
} }
const targetEnumType = getTypeOfSymbol(targetSymbol); const targetEnumType = getTypeOfSymbol(targetSymbol);
for (const property of getPropertiesOfType(getTypeOfSymbol(sourceSymbol))) { for (const property of getPropertiesOfType(getTypeOfSymbol(sourceSymbol))) {
if (property.flags & SymbolFlags.EnumMember) { if (property.flags & SymbolFlags.EnumMember) {
const targetProperty = getPropertyOfType(targetEnumType, property.name); const targetProperty = getPropertyOfType(targetEnumType, property.escapedName);
if (!targetProperty || !(targetProperty.flags & SymbolFlags.EnumMember)) { if (!targetProperty || !(targetProperty.flags & SymbolFlags.EnumMember)) {
if (errorReporter) { if (errorReporter) {
errorReporter(Diagnostics.Property_0_is_missing_in_type_1, unescapeLeadingUnderscores(property.name), errorReporter(Diagnostics.Property_0_is_missing_in_type_1, unescapeLeadingUnderscores(property.escapedName),
typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType)); typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType));
} }
enumRelation.set(id, false); enumRelation.set(id, false);
@ -8951,7 +8951,7 @@ namespace ts {
return false; return false;
} }
for (const prop of getPropertiesOfObjectType(source)) { for (const prop of getPropertiesOfObjectType(source)) {
if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { if (!isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
if (reportErrors) { if (reportErrors) {
// We know *exactly* where things went wrong when comparing the types. // We know *exactly* where things went wrong when comparing the types.
// Use this property as the error node as this will be more helpful in // Use this property as the error node as this will be more helpful in
@ -9014,10 +9014,10 @@ namespace ts {
const sourceProperties = getPropertiesOfObjectType(source); const sourceProperties = getPropertiesOfObjectType(source);
if (sourceProperties) { if (sourceProperties) {
for (const sourceProperty of sourceProperties) { for (const sourceProperty of sourceProperties) {
if (isDiscriminantProperty(target, sourceProperty.name)) { if (isDiscriminantProperty(target, sourceProperty.escapedName)) {
const sourceType = getTypeOfSymbol(sourceProperty); const sourceType = getTypeOfSymbol(sourceProperty);
for (const type of target.types) { for (const type of target.types) {
const targetType = getTypeOfPropertyOfType(type, sourceProperty.name); const targetType = getTypeOfPropertyOfType(type, sourceProperty.escapedName);
if (targetType && isRelatedTo(sourceType, targetType)) { if (targetType && isRelatedTo(sourceType, targetType)) {
return type; return type;
} }
@ -9332,7 +9332,7 @@ namespace ts {
const properties = getPropertiesOfObjectType(target); const properties = getPropertiesOfObjectType(target);
const requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & ObjectFlags.ObjectLiteral); const requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & ObjectFlags.ObjectLiteral);
for (const targetProp of properties) { for (const targetProp of properties) {
const sourceProp = getPropertyOfType(source, targetProp.name); const sourceProp = getPropertyOfType(source, targetProp.escapedName);
if (sourceProp !== targetProp) { if (sourceProp !== targetProp) {
if (!sourceProp) { if (!sourceProp) {
if (!(targetProp.flags & SymbolFlags.Optional) || requireOptionalProperties) { if (!(targetProp.flags & SymbolFlags.Optional) || requireOptionalProperties) {
@ -9432,7 +9432,7 @@ namespace ts {
function hasCommonProperties(source: Type, target: Type) { function hasCommonProperties(source: Type, target: Type) {
const isComparingJsxAttributes = !!(source.flags & TypeFlags.JsxAttributes); const isComparingJsxAttributes = !!(source.flags & TypeFlags.JsxAttributes);
for (const prop of getPropertiesOfType(source)) { for (const prop of getPropertiesOfType(source)) {
if (isKnownProperty(target, prop.name, isComparingJsxAttributes)) { if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
return true; return true;
} }
} }
@ -9450,7 +9450,7 @@ namespace ts {
} }
let result = Ternary.True; let result = Ternary.True;
for (const sourceProp of sourceProperties) { for (const sourceProp of sourceProperties) {
const targetProp = getPropertyOfObjectType(target, sourceProp.name); const targetProp = getPropertyOfObjectType(target, sourceProp.escapedName);
if (!targetProp) { if (!targetProp) {
return Ternary.False; return Ternary.False;
} }
@ -9567,7 +9567,7 @@ namespace ts {
function eachPropertyRelatedTo(source: Type, target: Type, kind: IndexKind, reportErrors: boolean): Ternary { function eachPropertyRelatedTo(source: Type, target: Type, kind: IndexKind, reportErrors: boolean): Ternary {
let result = Ternary.True; let result = Ternary.True;
for (const prop of getPropertiesOfObjectType(source)) { for (const prop of getPropertiesOfObjectType(source)) {
if (kind === IndexKind.String || isNumericLiteralName(prop.name)) { if (kind === IndexKind.String || isNumericLiteralName(prop.escapedName)) {
const related = isRelatedTo(getTypeOfSymbol(prop), target, reportErrors); const related = isRelatedTo(getTypeOfSymbol(prop), target, reportErrors);
if (!related) { if (!related) {
if (reportErrors) { if (reportErrors) {
@ -9670,7 +9670,7 @@ namespace ts {
function forEachProperty<T>(prop: Symbol, callback: (p: Symbol) => T): T { function forEachProperty<T>(prop: Symbol, callback: (p: Symbol) => T): T {
if (getCheckFlags(prop) & CheckFlags.Synthetic) { if (getCheckFlags(prop) & CheckFlags.Synthetic) {
for (const t of (<TransientSymbol>prop).containingType.types) { for (const t of (<TransientSymbol>prop).containingType.types) {
const p = getPropertyOfType(t, prop.name); const p = getPropertyOfType(t, prop.escapedName);
const result = p && forEachProperty(p, callback); const result = p && forEachProperty(p, callback);
if (result) { if (result) {
return result; return result;
@ -10008,7 +10008,7 @@ namespace ts {
} }
function createSymbolWithType(source: Symbol, type: Type) { function createSymbolWithType(source: Symbol, type: Type) {
const symbol = createSymbol(source.flags, source.name); const symbol = createSymbol(source.flags, source.escapedName);
symbol.declarations = source.declarations; symbol.declarations = source.declarations;
symbol.parent = source.parent; symbol.parent = source.parent;
symbol.type = type; symbol.type = type;
@ -10024,7 +10024,7 @@ namespace ts {
for (const property of getPropertiesOfObjectType(type)) { for (const property of getPropertiesOfObjectType(type)) {
const original = getTypeOfSymbol(property); const original = getTypeOfSymbol(property);
const updated = f(original); const updated = f(original);
members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); members.set(property.escapedName, updated === original ? property : createSymbolWithType(property, updated));
} }
return members; return members;
} }
@ -10068,7 +10068,7 @@ namespace ts {
for (const prop of getPropertiesOfObjectType(type)) { for (const prop of getPropertiesOfObjectType(type)) {
// Since get accessors already widen their return value there is no need to // Since get accessors already widen their return value there is no need to
// widen accessor based properties here. // widen accessor based properties here.
members.set(prop.name, prop.flags & SymbolFlags.Property ? getWidenedProperty(prop) : prop); members.set(prop.escapedName, prop.flags & SymbolFlags.Property ? getWidenedProperty(prop) : prop);
} }
const stringIndexInfo = getIndexInfoOfType(type, IndexKind.String); const stringIndexInfo = getIndexInfoOfType(type, IndexKind.String);
const numberIndexInfo = getIndexInfoOfType(type, IndexKind.Number); const numberIndexInfo = getIndexInfoOfType(type, IndexKind.Number);
@ -10131,7 +10131,7 @@ namespace ts {
const t = getTypeOfSymbol(p); const t = getTypeOfSymbol(p);
if (t.flags & TypeFlags.ContainsWideningType) { if (t.flags & TypeFlags.ContainsWideningType) {
if (!reportWideningErrorsInType(t)) { if (!reportWideningErrorsInType(t)) {
error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, unescapeLeadingUnderscores(p.name), typeToString(getWidenedType(t))); error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, unescapeLeadingUnderscores(p.escapedName), typeToString(getWidenedType(t)));
} }
errorReported = true; errorReported = true;
} }
@ -10292,11 +10292,11 @@ namespace ts {
if (!inferredPropType) { if (!inferredPropType) {
return undefined; return undefined;
} }
const inferredProp = createSymbol(SymbolFlags.Property | prop.flags & optionalMask, prop.name); const inferredProp = createSymbol(SymbolFlags.Property | prop.flags & optionalMask, prop.escapedName);
inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? CheckFlags.Readonly : 0; inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? CheckFlags.Readonly : 0;
inferredProp.declarations = prop.declarations; inferredProp.declarations = prop.declarations;
inferredProp.type = inferredPropType; inferredProp.type = inferredPropType;
members.set(prop.name, inferredProp); members.set(prop.escapedName, inferredProp);
} }
if (indexInfo) { if (indexInfo) {
const inferredIndexType = inferTargetType(indexInfo.type); const inferredIndexType = inferTargetType(indexInfo.type);
@ -10516,7 +10516,7 @@ namespace ts {
function inferFromProperties(source: Type, target: Type) { function inferFromProperties(source: Type, target: Type) {
const properties = getPropertiesOfObjectType(target); const properties = getPropertiesOfObjectType(target);
for (const targetProp of properties) { for (const targetProp of properties) {
const sourceProp = getPropertyOfObjectType(source, targetProp.name); const sourceProp = getPropertyOfObjectType(source, targetProp.escapedName);
if (sourceProp) { if (sourceProp) {
inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
} }
@ -12949,7 +12949,7 @@ namespace ts {
// For a (non-symbol) computed property, there is no reason to look up the name // For a (non-symbol) computed property, there is no reason to look up the name
// in the type. It will just be "__computed", which does not appear in any // in the type. It will just be "__computed", which does not appear in any
// SymbolTable. // SymbolTable.
const symbolName = getSymbolOfNode(element).name; const symbolName = getSymbolOfNode(element).escapedName;
const propertyType = getTypeOfPropertyOfContextualType(type, symbolName); const propertyType = getTypeOfPropertyOfContextualType(type, symbolName);
if (propertyType) { if (propertyType) {
return propertyType; return propertyType;
@ -13422,7 +13422,7 @@ namespace ts {
} }
typeFlags |= type.flags; typeFlags |= type.flags;
const prop = createSymbol(SymbolFlags.Property | member.flags, member.name); const prop = createSymbol(SymbolFlags.Property | member.flags, member.escapedName);
if (inDestructuringPattern) { if (inDestructuringPattern) {
// If object literal is an assignment pattern and if the assignment pattern specifies a default value // If object literal is an assignment pattern and if the assignment pattern specifies a default value
// for the property, make the property optional. // for the property, make the property optional.
@ -13439,7 +13439,7 @@ namespace ts {
else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) { else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) {
// If object literal is contextually typed by the implied type of a binding pattern, and if the // If object literal is contextually typed by the implied type of a binding pattern, and if the
// binding pattern specifies a default value for the property, make the property optional. // binding pattern specifies a default value for the property, make the property optional.
const impliedProp = getPropertyOfType(contextualType, member.name); const impliedProp = getPropertyOfType(contextualType, member.escapedName);
if (impliedProp) { if (impliedProp) {
prop.flags |= impliedProp.flags & SymbolFlags.Optional; prop.flags |= impliedProp.flags & SymbolFlags.Optional;
} }
@ -13499,7 +13499,7 @@ namespace ts {
} }
} }
else { else {
propertiesTable.set(member.name, member); propertiesTable.set(member.escapedName, member);
} }
propertiesArray.push(member); propertiesArray.push(member);
} }
@ -13508,12 +13508,12 @@ namespace ts {
// type with those properties for which the binding pattern specifies a default value. // type with those properties for which the binding pattern specifies a default value.
if (contextualTypeHasPattern) { if (contextualTypeHasPattern) {
for (const prop of getPropertiesOfType(contextualType)) { for (const prop of getPropertiesOfType(contextualType)) {
if (!propertiesTable.get(prop.name)) { if (!propertiesTable.get(prop.escapedName)) {
if (!(prop.flags & SymbolFlags.Optional)) { if (!(prop.flags & SymbolFlags.Optional)) {
error(prop.valueDeclaration || (<TransientSymbol>prop).bindingElement, error(prop.valueDeclaration || (<TransientSymbol>prop).bindingElement,
Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
} }
propertiesTable.set(prop.name, prop); propertiesTable.set(prop.escapedName, prop);
propertiesArray.push(prop); propertiesArray.push(prop);
} }
} }
@ -13631,7 +13631,7 @@ namespace ts {
checkExpression(attributeDecl.initializer, checkMode) : checkExpression(attributeDecl.initializer, checkMode) :
trueType; // <Elem attr /> is sugar for <Elem attr={true} /> trueType; // <Elem attr /> is sugar for <Elem attr={true} />
const attributeSymbol = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name); const attributeSymbol = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.escapedName);
attributeSymbol.declarations = member.declarations; attributeSymbol.declarations = member.declarations;
attributeSymbol.parent = member.parent; attributeSymbol.parent = member.parent;
if (member.valueDeclaration) { if (member.valueDeclaration) {
@ -13639,7 +13639,7 @@ namespace ts {
} }
attributeSymbol.type = exprType; attributeSymbol.type = exprType;
attributeSymbol.target = member; attributeSymbol.target = member;
attributesTable.set(attributeSymbol.name, attributeSymbol); attributesTable.set(attributeSymbol.escapedName, attributeSymbol);
attributesArray.push(attributeSymbol); attributesArray.push(attributeSymbol);
if (attributeDecl.name.escapedText === jsxChildrenPropertyName) { if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
explicitlySpecifyChildrenAttribute = true; explicitlySpecifyChildrenAttribute = true;
@ -13676,7 +13676,7 @@ namespace ts {
attributesTable = createSymbolTable(); attributesTable = createSymbolTable();
for (const attr of attributesArray) { for (const attr of attributesArray) {
if (!filter || filter(attr)) { if (!filter || filter(attr)) {
attributesTable.set(attr.name, attr); attributesTable.set(attr.escapedName, attr);
} }
} }
} }
@ -13856,7 +13856,7 @@ namespace ts {
// Element Attributes has one property, so the element attributes type will be the type of the corresponding // Element Attributes has one property, so the element attributes type will be the type of the corresponding
// property of the class instance type // property of the class instance type
else if (propertiesOfJsxElementAttribPropInterface.length === 1) { else if (propertiesOfJsxElementAttribPropInterface.length === 1) {
return propertiesOfJsxElementAttribPropInterface[0].name; return propertiesOfJsxElementAttribPropInterface[0].escapedName;
} }
else if (propertiesOfJsxElementAttribPropInterface.length > 1) { else if (propertiesOfJsxElementAttribPropInterface.length > 1) {
// More than one property on ElementAttributesProperty is an error // More than one property on ElementAttributesProperty is an error
@ -14324,7 +14324,7 @@ namespace ts {
// attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". // attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes".
const sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, const sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement,
attribute => { attribute => {
return isUnhyphenatedJsxName(attribute.name) || !!(getPropertyOfType(targetAttributesType, attribute.name)); return isUnhyphenatedJsxName(attribute.escapedName) || !!(getPropertyOfType(targetAttributesType, attribute.escapedName));
}); });
// If the targetAttributesType is an emptyObjectType, indicating that there is no property named 'props' on this instance type. // If the targetAttributesType is an emptyObjectType, indicating that there is no property named 'props' on this instance type.
@ -14585,7 +14585,7 @@ namespace ts {
function getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): __String | undefined { function getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): __String | undefined {
const suggestion = getSpellingSuggestionForName(unescapeLeadingUnderscores(node.escapedText), getPropertiesOfType(containingType), SymbolFlags.Value); const suggestion = getSpellingSuggestionForName(unescapeLeadingUnderscores(node.escapedText), getPropertiesOfType(containingType), SymbolFlags.Value);
return suggestion && suggestion.name; return suggestion && suggestion.escapedName;
} }
function getSuggestionForNonexistentSymbol(location: Node, name: __String, meaning: SymbolFlags): __String { function getSuggestionForNonexistentSymbol(location: Node, name: __String, meaning: SymbolFlags): __String {
@ -14600,7 +14600,7 @@ namespace ts {
return getSpellingSuggestionForName(unescapeLeadingUnderscores(name), arrayFrom(symbols.values()), meaning); return getSpellingSuggestionForName(unescapeLeadingUnderscores(name), arrayFrom(symbols.values()), meaning);
}); });
if (result) { if (result) {
return result.name; return result.escapedName;
} }
} }
@ -14631,7 +14631,7 @@ namespace ts {
} }
name = name.toLowerCase(); name = name.toLowerCase();
for (const candidate of symbols) { for (const candidate of symbols) {
let candidateName = unescapeLeadingUnderscores(candidate.name); let candidateName = unescapeLeadingUnderscores(candidate.escapedName);
if (candidate.flags & meaning && if (candidate.flags & meaning &&
candidateName && candidateName &&
Math.abs(candidateName.length - name.length) < maximumLengthDifference) { Math.abs(candidateName.length - name.length) < maximumLengthDifference) {
@ -15200,7 +15200,7 @@ namespace ts {
const attributesType = checkExpressionWithContextualType(node.attributes, paramType, /*contextualMapper*/ undefined); const attributesType = checkExpressionWithContextualType(node.attributes, paramType, /*contextualMapper*/ undefined);
const argProperties = getPropertiesOfType(attributesType); const argProperties = getPropertiesOfType(attributesType);
for (const arg of argProperties) { for (const arg of argProperties) {
if (!getPropertyOfType(paramType, arg.name) && isUnhyphenatedJsxName(arg.name)) { if (!getPropertyOfType(paramType, arg.escapedName) && isUnhyphenatedJsxName(arg.escapedName)) {
return false; return false;
} }
} }
@ -19625,11 +19625,11 @@ namespace ts {
!isParameterPropertyDeclaration(parameter) && !isParameterPropertyDeclaration(parameter) &&
!parameterIsThisKeyword(parameter) && !parameterIsThisKeyword(parameter) &&
!parameterNameStartsWithUnderscore(name)) { !parameterNameStartsWithUnderscore(name)) {
error(name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(local.name)); error(name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(local.escapedName));
} }
} }
else if (compilerOptions.noUnusedLocals) { else if (compilerOptions.noUnusedLocals) {
forEach(local.declarations, d => errorUnusedLocal(getNameOfDeclaration(d) || d, unescapeLeadingUnderscores(local.name))); forEach(local.declarations, d => errorUnusedLocal(getNameOfDeclaration(d) || d, unescapeLeadingUnderscores(local.escapedName)));
} }
} }
}); });
@ -19671,13 +19671,13 @@ namespace ts {
for (const member of node.members) { for (const member of node.members) {
if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) { if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) {
if (!member.symbol.isReferenced && getModifierFlags(member) & ModifierFlags.Private) { if (!member.symbol.isReferenced && getModifierFlags(member) & ModifierFlags.Private) {
error(member.name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(member.symbol.name)); error(member.name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(member.symbol.escapedName));
} }
} }
else if (member.kind === SyntaxKind.Constructor) { else if (member.kind === SyntaxKind.Constructor) {
for (const parameter of (<ConstructorDeclaration>member).parameters) { for (const parameter of (<ConstructorDeclaration>member).parameters) {
if (!parameter.symbol.isReferenced && getModifierFlags(parameter) & ModifierFlags.Private) { if (!parameter.symbol.isReferenced && getModifierFlags(parameter) & ModifierFlags.Private) {
error(parameter.name, Diagnostics.Property_0_is_declared_but_never_used, unescapeLeadingUnderscores(parameter.symbol.name)); error(parameter.name, Diagnostics.Property_0_is_declared_but_never_used, unescapeLeadingUnderscores(parameter.symbol.escapedName));
} }
} }
} }
@ -19698,7 +19698,7 @@ namespace ts {
} }
for (const typeParameter of node.typeParameters) { for (const typeParameter of node.typeParameters) {
if (!getMergedSymbol(typeParameter.symbol).isReferenced) { if (!getMergedSymbol(typeParameter.symbol).isReferenced) {
error(typeParameter.name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(typeParameter.symbol.name)); error(typeParameter.name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(typeParameter.symbol.escapedName));
} }
} }
} }
@ -19711,7 +19711,7 @@ namespace ts {
if (!local.isReferenced && !local.exportSymbol) { if (!local.isReferenced && !local.exportSymbol) {
for (const declaration of local.declarations) { for (const declaration of local.declarations) {
if (!isAmbientModule(declaration)) { if (!isAmbientModule(declaration)) {
errorUnusedLocal(getNameOfDeclaration(declaration), unescapeLeadingUnderscores(local.name)); errorUnusedLocal(getNameOfDeclaration(declaration), unescapeLeadingUnderscores(local.escapedName));
} }
} }
} }
@ -19737,7 +19737,7 @@ namespace ts {
} }
forEach(node.parameters, p => { forEach(node.parameters, p => {
if (p.name && !isBindingPattern(p.name) && p.name.escapedText === argumentsSymbol.name) { if (p.name && !isBindingPattern(p.name) && p.name.escapedText === argumentsSymbol.escapedName) {
error(p, Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters); error(p, Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters);
} }
}); });
@ -20938,7 +20938,7 @@ namespace ts {
const propDeclaration = prop.valueDeclaration; const propDeclaration = prop.valueDeclaration;
// index is numeric and property name is not valid numeric literal // index is numeric and property name is not valid numeric literal
if (indexKind === IndexKind.Number && !(propDeclaration ? isNumericName(getNameOfDeclaration(propDeclaration)) : isNumericLiteralName(prop.name))) { if (indexKind === IndexKind.Number && !(propDeclaration ? isNumericName(getNameOfDeclaration(propDeclaration)) : isNumericLiteralName(prop.escapedName))) {
return; return;
} }
@ -20958,7 +20958,7 @@ namespace ts {
// for interfaces property and indexer might be inherited from different bases // for interfaces property and indexer might be inherited from different bases
// check if any base class already has both property and indexer. // check if any base class already has both property and indexer.
// check should be performed only if 'type' is the first type that brings property\indexer together // check should be performed only if 'type' is the first type that brings property\indexer together
const someBaseClassHasBothPropertyAndIndexer = forEach(getBaseTypes(<InterfaceType>containingType), base => getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind)); const someBaseClassHasBothPropertyAndIndexer = forEach(getBaseTypes(<InterfaceType>containingType), base => getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind));
errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0];
} }
@ -21056,7 +21056,7 @@ namespace ts {
// If the type parameter node does not have the same as the resolved type // If the type parameter node does not have the same as the resolved type
// parameter at this position, we report an error. // parameter at this position, we report an error.
if (source.name.escapedText !== target.symbol.name) { if (source.name.escapedText !== target.symbol.escapedName) {
return false; return false;
} }
@ -21249,7 +21249,7 @@ namespace ts {
continue; continue;
} }
const derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); const derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName));
const baseDeclarationFlags = getDeclarationModifierFlagsFromSymbol(base); const baseDeclarationFlags = getDeclarationModifierFlagsFromSymbol(base);
Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
@ -21320,15 +21320,15 @@ namespace ts {
type InheritanceInfoMap = { prop: Symbol; containingType: Type }; type InheritanceInfoMap = { prop: Symbol; containingType: Type };
const seen = createUnderscoreEscapedMap<InheritanceInfoMap>(); const seen = createUnderscoreEscapedMap<InheritanceInfoMap>();
forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen.set(p.name, { prop: p, containingType: type }); }); forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen.set(p.escapedName, { prop: p, containingType: type }); });
let ok = true; let ok = true;
for (const base of baseTypes) { for (const base of baseTypes) {
const properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); const properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
for (const prop of properties) { for (const prop of properties) {
const existing = seen.get(prop.name); const existing = seen.get(prop.escapedName);
if (!existing) { if (!existing) {
seen.set(prop.name, { prop, containingType: base }); seen.set(prop.escapedName, { prop, containingType: base });
} }
else { else {
const isInheritedProperty = existing.containingType !== type; const isInheritedProperty = existing.containingType !== type;
@ -22488,7 +22488,7 @@ namespace ts {
*/ */
function copySymbol(symbol: Symbol, meaning: SymbolFlags): void { function copySymbol(symbol: Symbol, meaning: SymbolFlags): void {
if (getCombinedLocalAndExportSymbolFlags(symbol) & meaning) { if (getCombinedLocalAndExportSymbolFlags(symbol) & meaning) {
const id = symbol.name; const id = symbol.escapedName;
// We will copy all symbol regardless of its reserved name because // We will copy all symbol regardless of its reserved name because
// symbolsToArray will check whether the key is a reserved name and // symbolsToArray will check whether the key is a reserved name and
// it will not copy symbol with reserved name to the array // it will not copy symbol with reserved name to the array
@ -22946,8 +22946,8 @@ namespace ts {
const propsByName = createSymbolTable(getPropertiesOfType(type)); const propsByName = createSymbolTable(getPropertiesOfType(type));
if (getSignaturesOfType(type, SignatureKind.Call).length || getSignaturesOfType(type, SignatureKind.Construct).length) { if (getSignaturesOfType(type, SignatureKind.Call).length || getSignaturesOfType(type, SignatureKind.Construct).length) {
forEach(getPropertiesOfType(globalFunctionType), p => { forEach(getPropertiesOfType(globalFunctionType), p => {
if (!propsByName.has(p.name)) { if (!propsByName.has(p.escapedName)) {
propsByName.set(p.name, p); propsByName.set(p.escapedName, p);
} }
}); });
} }
@ -22957,7 +22957,7 @@ namespace ts {
function getRootSymbols(symbol: Symbol): Symbol[] { function getRootSymbols(symbol: Symbol): Symbol[] {
if (getCheckFlags(symbol) & CheckFlags.Synthetic) { if (getCheckFlags(symbol) & CheckFlags.Synthetic) {
const symbols: Symbol[] = []; const symbols: Symbol[] = [];
const name = symbol.name; const name = symbol.escapedName;
forEach(getSymbolLinks(symbol).containingType.types, t => { forEach(getSymbolLinks(symbol).containingType.types, t => {
const symbol = getPropertyOfType(t, name); const symbol = getPropertyOfType(t, name);
if (symbol) { if (symbol) {
@ -23094,7 +23094,7 @@ namespace ts {
const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration);
if (isStatementWithLocals(container)) { if (isStatementWithLocals(container)) {
const nodeLinks = getNodeLinks(symbol.valueDeclaration); const nodeLinks = getNodeLinks(symbol.valueDeclaration);
if (!!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { if (!!resolveName(container.parent, symbol.escapedName, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) {
// redeclaration - always should be renamed // redeclaration - always should be renamed
links.isDeclarationWithCollidingName = true; links.isDeclarationWithCollidingName = true;
} }

View file

@ -59,7 +59,7 @@ namespace ts {
const result = createMap<Symbol>() as SymbolTable; const result = createMap<Symbol>() as SymbolTable;
if (symbols) { if (symbols) {
for (const symbol of symbols) { for (const symbol of symbols) {
result.set(symbol.name, symbol); result.set(symbol.escapedName, symbol);
} }
} }
return result; return result;
@ -2306,7 +2306,7 @@ namespace ts {
function Symbol(this: Symbol, flags: SymbolFlags, name: __String) { function Symbol(this: Symbol, flags: SymbolFlags, name: __String) {
this.flags = flags; this.flags = flags;
this.name = name; this.escapedName = name;
this.declarations = undefined; this.declarations = undefined;
} }

View file

@ -2644,7 +2644,7 @@ namespace ts {
* on symbol names. * on symbol names.
*/ */
function recordEmittedDeclarationInScope(node: Node) { function recordEmittedDeclarationInScope(node: Node) {
const name = node.symbol && node.symbol.name; const name = node.symbol && node.symbol.escapedName;
if (name) { if (name) {
if (!currentScopeFirstDeclarationsOfName) { if (!currentScopeFirstDeclarationsOfName) {
currentScopeFirstDeclarationsOfName = createUnderscoreEscapedMap<Node>(); currentScopeFirstDeclarationsOfName = createUnderscoreEscapedMap<Node>();
@ -2662,7 +2662,7 @@ namespace ts {
*/ */
function isFirstEmittedDeclarationInScope(node: Node) { function isFirstEmittedDeclarationInScope(node: Node) {
if (currentScopeFirstDeclarationsOfName) { if (currentScopeFirstDeclarationsOfName) {
const name = node.symbol && node.symbol.name; const name = node.symbol && node.symbol.escapedName;
if (name) { if (name) {
return currentScopeFirstDeclarationsOfName.get(name) === node; return currentScopeFirstDeclarationsOfName.get(name) === node;
} }

View file

@ -2899,7 +2899,7 @@ namespace ts {
export interface Symbol { export interface Symbol {
flags: SymbolFlags; // Symbol flags flags: SymbolFlags; // Symbol flags
name: __String; // Name of symbol escapedName: __String; // Name of symbol
declarations?: Declaration[]; // Declarations associated with this symbol declarations?: Declaration[]; // Declarations associated with this symbol
valueDeclaration?: Declaration; // First value declaration of the symbol valueDeclaration?: Declaration; // First value declaration of the symbol
members?: SymbolTable; // Class, interface or literal instance members members?: SymbolTable; // Class, interface or literal instance members

View file

@ -35,7 +35,7 @@ namespace ts.codefix {
*/ */
export function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: Symbol[], checker: TypeChecker): Node[] { export function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: Symbol[], checker: TypeChecker): Node[] {
const classMembers = classDeclaration.symbol.members; const classMembers = classDeclaration.symbol.members;
const missingMembers = possiblyMissingSymbols.filter(symbol => !classMembers.has(symbol.name)); const missingMembers = possiblyMissingSymbols.filter(symbol => !classMembers.has(symbol.escapedName));
let newNodes: Node[] = []; let newNodes: Node[] = [];
for (const symbol of missingMembers) { for (const symbol of missingMembers) {
@ -205,7 +205,7 @@ namespace ts.codefix {
} }
} }
const maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); const maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0);
const maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(symbol => symbol.getUnescapedName()); const maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(symbol => symbol.name);
const parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, minArgumentCount, /*addAnyType*/ true); const parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, minArgumentCount, /*addAnyType*/ true);

View file

@ -148,7 +148,7 @@ namespace ts.codefix {
else if (isJsxOpeningLikeElement(token.parent) && token.parent.tagName === token) { else if (isJsxOpeningLikeElement(token.parent) && token.parent.tagName === token) {
// The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`.
symbol = checker.getAliasedSymbol(checker.resolveNameAtLocation(token, checker.getJsxNamespace(), SymbolFlags.Value)); symbol = checker.getAliasedSymbol(checker.resolveNameAtLocation(token, checker.getJsxNamespace(), SymbolFlags.Value));
symbolName = symbol.getUnescapedName(); symbolName = symbol.name;
} }
else { else {
Debug.fail("Either the symbol or the JSX namespace should be a UMD global if we got here"); Debug.fail("Either the symbol or the JSX namespace should be a UMD global if we got here");
@ -171,7 +171,7 @@ namespace ts.codefix {
const defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol); const defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol);
if (defaultExport) { if (defaultExport) {
const localSymbol = getLocalSymbolForExportDefault(defaultExport); const localSymbol = getLocalSymbolForExportDefault(defaultExport);
if (localSymbol && localSymbol.name === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) { if (localSymbol && localSymbol.escapedName === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) {
// check if this symbol is already used // check if this symbol is already used
const symbolId = getUniqueSymbolId(localSymbol); const symbolId = getUniqueSymbolId(localSymbol);
symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, name, /*isDefault*/ true)); symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, name, /*isDefault*/ true));

View file

@ -606,7 +606,7 @@ namespace ts.Completions {
if (symbol.flags & (SymbolFlags.Module | SymbolFlags.Enum)) { if (symbol.flags & (SymbolFlags.Module | SymbolFlags.Enum)) {
// Extract module or enum members // Extract module or enum members
const exportedSymbols = typeChecker.getExportsOfModule(symbol); const exportedSymbols = typeChecker.getExportsOfModule(symbol);
const isValidValueAccess = (symbol: Symbol) => typeChecker.isValidPropertyAccess(<PropertyAccessExpression>(node.parent), symbol.getUnescapedName()); const isValidValueAccess = (symbol: Symbol) => typeChecker.isValidPropertyAccess(<PropertyAccessExpression>(node.parent), symbol.name);
const isValidTypeAccess = (symbol: Symbol) => symbolCanBeReferencedAtTypeLocation(symbol); const isValidTypeAccess = (symbol: Symbol) => symbolCanBeReferencedAtTypeLocation(symbol);
const isValidAccess = isRhsOfImportDeclaration ? const isValidAccess = isRhsOfImportDeclaration ?
// Any kind is allowed when dotting off namespace in internal import equals declaration // Any kind is allowed when dotting off namespace in internal import equals declaration
@ -636,7 +636,7 @@ namespace ts.Completions {
function addTypeProperties(type: Type) { function addTypeProperties(type: Type) {
// Filter private properties // Filter private properties
for (const symbol of type.getApparentProperties()) { for (const symbol of type.getApparentProperties()) {
if (typeChecker.isValidPropertyAccess(<PropertyAccessExpression>(node.parent), symbol.getUnescapedName())) { if (typeChecker.isValidPropertyAccess(<PropertyAccessExpression>(node.parent), symbol.name)) {
symbols.push(symbol); symbols.push(symbol);
} }
} }
@ -1457,10 +1457,10 @@ namespace ts.Completions {
} }
if (existingImportsOrExports.size === 0) { if (existingImportsOrExports.size === 0) {
return filter(exportsOfModule, e => e.name !== "default"); return filter(exportsOfModule, e => e.escapedName !== "default");
} }
return filter(exportsOfModule, e => e.name !== "default" && !existingImportsOrExports.get(e.name)); return filter(exportsOfModule, e => e.escapedName !== "default" && !existingImportsOrExports.get(e.escapedName));
} }
/** /**
@ -1510,7 +1510,7 @@ namespace ts.Completions {
existingMemberNames.set(existingName, true); existingMemberNames.set(existingName, true);
} }
return filter(contextualMemberSymbols, m => !existingMemberNames.get(m.name)); return filter(contextualMemberSymbols, m => !existingMemberNames.get(m.escapedName));
} }
/** /**
@ -1571,7 +1571,7 @@ namespace ts.Completions {
} }
function isValidProperty(propertySymbol: Symbol, inValidModifierFlags: ModifierFlags) { function isValidProperty(propertySymbol: Symbol, inValidModifierFlags: ModifierFlags) {
return !existingMemberNames.get(propertySymbol.name) && return !existingMemberNames.get(propertySymbol.escapedName) &&
propertySymbol.getDeclarations() && propertySymbol.getDeclarations() &&
!(getDeclarationModifierFlagsFromSymbol(propertySymbol) & inValidModifierFlags); !(getDeclarationModifierFlagsFromSymbol(propertySymbol) & inValidModifierFlags);
} }
@ -1596,7 +1596,7 @@ namespace ts.Completions {
} }
} }
return filter(symbols, a => !seenNames.get(a.name)); return filter(symbols, a => !seenNames.get(a.escapedName));
} }
function isCurrentlyEditingNode(node: Node): boolean { function isCurrentlyEditingNode(node: Node): boolean {
@ -1610,7 +1610,7 @@ namespace ts.Completions {
* @return undefined if the name is of external module * @return undefined if the name is of external module
*/ */
function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean): string | undefined { function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean): string | undefined {
const name = symbol.getUnescapedName(); const name = symbol.name;
if (!name) return undefined; if (!name) return undefined;
// First check of the displayName is not external module; if it is an external module, it is not valid entry // First check of the displayName is not external module; if it is an external module, it is not valid entry

View file

@ -1417,7 +1417,7 @@ namespace ts.FindAllReferences.Core {
// Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members
if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.Parameter && if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.Parameter &&
isParameterPropertyDeclaration(<ParameterDeclaration>symbol.valueDeclaration)) { isParameterPropertyDeclaration(<ParameterDeclaration>symbol.valueDeclaration)) {
addRange(result, checker.getSymbolsOfParameterPropertyDeclaration(<ParameterDeclaration>symbol.valueDeclaration, symbol.getUnescapedName())); addRange(result, checker.getSymbolsOfParameterPropertyDeclaration(<ParameterDeclaration>symbol.valueDeclaration, symbol.name));
} }
// If this is symbol of binding element without propertyName declaration in Object binding pattern // If this is symbol of binding element without propertyName declaration in Object binding pattern
@ -1436,7 +1436,7 @@ namespace ts.FindAllReferences.Core {
// Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions
if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getUnescapedName(), result, /*previousIterationSymbolsCache*/ createSymbolTable(), checker); getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ createSymbolTable(), checker);
} }
} }
@ -1467,7 +1467,7 @@ namespace ts.FindAllReferences.Core {
// the function will add any found symbol of the property-name, then its sub-routine will call // the function will add any found symbol of the property-name, then its sub-routine will call
// getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already
// visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol.
if (previousIterationSymbolsCache.has(symbol.name)) { if (previousIterationSymbolsCache.has(symbol.escapedName)) {
return; return;
} }
@ -1494,7 +1494,7 @@ namespace ts.FindAllReferences.Core {
} }
// Visit the typeReference as well to see if it directly or indirectly use that property // Visit the typeReference as well to see if it directly or indirectly use that property
previousIterationSymbolsCache.set(symbol.name, symbol); previousIterationSymbolsCache.set(symbol.escapedName, symbol);
getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, checker); getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, checker);
} }
} }
@ -1554,7 +1554,7 @@ namespace ts.FindAllReferences.Core {
} }
const result: Symbol[] = []; const result: Symbol[] = [];
getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getUnescapedName(), result, /*previousIterationSymbolsCache*/ createSymbolTable(), state.checker); getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ createSymbolTable(), state.checker);
return find(result, search.includes); return find(result, search.includes);
} }

View file

@ -180,7 +180,7 @@ namespace ts.FindAllReferences {
* But re-exports will be placed in 'singleReferences' since they cannot be locally referenced. * But re-exports will be placed in 'singleReferences' since they cannot be locally referenced.
*/ */
function getSearchesFromDirectImports(directImports: Importer[], exportSymbol: Symbol, exportKind: ExportKind, checker: TypeChecker, isForRename: boolean): Pick<ImportsResult, "importSearches" | "singleReferences"> { function getSearchesFromDirectImports(directImports: Importer[], exportSymbol: Symbol, exportKind: ExportKind, checker: TypeChecker, isForRename: boolean): Pick<ImportsResult, "importSearches" | "singleReferences"> {
const exportName = exportSymbol.name; const exportName = exportSymbol.escapedName;
const importSearches: Array<[Identifier, Symbol]> = []; const importSearches: Array<[Identifier, Symbol]> = [];
const singleReferences: Identifier[] = []; const singleReferences: Identifier[] = [];
function addSearch(location: Identifier, symbol: Symbol): void { function addSearch(location: Identifier, symbol: Symbol): void {
@ -521,11 +521,11 @@ namespace ts.FindAllReferences {
// Search on the local symbol in the exporting module, not the exported symbol. // Search on the local symbol in the exporting module, not the exported symbol.
importedSymbol = skipExportSpecifierSymbol(importedSymbol, checker); importedSymbol = skipExportSpecifierSymbol(importedSymbol, checker);
// Similarly, skip past the symbol for 'export =' // Similarly, skip past the symbol for 'export ='
if (importedSymbol.name === "export=") { if (importedSymbol.escapedName === "export=") {
importedSymbol = getExportEqualsLocalSymbol(importedSymbol, checker); importedSymbol = getExportEqualsLocalSymbol(importedSymbol, checker);
} }
if (symbolName(importedSymbol) === symbol.name) { // If this is a rename import, do not continue searching. if (symbolName(importedSymbol) === symbol.escapedName) { // If this is a rename import, do not continue searching.
return { kind: ImportExport.Import, symbol: importedSymbol, ...isImport }; return { kind: ImportExport.Import, symbol: importedSymbol, ...isImport };
} }
} }
@ -595,8 +595,8 @@ namespace ts.FindAllReferences {
} }
function symbolName(symbol: Symbol): __String | undefined { function symbolName(symbol: Symbol): __String | undefined {
if (symbol.name !== "default") { if (symbol.escapedName !== "default") {
return symbol.getName(); return symbol.escapedName;
} }
return forEach(symbol.declarations, decl => { return forEach(symbol.declarations, decl => {

View file

@ -54,7 +54,7 @@ namespace ts.NavigateTo {
if (decl.kind === SyntaxKind.ImportClause || decl.kind === SyntaxKind.ImportSpecifier || decl.kind === SyntaxKind.ImportEqualsDeclaration) { if (decl.kind === SyntaxKind.ImportClause || decl.kind === SyntaxKind.ImportSpecifier || decl.kind === SyntaxKind.ImportEqualsDeclaration) {
const importer = checker.getSymbolAtLocation((decl as NamedDeclaration).name); const importer = checker.getSymbolAtLocation((decl as NamedDeclaration).name);
const imported = checker.getAliasedSymbol(importer); const imported = checker.getAliasedSymbol(importer);
return importer.name !== imported.name; return importer.escapedName !== imported.escapedName;
} }
else { else {
return true; return true;

View file

@ -239,7 +239,7 @@ namespace ts.Completions.PathCompletions {
const moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(directorySeparator)) : undefined; const moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(directorySeparator)) : undefined;
// Get modules that the type checker picked up // Get modules that the type checker picked up
const ambientModules = map(typeChecker.getAmbientModules(), sym => stripQuotes(sym.getUnescapedName())); const ambientModules = map(typeChecker.getAmbientModules(), sym => stripQuotes(sym.name));
let nonRelativeModuleNames = filter(ambientModules, moduleName => startsWith(moduleName, fragment)); let nonRelativeModuleNames = filter(ambientModules, moduleName => startsWith(moduleName, fragment));
// Nested modules of the form "module-name/sub" need to be adjusted to only return the string // Nested modules of the form "module-name/sub" need to be adjusted to only return the string

View file

@ -163,7 +163,7 @@ namespace ts.refactor {
deleteNode(nodeToDelete); deleteNode(nodeToDelete);
if (!assignmentBinaryExpression.right) { if (!assignmentBinaryExpression.right) {
return createProperty([], modifiers, symbol.getUnescapedName(), /*questionToken*/ undefined, return createProperty([], modifiers, symbol.name, /*questionToken*/ undefined,
/*type*/ undefined, /*initializer*/ undefined); /*type*/ undefined, /*initializer*/ undefined);
} }

View file

@ -304,7 +304,7 @@ namespace ts {
class SymbolObject implements Symbol { class SymbolObject implements Symbol {
flags: SymbolFlags; flags: SymbolFlags;
name: __String; escapedName: __String;
declarations?: Declaration[]; declarations?: Declaration[];
// Undefined is used to indicate the value has not been computed. If, after computing, the // Undefined is used to indicate the value has not been computed. If, after computing, the
@ -317,19 +317,23 @@ namespace ts {
constructor(flags: SymbolFlags, name: __String) { constructor(flags: SymbolFlags, name: __String) {
this.flags = flags; this.flags = flags;
this.name = name; this.escapedName = name;
} }
getFlags(): SymbolFlags { getFlags(): SymbolFlags {
return this.flags; return this.flags;
} }
getName(): __String { get name(): string {
return this.name; return unescapeLeadingUnderscores(this.escapedName);
} }
getUnescapedName(): string { getEscapedName(): __String {
return unescapeLeadingUnderscores(this.name); return this.escapedName;
}
getName(): string {
return this.name;
} }
getDeclarations(): Declaration[] | undefined { getDeclarations(): Declaration[] | undefined {

View file

@ -414,7 +414,7 @@ namespace ts.SignatureHelp {
typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation)); typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation));
return { return {
name: parameter.getUnescapedName(), name: parameter.name,
documentation: parameter.getDocumentationComment(), documentation: parameter.getDocumentationComment(),
displayParts, displayParts,
isOptional: typeChecker.isOptionalParameter(<ParameterDeclaration>parameter.valueDeclaration) isOptional: typeChecker.isOptionalParameter(<ParameterDeclaration>parameter.valueDeclaration)
@ -426,7 +426,7 @@ namespace ts.SignatureHelp {
typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation)); typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation));
return { return {
name: typeParameter.symbol.getUnescapedName(), name: typeParameter.symbol.name,
documentation: emptyArray, documentation: emptyArray,
displayParts, displayParts,
isOptional: false isOptional: false

View file

@ -27,9 +27,10 @@ namespace ts {
} }
export interface Symbol { export interface Symbol {
readonly name: string;
getFlags(): SymbolFlags; getFlags(): SymbolFlags;
getName(): __String; getEscapedName(): __String;
getUnescapedName(): string; getName(): string;
getDeclarations(): Declaration[] | undefined; getDeclarations(): Declaration[] | undefined;
getDocumentationComment(): SymbolDisplayPart[]; getDocumentationComment(): SymbolDisplayPart[];
getJsDocTags(): JSDocTagInfo[]; getJsDocTags(): JSDocTagInfo[];

View file

@ -1090,7 +1090,7 @@ namespace ts {
/** True if the symbol is for an external module, as opposed to a namespace. */ /** True if the symbol is for an external module, as opposed to a namespace. */
export function isExternalModuleSymbol(moduleSymbol: Symbol): boolean { export function isExternalModuleSymbol(moduleSymbol: Symbol): boolean {
Debug.assert(!!(moduleSymbol.flags & SymbolFlags.Module)); Debug.assert(!!(moduleSymbol.flags & SymbolFlags.Module));
return moduleSymbol.getUnescapedName().charCodeAt(0) === CharacterCodes.doubleQuote; return moduleSymbol.name.charCodeAt(0) === CharacterCodes.doubleQuote;
} }
/** Returns `true` the first time it encounters a node and `false` afterwards. */ /** Returns `true` the first time it encounters a node and `false` afterwards. */