(node: ImportDeclaration)
| 1160 | } |
| 1161 | |
| 1162 | private addImport(node: ImportDeclaration): void { |
| 1163 | const source = node.source.value; |
| 1164 | this.addSource(source, node); |
| 1165 | |
| 1166 | for (const specifier of node.specifiers) { |
| 1167 | const localName = specifier.local.name; |
| 1168 | if (this.scope.variables.has(localName) || this.importDescriptions.has(localName)) { |
| 1169 | this.error(logRedeclarationError(localName), specifier.local.start); |
| 1170 | } |
| 1171 | |
| 1172 | const name = |
| 1173 | node.phase === 'source' |
| 1174 | ? SOURCE_PHASE_IMPORT |
| 1175 | : specifier instanceof ImportDefaultSpecifier |
| 1176 | ? 'default' |
| 1177 | : specifier instanceof ImportNamespaceSpecifier |
| 1178 | ? '*' |
| 1179 | : specifier.imported instanceof Identifier |
| 1180 | ? specifier.imported.name |
| 1181 | : specifier.imported.value; |
| 1182 | this.importDescriptions.set(localName, { |
| 1183 | module: null as never, // filled in later |
| 1184 | name, |
| 1185 | phase: node.phase === 'source' ? 'source' : 'instance', |
| 1186 | source, |
| 1187 | start: specifier.start |
| 1188 | }); |
| 1189 | } |
| 1190 | } |
| 1191 | |
| 1192 | private addImportSource(importSource: string): void { |
| 1193 | if (importSource && !this.sourcesWithAttributes.has(importSource)) { |
no test coverage detected