* True if 'decl' provides a value, as in `function f() {}`; * false if 'decl' is just a location for a future write, as in 'let x;'
(decl)
| 137278 | * false if 'decl' is just a location for a future write, as in 'let x;' |
| 137279 | */ |
| 137280 | function declarationIsWriteAccess(decl) { |
| 137281 | // Consider anything in an ambient declaration to be a write access since it may be coming from JS. |
| 137282 | if (!!(decl.flags & 16777216 /* NodeFlags.Ambient */)) |
| 137283 | return true; |
| 137284 | switch (decl.kind) { |
| 137285 | case 221 /* SyntaxKind.BinaryExpression */: |
| 137286 | case 203 /* SyntaxKind.BindingElement */: |
| 137287 | case 257 /* SyntaxKind.ClassDeclaration */: |
| 137288 | case 226 /* SyntaxKind.ClassExpression */: |
| 137289 | case 88 /* SyntaxKind.DefaultKeyword */: |
| 137290 | case 260 /* SyntaxKind.EnumDeclaration */: |
| 137291 | case 299 /* SyntaxKind.EnumMember */: |
| 137292 | case 275 /* SyntaxKind.ExportSpecifier */: |
| 137293 | case 267 /* SyntaxKind.ImportClause */: // default import |
| 137294 | case 265 /* SyntaxKind.ImportEqualsDeclaration */: |
| 137295 | case 270 /* SyntaxKind.ImportSpecifier */: |
| 137296 | case 258 /* SyntaxKind.InterfaceDeclaration */: |
| 137297 | case 338 /* SyntaxKind.JSDocCallbackTag */: |
| 137298 | case 345 /* SyntaxKind.JSDocTypedefTag */: |
| 137299 | case 285 /* SyntaxKind.JsxAttribute */: |
| 137300 | case 261 /* SyntaxKind.ModuleDeclaration */: |
| 137301 | case 264 /* SyntaxKind.NamespaceExportDeclaration */: |
| 137302 | case 268 /* SyntaxKind.NamespaceImport */: |
| 137303 | case 274 /* SyntaxKind.NamespaceExport */: |
| 137304 | case 164 /* SyntaxKind.Parameter */: |
| 137305 | case 297 /* SyntaxKind.ShorthandPropertyAssignment */: |
| 137306 | case 259 /* SyntaxKind.TypeAliasDeclaration */: |
| 137307 | case 163 /* SyntaxKind.TypeParameter */: |
| 137308 | return true; |
| 137309 | case 296 /* SyntaxKind.PropertyAssignment */: |
| 137310 | // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) |
| 137311 | return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); |
| 137312 | case 256 /* SyntaxKind.FunctionDeclaration */: |
| 137313 | case 213 /* SyntaxKind.FunctionExpression */: |
| 137314 | case 171 /* SyntaxKind.Constructor */: |
| 137315 | case 169 /* SyntaxKind.MethodDeclaration */: |
| 137316 | case 172 /* SyntaxKind.GetAccessor */: |
| 137317 | case 173 /* SyntaxKind.SetAccessor */: |
| 137318 | return !!decl.body; |
| 137319 | case 254 /* SyntaxKind.VariableDeclaration */: |
| 137320 | case 167 /* SyntaxKind.PropertyDeclaration */: |
| 137321 | return !!decl.initializer || ts.isCatchClause(decl.parent); |
| 137322 | case 168 /* SyntaxKind.MethodSignature */: |
| 137323 | case 166 /* SyntaxKind.PropertySignature */: |
| 137324 | case 347 /* SyntaxKind.JSDocPropertyTag */: |
| 137325 | case 340 /* SyntaxKind.JSDocParameterTag */: |
| 137326 | return false; |
| 137327 | default: |
| 137328 | return ts.Debug.failBadSyntaxKind(decl); |
| 137329 | } |
| 137330 | } |
| 137331 | /** Encapsulates the core find-all-references algorithm. */ |
| 137332 | var Core; |
| 137333 | (function (Core) { |
no outgoing calls
no test coverage detected