@@ -853,6 +853,8 @@ type Checker struct {
853853 packagesMap map[string]bool
854854 activeMappers []*TypeMapper
855855 activeTypeMappersCaches []map[string]*Type
856+ ambientModulesOnce sync.Once
857+ ambientModules []*ast.Symbol
856858}
857859
858860func NewChecker(program Program) *Checker {
@@ -2085,7 +2087,7 @@ func (c *Checker) getSymbol(symbols ast.SymbolTable, name string, meaning ast.Sy
20852087}
20862088
20872089func (c *Checker) CheckSourceFile(ctx context.Context, sourceFile *ast.SourceFile) {
2088- if SkipTypeChecking(sourceFile, c.compilerOptions, c.program) {
2090+ if SkipTypeChecking(sourceFile, c.compilerOptions, c.program, false ) {
20892091 return
20902092 }
20912093 c.checkSourceFile(ctx, sourceFile)
@@ -10069,7 +10071,7 @@ func (c *Checker) checkCollisionWithRequireExportsInGeneratedCode(node *ast.Node
1006910071 parent := ast.GetDeclarationContainer(node)
1007010072 if ast.IsSourceFile(parent) && ast.IsExternalOrCommonJSModule(parent.AsSourceFile()) {
1007110073 // If the declaration happens to be in external module, report error that require and exports are reserved keywords
10072- c.error (name, diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, scanner.DeclarationNameToString(name), scanner.DeclarationNameToString(name))
10074+ c.errorSkippedOnNoEmit (name, diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, scanner.DeclarationNameToString(name), scanner.DeclarationNameToString(name))
1007310075 }
1007410076}
1007510077
@@ -13323,6 +13325,12 @@ func (c *Checker) error(location *ast.Node, message *diagnostics.Message, args .
1332313325 return diagnostic
1332413326}
1332513327
13328+ func (c *Checker) errorSkippedOnNoEmit(location *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic {
13329+ diagnostic := c.error(location, message, args...)
13330+ diagnostic.SetSkippedOnNoEmit()
13331+ return diagnostic
13332+ }
13333+
1332613334func (c *Checker) errorOrSuggestion(isError bool, location *ast.Node, message *diagnostics.Message, args ...any) {
1332713335 c.addErrorOrSuggestion(isError, NewDiagnosticForNode(location, message, args...))
1332813336}
@@ -14808,6 +14816,17 @@ func (c *Checker) tryFindAmbientModule(moduleName string, withAugmentations bool
1480814816 return symbol
1480914817}
1481014818
14819+ func (c *Checker) GetAmbientModules() []*ast.Symbol {
14820+ c.ambientModulesOnce.Do(func() {
14821+ for sym, global := range c.globals {
14822+ if strings.HasPrefix(sym, "\"") && strings.HasSuffix(sym, "\"") {
14823+ c.ambientModules = append(c.ambientModules, global)
14824+ }
14825+ }
14826+ })
14827+ return c.ambientModules
14828+ }
14829+
1481114830func (c *Checker) resolveExternalModuleSymbol(moduleSymbol *ast.Symbol, dontResolveAlias bool) *ast.Symbol {
1481214831 if moduleSymbol != nil {
1481314832 exportEquals := c.resolveSymbolEx(moduleSymbol.Exports[ast.InternalSymbolNameExportEquals], dontResolveAlias)
0 commit comments