(node)
| 47205 | declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* SymbolFlags.Alias */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); |
| 47206 | } |
| 47207 | function bindThisPropertyAssignment(node) { |
| 47208 | ts.Debug.assert(ts.isInJSFile(node)); |
| 47209 | // private identifiers *must* be declared (even in JS files) |
| 47210 | var hasPrivateIdentifier = (ts.isBinaryExpression(node) && ts.isPropertyAccessExpression(node.left) && ts.isPrivateIdentifier(node.left.name)) |
| 47211 | || (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)); |
| 47212 | if (hasPrivateIdentifier) { |
| 47213 | return; |
| 47214 | } |
| 47215 | var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); |
| 47216 | switch (thisContainer.kind) { |
| 47217 | case 256 /* SyntaxKind.FunctionDeclaration */: |
| 47218 | case 213 /* SyntaxKind.FunctionExpression */: |
| 47219 | var constructorSymbol = thisContainer.symbol; |
| 47220 | // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. |
| 47221 | if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { |
| 47222 | var l = thisContainer.parent.left; |
| 47223 | if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { |
| 47224 | constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); |
| 47225 | } |
| 47226 | } |
| 47227 | if (constructorSymbol && constructorSymbol.valueDeclaration) { |
| 47228 | // Declare a 'member' if the container is an ES5 class or ES6 constructor |
| 47229 | constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); |
| 47230 | // It's acceptable for multiple 'this' assignments of the same identifier to occur |
| 47231 | if (ts.hasDynamicName(node)) { |
| 47232 | bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members); |
| 47233 | } |
| 47234 | else { |
| 47235 | declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.PropertyExcludes */ & ~4 /* SymbolFlags.Property */); |
| 47236 | } |
| 47237 | addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); |
| 47238 | } |
| 47239 | break; |
| 47240 | case 171 /* SyntaxKind.Constructor */: |
| 47241 | case 167 /* SyntaxKind.PropertyDeclaration */: |
| 47242 | case 169 /* SyntaxKind.MethodDeclaration */: |
| 47243 | case 172 /* SyntaxKind.GetAccessor */: |
| 47244 | case 173 /* SyntaxKind.SetAccessor */: |
| 47245 | case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: |
| 47246 | // this.foo assignment in a JavaScript class |
| 47247 | // Bind this property to the containing class |
| 47248 | var containingClass = thisContainer.parent; |
| 47249 | var symbolTable = ts.isStatic(thisContainer) ? containingClass.symbol.exports : containingClass.symbol.members; |
| 47250 | if (ts.hasDynamicName(node)) { |
| 47251 | bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable); |
| 47252 | } |
| 47253 | else { |
| 47254 | declareSymbol(symbolTable, containingClass.symbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true); |
| 47255 | } |
| 47256 | break; |
| 47257 | case 305 /* SyntaxKind.SourceFile */: |
| 47258 | // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script |
| 47259 | if (ts.hasDynamicName(node)) { |
| 47260 | break; |
| 47261 | } |
| 47262 | else if (thisContainer.commonJsModuleIndicator) { |
| 47263 | declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */, 0 /* SymbolFlags.None */); |
| 47264 | } |
no test coverage detected