(sourceFile: ts.SourceFile)
| 558 | |
| 559 | function isFileAffectingGlobalScope(sourceFile: ts.SourceFile): boolean { |
| 560 | return ( |
| 561 | containsGlobalScopeAugmentation(sourceFile) || |
| 562 | (!isExternalOrCommonJsModule(sourceFile) && |
| 563 | !isJsonSourceFile(sourceFile) && |
| 564 | !containsOnlyAmbientModules(sourceFile)) |
| 565 | ); |
| 566 | } |
| 567 | |
| 568 | export function isNonModuleWithAmbiantDeclarations(sourceFile: ts.SourceFile): boolean { |
| 569 | const statements = sourceFile.statements; |
| 570 | |
| 571 | if (!statements.length) { |
| 572 | return false; |
| 573 | } |
| 574 | |
| 575 | let hasAmbiantModuleDeclarations = false; |
| 576 | let hasImport = false; |
| 577 | let hasExports = false; |
| 578 | |
| 579 | for (const statement of statements) { |
| 580 | const modifiers = ts.getCombinedModifierFlags(statement as unknown as ts.Declaration); |
| 581 | const isAmbiant = (modifiers & ts.ModifierFlags.Ambient) != 0; |
| 582 | const isExports = (modifiers & ts.ModifierFlags.Export) !== 0; |
| 583 | |
| 584 | if (isAmbiant) { |
| 585 | if (ts.isModuleDeclaration(statement) && ts.isStringLiteral(statement.name)) { |
| 586 | hasAmbiantModuleDeclarations = true; |
| 587 | } |
| 588 | } |
| 589 | if (isExports) { |
| 590 | hasExports = true; |
| 591 | } |
| 592 | |
| 593 | if (ts.isExportDeclaration(statement) || ts.isExportAssignment(statement)) { |
| 594 | hasExports = true; |
| 595 | } |
| 596 | |
| 597 | if (ts.isImportDeclaration(statement) || ts.isImportEqualsDeclaration(statement)) { |
| 598 | hasImport = true; |
no outgoing calls
no test coverage detected