(expr, symbol, assignmentKind)
| 78303 | ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); |
| 78304 | } |
| 78305 | function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { |
| 78306 | var _a, _b; |
| 78307 | if (assignmentKind === 0 /* AssignmentKind.None */) { |
| 78308 | // no assigment means it doesn't matter whether the entity is readonly |
| 78309 | return false; |
| 78310 | } |
| 78311 | if (isReadonlySymbol(symbol)) { |
| 78312 | // Allow assignments to readonly properties within constructors of the same class declaration. |
| 78313 | if (symbol.flags & 4 /* SymbolFlags.Property */ && |
| 78314 | ts.isAccessExpression(expr) && |
| 78315 | expr.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { |
| 78316 | // Look for if this is the constructor for the class that `symbol` is a property of. |
| 78317 | var ctor = ts.getContainingFunction(expr); |
| 78318 | if (!(ctor && (ctor.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(ctor)))) { |
| 78319 | return true; |
| 78320 | } |
| 78321 | if (symbol.valueDeclaration) { |
| 78322 | var isAssignmentDeclaration_1 = ts.isBinaryExpression(symbol.valueDeclaration); |
| 78323 | var isLocalPropertyDeclaration = ctor.parent === symbol.valueDeclaration.parent; |
| 78324 | var isLocalParameterProperty = ctor === symbol.valueDeclaration.parent; |
| 78325 | var isLocalThisPropertyAssignment = isAssignmentDeclaration_1 && ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) === ctor.parent; |
| 78326 | var isLocalThisPropertyAssignmentConstructorFunction = isAssignmentDeclaration_1 && ((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) === ctor; |
| 78327 | var isWriteableSymbol = isLocalPropertyDeclaration |
| 78328 | || isLocalParameterProperty |
| 78329 | || isLocalThisPropertyAssignment |
| 78330 | || isLocalThisPropertyAssignmentConstructorFunction; |
| 78331 | return !isWriteableSymbol; |
| 78332 | } |
| 78333 | } |
| 78334 | return true; |
| 78335 | } |
| 78336 | if (ts.isAccessExpression(expr)) { |
| 78337 | // references through namespace import should be readonly |
| 78338 | var node = ts.skipParentheses(expr.expression); |
| 78339 | if (node.kind === 79 /* SyntaxKind.Identifier */) { |
| 78340 | var symbol_2 = getNodeLinks(node).resolvedSymbol; |
| 78341 | if (symbol_2.flags & 2097152 /* SymbolFlags.Alias */) { |
| 78342 | var declaration = getDeclarationOfAliasSymbol(symbol_2); |
| 78343 | return !!declaration && declaration.kind === 268 /* SyntaxKind.NamespaceImport */; |
| 78344 | } |
| 78345 | } |
| 78346 | } |
| 78347 | return false; |
| 78348 | } |
| 78349 | function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { |
| 78350 | // References are combinations of identifiers, parentheses, and property accesses. |
| 78351 | var node = ts.skipOuterExpressions(expr, 6 /* OuterExpressionKinds.Assertions */ | 1 /* OuterExpressionKinds.Parentheses */); |
no test coverage detected
searching dependent graphs…