@@ -535,6 +535,7 @@ type Program interface {
535
535
GetSourceFileMetaData(path tspath.Path) *ast.SourceFileMetaData
536
536
GetJSXRuntimeImportSpecifier(path tspath.Path) (moduleReference string, specifier *ast.Node)
537
537
GetImportHelpersImportSpecifier(path tspath.Path) *ast.Node
538
+ SourceFileMayBeEmitted(sourceFile *ast.SourceFile, forceDtsEmit bool) bool
538
539
}
539
540
540
541
type Host interface {
@@ -14517,7 +14518,7 @@ func (c *Checker) resolveExternalModule(location *ast.Node, moduleReference stri
14517
14518
diagnostics.This_relative_import_path_is_unsafe_to_rewrite_because_it_looks_like_a_file_name_but_actually_resolves_to_0,
14518
14519
relativeToSourceFile,
14519
14520
)
14520
- } else if resolvedModule.ResolvedUsingTsExtension && !shouldRewrite && c.sourceFileMayBeEmitted (sourceFile) {
14521
+ } else if resolvedModule.ResolvedUsingTsExtension && !shouldRewrite && c.program.SourceFileMayBeEmitted (sourceFile, false ) {
14521
14522
c.error(
14522
14523
errorNode,
14523
14524
diagnostics.This_import_uses_a_0_extension_to_resolve_to_an_input_TypeScript_file_but_will_not_be_rewritten_during_emit_because_it_is_not_a_relative_path,
@@ -30408,24 +30409,4 @@ func (c *Checker) GetAliasedSymbol(symbol *ast.Symbol) *ast.Symbol {
30408
30409
return c.resolveAlias(symbol)
30409
30410
}
30410
30411
30411
- // sourceFileMayBeEmitted is a simplified version of the function in compiler/emitter.go
30412
- // that handles the basic checks needed for import rewrite diagnostics
30413
- func (c *Checker) sourceFileMayBeEmitted(sourceFile *ast.SourceFile) bool {
30414
- // Declaration files are not emitted
30415
- if sourceFile.IsDeclarationFile {
30416
- return false
30417
- }
30418
-
30419
- // Source file from node_modules are not emitted
30420
- if strings.Contains(sourceFile.FileName(), "/node_modules/") {
30421
- return false
30422
- }
30423
30412
30424
- // Any non json file should be emitted
30425
- if !ast.IsJsonSourceFile(sourceFile) {
30426
- return true
30427
- }
30428
-
30429
- // JSON files are generally not emitted
30430
- return false
30431
- }
0 commit comments