Skip to content

Build mode #1484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
1fada90
Add commandline --build parsing
sheetalkamat Jul 23, 2025
7ec429c
add help
sheetalkamat Aug 12, 2025
805a72e
Build order
sheetalkamat Jul 23, 2025
73b4c77
tsc -b
sheetalkamat Aug 6, 2025
7a4f78e
tsc --b commandline tests
sheetalkamat Aug 13, 2025
89f10c1
tsc --b --clean tests
sheetalkamat Aug 13, 2025
9de0c52
tsc -b config file errors tests
sheetalkamat Aug 13, 2025
f8f26ce
tsc composite tests
sheetalkamat Aug 13, 2025
965584e
tsc -b extends
sheetalkamat Aug 13, 2025
ef6ed6c
Include quotes of string literals of import in the file include reaso…
sheetalkamat Aug 15, 2025
5be7be4
tsc -b solution tests
sheetalkamat Aug 14, 2025
fb71b95
tsc -b and tsc -p declaration emit tests
sheetalkamat Aug 14, 2025
a44478d
emitdeclaration only tests
sheetalkamat Aug 14, 2025
a919b93
tsc -b file delete tests
sheetalkamat Aug 13, 2025
0c32645
tsc -b demo
sheetalkamat Aug 14, 2025
b44c79c
inferredTypeFromTransitiveModule tests
sheetalkamat Aug 13, 2025
99027c1
javascriptProjectEmit
sheetalkamat Aug 13, 2025
bc5b02c
lateBoundSymbol
sheetalkamat Aug 13, 2025
342ab47
tsc libraryResolution tests
sheetalkamat Aug 13, 2025
84cec7f
Store failed libResolution with --libReplacement so errors and trace …
sheetalkamat Aug 15, 2025
836c343
Dont do module resolution for lib.d.ts with --libReplacement as it wa…
sheetalkamat Aug 15, 2025
77e0872
Fix the text ranges for libRefrence and others
sheetalkamat Aug 15, 2025
6939296
tsc --listFilesOnly
sheetalkamat Aug 15, 2025
050885c
tsc module resolution
sheetalkamat Aug 15, 2025
44ad092
Use correct options for parsing paths
sheetalkamat Aug 15, 2025
e1ee69e
Use source file name to resolve module /type reference directive for …
sheetalkamat Aug 18, 2025
7c9fe75
tsc build module specifiers
sheetalkamat Aug 13, 2025
b05e45e
tsc --noCheck
sheetalkamat Aug 13, 2025
6e31cb1
Correct the noCheck error state encoding to work correctly with tsc -b
sheetalkamat Aug 15, 2025
e511fa4
tsc -b output paths
sheetalkamat Aug 16, 2025
bc7a3de
tsc project reference configs
sheetalkamat Aug 16, 2025
2b42497
Use correct config to check if its solution project before reporting …
sheetalkamat Aug 17, 2025
e09ab1b
projectReferenceWithRootDirInParent
sheetalkamat Aug 16, 2025
8c4ebd0
tsc -b resolvejsonmodule
sheetalkamat Aug 16, 2025
203631c
tsc -b roots
sheetalkamat Aug 16, 2025
9036604
tsc -b sample tests
sheetalkamat Aug 16, 2025
5b885d5
tsc -b transitive references
sheetalkamat Aug 17, 2025
263d4f8
tsc noEmitOnError
sheetalkamat Aug 16, 2025
d2376b2
Fix incorrect BuildInfoEmitSignature unmarshalling
sheetalkamat Aug 18, 2025
2e55292
tsc --noEmit
sheetalkamat Aug 16, 2025
4d34bc7
dts emit is pending when dts errors are pending, do not clean emit di…
sheetalkamat Aug 19, 2025
a3d8efc
Fix file explaining diagnostic when there is single reason and thats …
sheetalkamat Aug 19, 2025
5418093
Fix some feedback
sheetalkamat Aug 20, 2025
be1d83d
Move tests into two files tsc and tsbuild
sheetalkamat Aug 20, 2025
6aaebd7
Fix unnecessary *
sheetalkamat Aug 20, 2025
e3e5c8e
unmrshalling to report errors first
sheetalkamat Aug 20, 2025
7da98e2
Merge branch 'main' into buildMode
sheetalkamat Aug 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions internal/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"strconv"
"sync"
"time"

"github.com/go-json-experiment/json"
"github.com/microsoft/typescript-go/internal/bundled"
Expand Down Expand Up @@ -472,3 +473,8 @@ func (s *Server) Stat(path string) vfs.FileInfo {
func (s *Server) Remove(path string) error {
panic("unimplemented")
}

// Chtimes implements vfs.FS.
func (s *Server) Chtimes(path string, aTime time.Time, mTime time.Time) error {
panic("unimplemented")
}
7 changes: 7 additions & 0 deletions internal/bundled/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ func (vfs *wrappedFS) Remove(path string) error {
return vfs.fs.Remove(path)
}

func (vfs *wrappedFS) Chtimes(path string, aTime time.Time, mTime time.Time) error {
if _, ok := splitPath(path); ok {
panic("cannot change times on embedded file system")
}
return vfs.fs.Chtimes(path, aTime, mTime)
}

type fileInfo struct {
mode fs.FileMode
name string
Expand Down
10 changes: 5 additions & 5 deletions internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ type Program interface {
SourceFileMayBeEmitted(sourceFile *ast.SourceFile, forceDtsEmit bool) bool
IsSourceFromProjectReference(path tspath.Path) bool
IsSourceFileDefaultLibrary(path tspath.Path) bool
GetSourceAndProjectReference(path tspath.Path) *tsoptions.SourceAndProjectReference
GetProjectReferenceFromOutputDts(path tspath.Path) *tsoptions.SourceOutputAndProjectReference
GetRedirectForResolution(file ast.HasFileName) *tsoptions.ParsedCommandLine
CommonSourceDirectory() string
}
Expand Down Expand Up @@ -6483,7 +6483,7 @@ func (c *Checker) checkAliasSymbol(node *ast.Node) {
}
if c.compilerOptions.VerbatimModuleSyntax.IsTrue() && !ast.IsTypeOnlyImportOrExportDeclaration(node) && node.Flags&ast.NodeFlagsAmbient == 0 && targetFlags&ast.SymbolFlagsConstEnum != 0 {
constEnumDeclaration := target.ValueDeclaration
redirect := c.program.GetSourceAndProjectReference(ast.GetSourceFileOfNode(constEnumDeclaration).Path())
redirect := c.program.GetProjectReferenceFromOutputDts(ast.GetSourceFileOfNode(constEnumDeclaration).Path())
if constEnumDeclaration.Flags&ast.NodeFlagsAmbient != 0 && (redirect == nil || !redirect.Resolved.CompilerOptions().ShouldPreserveConstEnums()) {
c.error(node, diagnostics.Cannot_access_ambient_const_enums_when_0_is_enabled, c.getIsolatedModulesLikeFlagName())
}
Expand Down Expand Up @@ -7204,7 +7204,7 @@ func (c *Checker) checkConstEnumAccess(node *ast.Node, t *Type) {
if c.compilerOptions.IsolatedModules.IsTrue() || c.compilerOptions.VerbatimModuleSyntax.IsTrue() && ok && c.resolveName(node, ast.GetFirstIdentifier(node).Text(), ast.SymbolFlagsAlias, nil, false, true) == nil {
debug.Assert(t.symbol.Flags&ast.SymbolFlagsConstEnum != 0)
constEnumDeclaration := t.symbol.ValueDeclaration
redirect := c.program.GetSourceAndProjectReference(ast.GetSourceFileOfNode(constEnumDeclaration).Path())
redirect := c.program.GetProjectReferenceFromOutputDts(ast.GetSourceFileOfNode(constEnumDeclaration).Path())
if constEnumDeclaration.Flags&ast.NodeFlagsAmbient != 0 && !ast.IsValidTypeOnlyAliasUseSite(node) && (redirect == nil || !redirect.Resolved.CompilerOptions().ShouldPreserveConstEnums()) {
c.error(node, diagnostics.Cannot_access_ambient_const_enums_when_0_is_enabled, c.getIsolatedModulesLikeFlagName())
}
Expand Down Expand Up @@ -14636,7 +14636,7 @@ func (c *Checker) resolveExternalModule(location *ast.Node, moduleReference stri
}

var message *diagnostics.Message
if overrideHost != nil && overrideHost.Kind == ast.KindImportDeclaration && overrideHost.AsImportDeclaration().ImportClause.IsTypeOnly() {
if overrideHost != nil && overrideHost.Kind == ast.KindImportDeclaration && overrideHost.AsImportDeclaration().ImportClause != nil && overrideHost.AsImportDeclaration().ImportClause.IsTypeOnly() {
message = diagnostics.Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute
} else if overrideHost != nil && overrideHost.Kind == ast.KindImportType {
message = diagnostics.Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute
Expand Down Expand Up @@ -14689,7 +14689,7 @@ func (c *Checker) resolveExternalModule(location *ast.Node, moduleReference stri
if moduleNotFoundError != nil {
// See if this was possibly a projectReference redirect
if resolvedModule.IsResolved() {
redirect := c.program.GetOutputAndProjectReference(tspath.ToPath(resolvedModule.ResolvedFileName, c.program.GetCurrentDirectory(), c.program.UseCaseSensitiveFileNames()))
redirect := c.program.GetProjectReferenceFromSource(tspath.ToPath(resolvedModule.ResolvedFileName, c.program.GetCurrentDirectory(), c.program.UseCaseSensitiveFileNames()))
if redirect != nil && redirect.OutputDts != "" {
c.error(
errorNode,
Expand Down
7 changes: 6 additions & 1 deletion internal/collections/syncset.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ func (s *SyncSet[T]) Has(key T) bool {
return ok
}

func (s *SyncSet[T]) AddIfAbsent(key T) bool {
_, loaded := s.m.LoadOrStore(key, struct{}{})
return !loaded
}

func (s *SyncSet[T]) Add(key T) {
s.m.Store(key, struct{}{})
s.AddIfAbsent(key)
}

func (s *SyncSet[T]) Delete(key T) {
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler/emitHost.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func (host *emitHost) GetSourceOfProjectReferenceIfOutputIncluded(file ast.HasFi
return host.program.GetSourceOfProjectReferenceIfOutputIncluded(file)
}

func (host *emitHost) GetOutputAndProjectReference(path tspath.Path) *tsoptions.OutputDtsAndProjectReference {
return host.program.GetOutputAndProjectReference(path)
func (host *emitHost) GetProjectReferenceFromSource(path tspath.Path) *tsoptions.SourceOutputAndProjectReference {
return host.program.GetProjectReferenceFromSource(path)
}

func (host *emitHost) GetRedirectTargets(path tspath.Path) []string {
Expand Down
11 changes: 4 additions & 7 deletions internal/compiler/emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ type emitter struct {
}

func (e *emitter) emit() {
if e.host.Options().ListEmittedFiles.IsTrue() {
e.emitResult.EmittedFiles = []string{}
}
// !!! tracing
e.emitJSFile(e.sourceFile, e.paths.JsFilePath(), e.paths.SourceMapFilePath())
e.emitDeclarationFile(e.sourceFile, e.paths.DeclarationFilePath(), e.paths.DeclarationMapPath())
Expand Down Expand Up @@ -268,7 +265,7 @@ func (e *emitter) printSourceFile(jsFilePath string, sourceMapFilePath string, s
err := e.host.WriteFile(sourceMapFilePath, sourceMap, false /*writeByteOrderMark*/)
if err != nil {
e.emitterDiagnostics.Add(ast.NewCompilerDiagnostic(diagnostics.Could_not_write_file_0_Colon_1, jsFilePath, err.Error()))
} else if e.emitResult.EmittedFiles != nil {
} else {
e.emitResult.EmittedFiles = append(e.emitResult.EmittedFiles, sourceMapFilePath)
}
}
Expand All @@ -292,7 +289,7 @@ func (e *emitter) printSourceFile(jsFilePath string, sourceMapFilePath string, s
}
if err != nil {
e.emitterDiagnostics.Add(ast.NewCompilerDiagnostic(diagnostics.Could_not_write_file_0_Colon_1, jsFilePath, err.Error()))
} else if e.emitResult.EmittedFiles != nil && !skippedDtsWrite {
} else if !skippedDtsWrite {
e.emitResult.EmittedFiles = append(e.emitResult.EmittedFiles, jsFilePath)
}

Expand Down Expand Up @@ -391,7 +388,7 @@ func (e *emitter) getSourceMappingURL(mapOptions *core.CompilerOptions, sourceMa

type SourceFileMayBeEmittedHost interface {
Options() *core.CompilerOptions
GetOutputAndProjectReference(path tspath.Path) *tsoptions.OutputDtsAndProjectReference
GetProjectReferenceFromSource(path tspath.Path) *tsoptions.SourceOutputAndProjectReference
IsSourceFileFromExternalLibrary(file *ast.SourceFile) bool
GetCurrentDirectory() string
UseCaseSensitiveFileNames() bool
Expand Down Expand Up @@ -424,7 +421,7 @@ func sourceFileMayBeEmitted(sourceFile *ast.SourceFile, host SourceFileMayBeEmit

// Check other conditions for file emit
// Source files from referenced projects are not emitted
if host.GetOutputAndProjectReference(sourceFile.Path()) != nil {
if host.GetProjectReferenceFromSource(sourceFile.Path()) != nil {
return false
}

Expand Down
7 changes: 6 additions & 1 deletion internal/compiler/fileInclude.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/microsoft/typescript-go/internal/core"
"github.com/microsoft/typescript-go/internal/diagnostics"
"github.com/microsoft/typescript-go/internal/module"
"github.com/microsoft/typescript-go/internal/scanner"
"github.com/microsoft/typescript-go/internal/tsoptions"
"github.com/microsoft/typescript-go/internal/tspath"
)
Expand Down Expand Up @@ -57,7 +58,11 @@ type referenceFileLocation struct {

func (r *referenceFileLocation) text() string {
if r.node != nil {
return r.node.Text()
if !ast.NodeIsSynthesized(r.node) {
return r.file.Text()[scanner.SkipTrivia(r.file.Text(), r.node.Loc.Pos()):r.node.End()]
} else {
return fmt.Sprintf(`"%s"`, r.node.Text())
}
} else {
return r.file.Text()[r.ref.Pos():r.ref.End()]
}
Expand Down
27 changes: 15 additions & 12 deletions internal/compiler/fileloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ func processAllProgramFiles(

filesByPath := make(map[tspath.Path]*ast.SourceFile, totalFileCount)
loader.includeProcessor.fileIncludeReasons = make(map[tspath.Path][]*fileIncludeReason, totalFileCount)
outputFileToProjectReferenceSource := make(map[tspath.Path]string, totalFileCount)
var outputFileToProjectReferenceSource map[tspath.Path]string
if !opts.canUseProjectReferenceSource() {
outputFileToProjectReferenceSource = make(map[tspath.Path]string, totalFileCount)
}
resolvedModules := make(map[tspath.Path]module.ModeAwareCache[*module.ResolvedModule], totalFileCount+1)
typeResolutionsInFile := make(map[tspath.Path]module.ModeAwareCache[*module.ResolvedTypeReferenceDirective], totalFileCount)
sourceFileMetaDatas := make(map[tspath.Path]ast.SourceFileMetaData, totalFileCount)
Expand Down Expand Up @@ -454,9 +457,9 @@ func (p *fileLoader) resolveTypeReferenceDirectives(t *parseTask) {
typeResolutionsInFile := make(module.ModeAwareCache[*module.ResolvedTypeReferenceDirective], len(file.TypeReferenceDirectives))
var typeResolutionsTrace []string
for index, ref := range file.TypeReferenceDirectives {
redirect := p.projectReferenceFileMapper.getRedirectForResolution(file)
redirect, fileName := p.projectReferenceFileMapper.getRedirectForResolution(file)
resolutionMode := getModeForTypeReferenceDirectiveInFile(ref, file, meta, module.GetCompilerOptionsWithRedirect(p.opts.Config.CompilerOptions(), redirect))
resolved, trace := p.resolver.ResolveTypeReferenceDirective(ref.FileName, file.FileName(), resolutionMode, redirect)
resolved, trace := p.resolver.ResolveTypeReferenceDirective(ref.FileName, fileName, resolutionMode, redirect)
typeResolutionsInFile[module.ModeAwareCacheKey{Name: ref.FileName, Mode: resolutionMode}] = resolved
includeReason := &fileIncludeReason{
kind: fileIncludeKindTypeReferenceDirective,
Expand Down Expand Up @@ -498,7 +501,7 @@ func (p *fileLoader) resolveImportsAndModuleAugmentations(t *parseTask) {
isJavaScriptFile := ast.IsSourceFileJS(file)
isExternalModuleFile := ast.IsExternalModule(file)

redirect := p.projectReferenceFileMapper.getRedirectForResolution(file)
redirect, fileName := p.projectReferenceFileMapper.getRedirectForResolution(file)
optionsForFile := module.GetCompilerOptionsWithRedirect(p.opts.Config.CompilerOptions(), redirect)
if isJavaScriptFile || (!file.IsDeclarationFile && (optionsForFile.GetIsolatedModules() || isExternalModuleFile)) {
if optionsForFile.ImportHelpers.IsTrue() {
Expand Down Expand Up @@ -539,7 +542,7 @@ func (p *fileLoader) resolveImportsAndModuleAugmentations(t *parseTask) {
}

mode := getModeForUsageLocation(file.FileName(), meta, entry, optionsForFile)
resolvedModule, trace := p.resolver.ResolveModuleName(moduleName, file.FileName(), mode, redirect)
resolvedModule, trace := p.resolver.ResolveModuleName(moduleName, fileName, mode, redirect)
resolutionsInFile[module.ModeAwareCacheKey{Name: moduleName, Mode: mode}] = resolvedModule
resolutionsTrace = append(resolutionsTrace, trace...)

Expand All @@ -550,7 +553,7 @@ func (p *fileLoader) resolveImportsAndModuleAugmentations(t *parseTask) {
resolvedFileName := resolvedModule.ResolvedFileName
isFromNodeModulesSearch := resolvedModule.IsExternalLibraryImport
// Don't treat redirected files as JS files.
isJsFile := !tspath.FileExtensionIsOneOf(resolvedFileName, tspath.SupportedTSExtensionsWithJsonFlat) && p.projectReferenceFileMapper.getRedirectForResolution(ast.NewHasFileName(resolvedFileName, p.toPath(resolvedFileName))) == nil
isJsFile := !tspath.FileExtensionIsOneOf(resolvedFileName, tspath.SupportedTSExtensionsWithJsonFlat) && p.projectReferenceFileMapper.getRedirectParsedCommandLineForResolution(ast.NewHasFileName(resolvedFileName, p.toPath(resolvedFileName))) == nil
isJsFileFromNodeModules := isFromNodeModulesSearch && isJsFile && strings.Contains(resolvedFileName, "/node_modules/")

// add file to program only if:
Expand Down Expand Up @@ -610,19 +613,19 @@ func (p *fileLoader) pathForLibFile(name string) *LibFile {

path := tspath.CombinePaths(p.defaultLibraryPath, name)
replaced := false
if p.opts.Config.CompilerOptions().LibReplacement.IsTrue() {
if p.opts.Config.CompilerOptions().LibReplacement.IsTrue() && name != "lib.d.ts" {
libraryName := getLibraryNameFromLibFileName(name)
resolveFrom := getInferredLibraryNameResolveFrom(p.opts.Config.CompilerOptions(), p.opts.Host.GetCurrentDirectory(), name)
resolution, trace := p.resolver.ResolveModuleName(libraryName, resolveFrom, core.ModuleKindCommonJS, nil)
if resolution.IsResolved() {
path = resolution.ResolvedFileName
replaced = true
p.pathForLibFileResolutions.LoadOrStore(p.toPath(resolveFrom), &libResolution{
libraryName: libraryName,
resolution: resolution,
trace: trace,
})
}
p.pathForLibFileResolutions.LoadOrStore(p.toPath(resolveFrom), &libResolution{
libraryName: libraryName,
resolution: resolution,
trace: trace,
})
}

libPath, _ := p.pathForLibFileCache.LoadOrStore(name, &LibFile{name, path, replaced})
Expand Down
11 changes: 6 additions & 5 deletions internal/compiler/processingDiagnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (d *processingDiagnostic) toDiagnostic(program *Program) *ast.Diagnostic {

func (d *processingDiagnostic) createDiagnosticExplainingFile(program *Program) *ast.Diagnostic {
diag := d.asIncludeExplainingDiagnostic()
var chain []*ast.Diagnostic
var includeDetails []*ast.Diagnostic
var relatedInfo []*ast.Diagnostic
var redirectInfo []*ast.Diagnostic
var preferredLocation *fileIncludeReason
Expand All @@ -90,15 +90,15 @@ func (d *processingDiagnostic) createDiagnosticExplainingFile(program *Program)
if !seenReasons.AddIfAbsent(includeReason) {
return
}
chain = append(chain, includeReason.toDiagnostic(program, false))
includeDetails = append(includeDetails, includeReason.toDiagnostic(program, false))
processRelatedInfo(includeReason)
}

// !!! todo sheetal caching

if diag.file != "" {
reasons := program.includeProcessor.fileIncludeReasons[diag.file]
chain = make([]*ast.Diagnostic, 0, len(reasons))
includeDetails = make([]*ast.Diagnostic, 0, len(reasons))
for _, reason := range reasons {
processInclude(reason)
}
Expand All @@ -107,9 +107,10 @@ func (d *processingDiagnostic) createDiagnosticExplainingFile(program *Program)
if diag.diagnosticReason != nil {
processInclude(diag.diagnosticReason)
}
if chain != nil && (preferredLocation == nil || seenReasons.Len() != 1) {
var chain []*ast.Diagnostic
if includeDetails != nil && (preferredLocation == nil || seenReasons.Len() != 1) {
fileReason := ast.NewCompilerDiagnostic(diagnostics.The_file_is_in_the_program_because_Colon)
fileReason.SetMessageChain(chain)
fileReason.SetMessageChain(includeDetails)
chain = []*ast.Diagnostic{fileReason}
}
if redirectInfo != nil {
Expand Down
29 changes: 14 additions & 15 deletions internal/compiler/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,26 +113,27 @@ func (p *Program) GetSourceOfProjectReferenceIfOutputIncluded(file ast.HasFileNa
return file.FileName()
}

// GetOutputAndProjectReference implements checker.Program.
func (p *Program) GetOutputAndProjectReference(path tspath.Path) *tsoptions.OutputDtsAndProjectReference {
return p.projectReferenceFileMapper.getOutputAndProjectReference(path)
// GetProjectReferenceFromSource implements checker.Program.
func (p *Program) GetProjectReferenceFromSource(path tspath.Path) *tsoptions.SourceOutputAndProjectReference {
return p.projectReferenceFileMapper.getProjectReferenceFromSource(path)
}

// IsSourceFromProjectReference implements checker.Program.
func (p *Program) IsSourceFromProjectReference(path tspath.Path) bool {
return p.projectReferenceFileMapper.isSourceFromProjectReference(path)
}

func (p *Program) GetSourceAndProjectReference(path tspath.Path) *tsoptions.SourceAndProjectReference {
return p.projectReferenceFileMapper.getSourceAndProjectReference(path)
func (p *Program) GetProjectReferenceFromOutputDts(path tspath.Path) *tsoptions.SourceOutputAndProjectReference {
return p.projectReferenceFileMapper.getProjectReferenceFromOutputDts(path)
}

func (p *Program) GetResolvedProjectReferenceFor(path tspath.Path) (*tsoptions.ParsedCommandLine, bool) {
return p.projectReferenceFileMapper.getResolvedReferenceFor(path)
}

func (p *Program) GetRedirectForResolution(file ast.HasFileName) *tsoptions.ParsedCommandLine {
return p.projectReferenceFileMapper.getRedirectForResolution(file)
redirect, _ := p.projectReferenceFileMapper.getRedirectForResolution(file)
return redirect
}

func (p *Program) GetParseFileRedirect(fileName string) string {
Expand Down Expand Up @@ -270,6 +271,7 @@ func equalCheckJSDirectives(d1 *ast.CheckJsDirective, d2 *ast.CheckJsDirective)

func (p *Program) SourceFiles() []*ast.SourceFile { return p.files }
func (p *Program) Options() *core.CompilerOptions { return p.opts.Config.CompilerOptions() }
func (p *Program) GetRootFileNames() []string { return p.opts.Config.FileNames() }
func (p *Program) Host() CompilerHost { return p.opts.Host }
func (p *Program) GetConfigFileParsingDiagnostics() []*ast.Diagnostic {
return slices.Clip(p.opts.Config.GetConfigFileParsingDiagnostics())
Expand Down Expand Up @@ -862,7 +864,7 @@ func (p *Program) verifyProjectReferences() {
}
refOptions := config.CompilerOptions()
if !refOptions.Composite.IsTrue() || refOptions.NoEmit.IsTrue() {
if len(config.FileNames()) > 0 {
if len(p.opts.Config.FileNames()) > 0 {
if !refOptions.Composite.IsTrue() {
createDiagnosticForReference(parent, index, diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.Path)
}
Expand Down Expand Up @@ -1268,11 +1270,10 @@ func (p *Program) CommonSourceDirectory() string {
}

type WriteFileData struct {
SourceMapUrlPos int
BuildInfo any
Diagnostics []*ast.Diagnostic
DiffersOnlyInMap bool
SkippedDtsWrite bool
SourceMapUrlPos int
BuildInfo any
Diagnostics []*ast.Diagnostic
SkippedDtsWrite bool
}

type EmitOptions struct {
Expand Down Expand Up @@ -1364,9 +1365,7 @@ func CombineEmitResults(results []*EmitResult) *EmitResult {
result.EmitSkipped = true
}
result.Diagnostics = append(result.Diagnostics, emitResult.Diagnostics...)
if emitResult.EmittedFiles != nil {
result.EmittedFiles = append(result.EmittedFiles, emitResult.EmittedFiles...)
}
result.EmittedFiles = append(result.EmittedFiles, emitResult.EmittedFiles...)
if emitResult.SourceMaps != nil {
result.SourceMaps = append(result.SourceMaps, emitResult.SourceMaps...)
}
Expand Down
8 changes: 7 additions & 1 deletion internal/compiler/projectreferencedtsfakinghost.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package compiler

import (
"strings"
"time"

"github.com/microsoft/typescript-go/internal/collections"
"github.com/microsoft/typescript-go/internal/core"
Expand Down Expand Up @@ -82,6 +83,11 @@ func (fs *projectReferenceDtsFakingVfs) Remove(path string) error {
panic("should not be called by resolver")
}

// Chtimes implements vfs.FS.
func (fs *projectReferenceDtsFakingVfs) Chtimes(path string, aTime time.Time, mTime time.Time) error {
panic("should not be called by resolver")
}

// DirectoryExists implements vfs.FS.
func (fs *projectReferenceDtsFakingVfs) DirectoryExists(path string) bool {
if fs.projectReferenceFileMapper.opts.Host.FS().DirectoryExists(path) {
Expand Down Expand Up @@ -197,7 +203,7 @@ func (fs *projectReferenceDtsFakingVfs) fileOrDirectoryExistsUsingSource(fileOrD
}

func (fs *projectReferenceDtsFakingVfs) fileExistsIfProjectReferenceDts(file string) core.Tristate {
source := fs.projectReferenceFileMapper.getSourceAndProjectReference(fs.toPath(file))
source := fs.projectReferenceFileMapper.getProjectReferenceFromOutputDts(fs.toPath(file))
if source != nil {
return core.IfElse(fs.projectReferenceFileMapper.opts.Host.FS().FileExists(source.Source), core.TSTrue, core.TSFalse)
}
Expand Down
Loading
Loading