Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tsc/internal/execute/incremental/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,23 @@ func (p *Program) GetProgram() *compiler.Program {
return p.program
}

func (p *Program) ForEachEmittedDeclarationFile(action func(tspath.RootedFilePath, *ast.SourceFile)) {
p.panicIfNoProgram("ForEachEmittedDeclarationFile")
if p.Options().NoEmit.IsTrue() {
return
}
p.snapshot.emitSignatures.Range(func(path tspath.PathKey, _ *emitSignature) bool {
sourceFile := p.program.GetSourceFileByPath(path)
if sourceFile != nil && p.program.SourceFileMayBeEmitted(sourceFile, false) {
output := outputpaths.GetOutputPathsFor(sourceFile, p.Options(), p.program, outputpaths.ForceEmitPaths{}).DeclarationFilePath()
if output != "" {
action(output, sourceFile)
}
}
return true
})
}

func (p *Program) HasChangedDtsFile() bool {
return p.snapshot.hasChangedDtsFile
}
Expand Down
48 changes: 48 additions & 0 deletions tsc/internal/execute/tsctests/contentmapper_watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,54 @@ func TestContentMapperWatchManifestChangeIgnoresCase(t *testing.T) {
assert.Equal(t, spawner.closes.Load(), int32(1))
}

func TestContentMapperWatchNewUppercaseExtension(t *testing.T) {
t.Parallel()
for _, test := range []struct {
name string
ignoreCase bool
}{
{name: "case sensitive"},
{name: "case insensitive", ignoreCase: true},
} {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
synctest.Test(t, func(t *testing.T) {
const root = "/home/src/workspaces/project/"
testSys := newTestSys(&tscInput{
ignoreCase: test.ignoreCase,
files: FileMap{
root + "tsconfig.json": `{
"compilerOptions":{"listFiles":true},
"contentMappers":[{"package":"mapper","extensions":[".BOX"]}]
}`,
root + "first.ts": "export const first = 1;",
root + "node_modules/mapper/package.json": contentmappertest.PackageJSON(contentmappertest.VerbatimMapper),
},
}, false)
sys := &recordingContentMapperSystem{
TestSys: testSys,
spawner: &recordingContentMapperSpawner{inner: contentmappertest.NewSpawner()},
}
ctx, cancel := context.WithCancel(t.Context())
defer cancel()
result := execute.CommandLine(ctx, sys, []string{"--watch", "--runExternalCode"}, testSys)
w := result.Watcher.(*execute.Watcher)
assert.Assert(t, !strings.Contains(testSys.getOutput(false), "error TS"), testSys.getOutput(false))

path := root + "new.BOX"
testSys.writeFileNoError(path, "export const added = 2;")
testSys.clearOutput()
builds := w.FullBuilds()
testSys.mockWatchBackend.SendEvents([]fswatch.Event{{Kind: fswatch.EventUpdate, Path: path}})
w.DoCycle(ctx)
assert.Equal(t, w.FullBuilds(), builds+1)
// The root-file set must refresh even if compiling the newly discovered file reports an error.
assert.Assert(t, strings.Contains(testSys.getOutput(false), path), testSys.getOutput(false))
})
})
}
}

func TestContentMapperBuildWatchSymlinkedManifestDelete(t *testing.T) {
t.Parallel()
const manifestTarget = "/home/src/workspaces/mapper/package.json"
Expand Down
Loading
Loading