( binding: Binding, module: SourceModule, kindOfKey: KindOfKey, seen: Set<Node> )
| 4666 | } |
| 4667 | |
| 4668 | private bindingLiteralOf( |
| 4669 | binding: Binding, |
| 4670 | module: SourceModule, |
| 4671 | kindOfKey: KindOfKey, |
| 4672 | seen: Set<Node> |
| 4673 | ): Located | undefined { |
| 4674 | if (binding.kind === "import") { |
| 4675 | return this.targetLiteralOf( |
| 4676 | this.importOf(binding, module), |
| 4677 | kindOfKey, |
| 4678 | seen |
| 4679 | ) |
| 4680 | } |
| 4681 | const declaration = binding.declaration |
| 4682 | // a literal the program writes holds what the build can't tell |
| 4683 | if (binding.writes.length || this.writesThrough(binding, module).length) |
| 4684 | return |
| 4685 | if (binding.kind === "class") |
| 4686 | return { node: declaration, module, kindOfKey } |
| 4687 | if ( |
| 4688 | binding.kind !== "const" || |
| 4689 | declaration.type !== "VariableDeclarator" || |
| 4690 | !declaration.init |
| 4691 | ) |
| 4692 | return |
| 4693 | // e.g. `{ User }` for `users` in `const { users } = { users: { User } }` |
| 4694 | const held = this.destructuredValueOf( |
| 4695 | binding.id, |
| 4696 | declaration.id, |
| 4697 | { node: declaration.init, module, kindOfKey }, |
| 4698 | seen |
| 4699 | ) |
| 4700 | return held ? |
| 4701 | this.literalOf(held.node, held.module, held.kindOfKey, seen) |
| 4702 | : undefined |
| 4703 | } |
| 4704 | |
| 4705 | private targetLiteralOf( |
| 4706 | target: ImportTarget, |
no test coverage detected