( node: Node, pattern: Node, kind: KindBits, module: SourceModule, kindOfKey: KindOfKey, source?: Located )
| 3603 | } |
| 3604 | |
| 3605 | private patternKindOf( |
| 3606 | node: Node, |
| 3607 | pattern: Node, |
| 3608 | kind: KindBits, |
| 3609 | module: SourceModule, |
| 3610 | kindOfKey: KindOfKey, |
| 3611 | source?: Located |
| 3612 | ): KindBits { |
| 3613 | if (node === pattern) return kind |
| 3614 | const parent = node.parent! |
| 3615 | const isRest = parent.type === "RestElement" |
| 3616 | const owner = isRest ? parent.parent! : parent |
| 3617 | // e.g. `type(...)` for `user` in `const { user } = { user: type(...) }` |
| 3618 | const held = |
| 3619 | source && |
| 3620 | parent.type !== "AssignmentPattern" && |
| 3621 | this.destructuredValueOf( |
| 3622 | owner.type === "Property" ? owner.parent! : owner, |
| 3623 | pattern, |
| 3624 | source |
| 3625 | ) |
| 3626 | const literal = |
| 3627 | held && this.literalOf(held.node, held.module, held.kindOfKey) |
| 3628 | if (literal) { |
| 3629 | const value = |
| 3630 | isRest ? undefined : this.valueIn(literal, keyIn(owner, node)) |
| 3631 | return value ? |
| 3632 | this.transfer(value.node, value.module, value.kindOfKey) |
| 3633 | : kinds.data | |
| 3634 | (value === null ? 0 : this.heldKindOf(literal)) | |
| 3635 | unsureOf(kind) |
| 3636 | } |
| 3637 | // e.g. `User` in `const { User } = S`, with `S` a namespace import |
| 3638 | const exported = |
| 3639 | held && |
| 3640 | parent.type === "Property" && |
| 3641 | this.namespaceExportOf(held.node, keyNameOf(parent), held.module) |
| 3642 | if (exported) return this.targetKindOf(exported, held.kindOfKey) |
| 3643 | const alias = |
| 3644 | held && parent.type === "Property" ? |
| 3645 | this.aliasKindOf( |
| 3646 | held.node, |
| 3647 | keyNameOf(parent), |
| 3648 | held.module, |
| 3649 | held.kindOfKey |
| 3650 | ) |
| 3651 | : undefined |
| 3652 | if (alias !== undefined) return alias |
| 3653 | switch (parent.type) { |
| 3654 | case "Property": |
| 3655 | return memberKindOf( |
| 3656 | this.patternKindOf( |
| 3657 | parent.parent!, |
| 3658 | pattern, |
| 3659 | kind, |
| 3660 | module, |
| 3661 | kindOfKey, |
| 3662 | source |
no test coverage detected