@@ -14372,8 +14372,10 @@ namespace ts {
1437214372 const root = getReferenceRoot(node);
1437314373 const parent = root.parent;
1437414374 const isLengthPushOrUnshift = parent.kind === SyntaxKind.PropertyAccessExpression && (
14375- (<PropertyAccessExpression>parent).name.escapedText === "length" ||
14376- parent.parent.kind === SyntaxKind.CallExpression && isPushOrUnshiftIdentifier((<PropertyAccessExpression>parent).name));
14375+ (<PropertyAccessExpression>parent).name.escapedText === "length" || (
14376+ parent.parent.kind === SyntaxKind.CallExpression
14377+ && isIdentifier((parent as PropertyAccessExpression).name)
14378+ && isPushOrUnshiftIdentifier((parent as PropertyAccessExpression).name as Identifier)));
1437714379 const isElementAssignment = parent.kind === SyntaxKind.ElementAccessExpression &&
1437814380 (<ElementAccessExpression>parent).expression === root &&
1437914381 parent.parent.kind === SyntaxKind.BinaryExpression &&
@@ -17999,7 +18001,7 @@ namespace ts {
1799918001 return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right);
1800018002 }
1800118003
18002- function checkPropertyAccessExpressionOrQualifiedName(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, right: Identifier) {
18004+ function checkPropertyAccessExpressionOrQualifiedName(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, right: Identifier | PrivateName ) {
1800318005 let propType: Type;
1800418006 const leftType = checkNonNullExpression(left);
1800518007 const parentSymbol = getNodeLinks(left).resolvedSymbol;
@@ -18017,7 +18019,7 @@ namespace ts {
1801718019 }
1801818020 if (!prop) {
1801918021 const indexInfo = getIndexInfoOfType(apparentType, IndexKind.String);
18020- if (!(indexInfo && indexInfo.type)) {
18022+ if (!(indexInfo && indexInfo.type) || isPrivateName(right) ) {
1802118023 if (isJSLiteralType(leftType)) {
1802218024 return anyType;
1802318025 }
@@ -18075,7 +18077,7 @@ namespace ts {
1807518077 return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
1807618078 }
1807718079
18078- function checkPropertyNotUsedBeforeDeclaration(prop: Symbol, node: PropertyAccessExpression | QualifiedName, right: Identifier): void {
18080+ function checkPropertyNotUsedBeforeDeclaration(prop: Symbol, node: PropertyAccessExpression | QualifiedName, right: Identifier | PrivateName ): void {
1807918081 const { valueDeclaration } = prop;
1808018082 if (!valueDeclaration) {
1808118083 return;
@@ -18145,7 +18147,7 @@ namespace ts {
1814518147 return getIntersectionType(x);
1814618148 }
1814718149
18148- function reportNonexistentProperty(propNode: Identifier, containingType: Type) {
18150+ function reportNonexistentProperty(propNode: Identifier | PrivateName , containingType: Type) {
1814918151 let errorInfo: DiagnosticMessageChain | undefined;
1815018152 let relatedInfo: Diagnostic | undefined;
1815118153 if (containingType.flags & TypeFlags.Union && !(containingType.flags & TypeFlags.Primitive)) {
@@ -18188,11 +18190,11 @@ namespace ts {
1818818190 return prop !== undefined && prop.valueDeclaration && hasModifier(prop.valueDeclaration, ModifierFlags.Static);
1818918191 }
1819018192
18191- function getSuggestedSymbolForNonexistentProperty(name: Identifier | string, containingType: Type): Symbol | undefined {
18193+ function getSuggestedSymbolForNonexistentProperty(name: Identifier | PrivateName | string, containingType: Type): Symbol | undefined {
1819218194 return getSpellingSuggestionForName(isString(name) ? name : idText(name), getPropertiesOfType(containingType), SymbolFlags.Value);
1819318195 }
1819418196
18195- function getSuggestionForNonexistentProperty(name: Identifier | string, containingType: Type): string | undefined {
18197+ function getSuggestionForNonexistentProperty(name: Identifier | PrivateName | string, containingType: Type): string | undefined {
1819618198 const suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType);
1819718199 return suggestion && symbolName(suggestion);
1819818200 }
@@ -21909,6 +21911,9 @@ namespace ts {
2190921911 checkGrammarDecoratorsAndModifiers(node);
2191021912
2191121913 checkVariableLikeDeclaration(node);
21914+ if (node.name && isIdentifier(node.name) && node.name.originalKeywordKind === SyntaxKind.PrivateName) {
21915+ error(node, Diagnostics.Private_names_cannot_be_used_as_parameters);
21916+ }
2191221917 const func = getContainingFunction(node)!;
2191321918 if (hasModifier(node, ModifierFlags.ParameterPropertyModifier)) {
2191421919 if (!(func.kind === SyntaxKind.Constructor && nodeIsPresent(func.body))) {
@@ -23556,9 +23561,9 @@ namespace ts {
2355623561 }
2355723562 }
2355823563
23559- function getIdentifierFromEntityNameExpression(node: Identifier | PropertyAccessExpression): Identifier;
23560- function getIdentifierFromEntityNameExpression(node: Expression): Identifier | undefined;
23561- function getIdentifierFromEntityNameExpression(node: Expression): Identifier | undefined {
23564+ function getIdentifierFromEntityNameExpression(node: Identifier | PropertyAccessExpression): Identifier | PrivateName ;
23565+ function getIdentifierFromEntityNameExpression(node: Expression): Identifier | PrivateName | undefined;
23566+ function getIdentifierFromEntityNameExpression(node: Expression): Identifier | PrivateName | undefined {
2356223567 switch (node.kind) {
2356323568 case SyntaxKind.Identifier:
2356423569 return node as Identifier;
@@ -29322,6 +29327,10 @@ namespace ts {
2932229327 checkESModuleMarker(node.name);
2932329328 }
2932429329
29330+ if (isIdentifier(node.name) && node.name.originalKeywordKind === SyntaxKind.PrivateName) {
29331+ return grammarErrorOnNode(node.name, Diagnostics.Private_names_are_not_allowed_in_variable_declarations);
29332+ }
29333+
2932529334 const checkLetConstNames = (isLet(node) || isVarConst(node));
2932629335
2932729336 // 1. LexicalDeclaration : LetOrConst BindingList ;
0 commit comments