()
| 87476 | return ts.getDeclarationOfKind(moduleSymbol, 305 /* SyntaxKind.SourceFile */); |
| 87477 | } |
| 87478 | function initializeTypeChecker() { |
| 87479 | // Bind all source files and propagate errors |
| 87480 | for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { |
| 87481 | var file = _a[_i]; |
| 87482 | ts.bindSourceFile(file, compilerOptions); |
| 87483 | } |
| 87484 | amalgamatedDuplicates = new ts.Map(); |
| 87485 | // Initialize global symbol table |
| 87486 | var augmentations; |
| 87487 | for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { |
| 87488 | var file = _c[_b]; |
| 87489 | if (file.redirectInfo) { |
| 87490 | continue; |
| 87491 | } |
| 87492 | if (!ts.isExternalOrCommonJsModule(file)) { |
| 87493 | // It is an error for a non-external-module (i.e. script) to declare its own `globalThis`. |
| 87494 | // We can't use `builtinGlobals` for this due to synthetic expando-namespace generation in JS files. |
| 87495 | var fileGlobalThisSymbol = file.locals.get("globalThis"); |
| 87496 | if (fileGlobalThisSymbol === null || fileGlobalThisSymbol === void 0 ? void 0 : fileGlobalThisSymbol.declarations) { |
| 87497 | for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) { |
| 87498 | var declaration = _e[_d]; |
| 87499 | diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis")); |
| 87500 | } |
| 87501 | } |
| 87502 | mergeSymbolTable(globals, file.locals); |
| 87503 | } |
| 87504 | if (file.jsGlobalAugmentations) { |
| 87505 | mergeSymbolTable(globals, file.jsGlobalAugmentations); |
| 87506 | } |
| 87507 | if (file.patternAmbientModules && file.patternAmbientModules.length) { |
| 87508 | patternAmbientModules = ts.concatenate(patternAmbientModules, file.patternAmbientModules); |
| 87509 | } |
| 87510 | if (file.moduleAugmentations.length) { |
| 87511 | (augmentations || (augmentations = [])).push(file.moduleAugmentations); |
| 87512 | } |
| 87513 | if (file.symbol && file.symbol.globalExports) { |
| 87514 | // Merge in UMD exports with first-in-wins semantics (see #9771) |
| 87515 | var source = file.symbol.globalExports; |
| 87516 | source.forEach(function (sourceSymbol, id) { |
| 87517 | if (!globals.has(id)) { |
| 87518 | globals.set(id, sourceSymbol); |
| 87519 | } |
| 87520 | }); |
| 87521 | } |
| 87522 | } |
| 87523 | // We do global augmentations separately from module augmentations (and before creating global types) because they |
| 87524 | // 1. Affect global types. We won't have the correct global types until global augmentations are merged. Also, |
| 87525 | // 2. Module augmentation instantiation requires creating the type of a module, which, in turn, can require |
| 87526 | // checking for an export or property on the module (if export=) which, in turn, can fall back to the |
| 87527 | // apparent type of the module - either globalObjectType or globalFunctionType - which wouldn't exist if we |
| 87528 | // did module augmentations prior to finalizing the global types. |
| 87529 | if (augmentations) { |
| 87530 | // merge _global_ module augmentations. |
| 87531 | // this needs to be done after global symbol table is initialized to make sure that all ambient modules are indexed |
| 87532 | for (var _f = 0, augmentations_1 = augmentations; _f < augmentations_1.length; _f++) { |
| 87533 | var list = augmentations_1[_f]; |
| 87534 | for (var _g = 0, list_1 = list; _g < list_1.length; _g++) { |
| 87535 | var augmentation = list_1[_g]; |
no test coverage detected
searching dependent graphs…