* True when `id` reads the binding it names as a value. False for a type * position (`typeof execFileSync`), and for an identifier that only names a * declaration or a member: `x.exec`, `{ exec: … }`, `const spawn = …`, the * import specifier itself. A re-export (`export { spawn }`) and a shortha
(id: ts.Identifier)
| 141 | * property (`{ spawn }`) DO read the value. |
| 142 | */ |
| 143 | function isValueReference(id: ts.Identifier): boolean { |
| 144 | for (let n: ts.Node | undefined = id.parent; n; n = n.parent) if (ts.isTypeNode(n)) return false; |
| 145 | const p = id.parent as ts.Node & { name?: ts.Node; propertyName?: ts.Node }; |
| 146 | if (ts.isShorthandPropertyAssignment(p) || ts.isExportSpecifier(p)) return true; |
| 147 | if (p.name === id || p.propertyName === id) return false; |
| 148 | if (ts.isQualifiedName(p) && p.right === id) return false; |
| 149 | return true; |
| 150 | } |
| 151 | |
| 152 | /** Variable initializer or function parameter that `name` refers to at `from`. */ |
| 153 | function resolveBinding(name: string, from: ts.Node): ts.VariableDeclaration | ts.ParameterDeclaration | null { |