Skip to content

Commit 2822725

Browse files
committed
tsc -b
1 parent ef64ce3 commit 2822725

File tree

59 files changed

+2910
-497
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2910
-497
lines changed

internal/api/server.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io"
99
"strconv"
1010
"sync"
11+
"time"
1112

1213
"github.com/go-json-experiment/json"
1314
"github.com/microsoft/typescript-go/internal/bundled"
@@ -472,3 +473,8 @@ func (s *Server) Stat(path string) vfs.FileInfo {
472473
func (s *Server) Remove(path string) error {
473474
panic("unimplemented")
474475
}
476+
477+
// Chtimes implements vfs.FS.
478+
func (s *Server) Chtimes(path string, aTime time.Time, mTime time.Time) error {
479+
panic("unimplemented")
480+
}

internal/bundled/embed.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ func (vfs *wrappedFS) Remove(path string) error {
161161
return vfs.fs.Remove(path)
162162
}
163163

164+
func (vfs *wrappedFS) Chtimes(path string, aTime time.Time, mTime time.Time) error {
165+
if _, ok := splitPath(path); ok {
166+
panic("cannot change times on embedded file system")
167+
}
168+
return vfs.fs.Chtimes(path, aTime, mTime)
169+
}
170+
164171
type fileInfo struct {
165172
mode fs.FileMode
166173
name string

internal/compiler/emitter.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ type emitter struct {
4242
}
4343

4444
func (e *emitter) emit() {
45-
if e.host.Options().ListEmittedFiles.IsTrue() {
46-
e.emitResult.EmittedFiles = []string{}
47-
}
4845
// !!! tracing
4946
e.emitJSFile(e.sourceFile, e.paths.JsFilePath(), e.paths.SourceMapFilePath())
5047
e.emitDeclarationFile(e.sourceFile, e.paths.DeclarationFilePath(), e.paths.DeclarationMapPath())
@@ -254,7 +251,7 @@ func (e *emitter) printSourceFile(jsFilePath string, sourceMapFilePath string, s
254251
err := e.host.WriteFile(sourceMapFilePath, sourceMap, false /*writeByteOrderMark*/)
255252
if err != nil {
256253
e.emitterDiagnostics.Add(ast.NewCompilerDiagnostic(diagnostics.Could_not_write_file_0_Colon_1, jsFilePath, err.Error()))
257-
} else if e.emitResult.EmittedFiles != nil {
254+
} else {
258255
e.emitResult.EmittedFiles = append(e.emitResult.EmittedFiles, sourceMapFilePath)
259256
}
260257
}
@@ -278,7 +275,7 @@ func (e *emitter) printSourceFile(jsFilePath string, sourceMapFilePath string, s
278275
}
279276
if err != nil {
280277
e.emitterDiagnostics.Add(ast.NewCompilerDiagnostic(diagnostics.Could_not_write_file_0_Colon_1, jsFilePath, err.Error()))
281-
} else if e.emitResult.EmittedFiles != nil && !skippedDtsWrite {
278+
} else if !skippedDtsWrite {
282279
e.emitResult.EmittedFiles = append(e.emitResult.EmittedFiles, jsFilePath)
283280
}
284281

internal/compiler/program.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ func equalCheckJSDirectives(d1 *ast.CheckJsDirective, d2 *ast.CheckJsDirective)
270270

271271
func (p *Program) SourceFiles() []*ast.SourceFile { return p.files }
272272
func (p *Program) Options() *core.CompilerOptions { return p.opts.Config.CompilerOptions() }
273+
func (p *Program) GetRootFileNames() []string { return p.opts.Config.FileNames() }
273274
func (p *Program) Host() CompilerHost { return p.opts.Host }
274275
func (p *Program) GetConfigFileParsingDiagnostics() []*ast.Diagnostic {
275276
return slices.Clip(p.opts.Config.GetConfigFileParsingDiagnostics())
@@ -1364,9 +1365,7 @@ func CombineEmitResults(results []*EmitResult) *EmitResult {
13641365
result.EmitSkipped = true
13651366
}
13661367
result.Diagnostics = append(result.Diagnostics, emitResult.Diagnostics...)
1367-
if emitResult.EmittedFiles != nil {
1368-
result.EmittedFiles = append(result.EmittedFiles, emitResult.EmittedFiles...)
1369-
}
1368+
result.EmittedFiles = append(result.EmittedFiles, emitResult.EmittedFiles...)
13701369
if emitResult.SourceMaps != nil {
13711370
result.SourceMaps = append(result.SourceMaps, emitResult.SourceMaps...)
13721371
}

internal/compiler/projectreferencedtsfakinghost.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package compiler
22

33
import (
44
"strings"
5+
"time"
56

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

86+
// Chtimes implements vfs.FS.
87+
func (fs *projectReferenceDtsFakingVfs) Chtimes(path string, aTime time.Time, mTime time.Time) error {
88+
panic("should not be called by resolver")
89+
}
90+
8591
// DirectoryExists implements vfs.FS.
8692
func (fs *projectReferenceDtsFakingVfs) DirectoryExists(path string) bool {
8793
if fs.projectReferenceFileMapper.opts.Host.FS().DirectoryExists(path) {

internal/diagnostics/diagnostics_generated.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/diagnostics/extraDiagnosticMessages.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,21 @@
2222
"A JSDoc '@type' tag may not occur with a '@param' or '@returns' tag.": {
2323
"category": "Error",
2424
"code": 8040
25+
},
26+
"Failed to delete file '{0}'.": {
27+
"category": "Message",
28+
"code": 6353
29+
},
30+
"Project '{0}' is out of date because config file does not exist.": {
31+
"category": "Message",
32+
"code": 6401
33+
},
34+
"Project '{0}' is out of date because input '{1}' does not exist.": {
35+
"category": "Message",
36+
"code": 6420
37+
},
38+
"Failed to update timestamp of file '{0}'.": {
39+
"category": "Message",
40+
"code": 5074
2541
}
2642
}

internal/diagnosticwriter/diagnosticwriter.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type FormattingOptions struct {
2121
}
2222

2323
const (
24-
foregroundColorEscapeGrey = "\u001b[90m"
24+
ForegroundColorEscapeGrey = "\u001b[90m"
2525
foregroundColorEscapeRed = "\u001b[91m"
2626
foregroundColorEscapeYellow = "\u001b[93m"
2727
foregroundColorEscapeBlue = "\u001b[94m"
@@ -39,7 +39,6 @@ func FormatDiagnosticsWithColorAndContext(output io.Writer, diags []*ast.Diagnos
3939
if len(diags) == 0 {
4040
return
4141
}
42-
4342
for i, diagnostic := range diags {
4443
if i > 0 {
4544
fmt.Fprint(output, formatOpts.NewLine)
@@ -57,7 +56,7 @@ func FormatDiagnosticWithColorAndContext(output io.Writer, diagnostic *ast.Diagn
5756
}
5857

5958
writeWithStyleAndReset(output, diagnostic.Category().Name(), getCategoryFormat(diagnostic.Category()))
60-
fmt.Fprintf(output, "%s TS%d: %s", foregroundColorEscapeGrey, diagnostic.Code(), resetEscapeSequence)
59+
fmt.Fprintf(output, "%s TS%d: %s", ForegroundColorEscapeGrey, diagnostic.Code(), resetEscapeSequence)
6160
WriteFlattenedDiagnosticMessage(output, diagnostic, formatOpts.NewLine)
6261

6362
if diagnostic.File() != nil && diagnostic.Code() != diagnostics.File_appears_to_be_binary.Code() {
@@ -199,7 +198,7 @@ func getCategoryFormat(category diagnostics.Category) string {
199198
case diagnostics.CategoryWarning:
200199
return foregroundColorEscapeYellow
201200
case diagnostics.CategorySuggestion:
202-
return foregroundColorEscapeGrey
201+
return ForegroundColorEscapeGrey
203202
case diagnostics.CategoryMessage:
204203
return foregroundColorEscapeBlue
205204
}
@@ -362,7 +361,7 @@ func prettyPathForFileError(file *ast.SourceFile, fileErrors []*ast.Diagnostic,
362361
}
363362
return fmt.Sprintf("%s%s:%d%s",
364363
fileName,
365-
foregroundColorEscapeGrey,
364+
ForegroundColorEscapeGrey,
366365
line+1,
367366
resetEscapeSequence,
368367
)
@@ -386,3 +385,15 @@ func WriteFormatDiagnostic(output io.Writer, diagnostic *ast.Diagnostic, formatO
386385
WriteFlattenedDiagnosticMessage(output, diagnostic, formatOpts.NewLine)
387386
fmt.Fprint(output, formatOpts.NewLine)
388387
}
388+
389+
func FormatDiagnosticsStatusWithColorAndTime(output io.Writer, time string, diag *ast.Diagnostic, formatOpts *FormattingOptions) {
390+
fmt.Fprint(output, "[")
391+
writeWithStyleAndReset(output, time, ForegroundColorEscapeGrey)
392+
fmt.Fprint(output, "] ")
393+
WriteFlattenedDiagnosticMessage(output, diag, formatOpts.NewLine)
394+
}
395+
396+
func FormatDiagnosticsStatusAndTime(output io.Writer, time string, diag *ast.Diagnostic, formatOpts *FormattingOptions) {
397+
fmt.Fprint(output, time, " - ")
398+
WriteFlattenedDiagnosticMessage(output, diag, formatOpts.NewLine)
399+
}

0 commit comments

Comments
 (0)