(program: Program)
| 74 | isCommonJs = false |
| 75 | |
| 76 | constructor(program: Program) { |
| 77 | this.root = this.scope = createScope(program, undefined) |
| 78 | this.byNode.set(program, this.root) |
| 79 | for (const statement of program.body) this.visit(statement, program) |
| 80 | this.close() |
| 81 | for (const reference of this.references) { |
| 82 | if (reference.binding && reference.isWrite) |
| 83 | reference.binding.writes.push(reference.id) |
| 84 | } |
| 85 | if ( |
| 86 | !program.body.some(statement => statement.type in moduleSyntaxKinds) && |
| 87 | this.root.unresolved.some(({ id }) => id.name in commonJsGlobals) |
| 88 | ) { |
| 89 | this.isCommonJs = true |
| 90 | this.readCommonJs(program) |
| 91 | } |
| 92 | for (const name in this.exportsByName) { |
| 93 | const entry = this.exportsByName[name] |
| 94 | if (entry.kind === "binding") entry.binding.exportNames.push(name) |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // what tsc writes for a module's exports where it emits CommonJS, read as |
| 99 | // the declarations they were: `exports.a = value`, `__exportStar( |
nothing calls this directly
no test coverage detected