diff --git a/cmd/tsgo/main.go b/cmd/tsgo/main.go index 1f8ad09601..4e796eda6c 100644 --- a/cmd/tsgo/main.go +++ b/cmd/tsgo/main.go @@ -20,5 +20,6 @@ func runMain() int { return runAPI(args[1:]) } } - return int(execute.CommandLine(newSystem(), nil, args)) + status, _, _ := execute.CommandLine(newSystem(), args, false) + return int(status) } diff --git a/internal/ast/diagnostic.go b/internal/ast/diagnostic.go index 79d09afff7..7757501881 100644 --- a/internal/ast/diagnostic.go +++ b/internal/ast/diagnostic.go @@ -21,6 +21,7 @@ type Diagnostic struct { relatedInformation []*Diagnostic reportsUnnecessary bool reportsDeprecated bool + skippedOnNoEmit bool } func (d *Diagnostic) File() *SourceFile { return d.file } @@ -35,10 +36,12 @@ func (d *Diagnostic) MessageChain() []*Diagnostic { return d.messageChain func (d *Diagnostic) RelatedInformation() []*Diagnostic { return d.relatedInformation } func (d *Diagnostic) ReportsUnnecessary() bool { return d.reportsUnnecessary } func (d *Diagnostic) ReportsDeprecated() bool { return d.reportsDeprecated } +func (d *Diagnostic) SkippedOnNoEmit() bool { return d.skippedOnNoEmit } func (d *Diagnostic) SetFile(file *SourceFile) { d.file = file } func (d *Diagnostic) SetLocation(loc core.TextRange) { d.loc = loc } func (d *Diagnostic) SetCategory(category diagnostics.Category) { d.category = category } +func (d *Diagnostic) SetSkippedOnNoEmit() { d.skippedOnNoEmit = true } func (d *Diagnostic) SetMessageChain(messageChain []*Diagnostic) *Diagnostic { d.messageChain = messageChain @@ -69,6 +72,32 @@ func (d *Diagnostic) Clone() *Diagnostic { return &result } +func NewDiagnosticWith( + file *SourceFile, + loc core.TextRange, + code int32, + category diagnostics.Category, + message string, + messageChain []*Diagnostic, + relatedInformation []*Diagnostic, + reportsUnnecessary bool, + reportsDeprecated bool, + skippedOnNoEmit bool, +) *Diagnostic { + return &Diagnostic{ + file: file, + loc: loc, + code: code, + category: category, + message: message, + messageChain: messageChain, + relatedInformation: relatedInformation, + reportsUnnecessary: reportsUnnecessary, + reportsDeprecated: reportsDeprecated, + skippedOnNoEmit: skippedOnNoEmit, + } +} + func NewDiagnostic(file *SourceFile, loc core.TextRange, message *diagnostics.Message, args ...any) *Diagnostic { return &Diagnostic{ file: file, diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index 5c5fd2314d..da148d98bc 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -1644,6 +1644,10 @@ func IsModuleAugmentationExternal(node *Node) bool { return false } +func IsModuleWithStringLiteralName(node *Node) bool { + return IsModuleDeclaration(node) && node.Name().Kind == KindStringLiteral +} + func GetContainingClass(node *Node) *Node { return FindAncestor(node.Parent, IsClassLike) } diff --git a/internal/checker/checker.go b/internal/checker/checker.go index ca4dd45f4a..879d92b048 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -856,6 +856,8 @@ type Checker struct { skipDirectInferenceNodes collections.Set[*ast.Node] ctx context.Context packagesMap map[string]bool + ambientModulesOnce sync.Once + ambientModules []*ast.Symbol } func NewChecker(program Program) *Checker { @@ -2104,7 +2106,7 @@ func (c *Checker) getSymbol(symbols ast.SymbolTable, name string, meaning ast.Sy } func (c *Checker) CheckSourceFile(ctx context.Context, sourceFile *ast.SourceFile) { - if SkipTypeChecking(sourceFile, c.compilerOptions, c.program) { + if SkipTypeChecking(sourceFile, c.compilerOptions, c.program, false) { return } c.checkSourceFile(ctx, sourceFile) @@ -10088,7 +10090,7 @@ func (c *Checker) checkCollisionWithRequireExportsInGeneratedCode(node *ast.Node parent := ast.GetDeclarationContainer(node) if ast.IsSourceFile(parent) && ast.IsExternalOrCommonJSModule(parent.AsSourceFile()) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords - c.error(name, diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, scanner.DeclarationNameToString(name), scanner.DeclarationNameToString(name)) + c.errorSkippedOnNoEmit(name, diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, scanner.DeclarationNameToString(name), scanner.DeclarationNameToString(name)) } } @@ -13340,6 +13342,12 @@ func (c *Checker) error(location *ast.Node, message *diagnostics.Message, args . return diagnostic } +func (c *Checker) errorSkippedOnNoEmit(location *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic { + diagnostic := c.error(location, message, args...) + diagnostic.SetSkippedOnNoEmit() + return diagnostic +} + func (c *Checker) errorOrSuggestion(isError bool, location *ast.Node, message *diagnostics.Message, args ...any) { c.addErrorOrSuggestion(isError, NewDiagnosticForNode(location, message, args...)) } @@ -14836,6 +14844,17 @@ func (c *Checker) tryFindAmbientModule(moduleName string, withAugmentations bool return symbol } +func (c *Checker) GetAmbientModules() []*ast.Symbol { + c.ambientModulesOnce.Do(func() { + for sym, global := range c.globals { + if strings.HasPrefix(sym, "\"") && strings.HasSuffix(sym, "\"") { + c.ambientModules = append(c.ambientModules, global) + } + } + }) + return c.ambientModules +} + func (c *Checker) resolveExternalModuleSymbol(moduleSymbol *ast.Symbol, dontResolveAlias bool) *ast.Symbol { if moduleSymbol != nil { exportEquals := c.resolveSymbolEx(moduleSymbol.Exports[ast.InternalSymbolNameExportEquals], dontResolveAlias) diff --git a/internal/checker/checker_test.go b/internal/checker/checker_test.go index 161be261eb..4b7457bd46 100644 --- a/internal/checker/checker_test.go +++ b/internal/checker/checker_test.go @@ -77,7 +77,7 @@ func TestCheckSrcCompiler(t *testing.T) { Config: parsed, Host: host, }) - p.CheckSourceFiles(t.Context()) + p.CheckSourceFiles(t.Context(), nil) } func BenchmarkNewChecker(b *testing.B) { diff --git a/internal/checker/grammarchecks.go b/internal/checker/grammarchecks.go index cd3cca23f3..eada329c5c 100644 --- a/internal/checker/grammarchecks.go +++ b/internal/checker/grammarchecks.go @@ -42,6 +42,17 @@ func (c *Checker) grammarErrorOnNode(node *ast.Node, message *diagnostics.Messag return false } +func (c *Checker) grammarErrorOnNodeSkippedOnNoEmit(node *ast.Node, message *diagnostics.Message, args ...any) bool { + sourceFile := ast.GetSourceFileOfNode(node) + if !c.hasParseDiagnostics(sourceFile) { + d := NewDiagnosticForNode(node, message, args...) + d.SetSkippedOnNoEmit() + c.diagnostics.Add(d) + return true + } + return false +} + func (c *Checker) checkGrammarRegularExpressionLiteral(_ *ast.RegularExpressionLiteral) bool { // !!! // Unclear if this is needed until regular expression parsing is more thoroughly implemented. @@ -1648,7 +1659,7 @@ func (c *Checker) checkGrammarVariableDeclaration(node *ast.VariableDeclaration) func (c *Checker) checkGrammarForEsModuleMarkerInBindingName(name *ast.Node) bool { if ast.IsIdentifier(name) { if name.Text() == "__esModule" { - return c.grammarErrorOnNode(name, diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules) + return c.grammarErrorOnNodeSkippedOnNoEmit(name, diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules) } } else { for _, element := range name.AsBindingPattern().Elements.Nodes { diff --git a/internal/checker/symbolaccessibility.go b/internal/checker/symbolaccessibility.go index cd47e3c337..d9741f18a5 100644 --- a/internal/checker/symbolaccessibility.go +++ b/internal/checker/symbolaccessibility.go @@ -105,11 +105,7 @@ func (ch *Checker) IsAnySymbolAccessible(symbols []*ast.Symbol, enclosingDeclara } func hasNonGlobalAugmentationExternalModuleSymbol(declaration *ast.Node) bool { - return isModuleWithStringLiteralName(declaration) || (declaration.Kind == ast.KindSourceFile && ast.IsExternalOrCommonJSModule(declaration.AsSourceFile())) -} - -func isModuleWithStringLiteralName(node *ast.Node) bool { - return ast.IsModuleDeclaration(node) && node.Name().Kind == ast.KindStringLiteral + return ast.IsModuleWithStringLiteralName(declaration) || (declaration.Kind == ast.KindSourceFile && ast.IsExternalOrCommonJSModule(declaration.AsSourceFile())) } func getQualifiedLeftMeaning(rightMeaning ast.SymbolFlags) ast.SymbolFlags { diff --git a/internal/checker/utilities.go b/internal/checker/utilities.go index 30fd1e7e5b..41364ce14f 100644 --- a/internal/checker/utilities.go +++ b/internal/checker/utilities.go @@ -1467,8 +1467,8 @@ func forEachYieldExpression(body *ast.Node, visitor func(expr *ast.Node)) { traverse(body) } -func SkipTypeChecking(sourceFile *ast.SourceFile, options *core.CompilerOptions, host Program) bool { - return options.NoCheck.IsTrue() || +func SkipTypeChecking(sourceFile *ast.SourceFile, options *core.CompilerOptions, host Program, ignoreNoCheck bool) bool { + return (!ignoreNoCheck && options.NoCheck.IsTrue()) || options.SkipLibCheck.IsTrue() && sourceFile.IsDeclarationFile || options.SkipDefaultLibCheck.IsTrue() && host.IsSourceFileDefaultLibrary(sourceFile.Path()) || host.IsSourceFromProjectReference(sourceFile.Path()) || diff --git a/internal/collections/manytomanymap.go b/internal/collections/manytomanymap.go new file mode 100644 index 0000000000..87bfc2edb4 --- /dev/null +++ b/internal/collections/manytomanymap.go @@ -0,0 +1,68 @@ +package collections + +type ManyToManyMap[K comparable, V comparable] struct { + keyToValueSet map[K]*Set[V] + valueToKeySet map[V]*Set[K] +} + +func (m *ManyToManyMap[K, V]) GetKeys(value V) (*Set[K], bool) { + keys, present := m.valueToKeySet[value] + return keys, present +} + +func (m *ManyToManyMap[K, V]) GetValues(key K) (*Set[V], bool) { + values, present := m.keyToValueSet[key] + return values, present +} + +func (m *ManyToManyMap[K, V]) Len() int { + return len(m.keyToValueSet) +} + +func (m *ManyToManyMap[K, V]) Keys() map[K]*Set[V] { + return m.keyToValueSet +} + +func (m *ManyToManyMap[K, V]) Add(key K, valueSet *Set[V]) { + existingValueSet, hasExisting := m.keyToValueSet[key] + if m.keyToValueSet == nil { + m.keyToValueSet = make(map[K]*Set[V]) + } + m.keyToValueSet[key] = valueSet + for value := range valueSet.Keys() { + if !hasExisting || !existingValueSet.Has(value) { + // Add to valueToKeySet + if m.valueToKeySet == nil { + m.valueToKeySet = make(map[V]*Set[K]) + } + addToMapOfSet(m.valueToKeySet, value, key) + } + } + + if hasExisting { + for value := range existingValueSet.Keys() { + if !valueSet.Has(value) { + // Remove from valueToKeySet + defer deleteFromMapOfSet(m.valueToKeySet, value, key) + } + } + } +} + +func addToMapOfSet[K comparable, V comparable](mapKSetV map[K]*Set[V], key K, value V) { + set, exists := mapKSetV[key] + if !exists { + set = &Set[V]{} + mapKSetV[key] = set + } + set.Add(value) +} + +func deleteFromMapOfSet[K comparable, V comparable](mapKSetV map[K]*Set[V], key K, value V) { + if set, exists := mapKSetV[key]; exists { + set.Delete(value) + if set.Len() == 0 { + delete(mapKSetV, key) + } + } +} diff --git a/internal/collections/set.go b/internal/collections/set.go index 02df38acb9..8864b3d0b0 100644 --- a/internal/collections/set.go +++ b/internal/collections/set.go @@ -1,5 +1,7 @@ package collections +import "maps" + type Set[T comparable] struct { M map[T]struct{} } @@ -48,6 +50,32 @@ func (s *Set[T]) AddIfAbsent(key T) bool { return true } +func (s *Set[T]) Clone() *Set[T] { + if s == nil { + return nil + } + clone := &Set[T]{M: maps.Clone(s.M)} + return clone +} + +func (s *Set[T]) Equals(other *Set[T]) bool { + if s == other { + return true + } + if s == nil || other == nil { + return false + } + if s.Len() != other.Len() { + return false + } + for key := range s.M { + if !other.Has(key) { + return false + } + } + return true +} + func NewSetFromItems[T comparable](items ...T) *Set[T] { s := &Set[T]{} for _, item := range items { diff --git a/internal/collections/syncset.go b/internal/collections/syncset.go index 14124add03..2bd37a2da0 100644 --- a/internal/collections/syncset.go +++ b/internal/collections/syncset.go @@ -16,3 +16,19 @@ func (s *SyncSet[T]) Add(key T) { func (s *SyncSet[T]) Delete(key T) { s.m.Delete(key) } + +func (s *SyncSet[T]) Range(fn func(key T) bool) { + s.m.Range(func(key T, value struct{}) bool { + return fn(key) + }) +} + +func (s *SyncSet[T]) ToArray() []T { + var arr []T + arr = make([]T, 0, s.m.Size()) + s.m.Range(func(key T, value struct{}) bool { + arr = append(arr, key) + return true + }) + return arr +} diff --git a/internal/compiler/checkerpool.go b/internal/compiler/checkerpool.go index 17949cd568..9b32992f20 100644 --- a/internal/compiler/checkerpool.go +++ b/internal/compiler/checkerpool.go @@ -53,7 +53,7 @@ func (p *checkerPool) GetChecker(ctx context.Context) (*checker.Checker, func()) func (p *checkerPool) createCheckers() { p.createCheckersOnce.Do(func() { - wg := core.NewWorkGroup(p.program.singleThreaded()) + wg := core.NewWorkGroup(p.program.SingleThreaded()) for i := range p.checkerCount { wg.Queue(func() { p.checkers[i] = checker.NewChecker(p.program) diff --git a/internal/compiler/emitHost.go b/internal/compiler/emitHost.go index d1db60a4d9..a88fbd8446 100644 --- a/internal/compiler/emitHost.go +++ b/internal/compiler/emitHost.go @@ -14,14 +14,6 @@ import ( "github.com/microsoft/typescript-go/internal/tspath" ) -type WriteFileData struct { - SourceMapUrlPos int - // BuildInfo BuildInfo - Diagnostics []*ast.Diagnostic - DiffersOnlyInMap bool - SkippedDtsWrite bool -} - // NOTE: EmitHost operations must be thread-safe type EmitHost interface { printer.EmitHost @@ -120,7 +112,7 @@ func (host *emitHost) IsEmitBlocked(file string) bool { return false } -func (host *emitHost) WriteFile(fileName string, text string, writeByteOrderMark bool, _ []*ast.SourceFile, _ *printer.WriteFileData) error { +func (host *emitHost) WriteFile(fileName string, text string, writeByteOrderMark bool) error { return host.program.Host().FS().WriteFile(fileName, text, writeByteOrderMark) } diff --git a/internal/compiler/emitter.go b/internal/compiler/emitter.go index b031647c26..0746075049 100644 --- a/internal/compiler/emitter.go +++ b/internal/compiler/emitter.go @@ -1,7 +1,10 @@ package compiler import ( + "context" "encoding/base64" + "slices" + "time" "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/binder" @@ -21,32 +24,34 @@ import ( "github.com/microsoft/typescript-go/internal/tspath" ) -type emitOnly byte +type EmitOnly byte const ( - emitAll emitOnly = iota - emitOnlyJs - emitOnlyDts - emitOnlyBuildInfo + EmitAll EmitOnly = iota + EmitOnlyJs + EmitOnlyDts + EmitOnlyForcedDts ) type emitter struct { host EmitHost - emitOnly emitOnly - emittedFilesList []string + emitOnly EmitOnly emitterDiagnostics ast.DiagnosticsCollection - emitSkipped bool - sourceMapDataList []*SourceMapEmitResult writer printer.EmitTextWriter paths *outputpaths.OutputPaths sourceFile *ast.SourceFile + emitResult EmitResult + writeFile func(fileName string, text string, writeByteOrderMark bool, data *WriteFileData) error } 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()) - e.emitBuildInfo(e.paths.BuildInfoPath()) + e.emitResult.Diagnostics = e.emitterDiagnostics.GetDiagnostics() } func (e *emitter) getDeclarationTransformers(emitContext *printer.EmitContext, declarationFilePath string, declarationMapPath string) []*declarations.DeclarationTransformer { @@ -124,11 +129,12 @@ func getScriptTransformers(emitContext *printer.EmitContext, host printer.EmitHo func (e *emitter) emitJSFile(sourceFile *ast.SourceFile, jsFilePath string, sourceMapFilePath string) { options := e.host.Options() - if sourceFile == nil || e.emitOnly != emitAll && e.emitOnly != emitOnlyJs || len(jsFilePath) == 0 { + if sourceFile == nil || e.emitOnly != EmitAll && e.emitOnly != EmitOnlyJs || len(jsFilePath) == 0 { return } if options.NoEmit == core.TSTrue || e.host.IsEmitBlocked(jsFilePath) { + e.emitResult.EmitSkipped = true return } @@ -155,23 +161,17 @@ func (e *emitter) emitJSFile(sourceFile *ast.SourceFile, jsFilePath string, sour }, emitContext) e.printSourceFile(jsFilePath, sourceMapFilePath, sourceFile, printer, shouldEmitSourceMaps(options, sourceFile)) - - if e.emittedFilesList != nil { - e.emittedFilesList = append(e.emittedFilesList, jsFilePath) - if sourceMapFilePath != "" { - e.emittedFilesList = append(e.emittedFilesList, sourceMapFilePath) - } - } } func (e *emitter) emitDeclarationFile(sourceFile *ast.SourceFile, declarationFilePath string, declarationMapPath string) { options := e.host.Options() - if sourceFile == nil || e.emitOnly != emitAll && e.emitOnly != emitOnlyDts || len(declarationFilePath) == 0 { + if sourceFile == nil || e.emitOnly == EmitOnlyJs || len(declarationFilePath) == 0 { return } - if options.NoEmit == core.TSTrue || e.host.IsEmitBlocked(declarationFilePath) { + if e.emitOnly != EmitOnlyForcedDts && (options.NoEmit == core.TSTrue || e.host.IsEmitBlocked(declarationFilePath)) { + e.emitResult.EmitSkipped = true return } @@ -183,6 +183,8 @@ func (e *emitter) emitDeclarationFile(sourceFile *ast.SourceFile, declarationFil diags = append(diags, transformer.GetDiagnostics()...) } + // !!! strada skipped emit if there were diagnostics + printerOptions := printer.PrinterOptions{ RemoveComments: options.RemoveComments.IsTrue(), NewLine: options.NewLine, @@ -198,19 +200,14 @@ func (e *emitter) emitDeclarationFile(sourceFile *ast.SourceFile, declarationFil // !!! }, emitContext) - e.printSourceFile(declarationFilePath, declarationMapPath, sourceFile, printer, shouldEmitDeclarationSourceMaps(options, sourceFile)) - for _, elem := range diags { // Add declaration transform diagnostics to emit diagnostics e.emitterDiagnostics.Add(elem) } + e.printSourceFile(declarationFilePath, declarationMapPath, sourceFile, printer, e.emitOnly != EmitOnlyForcedDts && shouldEmitDeclarationSourceMaps(options, sourceFile)) } -func (e *emitter) emitBuildInfo(buildInfoPath string) { - // !!! -} - -func (e *emitter) printSourceFile(jsFilePath string, sourceMapFilePath string, sourceFile *ast.SourceFile, printer_ *printer.Printer, shouldEmitSourceMaps bool) bool { +func (e *emitter) printSourceFile(jsFilePath string, sourceMapFilePath string, sourceFile *ast.SourceFile, printer_ *printer.Printer, shouldEmitSourceMaps bool) { // !!! sourceMapGenerator options := e.host.Options() var sourceMapGenerator *sourcemap.Generator @@ -226,15 +223,12 @@ func (e *emitter) printSourceFile(jsFilePath string, sourceMapFilePath string, s ) } - // !!! bundles not implemented, may be deprecated - sourceFiles := []*ast.SourceFile{sourceFile} - printer_.Write(sourceFile.AsNode(), sourceFile, e.writer, sourceMapGenerator) sourceMapUrlPos := -1 if sourceMapGenerator != nil { if options.SourceMap.IsTrue() || options.InlineSourceMap.IsTrue() || options.GetAreDeclarationMapsEnabled() { - e.sourceMapDataList = append(e.sourceMapDataList, &SourceMapEmitResult{ + e.emitResult.SourceMaps = append(e.emitResult.SourceMaps, &SourceMapEmitResult{ InputSourceFileNames: sourceMapGenerator.Sources(), SourceMap: sourceMapGenerator.RawSourceMap(), GeneratedFile: jsFilePath, @@ -260,9 +254,11 @@ func (e *emitter) printSourceFile(jsFilePath string, sourceMapFilePath string, s // Write the source map if len(sourceMapFilePath) > 0 { sourceMap := sourceMapGenerator.String() - err := e.host.WriteFile(sourceMapFilePath, sourceMap, false /*writeByteOrderMark*/, sourceFiles, nil /*data*/) + 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 { + e.emitResult.EmittedFiles = append(e.emitResult.EmittedFiles, sourceMapFilePath) } } } else { @@ -271,15 +267,26 @@ func (e *emitter) printSourceFile(jsFilePath string, sourceMapFilePath string, s // Write the output file text := e.writer.String() - data := &printer.WriteFileData{SourceMapUrlPos: sourceMapUrlPos} // !!! transform diagnostics - err := e.host.WriteFile(jsFilePath, text, e.host.Options().EmitBOM.IsTrue(), sourceFiles, data) + var err error + var skippedDtsWrite bool + if e.writeFile == nil { + err = e.host.WriteFile(jsFilePath, text, e.host.Options().EmitBOM.IsTrue()) + } else { + data := &WriteFileData{ + SourceMapUrlPos: sourceMapUrlPos, + Diagnostics: e.emitterDiagnostics.GetDiagnostics(), + } + err = e.writeFile(jsFilePath, text, e.host.Options().EmitBOM.IsTrue(), data) + skippedDtsWrite = data.SkippedDtsWrite + } 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 { + e.emitResult.EmittedFiles = append(e.emitResult.EmittedFiles, jsFilePath) } // Reset state e.writer.Clear() - return !data.SkippedDtsWrite } func shouldEmitSourceMaps(mapOptions *core.CompilerOptions, sourceFile *ast.SourceFile) bool { @@ -462,3 +469,93 @@ func getDeclarationDiagnostics(host EmitHost, file *ast.SourceFile) []*ast.Diagn transform.TransformSourceFile(file) return transform.GetDiagnostics() } + +type AnyProgram interface { + Options() *core.CompilerOptions + GetSourceFiles() []*ast.SourceFile + GetConfigFileParsingDiagnostics() []*ast.Diagnostic + GetSyntacticDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic + GetBindDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic + GetOptionsDiagnostics(ctx context.Context) []*ast.Diagnostic + GetProgramDiagnostics() []*ast.Diagnostic + GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic + GetSemanticDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic + GetDeclarationDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic + Emit(ctx context.Context, options EmitOptions) *EmitResult +} + +func HandleNoEmitOnError(ctx context.Context, program AnyProgram, file *ast.SourceFile) *EmitResult { + if !program.Options().NoEmitOnError.IsTrue() { + return nil // No emit on error is not set, so we can proceed with emitting + } + + diagnostics := GetDiagnosticsOfAnyProgram(ctx, program, file, true, func(name string, start bool, nameStart time.Time) time.Time { return time.Time{} }) + if len(diagnostics) == 0 { + return nil // No diagnostics, so we can proceed with emitting + } + return &EmitResult{ + Diagnostics: diagnostics, + EmitSkipped: true, + } +} + +func GetDiagnosticsOfAnyProgram( + ctx context.Context, + program AnyProgram, + file *ast.SourceFile, + skipNoEmitCheckForDtsDiagnostics bool, + recordTime func(name string, start bool, nameStart time.Time) time.Time, +) []*ast.Diagnostic { + allDiagnostics := slices.Clip(program.GetConfigFileParsingDiagnostics()) + configFileParsingDiagnosticsLength := len(allDiagnostics) + + allDiagnostics = append(allDiagnostics, program.GetSyntacticDiagnostics(ctx, file)...) + allDiagnostics = append(allDiagnostics, program.GetProgramDiagnostics()...) + + if len(allDiagnostics) == configFileParsingDiagnosticsLength { + // Options diagnostics include global diagnostics (even though we collect them separately), + // and global diagnostics create checkers, which then bind all of the files. Do this binding + // early so we can track the time. + bindStart := recordTime("bind", true, time.Time{}) + _ = program.GetBindDiagnostics(ctx, file) + recordTime("bind", false, bindStart) + + allDiagnostics = append(allDiagnostics, program.GetOptionsDiagnostics(ctx)...) + + if program.Options().ListFilesOnly.IsFalseOrUnknown() { + allDiagnostics = append(allDiagnostics, program.GetGlobalDiagnostics(ctx)...) + + if len(allDiagnostics) == configFileParsingDiagnosticsLength { + // !!! add program diagnostics here instead of merging with the semantic diagnostics for better api usage with with incremental and + checkStart := recordTime("check", true, time.Time{}) + allDiagnostics = append(allDiagnostics, program.GetSemanticDiagnostics(ctx, file)...) + recordTime("check", false, checkStart) + } + + if (skipNoEmitCheckForDtsDiagnostics || program.Options().NoEmit.IsTrue()) && program.Options().GetEmitDeclarations() && len(allDiagnostics) == configFileParsingDiagnosticsLength { + allDiagnostics = append(allDiagnostics, program.GetDeclarationDiagnostics(ctx, file)...) + } + } + } + return allDiagnostics +} + +func CombineEmitResults(results []*EmitResult) *EmitResult { + result := &EmitResult{} + for _, emitResult := range results { + if emitResult == nil { + continue // Skip nil results + } + if emitResult.EmitSkipped { + result.EmitSkipped = true + } + result.Diagnostics = append(result.Diagnostics, emitResult.Diagnostics...) + if emitResult.EmittedFiles != nil { + result.EmittedFiles = append(result.EmittedFiles, emitResult.EmittedFiles...) + } + if emitResult.SourceMaps != nil { + result.SourceMaps = append(result.SourceMaps, emitResult.SourceMaps...) + } + } + return result +} diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 25607fdb62..dcf2fcf7d6 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -39,7 +39,6 @@ func (p *ProgramOptions) canUseProjectReferenceSource() bool { type Program struct { opts ProgramOptions - nodeModules map[string]*ast.SourceFile checkerPool CheckerPool comparePathsOptions tspath.ComparePathsOptions @@ -114,6 +113,10 @@ func (p *Program) GetRedirectForResolution(file ast.HasFileName) *tsoptions.Pars return p.projectReferenceFileMapper.getRedirectForResolution(file) } +func (p *Program) GetParseFileRedirect(fileName string) string { + return p.projectReferenceFileMapper.getParseFileRedirect(ast.NewHasFileName(fileName, tspath.ToPath(fileName, p.GetCurrentDirectory(), p.UseCaseSensitiveFileNames()))) +} + func (p *Program) ForEachResolvedProjectReference( fn func(path tspath.Path, config *tsoptions.ParsedCommandLine), ) { @@ -174,7 +177,7 @@ func (p *Program) GetSourceFileFromReference(origin *ast.SourceFile, ref *ast.Fi func NewProgram(opts ProgramOptions) *Program { p := &Program{opts: opts} p.initCheckerPool() - p.processedFiles = processAllProgramFiles(p.opts, p.singleThreaded()) + p.processedFiles = processAllProgramFiles(p.opts, p.SingleThreaded()) return p } @@ -188,7 +191,6 @@ func (p *Program) UpdateProgram(changedFilePath tspath.Path) (*Program, bool) { } result := &Program{ opts: p.opts, - nodeModules: p.nodeModules, comparePathsOptions: p.comparePathsOptions, processedFiles: p.processedFiles, usesUriStyleNodeCoreModules: p.usesUriStyleNodeCoreModules, @@ -206,7 +208,7 @@ func (p *Program) initCheckerPool() { if p.opts.CreateCheckerPool != nil { p.checkerPool = p.opts.CreateCheckerPool(p) } else { - p.checkerPool = newCheckerPool(core.IfElse(p.singleThreaded(), 1, 4), p) + p.checkerPool = newCheckerPool(core.IfElse(p.SingleThreaded(), 1, 4), p) } } @@ -246,12 +248,12 @@ func (p *Program) GetConfigFileParsingDiagnostics() []*ast.Diagnostic { return slices.Clip(p.opts.Config.GetConfigFileParsingDiagnostics()) } -func (p *Program) singleThreaded() bool { +func (p *Program) SingleThreaded() bool { return p.opts.SingleThreaded.DefaultIfUnknown(p.Options().SingleThreaded).IsTrue() } func (p *Program) BindSourceFiles() { - wg := core.NewWorkGroup(p.singleThreaded()) + wg := core.NewWorkGroup(p.SingleThreaded()) for _, file := range p.files { if !file.IsBound() { wg.Queue(func() { @@ -262,14 +264,16 @@ func (p *Program) BindSourceFiles() { wg.RunAndWait() } -func (p *Program) CheckSourceFiles(ctx context.Context) { - wg := core.NewWorkGroup(p.singleThreaded()) +func (p *Program) CheckSourceFiles(ctx context.Context, files []*ast.SourceFile) { + wg := core.NewWorkGroup(p.SingleThreaded()) checkers, done := p.checkerPool.GetAllCheckers(ctx) defer done() for _, checker := range checkers { wg.Queue(func() { for file := range p.checkerPool.Files(checker) { - checker.CheckSourceFile(ctx, file) + if files == nil || slices.Contains(files, file) { + checker.CheckSourceFile(ctx, file) + } } }) } @@ -326,6 +330,19 @@ func (p *Program) GetSemanticDiagnostics(ctx context.Context, sourceFile *ast.So return p.getDiagnosticsHelper(ctx, sourceFile, true /*ensureBound*/, true /*ensureChecked*/, p.getSemanticDiagnosticsForFile) } +func (p *Program) GetSemanticDiagnosticsNoFilter(ctx context.Context, sourceFiles []*ast.SourceFile) map[*ast.SourceFile][]*ast.Diagnostic { + p.BindSourceFiles() + p.CheckSourceFiles(ctx, sourceFiles) + if ctx.Err() != nil { + return nil + } + result := make(map[*ast.SourceFile][]*ast.Diagnostic, len(sourceFiles)) + for _, file := range sourceFiles { + result[file] = SortAndDeduplicateDiagnostics(p.getSemanticDiagnosticsForFileNotFilter(ctx, file)) + } + return result +} + func (p *Program) GetSuggestionDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { return p.getDiagnosticsHelper(ctx, sourceFile, true /*ensureBound*/, true /*ensureChecked*/, p.getSuggestionDiagnosticsForFile) } @@ -375,9 +392,26 @@ func (p *Program) getBindDiagnosticsForFile(ctx context.Context, sourceFile *ast return sourceFile.BindDiagnostics() } +func FilterNoEmitSemanticDiagnostics(diagnostics []*ast.Diagnostic, options *core.CompilerOptions) []*ast.Diagnostic { + if !options.NoEmit.IsTrue() { + return diagnostics + } + return core.Filter(diagnostics, func(d *ast.Diagnostic) bool { + return !d.SkippedOnNoEmit() + }) +} + func (p *Program) getSemanticDiagnosticsForFile(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { + diagnostics := p.getSemanticDiagnosticsForFileNotFilter(ctx, sourceFile) + if diagnostics == nil { + return nil + } + return FilterNoEmitSemanticDiagnostics(diagnostics, p.Options()) +} + +func (p *Program) getSemanticDiagnosticsForFileNotFilter(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { compilerOptions := p.Options() - if checker.SkipTypeChecking(sourceFile, compilerOptions, p) { + if checker.SkipTypeChecking(sourceFile, compilerOptions, p, false) { return nil } @@ -471,7 +505,7 @@ func (p *Program) getDeclarationDiagnosticsForFile(ctx context.Context, sourceFi } func (p *Program) getSuggestionDiagnosticsForFile(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { - if checker.SkipTypeChecking(sourceFile, p.Options(), p) { + if checker.SkipTypeChecking(sourceFile, p.Options(), p, false) { return nil } @@ -562,7 +596,7 @@ func (p *Program) getDiagnosticsHelper(ctx context.Context, sourceFile *ast.Sour p.BindSourceFiles() } if ensureChecked { - p.CheckSourceFiles(ctx) + p.CheckSourceFiles(ctx, nil) if ctx.Err() != nil { return nil } @@ -671,9 +705,18 @@ func (p *Program) CommonSourceDirectory() string { return p.commonSourceDirectory } +type WriteFileData struct { + SourceMapUrlPos int + BuildInfo any + Diagnostics []*ast.Diagnostic + DiffersOnlyInMap bool + SkippedDtsWrite bool +} + type EmitOptions struct { TargetSourceFile *ast.SourceFile // Single file to emit. If `nil`, emits all files - forceDtsEmit bool + EmitOnly EmitOnly + WriteFile func(fileName string, text string, writeByteOrderMark bool, data *WriteFileData) error } type EmitResult struct { @@ -689,29 +732,39 @@ type SourceMapEmitResult struct { GeneratedFile string } -func (p *Program) Emit(options EmitOptions) *EmitResult { +func (p *Program) Emit(ctx context.Context, options EmitOptions) *EmitResult { // !!! performance measurement p.BindSourceFiles() + if options.EmitOnly != EmitOnlyForcedDts { + result := HandleNoEmitOnError( + ctx, + p, + options.TargetSourceFile, + ) + if result != nil || ctx.Err() != nil { + return result + } + } writerPool := &sync.Pool{ New: func() any { return printer.NewTextWriter(p.Options().NewLine.GetNewLineCharacter()) }, } - wg := core.NewWorkGroup(p.singleThreaded()) + wg := core.NewWorkGroup(p.SingleThreaded()) var emitters []*emitter - sourceFiles := getSourceFilesToEmit(p, options.TargetSourceFile, options.forceDtsEmit) + sourceFiles := getSourceFilesToEmit(p, options.TargetSourceFile, options.EmitOnly == EmitOnlyForcedDts) for _, sourceFile := range sourceFiles { emitter := &emitter{ - emittedFilesList: nil, - sourceMapDataList: nil, - writer: nil, - sourceFile: sourceFile, + writer: nil, + sourceFile: sourceFile, + emitOnly: options.EmitOnly, + writeFile: options.WriteFile, } emitters = append(emitters, emitter) wg.Queue(func() { - host, done := newEmitHost(context.TODO(), p, sourceFile) + host, done := newEmitHost(ctx, p, sourceFile) defer done() emitter.host = host @@ -721,7 +774,7 @@ func (p *Program) Emit(options EmitOptions) *EmitResult { // attach writer and perform emit emitter.writer = writer - emitter.paths = outputpaths.GetOutputPathsFor(sourceFile, host.Options(), host, options.forceDtsEmit) + emitter.paths = outputpaths.GetOutputPathsFor(sourceFile, host.Options(), host, options.EmitOnly == EmitOnlyForcedDts) emitter.emit() emitter.writer = nil @@ -734,20 +787,9 @@ func (p *Program) Emit(options EmitOptions) *EmitResult { wg.RunAndWait() // collect results from emit, preserving input order - result := &EmitResult{} - for _, emitter := range emitters { - if emitter.emitSkipped { - result.EmitSkipped = true - } - result.Diagnostics = append(result.Diagnostics, emitter.emitterDiagnostics.GetDiagnostics()...) - if emitter.emittedFilesList != nil { - result.EmittedFiles = append(result.EmittedFiles, emitter.emittedFilesList...) - } - if emitter.sourceMapDataList != nil { - result.SourceMaps = append(result.SourceMaps, emitter.sourceMapDataList...) - } - } - return result + return CombineEmitResults(core.Map(emitters, func(e *emitter) *EmitResult { + return &e.emitResult + })) } func (p *Program) GetSourceFile(filename string) *ast.SourceFile { @@ -758,7 +800,7 @@ func (p *Program) GetSourceFile(filename string) *ast.SourceFile { func (p *Program) GetSourceFileForResolvedModule(fileName string) *ast.SourceFile { file := p.GetSourceFile(fileName) if file == nil { - filename := p.projectReferenceFileMapper.getParseFileRedirect(ast.NewHasFileName(fileName, tspath.ToPath(fileName, p.GetCurrentDirectory(), p.UseCaseSensitiveFileNames()))) + filename := p.GetParseFileRedirect(fileName) if filename != "" { return p.GetSourceFile(filename) } @@ -846,7 +888,7 @@ func (p *Program) GetImportHelpersImportSpecifier(path tspath.Path) *ast.Node { } func (p *Program) SourceFileMayBeEmitted(sourceFile *ast.SourceFile, forceDtsEmit bool) bool { - return sourceFileMayBeEmitted(sourceFile, &emitHost{program: p}, forceDtsEmit) + return sourceFileMayBeEmitted(sourceFile, p, forceDtsEmit) } var plainJSErrors = collections.NewSetFromItems( diff --git a/internal/core/compileroptions.go b/internal/core/compileroptions.go index bdfd520a60..5d19084daa 100644 --- a/internal/core/compileroptions.go +++ b/internal/core/compileroptions.go @@ -320,6 +320,10 @@ func (options *CompilerOptions) GetIsolatedModules() bool { return options.IsolatedModules == TSTrue || options.VerbatimModuleSyntax == TSTrue } +func (options *CompilerOptions) IsIncremental() bool { + return options.Incremental.IsTrue() || options.Composite.IsTrue() +} + func (options *CompilerOptions) GetEmitStandardClassFields() bool { return options.UseDefineForClassFields != TSFalse && options.GetEmitScriptTarget() >= ScriptTargetES2022 } diff --git a/internal/execute/export_test.go b/internal/execute/export_test.go deleted file mode 100644 index 665e0fbc18..0000000000 --- a/internal/execute/export_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package execute - -import ( - "github.com/microsoft/typescript-go/internal/compiler" - "github.com/microsoft/typescript-go/internal/tsoptions" -) - -func CommandLineTest(sys System, cb cbType, commandLineArgs []string) (*tsoptions.ParsedCommandLine, ExitStatus) { - parsedCommandLine := tsoptions.ParseCommandLine(commandLineArgs, sys) - e, _ := executeCommandLineWorker(sys, cb, parsedCommandLine) - return parsedCommandLine, e -} - -func CommandLineTestWatch(sys System, cb cbType, commandLineArgs []string) (*tsoptions.ParsedCommandLine, *watcher) { - parsedCommandLine := tsoptions.ParseCommandLine(commandLineArgs, sys) - _, w := executeCommandLineWorker(sys, cb, parsedCommandLine) - return parsedCommandLine, w -} - -func StartForTest(w *watcher) { - // this function should perform any initializations before w.doCycle() in `start(watcher)` - w.initialize() -} - -func RunWatchCycle(w *watcher) { - // this function should perform the same stuff as w.doCycle() without printing time-related output - if w.hasErrorsInTsConfig() { - // these are unrecoverable errors--report them and do not build - return - } - // todo: updateProgram() - w.program = compiler.NewProgram(compiler.ProgramOptions{ - Config: w.options, - Host: w.host, - }) - if w.hasBeenModified(w.program) { - w.compileAndEmit() - } -} diff --git a/internal/execute/outputs.go b/internal/execute/outputs.go index 9a1f73d4ca..a8b4348840 100644 --- a/internal/execute/outputs.go +++ b/internal/execute/outputs.go @@ -54,7 +54,7 @@ func shouldBePretty(sys System, options *core.CompilerOptions) bool { // todo: return defaultIsPretty(sys); return true } - return options.Pretty.IsTrue() + return false } func createReportErrorSummary(sys System, options *core.CompilerOptions) func(diagnostics []*ast.Diagnostic) { diff --git a/internal/execute/system.go b/internal/execute/system.go index 3861a04392..0f31a916b4 100644 --- a/internal/execute/system.go +++ b/internal/execute/system.go @@ -28,5 +28,4 @@ const ( ExitStatusInvalidProject_OutputsSkipped ExitStatus = 3 ExitStatusProjectReferenceCycle_OutputsSkipped ExitStatus = 4 ExitStatusNotImplemented ExitStatus = 5 - ExitStatusNotImplementedWatch ExitStatus = 6 ) diff --git a/internal/execute/testfs_test.go b/internal/execute/testfs_test.go new file mode 100644 index 0000000000..9b49e548dc --- /dev/null +++ b/internal/execute/testfs_test.go @@ -0,0 +1,37 @@ +package execute_test + +import ( + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/vfs" +) + +type testFs struct { + vfs.FS + defaultLibs *collections.SyncSet[string] + writtenFiles collections.SyncSet[string] +} + +func (f *testFs) removeIgnoreLibPath(path string) { + if f.defaultLibs != nil && f.defaultLibs.Has(path) { + f.defaultLibs.Delete(path) + } +} + +// ReadFile reads the file specified by path and returns the content. +// If the file fails to be read, ok will be false. +func (f *testFs) ReadFile(path string) (contents string, ok bool) { + f.removeIgnoreLibPath(path) + return f.FS.ReadFile(path) +} + +func (f *testFs) WriteFile(path string, data string, writeByteOrderMark bool) error { + f.removeIgnoreLibPath(path) + f.writtenFiles.Add(path) + return f.FS.WriteFile(path, data, writeByteOrderMark) +} + +// Removes `path` and all its contents. Will return the first error it encounters. +func (f *testFs) Remove(path string) error { + f.removeIgnoreLibPath(path) + return f.FS.Remove(path) +} diff --git a/internal/execute/testsys_test.go b/internal/execute/testsys_test.go index 92eda1f4ad..17b1dc5d5a 100644 --- a/internal/execute/testsys_test.go +++ b/internal/execute/testsys_test.go @@ -10,35 +10,92 @@ import ( "strings" "time" - "github.com/microsoft/typescript-go/internal/bundled" + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/execute" + "github.com/microsoft/typescript-go/internal/incremental" + "github.com/microsoft/typescript-go/internal/testutil/incrementaltestutil" + "github.com/microsoft/typescript-go/internal/testutil/stringtestutil" + "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/vfs" "github.com/microsoft/typescript-go/internal/vfs/vfstest" ) -type FileMap map[string]string +type FileMap map[string]any -func newTestSys(fileOrFolderList FileMap, cwd string, args ...string) *testSys { +var tscLibPath = "/home/src/tslibs/TS/Lib" + +var tscDefaultLibContent = stringtestutil.Dedent(` +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +`) + +func newTestSys(fileOrFolderList FileMap, cwd string) *testSys { if cwd == "" { cwd = "/home/src/workspaces/project" } - return &testSys{ - fs: bundled.WrapFS(vfstest.FromMap(fileOrFolderList, true /*useCaseSensitiveFileNames*/)), - defaultLibraryPath: bundled.LibPath(), + sys := &testSys{ + fs: &incrementaltestutil.FsHandlingBuildInfo{ + FS: &testFs{ + FS: vfstest.FromMap(fileOrFolderList, true /*useCaseSensitiveFileNames*/), + }, + }, + defaultLibraryPath: tscLibPath, cwd: cwd, files: slices.Collect(maps.Keys(fileOrFolderList)), output: []string{}, currentWrite: &strings.Builder{}, start: time.Now(), } + + // Ensure the default library file is present + sys.ensureLibPathExists("lib.d.ts") + for _, libFile := range tsoptions.TargetToLibMap() { + sys.ensureLibPathExists(libFile) + } + for libFile := range tsoptions.LibFilesSet.Keys() { + sys.ensureLibPathExists(libFile) + } + return sys +} + +type diffEntry struct { + content string + fileInfo fs.FileInfo +} + +type snapshot struct { + snap map[string]*diffEntry + defaultLibs *collections.SyncSet[string] } type testSys struct { // todo: original has write to output as a string[] because the separations are needed for baselining output []string currentWrite *strings.Builder - serializedDiff map[string]string + serializedDiff *snapshot - fs vfs.FS + fs *incrementaltestutil.FsHandlingBuildInfo defaultLibraryPath string cwd string files []string @@ -46,10 +103,7 @@ type testSys struct { start time.Time } -func (s *testSys) IsTestDone() bool { - // todo: test is done if there are no edits left. Edits are not yet implemented - return true -} +var _ execute.System = (*testSys)(nil) func (s *testSys) Now() time.Time { // todo: make a "test time" structure @@ -64,6 +118,28 @@ func (s *testSys) FS() vfs.FS { return s.fs } +func (s *testSys) testFs() *testFs { + return s.fs.FS.(*testFs) +} + +func (s *testSys) fsFromFileMap() vfs.FS { + return s.testFs().FS +} + +func (s *testSys) ensureLibPathExists(path string) { + path = tscLibPath + "/" + path + if _, ok := s.fsFromFileMap().ReadFile(path); !ok { + if s.testFs().defaultLibs == nil { + s.testFs().defaultLibs = &collections.SyncSet[string]{} + } + s.testFs().defaultLibs.Add(path) + err := s.fsFromFileMap().WriteFile(path, tscDefaultLibContent, false) + if err != nil { + panic("Failed to write default library file: " + err.Error()) + } + } +} + func (s *testSys) DefaultLibraryPath() string { return s.defaultLibraryPath } @@ -80,10 +156,60 @@ func (s *testSys) Writer() io.Writer { return s.currentWrite } +func sanitizeSysOutput(output string, prefixLine string, replaceString string) string { + if index := strings.Index(output, prefixLine); index != -1 { + indexOfNewLine := strings.Index(output[index:], "\n") + if indexOfNewLine != -1 { + output = output[:index] + replaceString + output[index+indexOfNewLine+1:] + } + } + return output +} + func (s *testSys) EndWrite() { // todo: revisit if improving tsc/build/watch unittest baselines - s.output = append(s.output, s.currentWrite.String()) + output := s.currentWrite.String() s.currentWrite.Reset() + output = sanitizeSysOutput(output, "Version "+core.Version(), "Version FakeTSVersion\n") + output = sanitizeSysOutput(output, "build starting at ", "") + output = sanitizeSysOutput(output, "build finished in ", "") + s.output = append(s.output, output) +} + +func (s *testSys) baselineProgram(baseline *strings.Builder, program *incremental.Program, watcher *execute.Watcher) { + if watcher != nil { + program = watcher.GetProgram() + } + if program == nil { + return + } + + baseline.WriteString("SemanticDiagnostics::\n") + semanticDiagnostics, diagnosticsFromOldProgram, updatedSignatureKinds := program.GetTestingData(program.GetProgram()) + for _, file := range program.GetProgram().GetSourceFiles() { + if diagnostics, ok := semanticDiagnostics[file.Path()]; ok { + if oldDiagnostics, ok := diagnosticsFromOldProgram[file.Path()]; !ok || oldDiagnostics != diagnostics { + baseline.WriteString("*refresh* " + file.FileName() + "\n") + } + } else { + baseline.WriteString("*not cached* " + file.FileName() + "\n") + } + } + + // Write signature updates + baseline.WriteString("Signatures::\n") + for _, file := range program.GetProgram().GetSourceFiles() { + if kind, loaded := updatedSignatureKinds.Load(file.Path()); loaded { + switch kind { + case incremental.SignatureUpdateKindComputedDts: + baseline.WriteString("(computed .d.ts) " + file.FileName() + "\n") + case incremental.SignatureUpdateKindStoredAtEmit: + baseline.WriteString("(stored at emit) " + file.FileName() + "\n") + case incremental.SignatureUpdateKindUsedVersion: + baseline.WriteString("(used version) " + file.FileName() + "\n") + } + } + } } func (s *testSys) serializeState(baseline *strings.Builder) { @@ -105,14 +231,17 @@ func (s *testSys) baselineOutput(baseline io.Writer) { } // todo screen clears s.printOutputs(baseline) +} + +func (s *testSys) clearOutput() { s.output = []string{} } func (s *testSys) baselineFSwithDiff(baseline io.Writer) { // todo: baselines the entire fs, possibly doesn't correctly diff all cases of emitted files, since emit isn't fully implemented and doesn't always emit the same way as strada - snap := map[string]string{} + snap := map[string]*diffEntry{} - err := s.FS().WalkDir("/", func(path string, d vfs.DirEntry, e error) error { + err := s.fsFromFileMap().WalkDir("/", func(path string, d vfs.DirEntry, e error) error { if e != nil { return e } @@ -121,41 +250,67 @@ func (s *testSys) baselineFSwithDiff(baseline io.Writer) { return nil } - newContents, ok := s.FS().ReadFile(path) + newContents, ok := s.fsFromFileMap().ReadFile(path) if !ok { return nil } - snap[path] = newContents - reportFSEntryDiff(baseline, s.serializedDiff[path], newContents, path) + fileInfo, err := d.Info() + if err != nil { + return nil + } + newEntry := &diffEntry{content: newContents, fileInfo: fileInfo} + snap[path] = newEntry + s.reportFSEntryDiff(baseline, newEntry, path) return nil }) if err != nil && !errors.Is(err, fs.ErrNotExist) { panic("walkdir error during diff: " + err.Error()) } - for path, oldDirContents := range s.serializedDiff { - if s.FS().FileExists(path) { - _, ok := s.FS().ReadFile(path) + if s.serializedDiff != nil { + for path := range s.serializedDiff.snap { + _, ok := s.fsFromFileMap().ReadFile(path) if !ok { // report deleted - reportFSEntryDiff(baseline, oldDirContents, "", path) + s.reportFSEntryDiff(baseline, nil, path) } } } - s.serializedDiff = snap + var defaultLibs collections.SyncSet[string] + if s.testFs().defaultLibs != nil { + s.testFs().defaultLibs.Range(func(libPath string) bool { + defaultLibs.Add(libPath) + return true + }) + } + s.serializedDiff = &snapshot{ + snap: snap, + defaultLibs: &defaultLibs, + } fmt.Fprintln(baseline) } -func reportFSEntryDiff(baseline io.Writer, oldDirContent string, newDirContent string, path string) { +func (s *testSys) reportFSEntryDiff(baseline io.Writer, newDirContent *diffEntry, path string) { + var oldDirContent *diffEntry + var defaultLibs *collections.SyncSet[string] + if s.serializedDiff != nil { + oldDirContent = s.serializedDiff.snap[path] + defaultLibs = s.serializedDiff.defaultLibs + } // todo handle more cases of fs changes - if oldDirContent == "" { - fmt.Fprint(baseline, "//// [", path, "] new file\n", newDirContent, "\n") - } else if newDirContent == "" { - fmt.Fprint(baseline, "//// [", path, "] deleted\n") - } else if newDirContent == oldDirContent { - fmt.Fprint(baseline, "//// [", path, "] no change\n") - } else { - fmt.Fprint(baseline, "//// [", path, "] modified. new content:\n", newDirContent, "\n") + if oldDirContent == nil { + if s.testFs().defaultLibs == nil || !s.testFs().defaultLibs.Has(path) { + fmt.Fprint(baseline, "//// [", path, "] *new* \n", newDirContent.content, "\n") + } + } else if newDirContent == nil { + fmt.Fprint(baseline, "//// [", path, "] *deleted*\n") + } else if newDirContent.content != oldDirContent.content { + fmt.Fprint(baseline, "//// [", path, "] *modified* \n", newDirContent.content, "\n") + } else if newDirContent.fileInfo.ModTime() != oldDirContent.fileInfo.ModTime() { + fmt.Fprint(baseline, "//// [", path, "] *modified time*\n") + } else if defaultLibs != nil && defaultLibs.Has(path) && s.testFs().defaultLibs != nil && !s.testFs().defaultLibs.Has(path) { + // Lib file that was read + fmt.Fprint(baseline, "//// [", path, "] *Lib*\n", newDirContent.content, "\n") } } @@ -163,3 +318,34 @@ func (s *testSys) printOutputs(baseline io.Writer) { // todo sanitize sys output fmt.Fprint(baseline, strings.Join(s.output, "\n")) } + +func (s *testSys) writeFileNoError(path string, content string, writeByteOrderMark bool) { + if err := s.fsFromFileMap().WriteFile(path, content, writeByteOrderMark); err != nil { + panic(err) + } +} + +func (s *testSys) replaceFileText(path string, oldText string, newText string) { + content, ok := s.fsFromFileMap().ReadFile(path) + if !ok { + panic("File not found: " + path) + } + content = strings.Replace(content, oldText, newText, 1) + s.writeFileNoError(path, content, false) +} + +func (s *testSys) appendFile(path string, text string) { + content, ok := s.fsFromFileMap().ReadFile(path) + if !ok { + panic("File not found: " + path) + } + s.writeFileNoError(path, content+text, false) +} + +func (s *testSys) prependFile(path string, text string) { + content, ok := s.fsFromFileMap().ReadFile(path) + if !ok { + panic("File not found: " + path) + } + s.writeFileNoError(path, text+content, false) +} diff --git a/internal/execute/tsc.go b/internal/execute/tsc.go index c2fefa12bd..5b414acd06 100644 --- a/internal/execute/tsc.go +++ b/internal/execute/tsc.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "runtime" - "slices" "strings" "time" @@ -15,6 +14,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/format" + "github.com/microsoft/typescript-go/internal/incremental" "github.com/microsoft/typescript-go/internal/parser" "github.com/microsoft/typescript-go/internal/pprof" "github.com/microsoft/typescript-go/internal/tsoptions" @@ -41,25 +41,20 @@ func applyBulkEdits(text string, edits []core.TextChange) string { return b.String() } -func CommandLine(sys System, cb cbType, commandLineArgs []string) ExitStatus { +func CommandLine(sys System, commandLineArgs []string, testing bool) (ExitStatus, *incremental.Program, *Watcher) { if len(commandLineArgs) > 0 { // !!! build mode switch strings.ToLower(commandLineArgs[0]) { case "-b", "--b", "-build", "--build": fmt.Fprint(sys.Writer(), "Build mode is currently unsupported."+sys.NewLine()) sys.EndWrite() - return ExitStatusNotImplemented + return ExitStatusNotImplemented, nil, nil // case "-f": // return fmtMain(sys, commandLineArgs[1], commandLineArgs[1]) } } - parsedCommandLine := tsoptions.ParseCommandLine(commandLineArgs, sys) - e, watcher := executeCommandLineWorker(sys, cb, parsedCommandLine) - if watcher == nil { - return e - } - return start(watcher) + return tscCompilation(sys, tsoptions.ParseCommandLine(commandLineArgs, sys), testing) } func fmtMain(sys System, input, output string) ExitStatus { @@ -88,7 +83,7 @@ func fmtMain(sys System, input, output string) ExitStatus { return ExitStatusSuccess } -func executeCommandLineWorker(sys System, cb cbType, commandLine *tsoptions.ParsedCommandLine) (ExitStatus, *watcher) { +func tscCompilation(sys System, commandLine *tsoptions.ParsedCommandLine, testing bool) (ExitStatus, *incremental.Program, *Watcher) { configFileName := "" reportDiagnostic := createDiagnosticReporter(sys, commandLine.CompilerOptions()) // if commandLine.Options().Locale != nil @@ -97,7 +92,7 @@ func executeCommandLineWorker(sys System, cb cbType, commandLine *tsoptions.Pars for _, e := range commandLine.Errors { reportDiagnostic(e) } - return ExitStatusDiagnosticsPresent_OutputsSkipped, nil + return ExitStatusDiagnosticsPresent_OutputsSkipped, nil, nil } if pprofDir := commandLine.CompilerOptions().PprofDir; pprofDir != "" { @@ -107,27 +102,28 @@ func executeCommandLineWorker(sys System, cb cbType, commandLine *tsoptions.Pars } if commandLine.CompilerOptions().Init.IsTrue() { - return ExitStatusNotImplemented, nil + return ExitStatusNotImplemented, nil, nil } if commandLine.CompilerOptions().Version.IsTrue() { printVersion(sys) - return ExitStatusSuccess, nil + return ExitStatusSuccess, nil, nil } if commandLine.CompilerOptions().Help.IsTrue() || commandLine.CompilerOptions().All.IsTrue() { printHelp(sys, commandLine) - return ExitStatusSuccess, nil + return ExitStatusSuccess, nil, nil } if commandLine.CompilerOptions().Watch.IsTrue() && commandLine.CompilerOptions().ListFilesOnly.IsTrue() { - return ExitStatusNotImplemented, nil + reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.Options_0_and_1_cannot_be_combined, "watch", "listFilesOnly")) + return ExitStatusDiagnosticsPresent_OutputsSkipped, nil, nil } if commandLine.CompilerOptions().Project != "" { if len(commandLine.FileNames()) != 0 { reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)) - return ExitStatusDiagnosticsPresent_OutputsSkipped, nil + return ExitStatusDiagnosticsPresent_OutputsSkipped, nil, nil } fileOrDirectory := tspath.NormalizePath(commandLine.CompilerOptions().Project) @@ -135,13 +131,13 @@ func executeCommandLineWorker(sys System, cb cbType, commandLine *tsoptions.Pars configFileName = tspath.CombinePaths(fileOrDirectory, "tsconfig.json") if !sys.FS().FileExists(configFileName) { reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, configFileName)) - return ExitStatusDiagnosticsPresent_OutputsSkipped, nil + return ExitStatusDiagnosticsPresent_OutputsSkipped, nil, nil } } else { configFileName = fileOrDirectory if !sys.FS().FileExists(configFileName) { reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.The_specified_path_does_not_exist_Colon_0, fileOrDirectory)) - return ExitStatusDiagnosticsPresent_OutputsSkipped, nil + return ExitStatusDiagnosticsPresent_OutputsSkipped, nil, nil } } } else if len(commandLine.FileNames()) == 0 { @@ -156,61 +152,56 @@ func executeCommandLineWorker(sys System, cb cbType, commandLine *tsoptions.Pars printVersion(sys) printHelp(sys, commandLine) } - return ExitStatusDiagnosticsPresent_OutputsSkipped, nil + return ExitStatusDiagnosticsPresent_OutputsSkipped, nil, nil } // !!! convert to options with absolute paths is usually done here, but for ease of implementation, it's done in `tsoptions.ParseCommandLine()` compilerOptionsFromCommandLine := commandLine.CompilerOptions() - + configForCompilation := commandLine + var extendedConfigCache collections.SyncMap[tspath.Path, *tsoptions.ExtendedConfigCacheEntry] + var configTime time.Duration if configFileName != "" { configStart := sys.Now() - extendedConfigCache := collections.SyncMap[tspath.Path, *tsoptions.ExtendedConfigCacheEntry]{} configParseResult, errors := tsoptions.GetParsedCommandLineOfConfigFile(configFileName, compilerOptionsFromCommandLine, sys, &extendedConfigCache) - configTime := sys.Now().Sub(configStart) + configTime = sys.Now().Sub(configStart) if len(errors) != 0 { // these are unrecoverable errors--exit to report them as diagnostics for _, e := range errors { reportDiagnostic(e) } - return ExitStatusDiagnosticsPresent_OutputsGenerated, nil - } - if compilerOptionsFromCommandLine.ShowConfig.IsTrue() { - showConfig(sys, configParseResult.CompilerOptions()) - return ExitStatusSuccess, nil - } - // updateReportDiagnostic - if isWatchSet(configParseResult.CompilerOptions()) { - return ExitStatusSuccess, createWatcher(sys, configParseResult, reportDiagnostic) + return ExitStatusDiagnosticsPresent_OutputsGenerated, nil, nil } - // !!! incremental - return performCompilation( + configForCompilation = configParseResult + // Updater to reflect pretty + reportDiagnostic = createDiagnosticReporter(sys, commandLine.CompilerOptions()) + } + + if compilerOptionsFromCommandLine.ShowConfig.IsTrue() { + showConfig(sys, configForCompilation.CompilerOptions()) + return ExitStatusSuccess, nil, nil + } + if configForCompilation.CompilerOptions().Watch.IsTrue() { + watcher := createWatcher(sys, configForCompilation, reportDiagnostic, testing) + watcher.start() + return ExitStatusSuccess, nil, watcher + } else if configForCompilation.CompilerOptions().IsIncremental() { + exitStatus, program := performIncrementalCompilation( sys, - cb, - configParseResult, + configForCompilation, reportDiagnostic, &extendedConfigCache, configTime, - ), nil - } else { - if compilerOptionsFromCommandLine.ShowConfig.IsTrue() { - showConfig(sys, compilerOptionsFromCommandLine) - return ExitStatusSuccess, nil - } - // todo update reportDiagnostic - if isWatchSet(compilerOptionsFromCommandLine) { - // !!! reportWatchModeWithoutSysSupport - return ExitStatusSuccess, createWatcher(sys, commandLine, reportDiagnostic) - } - // !!! incremental + testing, + ) + return exitStatus, program, nil } return performCompilation( sys, - cb, - commandLine, + configForCompilation, reportDiagnostic, - nil, - 0, /*configTime*/ - ), nil + &extendedConfigCache, + configTime, + ), nil, nil } func findConfigFile(searchPath string, fileExists func(string) bool, configName string) string { @@ -227,9 +218,38 @@ func findConfigFile(searchPath string, fileExists func(string) bool, configName return result } +func performIncrementalCompilation( + sys System, + config *tsoptions.ParsedCommandLine, + reportDiagnostic diagnosticReporter, + extendedConfigCache *collections.SyncMap[tspath.Path, *tsoptions.ExtendedConfigCacheEntry], + configTime time.Duration, + testing bool, +) (ExitStatus, *incremental.Program) { + host := compiler.NewCachedFSCompilerHost(config.CompilerOptions(), sys.GetCurrentDirectory(), sys.FS(), sys.DefaultLibraryPath(), extendedConfigCache) + oldProgram := incremental.ReadBuildInfoProgram(config, incremental.NewBuildInfoReader(host)) + // todo: cache, statistics, tracing + parseStart := sys.Now() + program := compiler.NewProgram(compiler.ProgramOptions{ + Config: config, + Host: host, + JSDocParsingMode: ast.JSDocParsingModeParseForTypeErrors, + }) + parseTime := sys.Now().Sub(parseStart) + incrementalProgram := incremental.NewProgram(program, oldProgram, testing) + return emitAndReportStatistics( + sys, + incrementalProgram, + incrementalProgram.GetProgram, + config, + reportDiagnostic, + configTime, + parseTime, + ), incrementalProgram +} + func performCompilation( sys System, - cb cbType, config *tsoptions.ParsedCommandLine, reportDiagnostic diagnosticReporter, extendedConfigCache *collections.SyncMap[tspath.Path, *tsoptions.ExtendedConfigCacheEntry], @@ -244,7 +264,28 @@ func performCompilation( JSDocParsingMode: ast.JSDocParsingModeParseForTypeErrors, }) parseTime := sys.Now().Sub(parseStart) + return emitAndReportStatistics( + sys, + program, + func() *compiler.Program { + return program + }, + config, + reportDiagnostic, + configTime, + parseTime, + ) +} +func emitAndReportStatistics( + sys System, + program compiler.AnyProgram, + getCoreProgram func() *compiler.Program, + config *tsoptions.ParsedCommandLine, + reportDiagnostic diagnosticReporter, + configTime time.Duration, + parseTime time.Duration, +) ExitStatus { result := emitFilesAndReportErrors(sys, program, reportDiagnostic) if result.status != ExitStatusSuccess { // compile exited early @@ -262,11 +303,7 @@ func performCompilation( runtime.GC() runtime.ReadMemStats(&memStats) - reportStatistics(sys, program, result, &memStats) - } - - if cb != nil { - cb(program) + reportStatistics(sys, getCoreProgram(), result, &memStats) } if result.emitResult.EmitSkipped && len(result.diagnostics) > 0 { @@ -289,47 +326,40 @@ type compileAndEmitResult struct { emitTime time.Duration } -func emitFilesAndReportErrors(sys System, program *compiler.Program, reportDiagnostic diagnosticReporter) (result compileAndEmitResult) { +func emitFilesAndReportErrors( + sys System, + program compiler.AnyProgram, + reportDiagnostic diagnosticReporter, +) (result compileAndEmitResult) { ctx := context.Background() - options := program.Options() - allDiagnostics := slices.Clip(program.GetConfigFileParsingDiagnostics()) - configFileParsingDiagnosticsLength := len(allDiagnostics) - - allDiagnostics = append(allDiagnostics, program.GetSyntacticDiagnostics(ctx, nil)...) - allDiagnostics = append(allDiagnostics, program.GetProgramDiagnostics()...) - if len(allDiagnostics) == configFileParsingDiagnosticsLength { - // Options diagnostics include global diagnostics (even though we collect them separately), - // and global diagnostics create checkers, which then bind all of the files. Do this binding - // early so we can track the time. - bindStart := sys.Now() - _ = program.GetBindDiagnostics(ctx, nil) - result.bindTime = sys.Now().Sub(bindStart) - - allDiagnostics = append(allDiagnostics, program.GetOptionsDiagnostics(ctx)...) - - if options.ListFilesOnly.IsFalseOrUnknown() { - allDiagnostics = append(allDiagnostics, program.GetGlobalDiagnostics(ctx)...) - - if len(allDiagnostics) == configFileParsingDiagnosticsLength { - checkStart := sys.Now() - allDiagnostics = append(allDiagnostics, program.GetSemanticDiagnostics(ctx, nil)...) - result.checkTime = sys.Now().Sub(checkStart) + allDiagnostics := compiler.GetDiagnosticsOfAnyProgram( + ctx, + program, + nil, + false, + func(name string, start bool, startTime time.Time) time.Time { + if !start { + switch name { + case "bind": + result.bindTime = sys.Now().Sub(startTime) + case "check": + result.checkTime = sys.Now().Sub(startTime) + } } - - if options.NoEmit.IsTrue() && options.GetEmitDeclarations() && len(allDiagnostics) == configFileParsingDiagnosticsLength { - allDiagnostics = append(allDiagnostics, program.GetDeclarationDiagnostics(ctx, nil)...) - } - } - } + return sys.Now() + }, + ) emitResult := &compiler.EmitResult{EmitSkipped: true, Diagnostics: []*ast.Diagnostic{}} - if !options.ListFilesOnly.IsTrue() { + if !program.Options().ListFilesOnly.IsTrue() { emitStart := sys.Now() - emitResult = program.Emit(compiler.EmitOptions{}) + emitResult = program.Emit(ctx, compiler.EmitOptions{}) result.emitTime = sys.Now().Sub(emitStart) } - allDiagnostics = append(allDiagnostics, emitResult.Diagnostics...) + if emitResult != nil { + allDiagnostics = append(allDiagnostics, emitResult.Diagnostics...) + } allDiagnostics = compiler.SortAndDeduplicateDiagnostics(allDiagnostics) for _, diagnostic := range allDiagnostics { @@ -338,7 +368,7 @@ func emitFilesAndReportErrors(sys System, program *compiler.Program, reportDiagn if sys.Writer() != nil { for _, file := range emitResult.EmittedFiles { - fmt.Fprint(sys.Writer(), "TSFILE: ", tspath.GetNormalizedAbsolutePath(file, sys.GetCurrentDirectory())) + fmt.Fprint(sys.Writer(), "TSFILE: ", tspath.GetNormalizedAbsolutePath(file, sys.GetCurrentDirectory()), sys.NewLine()) } listFiles(sys, program) } @@ -354,14 +384,6 @@ func emitFilesAndReportErrors(sys System, program *compiler.Program, reportDiagn // return len(args) > 0 && args[0] == "build" // } -func isWatchSet(options *core.CompilerOptions) bool { - return options.Watch.IsTrue() -} - -func isIncrementalCompilation(options *core.CompilerOptions) bool { - return options.Incremental.IsTrue() -} - func showConfig(sys System, config *core.CompilerOptions) { // !!! enc := json.NewEncoder(sys.Writer()) @@ -369,7 +391,7 @@ func showConfig(sys System, config *core.CompilerOptions) { enc.Encode(config) //nolint:errcheck,errchkjson } -func listFiles(sys System, program *compiler.Program) { +func listFiles(sys System, program compiler.AnyProgram) { options := program.Options() // !!! explainFiles if options.ListFiles.IsTrue() || options.ListFilesOnly.IsTrue() { diff --git a/internal/execute/tsc_test.go b/internal/execute/tsc_test.go index 4a4126b418..cc72906eba 100644 --- a/internal/execute/tsc_test.go +++ b/internal/execute/tsc_test.go @@ -3,21 +3,14 @@ package execute_test import ( "testing" - "github.com/microsoft/typescript-go/internal/bundled" + "github.com/microsoft/typescript-go/internal/testutil/stringtestutil" ) -func TestTsc(t *testing.T) { +func TestTscCommandline(t *testing.T) { t.Parallel() - if !bundled.Embedded { - // Without embedding, we'd need to read all of the lib files out from disk into the MapFS. - // Just skip this for now. - t.Skip("bundled files are not embedded") - } - testCases := []*tscInput{ { subScenario: "show help with ExitStatus.DiagnosticsPresent_OutputsSkipped", - sys: newTestSys(nil, ""), // , { // environmentVariables: new Map([["TS_TEST_TERMINAL_WIDTH", "120"]]), // }), @@ -25,12 +18,10 @@ func TestTsc(t *testing.T) { }, { subScenario: "show help with ExitStatus.DiagnosticsPresent_OutputsSkipped when host cannot provide terminal width", - sys: newTestSys(nil, ""), commandLineArgs: nil, }, { subScenario: "does not add color when NO_COLOR is set", - sys: newTestSys(nil, ""), // , { // environmentVariables: new Map([["NO_COLOR", "true"]]), // }), @@ -38,7 +29,6 @@ func TestTsc(t *testing.T) { }, { subScenario: "does not add color when NO_COLOR is set", - sys: newTestSys(nil, ""), // , { // environmentVariables: new Map([["NO_COLOR", "true"]]), // } @@ -47,204 +37,216 @@ func TestTsc(t *testing.T) { }, { subScenario: "when build not first argument", - sys: newTestSys(nil, ""), commandLineArgs: []string{"--verbose", "--build"}, }, { subScenario: "help", - sys: newTestSys(nil, ""), commandLineArgs: []string{"--help"}, }, { subScenario: "help all", - sys: newTestSys(nil, ""), commandLineArgs: []string{"--help", "--all"}, }, { subScenario: "Parse --lib option with file name", - sys: newTestSys(FileMap{"/home/src/workspaces/project/first.ts": `export const Key = Symbol()`}, ""), + files: FileMap{"/home/src/workspaces/project/first.ts": `export const Key = Symbol()`}, commandLineArgs: []string{"--lib", "es6 ", "first.ts"}, }, { subScenario: "Project is empty string", - sys: newTestSys(FileMap{ - "/home/src/workspaces/project/first.ts": `export const a = 1`, - "/home/src/workspaces/project/tsconfig.json": `{ "compilerOptions": { "strict": true, "noEmit": true } }`, - }, ""), + files: FileMap{ + "/home/src/workspaces/project/first.ts": `export const a = 1`, + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "strict": true, + "noEmit": true + } + }`), + }, commandLineArgs: []string{}, }, { subScenario: "Parse -p", - sys: newTestSys(FileMap{ - "/home/src/workspaces/project/first.ts": `export const a = 1`, - "/home/src/workspaces/project/tsconfig.json": `{ "compilerOptions": { "strict": true, "noEmit": true } }`, - }, ""), + files: FileMap{ + "/home/src/workspaces/project/first.ts": `export const a = 1`, + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "strict": true, + "noEmit": true + } + }`), + }, commandLineArgs: []string{"-p", "."}, }, { subScenario: "Parse -p with path to tsconfig file", - sys: newTestSys(FileMap{ - "/home/src/workspaces/project/first.ts": `export const a = 1`, - "/home/src/workspaces/project/tsconfig.json": `{ "compilerOptions": { "strict": true, "noEmit": true } }`, - }, ""), + files: FileMap{ + "/home/src/workspaces/project/first.ts": `export const a = 1`, + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "strict": true, + "noEmit": true + } + }`), + }, commandLineArgs: []string{"-p", "/home/src/workspaces/project/tsconfig.json"}, }, { subScenario: "Parse -p with path to tsconfig folder", - sys: newTestSys(FileMap{ - "/home/src/workspaces/project/first.ts": `export const a = 1`, - "/home/src/workspaces/project/tsconfig.json": `{ "compilerOptions": { "strict": true, "noEmit": true } }`, - }, ""), + files: FileMap{ + "/home/src/workspaces/project/first.ts": `export const a = 1`, + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "strict": true, + "noEmit": true + } + }`), + }, commandLineArgs: []string{"-p", "/home/src/workspaces/project"}, }, { subScenario: "Parse enum type options", - sys: newTestSys(nil, ""), commandLineArgs: []string{"--moduleResolution", "nodenext ", "first.ts", "--module", "nodenext", "--target", "esnext", "--moduleDetection", "auto", "--jsx", "react", "--newLine", "crlf"}, }, { subScenario: "Parse watch interval option", - sys: newTestSys(FileMap{ - "/home/src/workspaces/project/first.ts": `export const a = 1`, - "/home/src/workspaces/project/tsconfig.json": `{ "compilerOptions": { "strict": true, "noEmit": true } }`, - }, ""), + files: FileMap{ + "/home/src/workspaces/project/first.ts": `export const a = 1`, + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "strict": true, + "noEmit": true + } + }`), + }, commandLineArgs: []string{"-w", "--watchInterval", "1000"}, }, { subScenario: "Parse watch interval option without tsconfig.json", - sys: newTestSys(nil, ""), commandLineArgs: []string{"-w", "--watchInterval", "1000"}, }, } for _, testCase := range testCases { - testCase.verifyCommandLineParsing(t, "commandLine") + testCase.run(t, "commandLine") } } func TestNoEmit(t *testing.T) { t.Parallel() - if !bundled.Embedded { - // Without embedding, we'd need to read all of the lib files out from disk into the MapFS. - // Just skip this for now. - t.Skip("bundled files are not embedded") - } - (&tscInput{ subScenario: "when project has strict true", - sys: newTestSys(FileMap{ - "/home/src/workspaces/project/tsconfig.json": `{ - "compilerOptions": { - "incremental": true, - "strict": true, - }, -}`, + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "incremental": true, + "strict": true + } + }`), "/home/src/workspaces/project/class1.ts": `export class class1 {}`, - }, ""), + }, commandLineArgs: []string{"--noEmit"}, - }).verify(t, "noEmit") + }).run(t, "noEmit") } func TestExtends(t *testing.T) { t.Parallel() - if !bundled.Embedded { - // Without embedding, we'd need to read all of the lib files out from disk into the MapFS. - // Just skip this for now. - t.Skip("bundled files are not embedded") + extendsSysScenario := func(subScenario string, commandlineArgs []string) *tscInput { + return &tscInput{ + subScenario: subScenario, + commandLineArgs: commandlineArgs, + files: FileMap{ + "/home/src/projects/configs/first/tsconfig.json": stringtestutil.Dedent(` + { + "extends": "../second/tsconfig.json", + "include": ["${configDir}/src"], + "compilerOptions": { + "typeRoots": ["root1", "${configDir}/root2", "root3"], + "types": [], + } + }`), + "/home/src/projects/configs/second/tsconfig.json": stringtestutil.Dedent(` + { + "files": ["${configDir}/main.ts"], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "paths": { + "@myscope/*": ["${configDir}/types/*"], + "other/*": ["other/*"], + }, + "baseUrl": "${configDir}", + }, + "watchOptions": { + "excludeFiles": ["${configDir}/main.ts"], + }, + }`), + "/home/src/projects/myproject/tsconfig.json": stringtestutil.Dedent(` + { + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true, + }, + }`), + "/home/src/projects/myproject/main.ts": stringtestutil.Dedent(` + // some comment + export const y = 10; + import { x } from "@myscope/sometype"; + `), + "/home/src/projects/myproject/src/secondary.ts": stringtestutil.Dedent(` + // some comment + export const z = 10; + import { k } from "other/sometype2"; + `), + "/home/src/projects/myproject/types/sometype.ts": stringtestutil.Dedent(` + // some comment + export const x = 10; + `), + "/home/src/projects/myproject/root2/other/sometype2/index.d.ts": stringtestutil.Dedent(` + export const k = 10; + `), + }, + cwd: "/home/src/projects/myproject", + } } - extendsSysFiles := FileMap{ - "/home/src/projects/configs/first/tsconfig.json": `{ - "extends": "../second/tsconfig.json", - "include": ["${configDir}/src"], - "compilerOptions": { - "typeRoots": ["root1", "${configDir}/root2", "root3"], - "types": [], - }, -}`, - "/home/src/projects/configs/second/tsconfig.json": `{ - "files": ["${configDir}/main.ts"], - "compilerOptions": { - "declarationDir": "${configDir}/decls", - "paths": { - "@myscope/*": ["${configDir}/types/*"], - "other/*": ["other/*"], - }, - "baseUrl": "${configDir}", - }, - "watchOptions": { - "excludeFiles": ["${configDir}/main.ts"], - }, -}`, - "/home/src/projects/myproject/tsconfig.json": `{ - "extends": "../configs/first/tsconfig.json", - "compilerOptions": { - "declaration": true, - "outDir": "outDir", - "traceResolution": true, - }, -}`, - - "/home/src/projects/myproject/main.ts": ` - // some comment - export const y = 10; - import { x } from "@myscope/sometype"; -`, - "/home/src/projects/myproject/src/secondary.ts": ` - // some comment - export const z = 10; - import { k } from "other/sometype2"; -`, - "/home/src/projects/myproject/types/sometype.ts": ` - export const x = 10; -`, - "/home/src/projects/myproject/root2/other/sometype2/index.d.ts": ` - export const k = 10; -`, + cases := []*tscInput{ + extendsSysScenario("configDir template", []string{"--explainFiles"}), + extendsSysScenario("configDir template showConfig", []string{"--showConfig"}), + extendsSysScenario("configDir template with commandline", []string{"--explainFiles", "--outDir", "${configDir}/outDir"}), } - cases := []tscInput{{ - subScenario: "configDir template", - sys: newTestSys(extendsSysFiles, "/home/src/projects/myproject"), - commandLineArgs: []string{"--explainFiles"}, - }, { - subScenario: "configDir template showConfig", - sys: newTestSys(extendsSysFiles, "/home/src/projects/myproject"), - commandLineArgs: []string{"--showConfig"}, - }, { - subScenario: "configDir template with commandline", - sys: newTestSys(extendsSysFiles, "/home/src/projects/myproject"), - commandLineArgs: []string{"--explainFiles", "--outDir", "${configDir}/outDir"}, - }} - for _, c := range cases { - c.verify(t, "extends") + c.run(t, "extends") } } func TestTypeAcquisition(t *testing.T) { t.Parallel() - if !bundled.Embedded { - // Without embedding, we'd need to read all of the lib files out from disk into the MapFS. - // Just skip this for now. - t.Skip("bundled files are not embedded") - } (&tscInput{ subScenario: "parse tsconfig with typeAcquisition", - sys: newTestSys(FileMap{"/home/src/workspaces/project/tsconfig.json": `{ - "compilerOptions": { - "composite": true, - "noEmit": true, - }, - "typeAcquisition": { - "enable": true, - "include": ["0.d.ts", "1.d.ts"], - "exclude": ["0.js", "1.js"], - "disableFilenameBasedTypeAcquisition": true, - }, -}`}, - "/home/src/workspaces/project", - ), + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "composite": true, + "noEmit": true, + }, + "typeAcquisition": { + "enable": true, + "include": ["0.d.ts", "1.d.ts"], + "exclude": ["0.js", "1.js"], + "disableFilenameBasedTypeAcquisition": true, + }, + }`), + }, commandLineArgs: []string{}, - }).verify(t, "typeAcquisition") + }).run(t, "typeAcquisition") } diff --git a/internal/execute/tscincremental_test.go b/internal/execute/tscincremental_test.go new file mode 100644 index 0000000000..2604ee5d72 --- /dev/null +++ b/internal/execute/tscincremental_test.go @@ -0,0 +1,699 @@ +package execute_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/testutil/stringtestutil" +) + +func TestIncremental(t *testing.T) { + t.Parallel() + testCases := []*tscInput{ + { + subScenario: "serializing error chain", + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "incremental": true, + "strict": true, + "jsx": "react", + "module": "esnext", + }, + }`), + "/home/src/workspaces/project/index.tsx": stringtestutil.Dedent(` + declare namespace JSX { + interface ElementChildrenAttribute { children: {}; } + interface IntrinsicElements { div: {} } + } + + declare var React: any; + + declare function Component(props: never): any; + declare function Component(props: { children?: number }): any; + ( +
+
+ )`), + }, + edits: noChangeOnlyEdit, + }, + { + subScenario: "serializing composite project", + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "composite": true, + "strict": true, + "module": "esnext", + }, + }`), + "/home/src/workspaces/project/index.tsx": `export const a = 1;`, + "/home/src/workspaces/project/other.ts": `export const b = 2;`, + }, + }, + { + subScenario: "change to modifier of class expression field with declaration emit enabled", + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "module": "esnext", + "declaration": true + } + }`), + "/home/src/workspaces/project/main.ts": stringtestutil.Dedent(` + import MessageablePerson from './MessageablePerson.js'; + function logMessage( person: MessageablePerson ) { + console.log( person.message ); + }`), + "/home/src/workspaces/project/MessageablePerson.ts": stringtestutil.Dedent(` + const Messageable = () => { + return class MessageableClass { + public message = 'hello'; + } + }; + const wrapper = () => Messageable(); + type MessageablePerson = InstanceType>; + export default MessageablePerson;`), + tscLibPath + "/lib.d.ts": tscDefaultLibContent + "\n" + stringtestutil.Dedent(` + type ReturnType any> = T extends (...args: any) => infer R ? R : any; + type InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;`), + }, + commandLineArgs: []string{"--incremental"}, + edits: []*testTscEdit{ + noChange, + { + caption: "modify public to protected", + edit: func(sys *testSys) { + sys.replaceFileText("/home/src/workspaces/project/MessageablePerson.ts", "public", "protected") + }, + }, + noChange, + { + caption: "modify protected to public", + edit: func(sys *testSys) { + sys.replaceFileText("/home/src/workspaces/project/MessageablePerson.ts", "protected", "public") + }, + }, + noChange, + }, + }, + { + subScenario: "change to modifier of class expression field", + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "module": "esnext" + } + }`), + "/home/src/workspaces/project/main.ts": stringtestutil.Dedent(` + import MessageablePerson from './MessageablePerson.js'; + function logMessage( person: MessageablePerson ) { + console.log( person.message ); + }`), + "/home/src/workspaces/project/MessageablePerson.ts": stringtestutil.Dedent(` + const Messageable = () => { + return class MessageableClass { + public message = 'hello'; + } + }; + const wrapper = () => Messageable(); + type MessageablePerson = InstanceType>; + export default MessageablePerson;`), + tscLibPath + "/lib.d.ts": tscDefaultLibContent + "\n" + stringtestutil.Dedent(` + type ReturnType any> = T extends (...args: any) => infer R ? R : any; + type InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;`), + }, + commandLineArgs: []string{"--incremental"}, + edits: []*testTscEdit{ + noChange, + { + caption: "modify public to protected", + edit: func(sys *testSys) { + sys.replaceFileText("/home/src/workspaces/project/MessageablePerson.ts", "public", "protected") + }, + }, + noChange, + { + caption: "modify protected to public", + edit: func(sys *testSys) { + sys.replaceFileText("/home/src/workspaces/project/MessageablePerson.ts", "protected", "public") + }, + }, + noChange, + }, + }, + { + subScenario: "when passing filename for buildinfo on commandline", + files: FileMap{ + "/home/src/workspaces/project/src/main.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "target": "es5", + "module": "commonjs" + }, + "include": [ + "src/**/*.ts" + ], + }`), + }, + commandLineArgs: []string{"--incremental", "--tsBuildInfoFile", ".tsbuildinfo", "--explainFiles"}, + edits: noChangeOnlyEdit, + }, + { + subScenario: "when passing rootDir from commandline", + files: FileMap{ + "/home/src/workspaces/project/src/main.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "incremental": true, + "outDir": "dist" + } + }`), + }, + commandLineArgs: []string{"--rootDir", "src"}, + edits: noChangeOnlyEdit, + }, + { + subScenario: "with only dts files", + files: FileMap{ + "/home/src/workspaces/project/src/main.d.ts": "export const x = 10;", + "/home/src/workspaces/project/src/another.d.ts": "export const y = 10;", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + commandLineArgs: []string{"--incremental"}, + edits: []*testTscEdit{ + noChange, + { + caption: "modify d.ts file", + edit: func(sys *testSys) { + sys.appendFile("/home/src/workspaces/project/src/main.d.ts", "export const xy = 100;") + }, + }, + }, + }, + { + subScenario: "when passing rootDir is in the tsconfig", + files: FileMap{ + "/home/src/workspaces/project/src/main.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "incremental": true, + "outDir": "dist", + "rootDir": "./" + } + }`), + }, + edits: noChangeOnlyEdit, + }, + { + subScenario: "tsbuildinfo has error", + files: FileMap{ + "/home/src/workspaces/project/main.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": "{}", + "/home/src/workspaces/project/tsconfig.tsbuildinfo": "Some random string", + }, + commandLineArgs: []string{"-i"}, + edits: []*testTscEdit{ + { + caption: "tsbuildinfo written has error", + edit: func(sys *testSys) { + sys.prependFile("/home/src/workspaces/project/tsconfig.tsbuildinfo", "Some random string") + }, + }, + }, + }, + { + subScenario: "when global file is added, the signatures are updated", + files: FileMap{ + "/home/src/workspaces/project/src/main.ts": stringtestutil.Dedent(` + /// + /// + function main() { } + `), + "/home/src/workspaces/project/src/anotherFileWithSameReferenes.ts": stringtestutil.Dedent(` + /// + /// + function anotherFileWithSameReferenes() { } + `), + "/home/src/workspaces/project/src/filePresent.ts": `function something() { return 10; }`, + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { "composite": true }, + "include": ["src/**/*.ts"], + }`), + }, + commandLineArgs: []string{}, + edits: []*testTscEdit{ + noChange, + { + caption: "Modify main file", + edit: func(sys *testSys) { + sys.appendFile(`/home/src/workspaces/project/src/main.ts`, `something();`) + }, + }, + { + caption: "Modify main file again", + edit: func(sys *testSys) { + sys.appendFile(`/home/src/workspaces/project/src/main.ts`, `something();`) + }, + }, + { + caption: "Add new file and update main file", + edit: func(sys *testSys) { + sys.writeFileNoError(`/home/src/workspaces/project/src/newFile.ts`, "function foo() { return 20; }", false) + sys.prependFile( + `/home/src/workspaces/project/src/main.ts`, + `/// +`, + ) + sys.appendFile(`/home/src/workspaces/project/src/main.ts`, `foo();`) + }, + }, + { + caption: "Write file that could not be resolved", + edit: func(sys *testSys) { + sys.writeFileNoError(`/home/src/workspaces/project/src/fileNotFound.ts`, "function something2() { return 20; }", false) + }, + }, + { + caption: "Modify main file", + edit: func(sys *testSys) { + sys.appendFile(`/home/src/workspaces/project/src/main.ts`, `something();`) + }, + }, + }, + }, + { + subScenario: "react-jsx-emit-mode with no backing types found doesnt crash", + files: FileMap{ + "/home/src/workspaces/project/node_modules/react/jsx-runtime.js": "export {}", // js needs to be present so there's a resolution result + "/home/src/workspaces/project/node_modules/@types/react/index.d.ts": stringtestutil.Dedent(` + export {}; + declare global { + namespace JSX { + interface Element {} + interface IntrinsicElements { + div: { + propA?: boolean; + }; + } + } + }`), // doesn't contain a jsx-runtime definition + "/home/src/workspaces/project/src/index.tsx": `export const App = () =>
;`, + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "module": "commonjs", + "jsx": "react-jsx", + "incremental": true, + "jsxImportSource": "react" + } + }`), + }, + }, + { + subScenario: "react-jsx-emit-mode with no backing types found doesnt crash under --strict", + files: FileMap{ + "/home/src/workspaces/project/node_modules/react/jsx-runtime.js": "export {}", // js needs to be present so there's a resolution result + "/home/src/workspaces/project/node_modules/@types/react/index.d.ts": stringtestutil.Dedent(` + export {}; + declare global { + namespace JSX { + interface Element {} + interface IntrinsicElements { + div: { + propA?: boolean; + }; + } + } + }`), // doesn't contain a jsx-runtime definition + "/home/src/workspaces/project/src/index.tsx": `export const App = () =>
;`, + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "module": "commonjs", + "jsx": "react-jsx", + "incremental": true, + "jsxImportSource": "react" + } + }`), + }, + commandLineArgs: []string{"--strict"}, + }, + { + subScenario: "change to type that gets used as global through export in another file", + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "composite": true + } + }`), + "/home/src/workspaces/project/class1.ts": stringtestutil.Dedent(` + const a: MagicNumber = 1; + console.log(a);`), + "/home/src/workspaces/project/constants.ts": "export default 1;", + "/home/src/workspaces/project/types.d.ts": `type MagicNumber = typeof import('./constants').default`, + }, + edits: []*testTscEdit{ + { + caption: "Modify imports used in global file", + edit: func(sys *testSys) { + sys.writeFileNoError("/home/src/workspaces/project/constants.ts", "export default 2;", false) + }, + }, + }, + }, + { + subScenario: "change to type that gets used as global through export in another file through indirect import", + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "composite": true + } + }`), + "/home/src/workspaces/project/class1.ts": stringtestutil.Dedent(` + const a: MagicNumber = 1; + console.log(a);`), + "/home/src/workspaces/project/constants.ts": "export default 1;", + "/home/src/workspaces/project/reexport.ts": `export { default as ConstantNumber } from "./constants"`, + "/home/src/workspaces/project/types.d.ts": `type MagicNumber = typeof import('./reexport').ConstantNumber`, + }, + edits: []*testTscEdit{ + { + caption: "Modify imports used in global file", + edit: func(sys *testSys) { + sys.writeFileNoError("/home/src/workspaces/project/constants.ts", "export default 2;", false) + }, + }, + }, + }, + { + subScenario: "when file is deleted", + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "composite": true, + "outDir": "outDir" + } + }`), + "/home/src/workspaces/project/file1.ts": `export class C { }`, + "/home/src/workspaces/project/file2.ts": `export class D { }`, + }, + edits: []*testTscEdit{ + { + caption: "delete file with imports", + edit: func(sys *testSys) { + err := sys.fsFromFileMap().Remove("/home/src/workspaces/project/file2.ts") + if err != nil { + panic(err) + } + }, + }, + }, + }, + { + subScenario: "generates typerefs correctly", + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "composite": true, + "outDir": "outDir", + "checkJs": true + }, + "include": ["src"], + }`), + "/home/src/workspaces/project/src/box.ts": stringtestutil.Dedent(` + export interface Box { + unbox(): T + } + `), + "/home/src/workspaces/project/src/bug.js": stringtestutil.Dedent(` + import * as B from "./box.js" + import * as W from "./wrap.js" + + /** + * @template {object} C + * @param {C} source + * @returns {W.Wrap} + */ + const wrap = source => { + throw source + } + + /** + * @returns {B.Box} + */ + const box = (n = 0) => ({ unbox: () => n }) + + export const bug = wrap({ n: box(1) }); + `), + "/home/src/workspaces/project/src/wrap.ts": stringtestutil.Dedent(` + export type Wrap = { + [K in keyof C]: { wrapped: C[K] } + } + `), + }, + edits: []*testTscEdit{ + { + caption: "modify js file", + edit: func(sys *testSys) { + sys.appendFile("/home/src/workspaces/project/src/bug.js", `export const something = 1;`) + }, + }, + }, + }, + getConstEnumTest(` + export const enum A { + ONE = 1 + } + `, "/home/src/workspaces/project/b.d.ts", ""), + getConstEnumTest(` + export const enum AWorker { + ONE = 1 + } + export { AWorker as A }; + `, "/home/src/workspaces/project/b.d.ts", " aliased"), + getConstEnumTest(`export { AWorker as A } from "./worker";`, "/home/src/workspaces/project/worker.d.ts", " aliased in different file"), + { + subScenario: "option changes with composite", + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "composite": true, + } + }`), + "/home/src/workspaces/project/a.ts": `export const a = 10;const aLocal = 10;`, + "/home/src/workspaces/project/b.ts": `export const b = 10;const bLocal = 10;`, + "/home/src/workspaces/project/c.ts": `import { a } from "./a";export const c = a;`, + "/home/src/workspaces/project/d.ts": `import { b } from "./b";export const d = b;`, + }, + edits: []*testTscEdit{ + { + caption: "with sourceMap", + commandLineArgs: []string{"--sourceMap"}, + }, + { + caption: "should re-emit only js so they dont contain sourcemap", + }, + { + caption: "with declaration should not emit anything", + commandLineArgs: []string{"--declaration"}, + // discrepancyExplanation: () => [ + // `Clean build tsbuildinfo will have compilerOptions with composite and ${option.replace(/-/g, "")}`, + // `Incremental build will detect that it doesnt need to rebuild so tsbuild info is from before which has option composite only`, + // ], + }, + noChange, + { + caption: "with declaration and declarationMap", + commandLineArgs: []string{"--declaration", "--declarationMap"}, + }, + { + caption: "should re-emit only dts so they dont contain sourcemap", + }, + { + caption: "with emitDeclarationOnly should not emit anything", + commandLineArgs: []string{"--emitDeclarationOnly"}, + // discrepancyExplanation: () => [ + // `Clean build tsbuildinfo will have compilerOptions with composite and ${option.replace(/-/g, "")}`, + // `Incremental build will detect that it doesnt need to rebuild so tsbuild info is from before which has option composite only`, + // ], + }, + noChange, + { + caption: "local change", + edit: func(sys *testSys) { + sys.replaceFileText("/home/src/workspaces/project/a.ts", "Local = 1", "Local = 10") + }, + }, + { + caption: "with declaration should not emit anything", + commandLineArgs: []string{"--declaration"}, + // discrepancyExplanation: () => [ + // `Clean build tsbuildinfo will have compilerOptions with composite and ${option.replace(/-/g, "")}`, + // `Incremental build will detect that it doesnt need to rebuild so tsbuild info is from before which has option composite only`, + // ], + }, + { + caption: "with inlineSourceMap", + commandLineArgs: []string{"--inlineSourceMap"}, + }, + { + caption: "with sourceMap", + commandLineArgs: []string{"--sourceMap"}, + }, + { + caption: "declarationMap enabling", + edit: func(sys *testSys) { + sys.replaceFileText("/home/src/workspaces/project/tsconfig.json", `"composite": true,`, `"composite": true, "declarationMap": true`) + }, + }, + { + caption: "with sourceMap should not emit d.ts", + commandLineArgs: []string{"--sourceMap"}, + }, + }, + }, + { + subScenario: "option changes with incremental", + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "incremental": true, + } + }`), + "/home/src/workspaces/project/a.ts": `export const a = 10;const aLocal = 10;`, + "/home/src/workspaces/project/b.ts": `export const b = 10;const bLocal = 10;`, + "/home/src/workspaces/project/c.ts": `import { a } from "./a";export const c = a;`, + "/home/src/workspaces/project/d.ts": `import { b } from "./b";export const d = b;`, + }, + edits: []*testTscEdit{ + { + caption: "with sourceMap", + commandLineArgs: []string{"--sourceMap"}, + }, + { + caption: "should re-emit only js so they dont contain sourcemap", + }, + { + caption: "with declaration, emit Dts and should not emit js", + commandLineArgs: []string{"--declaration"}, + }, + { + caption: "with declaration and declarationMap", + commandLineArgs: []string{"--declaration", "--declarationMap"}, + }, + { + caption: "no change", + // discrepancyExplanation: () => [ + // `Clean build tsbuildinfo will have compilerOptions {}`, + // `Incremental build will detect that it doesnt need to rebuild so tsbuild info is from before which has option declaration and declarationMap`, + // ], + }, + { + caption: "local change", + edit: func(sys *testSys) { + sys.replaceFileText("/home/src/workspaces/project/a.ts", "Local = 1", "Local = 10") + }, + }, + { + caption: "with declaration and declarationMap", + commandLineArgs: []string{"--declaration", "--declarationMap"}, + }, + { + caption: "no change", + // discrepancyExplanation: () => [ + // `Clean build tsbuildinfo will have compilerOptions {}`, + // `Incremental build will detect that it doesnt need to rebuild so tsbuild info is from before which has option declaration and declarationMap`, + // ], + }, + { + caption: "with inlineSourceMap", + commandLineArgs: []string{"--inlineSourceMap"}, + }, + { + caption: "with sourceMap", + commandLineArgs: []string{"--sourceMap"}, + }, + { + caption: "emit js files", + }, + { + caption: "with declaration and declarationMap", + commandLineArgs: []string{"--declaration", "--declarationMap"}, + }, + { + caption: "with declaration and declarationMap, should not re-emit", + commandLineArgs: []string{"--declaration", "--declarationMap"}, + }, + }, + }, + } + + for _, test := range testCases { + test.run(t, "incremental") + } +} + +func getConstEnumTest(bdsContents string, changeEnumFile string, testSuffix string) *tscInput { + return &tscInput{ + subScenario: "const enums" + testSuffix, + files: FileMap{ + "/home/src/workspaces/project/a.ts": stringtestutil.Dedent(` + import {A} from "./c" + let a = A.ONE + `), + "/home/src/workspaces/project/b.d.ts": stringtestutil.Dedent(bdsContents), + "/home/src/workspaces/project/c.ts": stringtestutil.Dedent(` + import {A} from "./b" + let b = A.ONE + export {A} + `), + "/home/src/workspaces/project/worker.d.ts": stringtestutil.Dedent(` + export const enum AWorker { + ONE = 1 + } + `), + }, + commandLineArgs: []string{"-i", `a.ts`, "--tsbuildinfofile", "a.tsbuildinfo"}, + edits: []*testTscEdit{ + { + caption: "change enum value", + edit: func(sys *testSys) { + sys.replaceFileText(changeEnumFile, "1", "2") + }, + }, + { + caption: "change enum value again", + edit: func(sys *testSys) { + sys.replaceFileText(changeEnumFile, "2", "3") + }, + }, + { + caption: "something else changes in b.d.ts", + edit: func(sys *testSys) { + sys.appendFile("/home/src/workspaces/project/b.d.ts", "export const randomThing = 10;") + }, + }, + { + caption: "something else changes in b.d.ts again", + edit: func(sys *testSys) { + sys.appendFile("/home/src/workspaces/project/b.d.ts", "export const randomThing2 = 10;") + }, + }, + }, + } +} diff --git a/internal/execute/verifytsc_nocheck_test.go b/internal/execute/tscnocheck_test.go similarity index 53% rename from internal/execute/verifytsc_nocheck_test.go rename to internal/execute/tscnocheck_test.go index fab7d15277..339356f036 100644 --- a/internal/execute/verifytsc_nocheck_test.go +++ b/internal/execute/tscnocheck_test.go @@ -3,7 +3,7 @@ package execute_test import ( "testing" - "github.com/microsoft/typescript-go/internal/bundled" + "github.com/microsoft/typescript-go/internal/testutil/stringtestutil" ) type noCheckScenario struct { @@ -13,11 +13,6 @@ type noCheckScenario struct { func TestNoCheck(t *testing.T) { t.Parallel() - if !bundled.Embedded { - // Without embedding, we'd need to read all of the lib files out from disk into the MapFS. - // Just skip this for now. - t.Skip("bundled files are not embedded") - } cases := []noCheckScenario{ {"syntax errors", `export const a = "hello`}, {"semantic errors", `export const a: number = "hello";`}, @@ -25,19 +20,19 @@ func TestNoCheck(t *testing.T) { } for _, c := range cases { (&tscInput{ - subScenario: "outFile/" + c.subscenario, - sys: newTestSys(FileMap{ + subScenario: c.subscenario, + files: FileMap{ "/home/src/workspaces/project/a.ts": c.aText, "/home/src/workspaces/project/b.ts": `export const b = 10;`, - "/home/src/workspaces/project/tsconfig.json": `{ - "compilerOptions": { - "declaration": true, - } -}`, + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "declaration": true, + } + }`), // incremental: undefined, true - // ...options: {}, {module: amd, outfile: "outfile.js"} - }, "/home/src/workspaces/project"), + }, commandLineArgs: []string{"--noCheck", "--outFile", "built"}, - }).verify(t, "noCheck") + }).run(t, "noCheck") } } diff --git a/internal/execute/tscprojectreferences_test.go b/internal/execute/tscprojectreferences_test.go index ff2c54f70f..11bf1de91a 100644 --- a/internal/execute/tscprojectreferences_test.go +++ b/internal/execute/tscprojectreferences_test.go @@ -3,98 +3,109 @@ package execute_test import ( "testing" - "github.com/microsoft/typescript-go/internal/bundled" + "github.com/microsoft/typescript-go/internal/testutil/stringtestutil" ) func TestProjectReferences(t *testing.T) { t.Parallel() - if !bundled.Embedded { - // Without embedding, we'd need to read all of the lib files out from disk into the MapFS. - // Just skip this for now. - t.Skip("bundled files are not embedded") - } - cases := []tscInput{ // !!! sheetal todo verifyCompilerOptions - check for noEmit { subScenario: "when project references composite project with noEmit", - sys: newTestSys(FileMap{ + files: FileMap{ "/home/src/workspaces/solution/utils/index.ts": "export const x = 10;", - "/home/src/workspaces/solution/utils/tsconfig.json": `{ - "compilerOptions": { - "composite": true, - "noEmit": true, - }, - }`, + "/home/src/workspaces/solution/utils/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "composite": true, + "noEmit": true + } + }`), "/home/src/workspaces/solution/project/index.ts": `import { x } from "../utils";`, - "/home/src/workspaces/solution/project/tsconfig.json": `{ - "references": [ - { "path": "../utils" }, - ], - }`, + "/home/src/workspaces/solution/project/tsconfig.json": stringtestutil.Dedent(` + { + "references": [ + { "path": "../utils" }, + ], + }`), }, - "/home/src/workspaces/solution", - ), + cwd: "/home/src/workspaces/solution", commandLineArgs: []string{"--p", "project"}, }, { subScenario: "when project references composite", - sys: newTestSys(FileMap{ + files: FileMap{ "/home/src/workspaces/solution/utils/index.ts": "export const x = 10;", "/home/src/workspaces/solution/utils/index.d.ts": "export declare const x = 10;", - "/home/src/workspaces/solution/utils/tsconfig.json": `{ - "compilerOptions": { - "composite": true, - }, -}`, + "/home/src/workspaces/solution/utils/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "composite": true + } + }`), "/home/src/workspaces/solution/project/index.ts": `import { x } from "../utils";`, - "/home/src/workspaces/solution/project/tsconfig.json": `{ - "references": [ - { "path": "../utils" }, - ], -}`, - }, "/home/src/workspaces/solution"), + "/home/src/workspaces/solution/project/tsconfig.json": stringtestutil.Dedent(` + { + "references": [ + { "path": "../utils" }, + ], + }`), + }, + cwd: "/home/src/workspaces/solution", commandLineArgs: []string{"--p", "project"}, }, { subScenario: "when project reference is not built", - sys: newTestSys(FileMap{ + files: FileMap{ "/home/src/workspaces/solution/utils/index.ts": "export const x = 10;", - "/home/src/workspaces/solution/utils/tsconfig.json": `{ - "compilerOptions": { - "composite": true, - }, -}`, + "/home/src/workspaces/solution/utils/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "composite": true + } + }`), "/home/src/workspaces/solution/project/index.ts": `import { x } from "../utils";`, - "/home/src/workspaces/solution/project/tsconfig.json": `{ - "references": [ - { "path": "../utils" }, - ], -}`, - }, "/home/src/workspaces/solution"), + "/home/src/workspaces/solution/project/tsconfig.json": stringtestutil.Dedent(` + { + "references": [ + { "path": "../utils" }, + ], + }`), + }, + cwd: "/home/src/workspaces/solution", commandLineArgs: []string{"--p", "project"}, }, { // !!! sheetal verifyProjectReferences - checks this subScenario: "when project contains invalid project reference", - sys: newTestSys(FileMap{ + files: FileMap{ "/home/src/workspaces/solution/project/index.ts": `export const x = 10;`, - "/home/src/workspaces/solution/project/tsconfig.json": `{ - "references": [ - { "path": "../utils" }, - ], -}`, - }, "/home/src/workspaces/solution"), + "/home/src/workspaces/solution/project/tsconfig.json": stringtestutil.Dedent(` + { + "references": [ + { "path": "../utils" }, + ], + }`), + }, + cwd: "/home/src/workspaces/solution", commandLineArgs: []string{"--p", "project"}, }, { subScenario: "default import interop uses referenced project settings", - sys: newTestSys(FileMap{ - "/home/src/workspaces/project/node_modules/ambiguous-package/package.json": `{ "name": "ambiguous-package" }`, - "/home/src/workspaces/project/node_modules/ambiguous-package/index.d.ts": "export declare const ambiguous: number;", - "/home/src/workspaces/project/node_modules/esm-package/package.json": `{ "name": "esm-package", "type": "module" }`, - "/home/src/workspaces/project/node_modules/esm-package/index.d.ts": "export declare const esm: number;", - "/home/src/workspaces/project/lib/tsconfig.json": `{ + files: FileMap{ + "/home/src/workspaces/project/node_modules/ambiguous-package/package.json": stringtestutil.Dedent(` + { + "name": "ambiguous-package" + }`), + "/home/src/workspaces/project/node_modules/ambiguous-package/index.d.ts": "export declare const ambiguous: number;", + "/home/src/workspaces/project/node_modules/esm-package/package.json": stringtestutil.Dedent(` + { + "name": "esm-package", + "type": "module" + }`), + "/home/src/workspaces/project/node_modules/esm-package/index.d.ts": "export declare const esm: number;", + "/home/src/workspaces/project/lib/tsconfig.json": stringtestutil.Dedent(` + { "compilerOptions": { "composite": true, "declaration": true, @@ -104,10 +115,11 @@ func TestProjectReferences(t *testing.T) { "moduleResolution": "bundler", }, "include": ["src"], - }`, + }`), "/home/src/workspaces/project/lib/src/a.ts": "export const a = 0;", "/home/src/workspaces/project/lib/dist/a.d.ts": "export declare const a = 0;", - "/home/src/workspaces/project/app/tsconfig.json": `{ + "/home/src/workspaces/project/app/tsconfig.json": stringtestutil.Dedent(` + { "compilerOptions": { "module": "esnext", "moduleResolution": "bundler", @@ -118,68 +130,74 @@ func TestProjectReferences(t *testing.T) { "references": [ { "path": "../lib" }, ], - }`, + }`), "/home/src/workspaces/project/app/src/local.ts": "export const local = 0;", - "/home/src/workspaces/project/app/src/index.ts": ` + "/home/src/workspaces/project/app/src/index.ts": stringtestutil.Dedent(` import local from "./local"; // Error import esm from "esm-package"; // Error import referencedSource from "../../lib/src/a"; // Error import referencedDeclaration from "../../lib/dist/a"; // Error - import ambiguous from "ambiguous-package"; // Ok`, - }, "/home/src/workspaces/project"), + import ambiguous from "ambiguous-package"; // Ok`), + }, commandLineArgs: []string{"--p", "app", "--pretty", "false"}, }, { subScenario: "referencing ambient const enum from referenced project with preserveConstEnums", - sys: newTestSys(FileMap{ + files: FileMap{ "/home/src/workspaces/solution/utils/index.ts": "export const enum E { A = 1 }", "/home/src/workspaces/solution/utils/index.d.ts": "export declare const enum E { A = 1 }", - "/home/src/workspaces/solution/utils/tsconfig.json": `{ + "/home/src/workspaces/solution/utils/tsconfig.json": stringtestutil.Dedent(` + { "compilerOptions": { "composite": true, "declaration": true, "preserveConstEnums": true, }, - }`, + }`), "/home/src/workspaces/solution/project/index.ts": `import { E } from "../utils"; E.A;`, - "/home/src/workspaces/solution/project/tsconfig.json": `{ + "/home/src/workspaces/solution/project/tsconfig.json": stringtestutil.Dedent(` + { "compilerOptions": { "isolatedModules": true, }, "references": [ { "path": "../utils" }, ], - }`, - }, "/home/src/workspaces/solution"), + }`), + }, + cwd: "/home/src/workspaces/solution", commandLineArgs: []string{"--p", "project"}, }, { subScenario: "importing const enum from referenced project with preserveConstEnums and verbatimModuleSyntax", - sys: newTestSys(FileMap{ + files: FileMap{ "/home/src/workspaces/solution/preserve/index.ts": "export const enum E { A = 1 }", "/home/src/workspaces/solution/preserve/index.d.ts": "export declare const enum E { A = 1 }", - "/home/src/workspaces/solution/preserve/tsconfig.json": `{ + "/home/src/workspaces/solution/preserve/tsconfig.json": stringtestutil.Dedent(` + { "compilerOptions": { "composite": true, "declaration": true, "preserveConstEnums": true, }, - }`, + }`), "/home/src/workspaces/solution/no-preserve/index.ts": "export const enum E { A = 1 }", "/home/src/workspaces/solution/no-preserve/index.d.ts": "export declare const enum F { A = 1 }", - "/home/src/workspaces/solution/no-preserve/tsconfig.json": `{ + "/home/src/workspaces/solution/no-preserve/tsconfig.json": stringtestutil.Dedent(` + { "compilerOptions": { "composite": true, "declaration": true, "preserveConstEnums": false, }, - }`, - "/home/src/workspaces/solution/project/index.ts": ` - import { E } from "../preserve"; - import { F } from "../no-preserve"; - E.A; - F.A;`, - "/home/src/workspaces/solution/project/tsconfig.json": `{ + }`), + "/home/src/workspaces/solution/project/index.ts": stringtestutil.Dedent(` + import { E } from "../preserve"; + import { F } from "../no-preserve"; + E.A; + F.A;`), + "/home/src/workspaces/solution/project/tsconfig.json": stringtestutil.Dedent(` + { "compilerOptions": { "module": "preserve", "verbatimModuleSyntax": true, @@ -188,22 +206,25 @@ func TestProjectReferences(t *testing.T) { { "path": "../preserve" }, { "path": "../no-preserve" }, ], - }`, - }, "/home/src/workspaces/solution"), + }`), + }, + cwd: "/home/src/workspaces/solution", commandLineArgs: []string{"--p", "project", "--pretty", "false"}, }, { subScenario: "rewriteRelativeImportExtensionsProjectReferences1", - sys: newTestSys(FileMap{ - "/home/src/workspaces/packages/common/tsconfig.json": `{ + files: FileMap{ + "/home/src/workspaces/packages/common/tsconfig.json": stringtestutil.Dedent(` + { "compilerOptions": { "composite": true, "rootDir": "src", "outDir": "dist", "module": "nodenext" } - }`, - "/home/src/workspaces/packages/common/package.json": `{ + }`), + "/home/src/workspaces/packages/common/package.json": stringtestutil.Dedent(` + { "name": "common", "version": "1.0.0", "type": "module", @@ -213,10 +234,11 @@ func TestProjectReferences(t *testing.T) { "default": "./dist/index.js" } } - }`, + }`), "/home/src/workspaces/packages/common/src/index.ts": "export {};", "/home/src/workspaces/packages/common/dist/index.d.ts": "export {};", - "/home/src/workspaces/packages/main/tsconfig.json": `{ + "/home/src/workspaces/packages/main/tsconfig.json": stringtestutil.Dedent(` + { "compilerOptions": { "module": "nodenext", "rewriteRelativeImportExtensions": true, @@ -226,16 +248,21 @@ func TestProjectReferences(t *testing.T) { "references": [ { "path": "../common" } ] - }`, - "/home/src/workspaces/packages/main/package.json": `{ "type": "module" }`, + }`), + "/home/src/workspaces/packages/main/package.json": stringtestutil.Dedent(` + { + "type": "module" + }`), "/home/src/workspaces/packages/main/src/index.ts": `import {} from "../../common/src/index.ts";`, - }, "/home/src/workspaces"), + }, + cwd: "/home/src/workspaces", commandLineArgs: []string{"-p", "packages/main", "--pretty", "false"}, }, { subScenario: "rewriteRelativeImportExtensionsProjectReferences2", - sys: newTestSys(FileMap{ - "/home/src/workspaces/solution/src/tsconfig-base.json": `{ + files: FileMap{ + "/home/src/workspaces/solution/src/tsconfig-base.json": stringtestutil.Dedent(` + { "compilerOptions": { "module": "nodenext", "composite": true, @@ -243,44 +270,50 @@ func TestProjectReferences(t *testing.T) { "outDir": "../dist", "rewriteRelativeImportExtensions": true } - }`, - "/home/src/workspaces/solution/src/compiler/tsconfig.json": `{ + }`), + "/home/src/workspaces/solution/src/compiler/tsconfig.json": stringtestutil.Dedent(` + { "extends": "../tsconfig-base.json", "compilerOptions": {} - }`, + }`), "/home/src/workspaces/solution/src/compiler/parser.ts": "export {};", "/home/src/workspaces/solution/dist/compiler/parser.d.ts": "export {};", - "/home/src/workspaces/solution/src/services/tsconfig.json": `{ - "extends": "../tsconfig-base.json", + "/home/src/workspaces/solution/src/services/tsconfig.json": stringtestutil.Dedent(` + { + "extends": "../tsconfig-base.json", "compilerOptions": {}, "references": [ { "path": "../compiler" } ] - }`, + }`), "/home/src/workspaces/solution/src/services/services.ts": `import {} from "../compiler/parser.ts";`, - }, "/home/src/workspaces/solution"), + }, + cwd: "/home/src/workspaces/solution", commandLineArgs: []string{"--p", "src/services", "--pretty", "false"}, }, { subScenario: "rewriteRelativeImportExtensionsProjectReferences3", - sys: newTestSys(FileMap{ - "/home/src/workspaces/solution/src/tsconfig-base.json": `{ + files: FileMap{ + "/home/src/workspaces/solution/src/tsconfig-base.json": stringtestutil.Dedent(` + { "compilerOptions": { "module": "nodenext", "composite": true, "rewriteRelativeImportExtensions": true } - }`, - "/home/src/workspaces/solution/src/compiler/tsconfig.json": `{ + }`), + "/home/src/workspaces/solution/src/compiler/tsconfig.json": stringtestutil.Dedent(` + { "extends": "../tsconfig-base.json", "compilerOptions": { "rootDir": ".", "outDir": "../../dist/compiler" } - }`, + }`), "/home/src/workspaces/solution/src/compiler/parser.ts": "export {};", "/home/src/workspaces/solution/dist/compiler/parser.d.ts": "export {};", - "/home/src/workspaces/solution/src/services/tsconfig.json": `{ + "/home/src/workspaces/solution/src/services/tsconfig.json": stringtestutil.Dedent(` + { "extends": "../tsconfig-base.json", "compilerOptions": { "rootDir": ".", @@ -289,14 +322,15 @@ func TestProjectReferences(t *testing.T) { "references": [ { "path": "../compiler" } ] - }`, + }`), "/home/src/workspaces/solution/src/services/services.ts": `import {} from "../compiler/parser.ts";`, - }, "/home/src/workspaces/solution"), + }, + cwd: "/home/src/workspaces/solution", commandLineArgs: []string{"--p", "src/services", "--pretty", "false"}, }, } for _, c := range cases { - c.verify(t, "projectReferences") + c.run(t, "projectReferences") } } diff --git a/internal/execute/tsctestrunner_test.go b/internal/execute/tsctestrunner_test.go new file mode 100644 index 0000000000..3934afaa50 --- /dev/null +++ b/internal/execute/tsctestrunner_test.go @@ -0,0 +1,176 @@ +package execute_test + +import ( + "fmt" + "path/filepath" + "slices" + "strings" + "testing" + + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/execute" + "github.com/microsoft/typescript-go/internal/incremental" + "github.com/microsoft/typescript-go/internal/testutil/baseline" + "github.com/microsoft/typescript-go/internal/tspath" +) + +type testTscEdit struct { + caption string + commandLineArgs []string + edit func(*testSys) + expectedDiff string +} + +var noChange = &testTscEdit{ + caption: "no change", +} + +var noChangeOnlyEdit = []*testTscEdit{ + noChange, +} + +type tscInput struct { + subScenario string + commandLineArgs []string + files FileMap + cwd string + edits []*testTscEdit +} + +func (test *tscInput) executeCommand(sys *testSys, baselineBuilder *strings.Builder, commandLineArgs []string) (*incremental.Program, *execute.Watcher) { + fmt.Fprint(baselineBuilder, "tsgo ", strings.Join(commandLineArgs, " "), "\n") + exit, incrementalProgram, watcher := execute.CommandLine(sys, commandLineArgs, true) + switch exit { + case execute.ExitStatusSuccess: + baselineBuilder.WriteString("ExitStatus:: Success") + case execute.ExitStatusDiagnosticsPresent_OutputsSkipped: + baselineBuilder.WriteString("ExitStatus:: DiagnosticsPresent_OutputsSkipped") + case execute.ExitStatusDiagnosticsPresent_OutputsGenerated: + baselineBuilder.WriteString("ExitStatus:: DiagnosticsPresent_OutputsGenerated") + case execute.ExitStatusInvalidProject_OutputsSkipped: + baselineBuilder.WriteString("ExitStatus:: InvalidProject_OutputsSkipped") + case execute.ExitStatusProjectReferenceCycle_OutputsSkipped: + baselineBuilder.WriteString("ExitStatus:: ProjectReferenceCycle_OutputsSkipped") + case execute.ExitStatusNotImplemented: + baselineBuilder.WriteString("ExitStatus:: NotImplemented") + default: + panic(fmt.Sprintf("UnknownExitStatus %d", exit)) + } + return incrementalProgram, watcher +} + +func (test *tscInput) run(t *testing.T, scenario string) { + t.Helper() + // !!! sheetal TODO :: add incremental correctness + t.Run(test.subScenario+" tsc baseline", func(t *testing.T) { + t.Parallel() + // initial test tsc compile + baselineBuilder := &strings.Builder{} + sys := newTestSys(test.files, test.cwd) + fmt.Fprint( + baselineBuilder, + "currentDirectory::", + sys.GetCurrentDirectory(), + "\nuseCaseSensitiveFileNames::", + sys.FS().UseCaseSensitiveFileNames(), + "\nInput::\n", + ) + sys.baselineFSwithDiff(baselineBuilder) + incrementalProgram, watcher := test.executeCommand(sys, baselineBuilder, test.commandLineArgs) + sys.serializeState(baselineBuilder) + sys.baselineProgram(baselineBuilder, incrementalProgram, watcher) + + for index, do := range test.edits { + sys.clearOutput() + wg := core.NewWorkGroup(false) + var nonIncrementalSys *testSys + commandLineArgs := core.IfElse(do.commandLineArgs == nil, test.commandLineArgs, do.commandLineArgs) + wg.Queue(func() { + baselineBuilder.WriteString(fmt.Sprintf("\n\nEdit [%d]:: %s\n", index, do.caption)) + if do.edit != nil { + do.edit(sys) + } + sys.baselineFSwithDiff(baselineBuilder) + + var incrementalProgram *incremental.Program + if watcher == nil { + incrementalProgram, watcher = test.executeCommand(sys, baselineBuilder, commandLineArgs) + } else { + watcher.DoCycle() + } + sys.serializeState(baselineBuilder) + sys.baselineProgram(baselineBuilder, incrementalProgram, watcher) + }) + wg.Queue(func() { + // !!! Compute build with all the edits + nonIncrementalSys = newTestSys(test.files, test.cwd) + for i := range index + 1 { + if test.edits[i].edit != nil { + test.edits[i].edit(nonIncrementalSys) + } + execute.CommandLine(nonIncrementalSys, commandLineArgs, true) + } + }) + wg.RunAndWait() + + diff := getDiffForIncremental(sys, nonIncrementalSys) + if diff != "" { + baselineBuilder.WriteString(fmt.Sprintf("\n\nDiff:: %s\n", core.IfElse(do.expectedDiff == "", "!!! Unexpected !!!", do.expectedDiff))) + baselineBuilder.WriteString(diff) + } else if do.expectedDiff != "" { + baselineBuilder.WriteString(fmt.Sprintf("\n\nDiff:: %s !!! Unexpected !!!\n", do.expectedDiff)) + } + } + baseline.Run(t, strings.ReplaceAll(test.subScenario, " ", "-")+".js", baselineBuilder.String(), baseline.Options{Subfolder: filepath.Join(test.getBaselineSubFolder(), scenario)}) + }) +} + +func getDiffForIncremental(incrementalSys *testSys, nonIncrementalSys *testSys) string { + var diffBuilder strings.Builder + + nonIncrementalOutputs := nonIncrementalSys.testFs().writtenFiles.ToArray() + slices.Sort(nonIncrementalOutputs) + for _, nonIncrementalOutput := range nonIncrementalOutputs { + if tspath.FileExtensionIs(nonIncrementalOutput, tspath.ExtensionTsBuildInfo) { + // Just check existence + if !incrementalSys.fsFromFileMap().FileExists(nonIncrementalOutput) { + diffBuilder.WriteString(baseline.DiffText("nonIncremental "+nonIncrementalOutput, "incremental "+nonIncrementalOutput, "Exists", "")) + diffBuilder.WriteString("\n") + } + } else { + nonIncrementalText, ok := nonIncrementalSys.fsFromFileMap().ReadFile(nonIncrementalOutput) + if !ok { + panic("Written file not found " + nonIncrementalOutput) + } + incrementalText, ok := incrementalSys.fsFromFileMap().ReadFile(nonIncrementalOutput) + if !ok || incrementalText != nonIncrementalText { + diffBuilder.WriteString(baseline.DiffText("nonIncremental "+nonIncrementalOutput, "incremental "+nonIncrementalOutput, nonIncrementalText, incrementalText)) + diffBuilder.WriteString("\n") + } + } + } + + incrementalErrors := strings.Join(incrementalSys.output, "\n") + nonIncrementalErrors := strings.Join(nonIncrementalSys.output, "\n") + if incrementalErrors != nonIncrementalErrors { + diffBuilder.WriteString(baseline.DiffText("nonIncremental errors.txt", "incremental errors.txt", nonIncrementalErrors, incrementalErrors)) + } + // !!! sheetal errors + return diffBuilder.String() +} + +func (test *tscInput) getBaselineSubFolder() string { + commandName := "tsc" + if slices.ContainsFunc(test.commandLineArgs, func(arg string) bool { + return arg == "--build" || arg == "-b" + }) { + commandName = "tsbuild" + } + w := "" + if slices.ContainsFunc(test.commandLineArgs, func(arg string) bool { + return arg == "--watch" || arg == "-w" + }) { + w = "Watch" + } + return commandName + w +} diff --git a/internal/execute/tscwatch_test.go b/internal/execute/tscwatch_test.go new file mode 100644 index 0000000000..693a7630af --- /dev/null +++ b/internal/execute/tscwatch_test.go @@ -0,0 +1,123 @@ +package execute_test + +import ( + "strings" + "testing" +) + +func TestWatch(t *testing.T) { + t.Parallel() + testCases := []*tscInput{ + { + subScenario: "watch with no tsconfig", + files: FileMap{ + "/home/src/workspaces/project/index.ts": "", + }, + commandLineArgs: []string{"index.ts", "--watch"}, + }, + } + + for _, test := range testCases { + test.run(t, "commandLineWatch") + } +} + +func listToTsconfig(base string, tsconfigOpts ...string) (string, string) { + optionString := strings.Join(tsconfigOpts, ",\n ") + tsconfigText := `{ + "compilerOptions": { +` + after := " " + if base != "" { + tsconfigText += " " + base + after = ",\n " + } + if len(tsconfigOpts) != 0 { + tsconfigText += after + optionString + } + tsconfigText += ` + } +}` + return tsconfigText, optionString +} + +func toTsconfig(base string, compilerOpts string) string { + tsconfigText, _ := listToTsconfig(base, compilerOpts) + return tsconfigText +} + +func noEmitWatchTestInput( + subScenario string, + commandLineArgs []string, + aText string, + tsconfigOptions []string, +) *tscInput { + noEmitOpt := `"noEmit": true` + tsconfigText, optionString := listToTsconfig(noEmitOpt, tsconfigOptions...) + return &tscInput{ + subScenario: subScenario, + commandLineArgs: commandLineArgs, + files: FileMap{ + "/home/src/workspaces/project/a.ts": aText, + "/home/src/workspaces/project/tsconfig.json": tsconfigText, + }, + edits: []*testTscEdit{ + newTscEdit("fix error", func(sys *testSys) { + sys.writeFileNoError("/home/src/workspaces/project/a.ts", `const a = "hello";`, false) + }), + newTscEdit("emit after fixing error", func(sys *testSys) { + sys.writeFileNoError("/home/src/workspaces/project/tsconfig.json", toTsconfig("", optionString), false) + }), + newTscEdit("no emit run after fixing error", func(sys *testSys) { + sys.writeFileNoError("/home/src/workspaces/project/tsconfig.json", toTsconfig(noEmitOpt, optionString), false) + }), + newTscEdit("introduce error", func(sys *testSys) { + sys.writeFileNoError("/home/src/workspaces/project/a.ts", aText, false) + }), + newTscEdit("emit when error", func(sys *testSys) { + sys.writeFileNoError("/home/src/workspaces/project/tsconfig.json", toTsconfig("", optionString), false) + }), + newTscEdit("no emit run when error", func(sys *testSys) { + sys.writeFileNoError("/home/src/workspaces/project/tsconfig.json", toTsconfig(noEmitOpt, optionString), false) + }), + }, + } +} + +func newTscEdit(name string, edit func(sys *testSys)) *testTscEdit { + return &testTscEdit{name, []string{}, edit} +} + +func TestTscNoEmitWatch(t *testing.T) { + t.Parallel() + + testCases := []*tscInput{ + noEmitWatchTestInput("syntax errors", + []string{"-w"}, + `const a = "hello`, + nil, + ), + noEmitWatchTestInput( + "semantic errors", + []string{"-w"}, + `const a: number = "hello"`, + nil, + ), + noEmitWatchTestInput( + "dts errors without dts enabled", + []string{"-w"}, + `const a = class { private p = 10; };`, + nil, + ), + noEmitWatchTestInput( + "dts errors", + []string{"-w"}, + `const a = class { private p = 10; };`, + []string{`"declaration": true`}, + ), + } + + for _, test := range testCases { + test.run(t, "noEmit") + } +} diff --git a/internal/execute/verifytsc_test.go b/internal/execute/verifytsc_test.go deleted file mode 100644 index bee7353071..0000000000 --- a/internal/execute/verifytsc_test.go +++ /dev/null @@ -1,107 +0,0 @@ -package execute_test - -import ( - "encoding/json" - "fmt" - "path/filepath" - "strings" - "testing" - - "github.com/microsoft/typescript-go/internal/execute" - "github.com/microsoft/typescript-go/internal/testutil/baseline" -) - -type testTscEdit struct { - caption string - commandLineArgs []string - edit func(execute.System) -} - -type tscInput struct { - subScenario string - commandLineArgs []string - sys *testSys - - // for watch tests - data map[string]string -} - -func (test *tscInput) verify(t *testing.T, scenario string) { - t.Helper() - t.Run(test.getTestName(scenario), func(t *testing.T) { - t.Parallel() - t.Run("baseline for the tsc compiles", func(t *testing.T) { - t.Parallel() - // initial test tsc compile - baselineBuilder := test.startBaseline() - - parsedCommandLine, exit := execute.CommandLineTest(test.sys, nil, test.commandLineArgs) - baselineBuilder.WriteString("ExitStatus:: " + fmt.Sprint(exit)) - - compilerOptionsString, _ := json.MarshalIndent(parsedCommandLine.CompilerOptions(), "", " ") - baselineBuilder.WriteString("\n\nCompilerOptions::") - baselineBuilder.Write(compilerOptionsString) - - test.sys.serializeState(baselineBuilder) - options, name := test.getBaselineName(scenario, false, "") - baseline.Run(t, name, baselineBuilder.String(), options) - }) - }) -} - -func (test *tscInput) getTestName(scenario string) string { - return "tsc " + strings.Join(test.commandLineArgs, " ") + " " + scenario + ":: " + test.subScenario -} - -func (test *tscInput) getBaselineName(scenario string, watch bool, suffix string) (baseline.Options, string) { - commandName := "tsc" - // todo build - // if isBuildCommand(v.data.commandLineArgs) { - // commandName = "tsbuild" - // } - w := "" - if watch { - w = "Watch" - } - - return baseline.Options{Subfolder: filepath.Join(commandName+w, scenario)}, - strings.ReplaceAll(test.subScenario, " ", "-") + suffix + ".js" -} - -func (test *tscInput) startBaseline() *strings.Builder { - s := &strings.Builder{} - fmt.Fprint( - s, - "\ncurrentDirectory::", - test.sys.GetCurrentDirectory(), - "\nuseCaseSensitiveFileNames::", - test.sys.FS().UseCaseSensitiveFileNames(), - "\nInput::", - ) - fmt.Fprint(s, strings.Join(test.commandLineArgs, " "), "\n") - test.sys.baselineFSwithDiff(s) - return s -} - -func (test *tscInput) verifyCommandLineParsing(t *testing.T, scenario string) { - t.Helper() - t.Run(test.getTestName(scenario), func(t *testing.T) { - t.Parallel() - t.Run("baseline for the tsc compiles", func(t *testing.T) { - t.Parallel() - // initial test tsc compile - baselineBuilder := test.startBaseline() - - parsedCommandLine, exit := execute.CommandLineTest(test.sys, nil, test.commandLineArgs) - baselineBuilder.WriteString("ExitStatus:: " + fmt.Sprint(exit)) - //nolint:musttag - parsedCommandLineString, _ := json.MarshalIndent(parsedCommandLine, "", " ") - baselineBuilder.WriteString("\n\nParsedCommandLine::") - baselineBuilder.Write(parsedCommandLineString) - - test.sys.serializeState(baselineBuilder) - options, name := test.getBaselineName(scenario, false, "") - baseline.Run(t, name, baselineBuilder.String(), options) - }) - }) -} diff --git a/internal/execute/verifytscwatch_test.go b/internal/execute/verifytscwatch_test.go deleted file mode 100644 index 6a8fc6ad37..0000000000 --- a/internal/execute/verifytscwatch_test.go +++ /dev/null @@ -1,181 +0,0 @@ -package execute_test - -import ( - "encoding/json" - "strings" - "testing" - - "github.com/microsoft/typescript-go/internal/bundled" - "github.com/microsoft/typescript-go/internal/execute" - "github.com/microsoft/typescript-go/internal/testutil/baseline" -) - -func verifyWatch(t *testing.T, test *tscInput, scenario string, edits []*testTscEdit) { - t.Helper() - t.Run(test.getTestName(scenario), func(t *testing.T) { - t.Parallel() - t.Run("baseline for the tsc compiles", func(t *testing.T) { - t.Parallel() - baselineBuilder := test.startBaseline() - - parsedCommandLine, watcher := execute.CommandLineTestWatch(test.sys, nil, test.commandLineArgs) - - compilerOptionsString, _ := json.MarshalIndent(parsedCommandLine.CompilerOptions(), "", " ") - baselineBuilder.WriteString("\n\nCompilerOptions::") - baselineBuilder.Write(compilerOptionsString) - - baselineBuilder.WriteString("\n\n") - - // build initial state - execute.StartForTest(watcher) - execute.RunWatchCycle(watcher) - test.sys.serializeState(baselineBuilder) - - for _, do := range edits { - do.edit(test.sys) - baselineBuilder.WriteString("\n\nEdit:: " + do.caption + "\n") - - execute.RunWatchCycle(watcher) - test.sys.serializeState(baselineBuilder) - } - - options, name := test.getBaselineName(scenario, true, "") - baseline.Run(t, name, baselineBuilder.String(), options) - }) - }) -} - -func TestWatch(t *testing.T) { - t.Parallel() - if !bundled.Embedded { - // Without embedding, we'd need to read all of the lib files out from disk into the MapFS. - // Just skip this for now. - t.Skip("bundled files are not embedded") - } - - testCases := []*tscInput{ - { - subScenario: "watch with no tsconfig", - sys: newTestSys(FileMap{ - "/home/src/workspaces/project/index.ts": "", - }, "/home/src/workspaces/project"), - commandLineArgs: []string{"index.ts", "--watch"}, - }, - } - - for _, test := range testCases { - verifyWatch(t, test, "commandLineWatch", nil) - } -} - -func listToTsconfig(base string, tsconfigOpts ...string) (string, string) { - optionString := strings.Join(tsconfigOpts, ",\n ") - tsconfigText := `{ - "compilerOptions": { -` - after := " " - if base != "" { - tsconfigText += " " + base - after = ",\n " - } - if len(tsconfigOpts) != 0 { - tsconfigText += after + optionString - } - tsconfigText += ` - } -}` - return tsconfigText, optionString -} - -func toTsconfig(base string, compilerOpts string) string { - tsconfigText, _ := listToTsconfig(base, compilerOpts) - return tsconfigText -} - -func noEmitWatchTestInput( - subScenario string, - commandLineArgs []string, - aText string, - tsconfigOptions []string, -) *tscInput { - noEmitOpt := `"noEmit": true` - tsconfigText, optionString := listToTsconfig(noEmitOpt, tsconfigOptions...) - sys := newTestSys(FileMap{ - "/home/src/workspaces/project/a.ts": aText, - "/home/src/workspaces/project/tsconfig.json": tsconfigText, - }, "/home/src/workspaces/project") - data := map[string]string{ - "baseOpt": noEmitOpt, - "originalOpts": optionString, - "aText": aText, - } - return &tscInput{ - subScenario, - commandLineArgs, - sys, - data, - } -} - -func newTscEdit(name string, edit func(sys execute.System)) *testTscEdit { - return &testTscEdit{name, []string{}, edit} -} - -func TestTscNoEmitWatch(t *testing.T) { - t.Parallel() - if !bundled.Embedded { - // Without embedding, we'd need to read all of the lib files out from disk into the MapFS. - // Just skip this for now. - t.Skip("bundled files are not embedded") - } - - testCases := []*tscInput{ - noEmitWatchTestInput("syntax errors", - []string{"-w"}, - `const a = "hello`, - []string{`"outFile": "../outFile.js"`}, - ), - noEmitWatchTestInput( - "semantic errors", - []string{"-w"}, - `const a: number = "hello"`, - []string{`"outFile": "../outFile.js"`}, - ), - noEmitWatchTestInput( - "dts errors without dts enabled", - []string{"-w"}, - `const a = class { private p = 10; };`, - []string{`"outFile": "../outFile.js"`}, - ), - noEmitWatchTestInput( - "dts errors", - []string{"-w"}, - `const a = class { private p = 10; };`, - []string{`"outFile": "../outFile.js"`, `"declaration": true`}, - ), - } - - for _, test := range testCases { - //nolint:errcheck - verifyWatch(t, test, "noEmit", []*testTscEdit{ - newTscEdit("fix syntax error", func(sys execute.System) { - sys.FS().WriteFile("/home/src/workspaces/project/a.ts", `const a = "hello";`, false) - }), - newTscEdit("emit after fixing error", func(sys execute.System) { - sys.FS().WriteFile("/home/src/workspaces/project/tsconfig.json", toTsconfig("", test.data["originalOpts"]), false) - }), - newTscEdit("no emit run after fixing error", func(sys execute.System) { - sys.FS().WriteFile("/home/src/workspaces/project/tsconfig.json", toTsconfig(test.data["baseOpt"], test.data["originalOpts"]), false) - }), - newTscEdit("introduce error", func(sys execute.System) { - sys.FS().WriteFile("/home/src/workspaces/project/a.ts", test.data["aText"], false) - }), - newTscEdit("emit when error", func(sys execute.System) { - sys.FS().WriteFile("/home/src/workspaces/project/tsconfig.json", toTsconfig("", test.data["originalOpts"]), false) - }), - newTscEdit("no emit run when error", func(sys execute.System) { - sys.FS().WriteFile("/home/src/workspaces/project/tsconfig.json", toTsconfig(test.data["baseOpt"], test.data["originalOpts"]), false) - }), - }) - } -} diff --git a/internal/execute/watch.go b/internal/execute/watch.go deleted file mode 100644 index 6d587951d1..0000000000 --- a/internal/execute/watch.go +++ /dev/null @@ -1,53 +0,0 @@ -package execute - -import ( - "fmt" - "time" - - "github.com/microsoft/typescript-go/internal/ast" - "github.com/microsoft/typescript-go/internal/compiler" -) - -func start(w *watcher) ExitStatus { - w.initialize() - - watchInterval := 1000 * time.Millisecond - if w.options.ParsedConfig.WatchOptions != nil { - watchInterval = time.Duration(*w.options.ParsedConfig.WatchOptions.Interval) * time.Millisecond - } - for { - w.doCycle() - time.Sleep(watchInterval) - } -} - -func (w *watcher) initialize() { - // if this function is updated, make sure to update `StartForTest` in export_test.go as needed - if w.configFileName == "" { - w.host = compiler.NewCompilerHost(w.options.CompilerOptions(), w.sys.GetCurrentDirectory(), w.sys.FS(), w.sys.DefaultLibraryPath(), nil) - } -} - -func (w *watcher) doCycle() { - // if this function is updated, make sure to update `RunWatchCycle` in export_test.go as needed - - if w.hasErrorsInTsConfig() { - // these are unrecoverable errors--report them and do not build - return - } - // updateProgram() - w.program = compiler.NewProgram(compiler.ProgramOptions{ - Config: w.options, - Host: w.host, - JSDocParsingMode: ast.JSDocParsingModeParseForTypeErrors, - }) - if w.hasBeenModified(w.program) { - fmt.Fprint(w.sys.Writer(), "build starting at ", w.sys.Now(), w.sys.NewLine()) - timeStart := w.sys.Now() - w.compileAndEmit() - fmt.Fprint(w.sys.Writer(), "build finished in ", w.sys.Now().Sub(timeStart), w.sys.NewLine()) - } else { - // print something??? - // fmt.Fprint(w.sys.Writer(), "no changes detected at ", w.sys.Now(), w.sys.NewLine()) - } -} diff --git a/internal/execute/watcher.go b/internal/execute/watcher.go index 5697c7525d..18b92a157a 100644 --- a/internal/execute/watcher.go +++ b/internal/execute/watcher.go @@ -1,33 +1,38 @@ package execute import ( + "fmt" "reflect" "time" + "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/incremental" "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" ) -type watcher struct { +type Watcher struct { sys System configFileName string options *tsoptions.ParsedCommandLine reportDiagnostic diagnosticReporter + testing bool host compiler.CompilerHost - program *compiler.Program + program *incremental.Program prevModified map[string]time.Time configModified bool } -func createWatcher(sys System, configParseResult *tsoptions.ParsedCommandLine, reportDiagnostic diagnosticReporter) *watcher { - w := &watcher{ +func createWatcher(sys System, configParseResult *tsoptions.ParsedCommandLine, reportDiagnostic diagnosticReporter, testing bool) *Watcher { + w := &Watcher{ sys: sys, options: configParseResult, reportDiagnostic: reportDiagnostic, + testing: testing, // reportWatchStatus: createWatchStatusReporter(sys, configParseResult.CompilerOptions().Pretty), } if configParseResult.ConfigFile != nil { @@ -36,13 +41,60 @@ func createWatcher(sys System, configParseResult *tsoptions.ParsedCommandLine, r return w } -func (w *watcher) compileAndEmit() { +func (w *Watcher) start() { + // if this function is updated, make sure to update `StartForTest` in export_test.go as needed + if w.configFileName == "" { + w.host = compiler.NewCompilerHost(w.options.CompilerOptions(), w.sys.GetCurrentDirectory(), w.sys.FS(), w.sys.DefaultLibraryPath(), nil) + } + w.program = incremental.ReadBuildInfoProgram(w.options, incremental.NewBuildInfoReader(w.host)) + + if !w.testing { + watchInterval := 1000 * time.Millisecond + if w.options.ParsedConfig.WatchOptions != nil { + watchInterval = time.Duration(*w.options.ParsedConfig.WatchOptions.Interval) * time.Millisecond + } + for { + w.DoCycle() + time.Sleep(watchInterval) + } + } else { + // Initial compilation in test mode + w.DoCycle() + } +} + +func (w *Watcher) DoCycle() { + // if this function is updated, make sure to update `RunWatchCycle` in export_test.go as needed + + if w.hasErrorsInTsConfig() { + // these are unrecoverable errors--report them and do not build + return + } + // updateProgram() + w.program = incremental.NewProgram(compiler.NewProgram(compiler.ProgramOptions{ + Config: w.options, + Host: w.host, + JSDocParsingMode: ast.JSDocParsingModeParseForTypeErrors, + }), w.program, w.testing) + + if w.hasBeenModified(w.program.GetProgram()) { + fmt.Fprint(w.sys.Writer(), "build starting at ", w.sys.Now(), w.sys.NewLine()) + timeStart := w.sys.Now() + w.compileAndEmit() + fmt.Fprint(w.sys.Writer(), "build finished in ", w.sys.Now().Sub(timeStart), w.sys.NewLine()) + } else { + // print something??? + // fmt.Fprint(w.sys.Writer(), "no changes detected at ", w.sys.Now(), w.sys.NewLine()) + } +} + +func (w *Watcher) compileAndEmit() { // !!! output/error reporting is currently the same as non-watch mode // diagnostics, emitResult, exitStatus := emitFilesAndReportErrors(w.sys, w.program, w.reportDiagnostic) } -func (w *watcher) hasErrorsInTsConfig() bool { +func (w *Watcher) hasErrorsInTsConfig() bool { // only need to check and reparse tsconfig options/update host if we are watching a config file if w.configFileName != "" { extendedConfigCache := collections.SyncMap[tspath.Path, *tsoptions.ExtendedConfigCacheEntry]{} @@ -65,7 +117,7 @@ func (w *watcher) hasErrorsInTsConfig() bool { return false } -func (w *watcher) hasBeenModified(program *compiler.Program) bool { +func (w *Watcher) hasBeenModified(program *compiler.Program) bool { // checks watcher's snapshot against program file modified times currState := map[string]time.Time{} filesModified := w.configModified @@ -97,3 +149,7 @@ func (w *watcher) hasBeenModified(program *compiler.Program) bool { w.configModified = false return filesModified } + +func (w *Watcher) GetProgram() *incremental.Program { + return w.program +} diff --git a/internal/incremental/affectedfileshandler.go b/internal/incremental/affectedfileshandler.go new file mode 100644 index 0000000000..9b512a4482 --- /dev/null +++ b/internal/incremental/affectedfileshandler.go @@ -0,0 +1,443 @@ +package incremental + +import ( + "context" + "crypto/sha256" + "fmt" + "maps" + "slices" + "strings" + "sync" + "sync/atomic" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/checker" + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/tspath" +) + +type dtsMayChange map[tspath.Path]FileEmitKind + +func (c dtsMayChange) addFileToAffectedFilesPendingEmit(filePath tspath.Path, emitKind FileEmitKind) { + c[filePath] = emitKind +} + +type affectedFilesHandler struct { + ctx context.Context + program *Program + hasAllFilesExcludingDefaultLibraryFile atomic.Bool + updatedSignatures collections.SyncMap[tspath.Path, string] + updatedSignatureKinds *collections.SyncMap[tspath.Path, SignatureUpdateKind] + dtsMayChange []dtsMayChange + filesToRemoveDiagnostics collections.SyncSet[tspath.Path] + cleanedDiagnosticsOfLibFiles sync.Once + seenFileAndExportsOfFile collections.SyncMap[tspath.Path, bool] +} + +func (h *affectedFilesHandler) getDtsMayChange(affectedFilePath tspath.Path, affectedFileEmitKind FileEmitKind) dtsMayChange { + result := dtsMayChange(map[tspath.Path]FileEmitKind{affectedFilePath: affectedFileEmitKind}) + h.dtsMayChange = append(h.dtsMayChange, result) + return result +} + +func (h *affectedFilesHandler) isChangedSignature(path tspath.Path) bool { + newSignature, _ := h.updatedSignatures.Load(path) + oldSignature := h.program.snapshot.fileInfos[path].signature + return newSignature != oldSignature +} + +func (h *affectedFilesHandler) removeSemanticDiagnosticsOf(path tspath.Path) { + h.filesToRemoveDiagnostics.Add(path) +} + +func (h *affectedFilesHandler) removeDiagnosticsOfLibraryFiles() { + h.cleanedDiagnosticsOfLibFiles.Do(func() { + for _, file := range h.program.GetSourceFiles() { + if h.program.program.IsSourceFileDefaultLibrary(file.Path()) && !checker.SkipTypeChecking(file, h.program.snapshot.options, h.program.program, true) { + h.removeSemanticDiagnosticsOf(file.Path()) + } + } + }) +} + +func (h *affectedFilesHandler) computeDtsSignature(file *ast.SourceFile) string { + var signature string + h.program.program.Emit(h.ctx, compiler.EmitOptions{ + TargetSourceFile: file, + EmitOnly: compiler.EmitOnlyForcedDts, + WriteFile: func(fileName string, text string, writeByteOrderMark bool, data *compiler.WriteFileData) error { + if !tspath.IsDeclarationFileName(fileName) { + panic("File extension for signature expected to be dts, got : " + fileName) + } + signature = computeSignatureWithDiagnostics(file, text, data) + return nil + }, + }) + return signature +} + +func (h *affectedFilesHandler) updateShapeSignature(file *ast.SourceFile, useFileVersionAsSignature bool) bool { + // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate + if _, ok := h.updatedSignatures.Load(file.Path()); ok { + return false + } + + info := h.program.snapshot.fileInfos[file.Path()] + prevSignature := info.signature + var latestSignature string + var updateKind SignatureUpdateKind + if !file.IsDeclarationFile && !useFileVersionAsSignature { + latestSignature = h.computeDtsSignature(file) + } + // Default is to use file version as signature + if latestSignature == "" { + latestSignature = info.version + updateKind = SignatureUpdateKindUsedVersion + } + h.updatedSignatures.Store(file.Path(), latestSignature) + if h.updatedSignatureKinds != nil { + h.updatedSignatureKinds.Store(file.Path(), updateKind) + } + return latestSignature != prevSignature +} + +func (h *affectedFilesHandler) getFilesAffectedBy(path tspath.Path) []*ast.SourceFile { + file := h.program.program.GetSourceFileByPath(path) + if file == nil { + return nil + } + + if !h.updateShapeSignature(file, false) { + return []*ast.SourceFile{file} + } + + if info := h.program.snapshot.fileInfos[file.Path()]; info.affectsGlobalScope { + h.hasAllFilesExcludingDefaultLibraryFile.Store(true) + h.program.snapshot.getAllFilesExcludingDefaultLibraryFile(h.program.program, file) + } + + if h.program.snapshot.options.IsolatedModules.IsTrue() { + return []*ast.SourceFile{file} + } + + // Now we need to if each file in the referencedBy list has a shape change as well. + // Because if so, its own referencedBy files need to be saved as well to make the + // emitting result consistent with files on disk. + seenFileNamesMap := h.forEachFileReferencedBy( + file, + func(currentFile *ast.SourceFile, currentPath tspath.Path) (queueForFile bool, fastReturn bool) { + // If the current file is not nil and has a shape change, we need to queue it for processing + if currentFile != nil && h.updateShapeSignature(currentFile, false) { + return true, false + } + return false, false + }, + ) + // Return array of values that needs emit + return core.Filter(slices.Collect(maps.Values(seenFileNamesMap)), func(file *ast.SourceFile) bool { + return file != nil + }) +} + +// Gets the files referenced by the the file path +func (h *affectedFilesHandler) getReferencedByPaths(file tspath.Path) map[tspath.Path]struct{} { + keys, ok := h.program.snapshot.referencedMap.GetKeys(file) + if !ok { + return nil + } + return keys.Keys() +} + +func (h *affectedFilesHandler) forEachFileReferencedBy(file *ast.SourceFile, fn func(currentFile *ast.SourceFile, currentPath tspath.Path) (queueForFile bool, fastReturn bool)) map[tspath.Path]*ast.SourceFile { + // Now we need to if each file in the referencedBy list has a shape change as well. + // Because if so, its own referencedBy files need to be saved as well to make the + // emitting result consistent with files on disk. + seenFileNamesMap := map[tspath.Path]*ast.SourceFile{} + // Start with the paths this file was referenced by + seenFileNamesMap[file.Path()] = file + references := h.getReferencedByPaths(file.Path()) + queue := slices.Collect(maps.Keys(references)) + for len(queue) > 0 { + currentPath := queue[len(queue)-1] + queue = queue[:len(queue)-1] + if _, ok := seenFileNamesMap[currentPath]; !ok { + currentFile := h.program.program.GetSourceFileByPath(currentPath) + seenFileNamesMap[currentPath] = currentFile + queueForFile, fastReturn := fn(currentFile, currentPath) + if fastReturn { + return seenFileNamesMap + } + if queueForFile { + for ref := range h.getReferencedByPaths(currentFile.Path()) { + queue = append(queue, ref) + } + } + } + } + return seenFileNamesMap +} + +// Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file +// This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change +func (h *affectedFilesHandler) handleDtsMayChangeOfAffectedFile(dtsMayChange dtsMayChange, affectedFile *ast.SourceFile) { + h.removeSemanticDiagnosticsOf(affectedFile.Path()) + + // If affected files is everything except default library, then nothing more to do + if h.hasAllFilesExcludingDefaultLibraryFile.Load() { + h.removeDiagnosticsOfLibraryFiles() + // When a change affects the global scope, all files are considered to be affected without updating their signature + // That means when affected file is handled, its signature can be out of date + // To avoid this, ensure that we update the signature for any affected file in this scenario. + h.updateShapeSignature(affectedFile, false) + return + } + + if h.program.snapshot.options.AssumeChangesOnlyAffectDirectDependencies.IsTrue() { + return + } + + // Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit + // If there was change in signature (dts output) for the changed file, + // then only we need to handle pending file emit + if !h.program.snapshot.changedFilesSet.Has(affectedFile.Path()) || + !h.isChangedSignature(affectedFile.Path()) { + return + } + + // Since isolated modules dont change js files, files affected by change in signature is itself + // But we need to cleanup semantic diagnostics and queue dts emit for affected files + if h.program.snapshot.options.IsolatedModules.IsTrue() { + h.forEachFileReferencedBy( + affectedFile, + func(currentFile *ast.SourceFile, currentPath tspath.Path) (queueForFile bool, fastReturn bool) { + if h.handleDtsMayChangeOfGlobalScope(dtsMayChange, currentPath /*invalidateJsFiles*/, false) { + return false, true + } + h.handleDtsMayChangeOf(dtsMayChange, currentPath /*invalidateJsFiles*/, false) + if h.isChangedSignature(currentPath) { + return true, false + } + return false, false + }, + ) + } + + invalidateJsFiles := false + var typeChecker *checker.Checker + var done func() + // If exported const enum, we need to ensure that js files are emitted as well since the const enum value changed + if affectedFile.Symbol != nil { + for _, exported := range affectedFile.Symbol.Exports { + if exported.Flags&ast.SymbolFlagsConstEnum != 0 { + invalidateJsFiles = true + break + } + if typeChecker == nil { + typeChecker, done = h.program.program.GetTypeCheckerForFile(h.ctx, affectedFile) + } + aliased := checker.SkipAlias(exported, typeChecker) + if aliased == exported { + continue + } + if (aliased.Flags & ast.SymbolFlagsConstEnum) != 0 { + if slices.ContainsFunc(aliased.Declarations, func(d *ast.Node) bool { + return ast.GetSourceFileOfNode(d) == affectedFile + }) { + invalidateJsFiles = true + break + } + } + } + } + if done != nil { + done() + } + + // Go through files that reference affected file and handle dts emit and semantic diagnostics for them and their references + if keys, ok := h.program.snapshot.referencedMap.GetKeys(affectedFile.Path()); ok { + for exportedFromPath := range keys.Keys() { + if h.handleDtsMayChangeOfGlobalScope(dtsMayChange, exportedFromPath, invalidateJsFiles) { + return + } + if references, ok := h.program.snapshot.referencedMap.GetKeys(exportedFromPath); ok { + for filePath := range references.Keys() { + if h.handleDtsMayChangeOfFileAndExportsOfFile(dtsMayChange, filePath, invalidateJsFiles) { + return + } + } + } + } + } +} + +func (h *affectedFilesHandler) handleDtsMayChangeOfFileAndExportsOfFile(dtsMayChange dtsMayChange, filePath tspath.Path, invalidateJsFiles bool) bool { + if existing, loaded := h.seenFileAndExportsOfFile.LoadOrStore(filePath, invalidateJsFiles); loaded && (existing || !invalidateJsFiles) { + return false + } + if h.handleDtsMayChangeOfGlobalScope(dtsMayChange, filePath, invalidateJsFiles) { + return true + } + h.handleDtsMayChangeOf(dtsMayChange, filePath, invalidateJsFiles) + + // Remove the diagnostics of files that import this file and handle all its exports too + if keys, ok := h.program.snapshot.referencedMap.GetKeys(filePath); ok { + for referencingFilePath := range keys.Keys() { + if h.handleDtsMayChangeOfFileAndExportsOfFile(dtsMayChange, referencingFilePath, invalidateJsFiles) { + return true + } + } + } + return false +} + +func (h *affectedFilesHandler) handleDtsMayChangeOfGlobalScope(dtsMayChange dtsMayChange, filePath tspath.Path, invalidateJsFiles bool) bool { + if info, ok := h.program.snapshot.fileInfos[filePath]; !ok || !info.affectsGlobalScope { + return false + } + // Every file needs to be handled + for _, file := range h.program.snapshot.getAllFilesExcludingDefaultLibraryFile(h.program.program, nil) { + h.handleDtsMayChangeOf(dtsMayChange, file.Path(), invalidateJsFiles) + } + h.removeDiagnosticsOfLibraryFiles() + return true +} + +// Handle the dts may change, so they need to be added to pending emit if dts emit is enabled, +// Also we need to make sure signature is updated for these files +func (h *affectedFilesHandler) handleDtsMayChangeOf(dtsMayChange dtsMayChange, path tspath.Path, invalidateJsFiles bool) { + if h.program.snapshot.changedFilesSet.Has(path) { + return + } + file := h.program.program.GetSourceFileByPath(path) + if file == nil { + return + } + h.removeSemanticDiagnosticsOf(path) + // Even though the js emit doesnt change and we are already handling dts emit and semantic diagnostics + // we need to update the signature to reflect correctness of the signature(which is output d.ts emit) of this file + // This ensures that we dont later during incremental builds considering wrong signature. + // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build + // But we avoid expensive full shape computation, as using file version as shape is enough for correctness. + h.updateShapeSignature(file, true) + // If not dts emit, nothing more to do + if invalidateJsFiles { + dtsMayChange.addFileToAffectedFilesPendingEmit(path, GetFileEmitKind(h.program.snapshot.options)) + } else if h.program.snapshot.options.GetEmitDeclarations() { + dtsMayChange.addFileToAffectedFilesPendingEmit(path, core.IfElse(h.program.snapshot.options.DeclarationMap.IsTrue(), FileEmitKindAllDts, FileEmitKindDts)) + } +} + +func (h *affectedFilesHandler) updateSnapshot() { + if h.ctx.Err() != nil { + return + } + h.updatedSignatures.Range(func(filePath tspath.Path, signature string) bool { + h.program.snapshot.fileInfos[filePath].signature = signature + return true + }) + if h.updatedSignatureKinds != nil { + h.updatedSignatureKinds.Range(func(filePath tspath.Path, kind SignatureUpdateKind) bool { + h.program.updatedSignatureKinds.Store(filePath, kind) + return true + }) + } + h.filesToRemoveDiagnostics.Range(func(file tspath.Path) bool { + delete(h.program.snapshot.semanticDiagnosticsPerFile, file) + return true + }) + for _, change := range h.dtsMayChange { + for filePath, emitKind := range change { + h.program.snapshot.addFileToAffectedFilesPendingEmit(filePath, emitKind) + } + } + h.program.snapshot.changedFilesSet = &collections.Set[tspath.Path]{} + h.program.snapshot.buildInfoEmitPending = true +} + +func collectAllAffectedFiles(ctx context.Context, program *Program) { + if program.snapshot.changedFilesSet.Len() == 0 { + return + } + + handler := affectedFilesHandler{ctx: ctx, program: program, updatedSignatureKinds: core.IfElse(program.updatedSignatureKinds == nil, nil, &collections.SyncMap[tspath.Path, SignatureUpdateKind]{})} + wg := core.NewWorkGroup(handler.program.program.SingleThreaded()) + var result collections.SyncSet[*ast.SourceFile] + for file := range program.snapshot.changedFilesSet.Keys() { + wg.Queue(func() { + for _, affectedFile := range handler.getFilesAffectedBy(file) { + result.Add(affectedFile) + } + }) + } + wg.RunAndWait() + + if ctx.Err() != nil { + return + } + + // For all the affected files, get all the files that would need to change their dts or js files, + // update their diagnostics + wg = core.NewWorkGroup(program.program.SingleThreaded()) + emitKind := GetFileEmitKind(program.snapshot.options) + result.Range(func(file *ast.SourceFile) bool { + // remove the cached semantic diagnostics and handle dts emit and js emit if needed + dtsMayChange := handler.getDtsMayChange(file.Path(), emitKind) + wg.Queue(func() { + handler.handleDtsMayChangeOfAffectedFile(dtsMayChange, file) + }) + return true + }) + wg.RunAndWait() + + // Update the snapshot with the new state + handler.updateSnapshot() +} + +func getTextHandlingSourceMapForSignature(text string, data *compiler.WriteFileData) string { + if data.SourceMapUrlPos != -1 { + return text[:data.SourceMapUrlPos] + } + return text +} + +func computeSignatureWithDiagnostics(file *ast.SourceFile, text string, data *compiler.WriteFileData) string { + var builder strings.Builder + builder.WriteString(getTextHandlingSourceMapForSignature(text, data)) + for _, diag := range data.Diagnostics { + diagnosticToStringBuilder(diag, file, &builder) + } + return computeHash(builder.String()) +} + +func diagnosticToStringBuilder(diagnostic *ast.Diagnostic, file *ast.SourceFile, builder *strings.Builder) string { + if diagnostic == nil { + return "" + } + builder.WriteString("\n") + if diagnostic.File() != file { + builder.WriteString(tspath.EnsurePathIsNonModuleName(tspath.GetRelativePathFromDirectory( + tspath.GetDirectoryPath(string(file.Path())), + string(diagnostic.File().Path()), + tspath.ComparePathsOptions{}, + ))) + } + if diagnostic.File() != nil { + builder.WriteString(fmt.Sprintf("(%d,%d): ", diagnostic.Pos(), diagnostic.Len())) + } + builder.WriteString(diagnostic.Category().Name()) + builder.WriteString(fmt.Sprintf("%d: ", diagnostic.Code())) + builder.WriteString(diagnostic.Message()) + for _, chain := range diagnostic.MessageChain() { + diagnosticToStringBuilder(chain, file, builder) + } + for _, info := range diagnostic.RelatedInformation() { + diagnosticToStringBuilder(info, file, builder) + } + return builder.String() +} + +func computeHash(text string) string { + return fmt.Sprintf("%x", sha256.Sum256([]byte(text))) +} diff --git a/internal/incremental/buildInfo.go b/internal/incremental/buildInfo.go new file mode 100644 index 0000000000..ad41b131b8 --- /dev/null +++ b/internal/incremental/buildInfo.go @@ -0,0 +1,459 @@ +package incremental + +import ( + "encoding/json" + "fmt" + + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/tsoptions" + "github.com/microsoft/typescript-go/internal/tspath" +) + +type ( + BuildInfoFileId int + BuildInfoFileIdListId int +) + +// /** +// * buildInfoRoot is +// * for incremental program buildinfo +// * - start and end of FileId for consecutive fileIds to be included as root +// * - single fileId that is root +// * for non incremental program buildinfo +// * - string that is the root file name +// */ +// type BuildInfoRoot struct { +// StartEnd *[2]BuildInfoFileId +// Single BuildInfoFileId +// nonIncremental string +// } + +// func (o BuildInfoRoot) MarshalJSON() ([]byte, error) { +// if o.StartEnd != nil { +// return json.Marshal(o.StartEnd) +// } +// if o.Single != 0 { +// return json.Marshal(o.Single) +// } +// if o.nonIncremental != "" { +// return json.Marshal(o.nonIncremental) +// } +// panic("unknown BuildInfoRoot type") +// } + +// func (o *BuildInfoRoot) UnmarshalJSON(data []byte) error { +// *o = BuildInfoRoot{} +// var vStartEnd [2]BuildInfoFileId +// if err := json.Unmarshal(data, &vStartEnd); err == nil { +// o.StartEnd = &vStartEnd +// return nil +// } +// var vSingle BuildInfoFileId +// if err := json.Unmarshal(data, &vSingle); err == nil { +// o.Single = vSingle +// return nil +// } +// var vNonIncremental string +// if err := json.Unmarshal(data, &vNonIncremental); err == nil { +// o.nonIncremental = vNonIncremental +// return nil +// } +// return fmt.Errorf("invalid BuildInfoRoot: %s", data) +// } + +type buildInfoFileInfoNoSignature struct { + Version string `json:"version,omitzero"` + NoSignature bool `json:"noSignature,omitzero"` + AffectsGlobalScope bool `json:"affectsGlobalScope,omitzero"` + ImpliedNodeFormat core.ResolutionMode `json:"impliedNodeFormat,omitzero"` +} + +// Signature is +// - undefined if FileInfo.version === FileInfo.signature +// - string actual signature +type buildInfoFileInfoWithSignature struct { + Version string `json:"version,omitzero"` + Signature string `json:"signature,omitzero"` + AffectsGlobalScope bool `json:"affectsGlobalScope,omitzero"` + ImpliedNodeFormat core.ResolutionMode `json:"impliedNodeFormat,omitzero"` +} + +type BuildInfoFileInfo struct { + signature string + noSignature *buildInfoFileInfoNoSignature + fileInfo *buildInfoFileInfoWithSignature +} + +func newBuildInfoFileInfo(fileInfo *fileInfo) *BuildInfoFileInfo { + if fileInfo.version == fileInfo.signature { + if !fileInfo.affectsGlobalScope && fileInfo.impliedNodeFormat == core.ResolutionModeCommonJS { + return &BuildInfoFileInfo{signature: fileInfo.signature} + } + } else if fileInfo.signature == "" { + return &BuildInfoFileInfo{noSignature: &buildInfoFileInfoNoSignature{ + Version: fileInfo.version, + NoSignature: true, + AffectsGlobalScope: fileInfo.affectsGlobalScope, + ImpliedNodeFormat: fileInfo.impliedNodeFormat, + }} + } + return &BuildInfoFileInfo{fileInfo: &buildInfoFileInfoWithSignature{ + Version: fileInfo.version, + Signature: core.IfElse(fileInfo.signature == fileInfo.version, "", fileInfo.signature), + AffectsGlobalScope: fileInfo.affectsGlobalScope, + ImpliedNodeFormat: fileInfo.impliedNodeFormat, + }} +} + +func (b *BuildInfoFileInfo) GetFileInfo() *fileInfo { + if b.signature != "" { + return &fileInfo{ + version: b.signature, + signature: b.signature, + impliedNodeFormat: core.ResolutionModeCommonJS, + } + } + if b.noSignature != nil { + return &fileInfo{ + version: b.noSignature.Version, + affectsGlobalScope: b.noSignature.AffectsGlobalScope, + impliedNodeFormat: b.noSignature.ImpliedNodeFormat, + } + } + return &fileInfo{ + version: b.fileInfo.Version, + signature: core.IfElse(b.fileInfo.Signature == "", b.fileInfo.Version, b.fileInfo.Signature), + affectsGlobalScope: b.fileInfo.AffectsGlobalScope, + impliedNodeFormat: b.fileInfo.ImpliedNodeFormat, + } +} + +func (b *BuildInfoFileInfo) HasSignature() bool { + return b.signature != "" +} + +func (b *BuildInfoFileInfo) MarshalJSON() ([]byte, error) { + if b.signature != "" { + return json.Marshal(b.signature) + } + if b.noSignature != nil { + return json.Marshal(b.noSignature) + } + return json.Marshal(b.fileInfo) +} + +func (b *BuildInfoFileInfo) UnmarshalJSON(data []byte) error { + var vSignature string + if err := json.Unmarshal(data, &vSignature); err == nil { + *b = BuildInfoFileInfo{signature: vSignature} + return nil + } + var noSignature buildInfoFileInfoNoSignature + if err := json.Unmarshal(data, &noSignature); err == nil && noSignature.NoSignature { + *b = BuildInfoFileInfo{noSignature: &noSignature} + return nil + } + var fileInfo buildInfoFileInfoWithSignature + if err := json.Unmarshal(data, &fileInfo); err != nil { + return fmt.Errorf("invalid BuildInfoFileInfo: %s", data) + } + *b = BuildInfoFileInfo{fileInfo: &fileInfo} + return nil +} + +type BuildInfoReferenceMapEntry struct { + FileId BuildInfoFileId + FileIdListId BuildInfoFileIdListId +} + +func (b *BuildInfoReferenceMapEntry) MarshalJSON() ([]byte, error) { + return json.Marshal([2]int{int(b.FileId), int(b.FileIdListId)}) +} + +func (b *BuildInfoReferenceMapEntry) UnmarshalJSON(data []byte) error { + var v *[2]int + if err := json.Unmarshal(data, &v); err != nil { + return err + } + *b = BuildInfoReferenceMapEntry{ + FileId: BuildInfoFileId(v[0]), + FileIdListId: BuildInfoFileIdListId(v[1]), + } + return nil +} + +type BuildInfoDiagnostic struct { + // BuildInfoFileId if it is for a File thats other than its stored for + File BuildInfoFileId `json:"file,omitzero"` + NoFile bool `json:"noFile,omitzero"` + Pos int `json:"pos,omitzero"` + End int `json:"end,omitzero"` + Code int32 `json:"code,omitzero"` + Category diagnostics.Category `json:"category,omitzero"` + Message string `json:"message,omitzero"` + MessageChain []*BuildInfoDiagnostic `json:"messageChain,omitzero"` + RelatedInformation []*BuildInfoDiagnostic `json:"relatedInformation,omitzero"` + ReportsUnnecessary bool `json:"reportsUnnecessary,omitzero"` + ReportsDeprecated bool `json:"reportsDeprecated,omitzero"` + SkippedOnNoEmit bool `json:"skippedOnNoEmit,omitzero"` +} + +type BuildInfoDiagnosticsOfFile struct { + FileId BuildInfoFileId + Diagnostics []*BuildInfoDiagnostic +} + +func (b *BuildInfoDiagnosticsOfFile) MarshalJSON() ([]byte, error) { + fileIdAndDiagnostics := make([]any, 0, 2) + fileIdAndDiagnostics = append(fileIdAndDiagnostics, b.FileId) + fileIdAndDiagnostics = append(fileIdAndDiagnostics, b.Diagnostics) + return json.Marshal(fileIdAndDiagnostics) +} + +func (b *BuildInfoDiagnosticsOfFile) UnmarshalJSON(data []byte) error { + var fileIdAndDiagnostics []json.RawMessage + if err := json.Unmarshal(data, &fileIdAndDiagnostics); err != nil { + return fmt.Errorf("invalid BuildInfoDiagnosticsOfFile: %s", data) + } + if len(fileIdAndDiagnostics) != 2 { + return fmt.Errorf("invalid BuildInfoDiagnosticsOfFile: expected 2 elements, got %d", len(fileIdAndDiagnostics)) + } + var fileId BuildInfoFileId + if err := json.Unmarshal(fileIdAndDiagnostics[0], &fileId); err != nil { + return fmt.Errorf("invalid fileId in BuildInfoDiagnosticsOfFile: %w", err) + } + + var diagnostics []*BuildInfoDiagnostic + if err := json.Unmarshal(fileIdAndDiagnostics[1], &diagnostics); err != nil { + return fmt.Errorf("invalid diagnostics in BuildInfoDiagnosticsOfFile: %w", err) + } + *b = BuildInfoDiagnosticsOfFile{ + FileId: fileId, + Diagnostics: diagnostics, + } + return nil +} + +type BuildInfoSemanticDiagnostic struct { + FileId BuildInfoFileId // File is not in changedSet and still doesnt have cached diagnostics + Diagnostics *BuildInfoDiagnosticsOfFile // Diagnostics for file +} + +func (b *BuildInfoSemanticDiagnostic) MarshalJSON() ([]byte, error) { + if b.FileId != 0 { + return json.Marshal(b.FileId) + } + return json.Marshal(b.Diagnostics) +} + +func (b *BuildInfoSemanticDiagnostic) UnmarshalJSON(data []byte) error { + var fileId BuildInfoFileId + if err := json.Unmarshal(data, &fileId); err == nil { + *b = BuildInfoSemanticDiagnostic{ + FileId: fileId, + } + return nil + } + var diagnostics BuildInfoDiagnosticsOfFile + if err := json.Unmarshal(data, &diagnostics); err == nil { + *b = BuildInfoSemanticDiagnostic{ + Diagnostics: &diagnostics, + } + return nil + } + return fmt.Errorf("invalid BuildInfoSemanticDiagnostic: %s", data) +} + +// fileId if pending emit is same as what compilerOptions suggest +// [fileId] if pending emit is only dts file emit +// [fileId, emitKind] if any other type emit is pending +type BuildInfoFilePendingEmit struct { + FileId BuildInfoFileId + EmitKind FileEmitKind +} + +func (b *BuildInfoFilePendingEmit) MarshalJSON() ([]byte, error) { + if b.EmitKind == 0 { + return json.Marshal(b.FileId) + } + if b.EmitKind == FileEmitKindDts { + fileListIds := []BuildInfoFileId{b.FileId} + return json.Marshal(fileListIds) + } + fileAndEmitKind := []int{int(b.FileId), int(b.EmitKind)} + return json.Marshal(fileAndEmitKind) +} + +func (b *BuildInfoFilePendingEmit) UnmarshalJSON(data []byte) error { + var fileId BuildInfoFileId + if err := json.Unmarshal(data, &fileId); err == nil { + *b = BuildInfoFilePendingEmit{ + FileId: fileId, + } + return nil + } + var intTuple []int + if err := json.Unmarshal(data, &intTuple); err == nil { + if len(intTuple) == 1 { + *b = BuildInfoFilePendingEmit{ + FileId: BuildInfoFileId(intTuple[0]), + EmitKind: FileEmitKindDts, + } + return nil + } else if len(intTuple) == 2 { + *b = BuildInfoFilePendingEmit{ + FileId: BuildInfoFileId(intTuple[0]), + EmitKind: FileEmitKind(intTuple[1]), + } + return nil + } + return fmt.Errorf("invalid BuildInfoFilePendingEmit: expected 1 or 2 integers, got %d", len(intTuple)) + } + return fmt.Errorf("invalid BuildInfoFilePendingEmit: %s", data) +} + +// [fileId, signature] if different from file's signature +// fileId if file wasnt emitted +type BuildInfoEmitSignature struct { + FileId BuildInfoFileId + Signature string // Signature if it is different from file's Signature + DiffersOnlyInDtsMap bool // true if signature is different only in dtsMap value + DiffersInOptions bool // true if signature is different in options used to emit file +} + +func (b *BuildInfoEmitSignature) noEmitSignature() bool { + return b.Signature == "" && !b.DiffersOnlyInDtsMap && !b.DiffersInOptions +} + +func (b *BuildInfoEmitSignature) toEmitSignature(path tspath.Path, emitSignatures map[tspath.Path]*emitSignature) *emitSignature { + var signature string + var signatureWithDifferentOptions []string + if b.DiffersOnlyInDtsMap { + signatureWithDifferentOptions = make([]string, 0, 1) + signatureWithDifferentOptions = append(signatureWithDifferentOptions, emitSignatures[path].signature) + } else if b.DiffersInOptions { + signatureWithDifferentOptions = make([]string, 0, 1) + signatureWithDifferentOptions = append(signatureWithDifferentOptions, b.Signature) + } else { + signature = b.Signature + } + return &emitSignature{ + signature: signature, + signatureWithDifferentOptions: signatureWithDifferentOptions, + } +} + +func (b *BuildInfoEmitSignature) MarshalJSON() ([]byte, error) { + if b.noEmitSignature() { + return json.Marshal(b.FileId) + } + fileIdAndSignature := make([]any, 2) + fileIdAndSignature[0] = b.FileId + var signature any + if b.DiffersOnlyInDtsMap { + signature = []string{} + } else if b.DiffersInOptions { + signature = []string{b.Signature} + } else { + signature = b.Signature + } + fileIdAndSignature[1] = signature + return json.Marshal(fileIdAndSignature) +} + +func (b *BuildInfoEmitSignature) UnmarshalJSON(data []byte) error { + var fileId BuildInfoFileId + if err := json.Unmarshal(data, &fileId); err == nil { + *b = BuildInfoEmitSignature{ + FileId: fileId, + } + return nil + } + var fileIdAndSignature []any + if err := json.Unmarshal(data, &fileIdAndSignature); err == nil { + if len(fileIdAndSignature) == 2 { + var fileId BuildInfoFileId + if id, ok := fileIdAndSignature[0].(float64); ok { + fileId = BuildInfoFileId(id) + } else { + return fmt.Errorf("invalid fileId in BuildInfoEmitSignature: expected float64, got %T", fileIdAndSignature[0]) + } + var signature string + var differsOnlyInDtsMap, differsInOptions bool + if signatureV, ok := fileIdAndSignature[1].(string); !ok { + if signatureList, ok := fileIdAndSignature[1].([]string); ok { + if len(signatureList) == 0 { + differsOnlyInDtsMap = true + } else if len(signatureList) == 1 { + signature = signatureList[0] + differsInOptions = true + } else { + return fmt.Errorf("invalid signature in BuildInfoEmitSignature: expected string or []string with 0 or 1 element, got %d elements", len(signatureList)) + } + } else { + return fmt.Errorf("invalid signature in BuildInfoEmitSignature: expected string or []string, got %T", fileIdAndSignature[1]) + } + } else { + signature = signatureV + } + *b = BuildInfoEmitSignature{ + FileId: fileId, + Signature: signature, + DiffersOnlyInDtsMap: differsOnlyInDtsMap, + DiffersInOptions: differsInOptions, + } + return nil + } + return fmt.Errorf("invalid BuildInfoEmitSignature: expected 2 elements, got %d", len(fileIdAndSignature)) + } + return fmt.Errorf("invalid BuildInfoEmitSignature: %s", data) +} + +type BuildInfo struct { + Version string `json:"version,omitzero"` + + // Common between incremental and tsc -b buildinfo for non incremental programs + Errors bool `json:"errors,omitzero"` + CheckPending bool `json:"checkPending,omitzero"` + // Root []BuildInfoRoot `json:"root,omitzero"` + + // IncrementalProgram info + FileNames []string `json:"fileNames,omitzero"` + FileInfos []*BuildInfoFileInfo `json:"fileInfos,omitzero"` + FileIdsList [][]BuildInfoFileId `json:"fileIdsList,omitzero"` + Options *collections.OrderedMap[string, any] `json:"options,omitzero"` + ReferencedMap []*BuildInfoReferenceMapEntry `json:"referencedMap,omitzero"` + SemanticDiagnosticsPerFile []*BuildInfoSemanticDiagnostic `json:"semanticDiagnosticsPerFile,omitzero"` + EmitDiagnosticsPerFile []*BuildInfoDiagnosticsOfFile `json:"emitDiagnosticsPerFile,omitzero"` + ChangeFileSet []BuildInfoFileId `json:"changeFileSet,omitzero"` + AffectedFilesPendingEmit []*BuildInfoFilePendingEmit `json:"affectedFilesPendingEmit,omitzero"` + LatestChangedDtsFile string `json:"latestChangedDtsFile,omitzero"` // Because this is only output file in the program, we dont need fileId to deduplicate name + EmitSignatures []*BuildInfoEmitSignature `json:"emitSignatures,omitzero"` + // resolvedRoot: readonly BuildInfoResolvedRoot[] | undefined; +} + +func (b *BuildInfo) IsValidVersion() bool { + return b.Version == core.Version() +} + +func (b *BuildInfo) IsIncremental() bool { + return b != nil && len(b.FileNames) != 0 +} + +func (b *BuildInfo) GetCompilerOptions(buildInfoDirectory string) *core.CompilerOptions { + options := &core.CompilerOptions{} + for option, value := range b.Options.Entries() { + if buildInfoDirectory != "" { + result, ok := tsoptions.ConvertOptionToAbsolutePath(option, value, tsoptions.CommandLineCompilerOptionsMap, buildInfoDirectory) + if ok { + tsoptions.ParseCompilerOptions(option, result, options) + continue + } + } + tsoptions.ParseCompilerOptions(option, value, options) + + } + return options +} diff --git a/internal/incremental/emitfileshandler.go b/internal/incremental/emitfileshandler.go new file mode 100644 index 0000000000..04d223d964 --- /dev/null +++ b/internal/incremental/emitfileshandler.go @@ -0,0 +1,280 @@ +package incremental + +import ( + "context" + "slices" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/tspath" +) + +type emitUpdate struct { + pendingKind FileEmitKind + result *compiler.EmitResult +} + +type emitFilesHandler struct { + ctx context.Context + program *Program + isForDtsErrors bool + signatures collections.SyncMap[tspath.Path, string] + emitSignatures collections.SyncMap[tspath.Path, *emitSignature] + latestChangedDtsFiles collections.SyncSet[string] + deletedPendingKinds collections.Set[tspath.Path] + emitUpdates collections.SyncMap[tspath.Path, *emitUpdate] +} + +// Determining what all is pending to be emitted based on previous options or previous file emit flags +func (h *emitFilesHandler) getPendingEmitKindForEmitOptions(emitKind FileEmitKind, options compiler.EmitOptions) FileEmitKind { + pendingKind := getPendingEmitKind(emitKind, 0) + if options.EmitOnly == compiler.EmitOnlyDts { + pendingKind &= FileEmitKindAllDts + } + if h.isForDtsErrors { + pendingKind &= FileEmitKindDtsErrors + } + return pendingKind +} + +// Emits the next affected file's emit result (EmitResult and sourceFiles emitted) or returns undefined if iteration is complete +// The first of writeFile if provided, writeFile of BuilderProgramHost if provided, writeFile of compiler host +// in that order would be used to write the files +func (h *emitFilesHandler) emitAllAffectedFiles(options compiler.EmitOptions) *compiler.EmitResult { + // Get all affected files + collectAllAffectedFiles(h.ctx, h.program) + if h.ctx.Err() != nil { + return nil + } + + // Emit all affected files + var results []*compiler.EmitResult + if len(h.program.snapshot.affectedFilesPendingEmit) != 0 { + wg := core.NewWorkGroup(h.program.program.SingleThreaded()) + for path, emitKind := range h.program.snapshot.affectedFilesPendingEmit { + affectedFile := h.program.program.GetSourceFileByPath(path) + if affectedFile == nil || !h.program.program.SourceFileMayBeEmitted(affectedFile, false) { + h.deletedPendingKinds.Add(path) + continue + } + pendingKind := h.getPendingEmitKindForEmitOptions(emitKind, options) + if pendingKind != 0 { + wg.Queue(func() { + // Determine if we can do partial emit + var emitOnly compiler.EmitOnly + if (pendingKind & FileEmitKindAllJs) != 0 { + emitOnly = compiler.EmitOnlyJs + } + if (pendingKind & FileEmitKindAllDts) != 0 { + if emitOnly == compiler.EmitOnlyJs { + emitOnly = compiler.EmitAll + } else { + emitOnly = compiler.EmitOnlyDts + } + } + var result *compiler.EmitResult + if !h.isForDtsErrors { + result = h.program.program.Emit(h.ctx, h.getEmitOptions(compiler.EmitOptions{ + TargetSourceFile: affectedFile, + EmitOnly: emitOnly, + WriteFile: options.WriteFile, + })) + } else { + result = &compiler.EmitResult{ + EmitSkipped: true, + Diagnostics: h.program.program.GetDeclarationDiagnostics(h.ctx, affectedFile), + } + } + + // Update the pendingEmit for the file + h.emitUpdates.Store(path, &emitUpdate{pendingKind: getPendingEmitKind(emitKind, pendingKind), result: result}) + }) + } + } + wg.RunAndWait() + if h.ctx.Err() != nil { + return nil + } + } + + // Get updated errors that were not included in affected files emit + for path, diagnostics := range h.program.snapshot.emitDiagnosticsPerFile { + if _, ok := h.emitUpdates.Load(path); !ok { + affectedFile := h.program.program.GetSourceFileByPath(path) + if affectedFile == nil || !h.program.program.SourceFileMayBeEmitted(affectedFile, false) { + h.deletedPendingKinds.Add(path) + continue + } + pendingKind := h.program.snapshot.affectedFilesPendingEmit[path] + h.emitUpdates.Store(path, &emitUpdate{pendingKind: pendingKind, result: &compiler.EmitResult{ + EmitSkipped: true, + Diagnostics: diagnostics.getDiagnostics(h.program.program, affectedFile), + }}) + } + } + + results = h.updateSnapshot() + + // Combine results and update buildInfo + if h.isForDtsErrors && options.TargetSourceFile != nil { + // Result from cache + diagnostics := h.program.snapshot.emitDiagnosticsPerFile[options.TargetSourceFile.Path()] + return &compiler.EmitResult{ + EmitSkipped: true, + Diagnostics: diagnostics.getDiagnostics(h.program.program, options.TargetSourceFile), + } + } + + result := compiler.CombineEmitResults(results) + if !h.isForDtsErrors { + buildInfoResult := h.program.emitBuildInfo(h.ctx, options) + if buildInfoResult != nil { + result.Diagnostics = append(result.Diagnostics, buildInfoResult.Diagnostics...) + result.EmittedFiles = append(result.EmittedFiles, buildInfoResult.EmittedFiles...) + } + } + + return result +} + +func (h *emitFilesHandler) getEmitOptions(options compiler.EmitOptions) compiler.EmitOptions { + if !h.program.snapshot.options.GetEmitDeclarations() { + return options + } + return compiler.EmitOptions{ + TargetSourceFile: options.TargetSourceFile, + EmitOnly: options.EmitOnly, + WriteFile: func(fileName string, text string, writeByteOrderMark bool, data *compiler.WriteFileData) error { + if tspath.IsDeclarationFileName(fileName) { + var emitSignature string + info := h.program.snapshot.fileInfos[options.TargetSourceFile.Path()] + if info.signature == info.version { + signature := computeSignatureWithDiagnostics(options.TargetSourceFile, text, data) + // With d.ts diagnostics they are also part of the signature so emitSignature will be different from it since its just hash of d.ts + if len(data.Diagnostics) == 0 { + emitSignature = signature + } + if signature != info.version { // Update it + h.signatures.Store(options.TargetSourceFile.Path(), signature) + } + } + + // Store d.ts emit hash so later can be compared to check if d.ts has changed. + // Currently we do this only for composite projects since these are the only projects that can be referenced by other projects + // and would need their d.ts change time in --build mode + if h.skipDtsOutputOfComposite(options.TargetSourceFile, fileName, text, data, emitSignature) { + return nil + } + } + + if options.WriteFile != nil { + return options.WriteFile(fileName, text, writeByteOrderMark, data) + } + return h.program.program.Host().FS().WriteFile(fileName, text, writeByteOrderMark) + }, + } +} + +// Compare to existing computed signature and store it or handle the changes in d.ts map option from before +// returning undefined means that, we dont need to emit this d.ts file since its contents didnt change +func (h *emitFilesHandler) skipDtsOutputOfComposite(file *ast.SourceFile, outputFileName string, text string, data *compiler.WriteFileData, newSignature string) bool { + if !h.program.snapshot.options.Composite.IsTrue() { + return false + } + var oldSignature string + oldSignatureFormat, ok := h.program.snapshot.emitSignatures[file.Path()] + if ok { + if oldSignatureFormat.signature != "" { + oldSignature = oldSignatureFormat.signature + } else { + oldSignature = oldSignatureFormat.signatureWithDifferentOptions[0] + } + } + if newSignature == "" { + newSignature = computeHash(getTextHandlingSourceMapForSignature(text, data)) + } + // Dont write dts files if they didn't change + if newSignature == oldSignature { + // If the signature was encoded as string the dts map options match so nothing to do + if oldSignatureFormat != nil && oldSignatureFormat.signature == oldSignature { + data.SkippedDtsWrite = true + return true + } else { + // Mark as differsOnlyInMap so that --build can reverse the timestamp so that + // the downstream projects dont detect this as change in d.ts file + data.DiffersOnlyInMap = true + } + } else { + h.latestChangedDtsFiles.Add(outputFileName) + } + h.emitSignatures.Store(file.Path(), &emitSignature{signature: newSignature}) + return false +} + +func (h *emitFilesHandler) updateSnapshot() []*compiler.EmitResult { + h.signatures.Range(func(file tspath.Path, signature string) bool { + info := h.program.snapshot.fileInfos[file] + info.signature = signature + if h.program.updatedSignatureKinds != nil { + h.program.updatedSignatureKinds.Store(file, SignatureUpdateKindStoredAtEmit) + } + h.program.snapshot.buildInfoEmitPending = true + return true + }) + h.emitSignatures.Range(func(file tspath.Path, signature *emitSignature) bool { + if h.program.snapshot.emitSignatures == nil { + h.program.snapshot.emitSignatures = make(map[tspath.Path]*emitSignature) + } + h.program.snapshot.emitSignatures[file] = signature + h.program.snapshot.buildInfoEmitPending = true + return true + }) + latestChangedDtsFiles := h.latestChangedDtsFiles.ToArray() + slices.Sort(latestChangedDtsFiles) + if latestChangedDtsFile := core.LastOrNil(latestChangedDtsFiles); latestChangedDtsFile != "" { + h.program.snapshot.latestChangedDtsFile = latestChangedDtsFile + h.program.snapshot.buildInfoEmitPending = true + } + for file := range h.deletedPendingKinds.Keys() { + delete(h.program.snapshot.affectedFilesPendingEmit, file) + h.program.snapshot.buildInfoEmitPending = true + } + var results []*compiler.EmitResult + h.emitUpdates.Range(func(file tspath.Path, update *emitUpdate) bool { + if update.pendingKind == 0 { + delete(h.program.snapshot.affectedFilesPendingEmit, file) + } else { + h.program.snapshot.affectedFilesPendingEmit[file] = update.pendingKind + } + if update.result != nil { + results = append(results, update.result) + if len(update.result.Diagnostics) != 0 { + if h.program.snapshot.emitDiagnosticsPerFile == nil { + h.program.snapshot.emitDiagnosticsPerFile = make(map[tspath.Path]*diagnosticsOrBuildInfoDiagnosticsWithFileName) + } + h.program.snapshot.emitDiagnosticsPerFile[file] = &diagnosticsOrBuildInfoDiagnosticsWithFileName{diagnostics: update.result.Diagnostics} + } + } + h.program.snapshot.buildInfoEmitPending = true + return true + }) + return results +} + +func emitFiles(ctx context.Context, program *Program, options compiler.EmitOptions, isForDtsErrors bool) *compiler.EmitResult { + emitHandler := &emitFilesHandler{ctx: ctx, program: program, isForDtsErrors: isForDtsErrors} + + if options.TargetSourceFile != nil { + result := program.program.Emit(ctx, emitHandler.getEmitOptions(options)) + if ctx.Err() != nil { + return nil + } + emitHandler.updateSnapshot() + return result + } + + // Emit only affected files if using builder for emit + return emitHandler.emitAllAffectedFiles(options) +} diff --git a/internal/incremental/incremental.go b/internal/incremental/incremental.go new file mode 100644 index 0000000000..6b3f9f87e9 --- /dev/null +++ b/internal/incremental/incremental.go @@ -0,0 +1,62 @@ +package incremental + +import ( + "encoding/json" + + "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/outputpaths" + "github.com/microsoft/typescript-go/internal/tsoptions" + "github.com/microsoft/typescript-go/internal/tspath" +) + +type BuildInfoReader interface { + ReadBuildInfo(buildInfoFileName string) *BuildInfo +} + +var _ BuildInfoReader = (*buildInfoReader)(nil) + +type buildInfoReader struct { + host compiler.CompilerHost +} + +func (r *buildInfoReader) ReadBuildInfo(buildInfoFileName string) *BuildInfo { + // Read build info file + data, ok := r.host.FS().ReadFile(buildInfoFileName) + if !ok { + return nil + } + var buildInfo BuildInfo + err := json.Unmarshal([]byte(data), &buildInfo) + if err != nil { + return nil + } + return &buildInfo +} + +func NewBuildInfoReader( + host compiler.CompilerHost, +) BuildInfoReader { + return &buildInfoReader{host: host} +} + +func ReadBuildInfoProgram(config *tsoptions.ParsedCommandLine, reader BuildInfoReader) *Program { + buildInfoFileName := outputpaths.GetBuildInfoFileName(config.CompilerOptions(), tspath.ComparePathsOptions{ + CurrentDirectory: config.GetCurrentDirectory(), + UseCaseSensitiveFileNames: config.UseCaseSensitiveFileNames(), + }) + if buildInfoFileName == "" { + return nil + } + + // Read buildinFo file + buildInfo := reader.ReadBuildInfo(buildInfoFileName) + if buildInfo == nil || !buildInfo.IsValidVersion() || !buildInfo.IsIncremental() { + return nil + } + + // Convert to information that can be used to create incremental program + incrementalProgram := &Program{ + snapshot: buildInfoToSnapshot(buildInfo, buildInfoFileName, config), + } + return incrementalProgram +} diff --git a/internal/incremental/program.go b/internal/incremental/program.go new file mode 100644 index 0000000000..cbf58468cb --- /dev/null +++ b/internal/incremental/program.go @@ -0,0 +1,311 @@ +package incremental + +import ( + "context" + "encoding/json" + "fmt" + "slices" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/outputpaths" + "github.com/microsoft/typescript-go/internal/tspath" +) + +type SignatureUpdateKind byte + +const ( + SignatureUpdateKindComputedDts SignatureUpdateKind = iota + SignatureUpdateKindStoredAtEmit + SignatureUpdateKindUsedVersion +) + +type Program struct { + snapshot *snapshot + program *compiler.Program + semanticDiagnosticsPerFile map[tspath.Path]*diagnosticsOrBuildInfoDiagnosticsWithFileName + updatedSignatureKinds *collections.SyncMap[tspath.Path, SignatureUpdateKind] +} + +var _ compiler.AnyProgram = (*Program)(nil) + +func NewProgram(program *compiler.Program, oldProgram *Program, testing bool) *Program { + incrementalProgram := &Program{ + snapshot: newSnapshotForProgram(program, oldProgram), + program: program, + } + + if testing { + if oldProgram != nil { + incrementalProgram.semanticDiagnosticsPerFile = oldProgram.snapshot.semanticDiagnosticsPerFile + } + incrementalProgram.updatedSignatureKinds = &collections.SyncMap[tspath.Path, SignatureUpdateKind]{} + } + return incrementalProgram +} + +func (h *Program) GetTestingData(program *compiler.Program) (map[tspath.Path]*diagnosticsOrBuildInfoDiagnosticsWithFileName, map[tspath.Path]*diagnosticsOrBuildInfoDiagnosticsWithFileName, *collections.SyncMap[tspath.Path, SignatureUpdateKind]) { + return h.snapshot.semanticDiagnosticsPerFile, h.semanticDiagnosticsPerFile, h.updatedSignatureKinds +} + +func (h *Program) panicIfNoProgram(method string) { + if h.program == nil { + panic(method + ": should not be called without program") + } +} + +func (h *Program) GetProgram() *compiler.Program { + h.panicIfNoProgram("GetProgram") + return h.program +} + +// Options implements compiler.AnyProgram interface. +func (h *Program) Options() *core.CompilerOptions { + return h.snapshot.options +} + +// GetSourceFiles implements compiler.AnyProgram interface. +func (h *Program) GetSourceFiles() []*ast.SourceFile { + h.panicIfNoProgram("GetSourceFiles") + return h.program.GetSourceFiles() +} + +// GetConfigFileParsingDiagnostics implements compiler.AnyProgram interface. +func (h *Program) GetConfigFileParsingDiagnostics() []*ast.Diagnostic { + h.panicIfNoProgram("GetConfigFileParsingDiagnostics") + return h.program.GetConfigFileParsingDiagnostics() +} + +// GetSyntacticDiagnostics implements compiler.AnyProgram interface. +func (h *Program) GetSyntacticDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic { + h.panicIfNoProgram("GetSyntacticDiagnostics") + return h.program.GetSyntacticDiagnostics(ctx, file) +} + +// GetBindDiagnostics implements compiler.AnyProgram interface. +func (h *Program) GetBindDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic { + h.panicIfNoProgram("GetBindDiagnostics") + return h.program.GetBindDiagnostics(ctx, file) +} + +// GetOptionsDiagnostics implements compiler.AnyProgram interface. +func (h *Program) GetOptionsDiagnostics(ctx context.Context) []*ast.Diagnostic { + h.panicIfNoProgram("GetOptionsDiagnostics") + return h.program.GetOptionsDiagnostics(ctx) +} + +func (h *Program) GetProgramDiagnostics() []*ast.Diagnostic { + h.panicIfNoProgram("GetProgramDiagnostics") + return h.program.GetProgramDiagnostics() +} + +func (h *Program) GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic { + h.panicIfNoProgram("GetGlobalDiagnostics") + return h.program.GetGlobalDiagnostics(ctx) +} + +// GetSemanticDiagnostics implements compiler.AnyProgram interface. +func (h *Program) GetSemanticDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic { + h.panicIfNoProgram("GetSemanticDiagnostics") + if h.snapshot.options.NoCheck.IsTrue() { + return nil + } + + // Ensure all the diagnsotics are cached + h.collectSemanticDiagnosticsOfAffectedFiles(ctx, file) + if ctx.Err() != nil { + return nil + } + + // Return result from cache + if file != nil { + cachedDiagnostics, ok := h.snapshot.semanticDiagnosticsPerFile[file.Path()] + if !ok { + panic("After handling all the affected files, there shouldnt be more changes") + } + return compiler.FilterNoEmitSemanticDiagnostics(cachedDiagnostics.getDiagnostics(h.program, file), h.snapshot.options) + } + + var diagnostics []*ast.Diagnostic + for _, file := range h.program.GetSourceFiles() { + cachedDiagnostics, ok := h.snapshot.semanticDiagnosticsPerFile[file.Path()] + if !ok { + panic("After handling all the affected files, there shouldnt be more changes") + } + diagnostics = append(diagnostics, compiler.FilterNoEmitSemanticDiagnostics(cachedDiagnostics.getDiagnostics(h.program, file), h.snapshot.options)...) + } + return diagnostics +} + +// GetDeclarationDiagnostics implements compiler.AnyProgram interface. +func (h *Program) GetDeclarationDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic { + h.panicIfNoProgram("GetDeclarationDiagnostics") + result := emitFiles(ctx, h, compiler.EmitOptions{ + TargetSourceFile: file, + }, true) + if result != nil { + return result.Diagnostics + } + return nil +} + +// GetModeForUsageLocation implements compiler.AnyProgram interface. +func (h *Program) Emit(ctx context.Context, options compiler.EmitOptions) *compiler.EmitResult { + h.panicIfNoProgram("Emit") + + var result *compiler.EmitResult + if h.snapshot.options.NoEmit.IsTrue() { + result = &compiler.EmitResult{EmitSkipped: true} + } else { + result = compiler.HandleNoEmitOnError(ctx, h, options.TargetSourceFile) + if ctx.Err() != nil { + return nil + } + } + if result != nil { + if options.TargetSourceFile != nil { + return result + } + + // Emit buildInfo and combine result + buildInfoResult := h.emitBuildInfo(ctx, options) + if buildInfoResult != nil && buildInfoResult.EmittedFiles != nil { + result.Diagnostics = append(result.Diagnostics, buildInfoResult.Diagnostics...) + result.EmittedFiles = append(result.EmittedFiles, buildInfoResult.EmittedFiles...) + } + return result + } + return emitFiles(ctx, h, options, false) +} + +// Handle affected files and cache the semantic diagnostics for all of them or the file asked for +func (h *Program) collectSemanticDiagnosticsOfAffectedFiles(ctx context.Context, file *ast.SourceFile) { + // Get all affected files + collectAllAffectedFiles(ctx, h) + if ctx.Err() != nil { + return + } + + if len(h.snapshot.semanticDiagnosticsPerFile) == len(h.program.GetSourceFiles()) { + // If we have all the files, + return + } + + var affectedFiles []*ast.SourceFile + if file != nil { + _, ok := h.snapshot.semanticDiagnosticsPerFile[file.Path()] + if ok { + return + } + affectedFiles = []*ast.SourceFile{file} + } else { + for _, file := range h.program.GetSourceFiles() { + if _, ok := h.snapshot.semanticDiagnosticsPerFile[file.Path()]; !ok { + affectedFiles = append(affectedFiles, file) + } + } + } + + // Get their diagnostics and cache them + diagnosticsPerFile := h.program.GetSemanticDiagnosticsNoFilter(ctx, affectedFiles) + // commit changes if no err + if ctx.Err() != nil { + return + } + + // Commit changes to snapshot + for file, diagnostics := range diagnosticsPerFile { + h.snapshot.semanticDiagnosticsPerFile[file.Path()] = &diagnosticsOrBuildInfoDiagnosticsWithFileName{diagnostics: diagnostics} + } + if len(h.snapshot.semanticDiagnosticsPerFile) == len(h.program.GetSourceFiles()) && h.snapshot.checkPending && !h.snapshot.options.NoCheck.IsTrue() { + h.snapshot.checkPending = false + } + h.snapshot.buildInfoEmitPending = true +} + +func (h *Program) emitBuildInfo(ctx context.Context, options compiler.EmitOptions) *compiler.EmitResult { + buildInfoFileName := outputpaths.GetBuildInfoFileName(h.snapshot.options, tspath.ComparePathsOptions{ + CurrentDirectory: h.program.GetCurrentDirectory(), + UseCaseSensitiveFileNames: h.program.UseCaseSensitiveFileNames(), + }) + if buildInfoFileName == "" { + return nil + } + if h.snapshot.hasErrors == core.TSUnknown { + h.snapshot.hasErrors = h.ensureHasErrorsForState(ctx, h.program) + if h.snapshot.hasErrors != h.snapshot.hasErrorsFromOldState { + h.snapshot.buildInfoEmitPending = true + } + } + if !h.snapshot.buildInfoEmitPending { + return nil + } + if ctx.Err() != nil { + return nil + } + buildInfo := snapshotToBuildInfo(h.snapshot, h.program, buildInfoFileName) + text, err := json.Marshal(buildInfo) + if err != nil { + panic(fmt.Sprintf("Failed to marshal build info: %v", err)) + } + if options.WriteFile != nil { + err = options.WriteFile(buildInfoFileName, string(text), false, &compiler.WriteFileData{ + BuildInfo: &buildInfo, + }) + } else { + err = h.program.Host().FS().WriteFile(buildInfoFileName, string(text), false) + } + if err != nil { + return &compiler.EmitResult{ + EmitSkipped: true, + Diagnostics: []*ast.Diagnostic{ + ast.NewCompilerDiagnostic(diagnostics.Could_not_write_file_0_Colon_1, buildInfoFileName, err.Error()), + }, + } + } + h.snapshot.buildInfoEmitPending = false + + var emittedFiles []string + if h.snapshot.options.ListEmittedFiles.IsTrue() { + emittedFiles = []string{buildInfoFileName} + } + return &compiler.EmitResult{ + EmitSkipped: false, + EmittedFiles: emittedFiles, + } +} + +func (h *Program) ensureHasErrorsForState(ctx context.Context, program *compiler.Program) core.Tristate { + // Check semantic and emit diagnostics first as we dont need to ask program about it + if slices.ContainsFunc(program.GetSourceFiles(), func(file *ast.SourceFile) bool { + semanticDiagnostics := h.snapshot.semanticDiagnosticsPerFile[file.Path()] + if semanticDiagnostics == nil { + // Missing semantic diagnostics in cache will be encoded in incremental buildInfo + return h.snapshot.options.IsIncremental() + } + if len(semanticDiagnostics.diagnostics) > 0 || len(semanticDiagnostics.buildInfoDiagnostics) > 0 { + // cached semantic diagnostics will be encoded in buildInfo + return true + } + if _, ok := h.snapshot.emitDiagnosticsPerFile[file.Path()]; ok { + // emit diagnostics will be encoded in buildInfo; + return true + } + return false + }) { + // Because semantic diagnostics are recorded in buildInfo, we dont need to encode hasErrors in incremental buildInfo + // But encode as errors in non incremental buildInfo + return core.IfElse(h.snapshot.options.IsIncremental(), core.TSFalse, core.TSTrue) + } + if len(program.GetConfigFileParsingDiagnostics()) > 0 || + len(program.GetSyntacticDiagnostics(ctx, nil)) > 0 || + len(program.GetBindDiagnostics(ctx, nil)) > 0 || + len(program.GetOptionsDiagnostics(ctx)) > 0 { + return core.TSTrue + } else { + return core.TSFalse + } +} diff --git a/internal/incremental/snapshot.go b/internal/incremental/snapshot.go new file mode 100644 index 0000000000..6e8c35f8f7 --- /dev/null +++ b/internal/incremental/snapshot.go @@ -0,0 +1,508 @@ +package incremental + +import ( + "context" + "maps" + "sync" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/checker" + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/tsoptions" + "github.com/microsoft/typescript-go/internal/tspath" +) + +type fileInfo struct { + version string + signature string + affectsGlobalScope bool + impliedNodeFormat core.ResolutionMode +} + +func (f *fileInfo) Version() string { return f.version } +func (f *fileInfo) Signature() string { return f.signature } +func (f *fileInfo) AffectsGlobalScope() bool { return f.affectsGlobalScope } +func (f *fileInfo) ImpliedNodeFormat() core.ResolutionMode { return f.impliedNodeFormat } + +type FileEmitKind uint32 + +const ( + FileEmitKindNone FileEmitKind = 0 + FileEmitKindJs FileEmitKind = 1 << 0 // emit js file + FileEmitKindJsMap FileEmitKind = 1 << 1 // emit js.map file + FileEmitKindJsInlineMap FileEmitKind = 1 << 2 // emit inline source map in js file + FileEmitKindDtsErrors FileEmitKind = 1 << 3 // emit dts errors + FileEmitKindDtsEmit FileEmitKind = 1 << 4 // emit d.ts file + FileEmitKindDtsMap FileEmitKind = 1 << 5 // emit d.ts.map file + + FileEmitKindDts = FileEmitKindDtsErrors | FileEmitKindDtsEmit + FileEmitKindAllJs = FileEmitKindJs | FileEmitKindJsMap | FileEmitKindJsInlineMap + FileEmitKindAllDtsEmit = FileEmitKindDtsEmit | FileEmitKindDtsMap + FileEmitKindAllDts = FileEmitKindDts | FileEmitKindDtsMap + FileEmitKindAll = FileEmitKindAllJs | FileEmitKindAllDts +) + +func GetFileEmitKind(options *core.CompilerOptions) FileEmitKind { + result := FileEmitKindJs + if options.SourceMap.IsTrue() { + result |= FileEmitKindJsMap + } + if options.InlineSourceMap.IsTrue() { + result |= FileEmitKindJsInlineMap + } + if options.GetEmitDeclarations() { + result |= FileEmitKindDts + } + if options.DeclarationMap.IsTrue() { + result |= FileEmitKindDtsMap + } + if options.EmitDeclarationOnly.IsTrue() { + result &= FileEmitKindAllDts + } + return result +} + +func getPendingEmitKindWithOptions(options *core.CompilerOptions, oldOptions *core.CompilerOptions) FileEmitKind { + oldEmitKind := GetFileEmitKind(oldOptions) + newEmitKind := GetFileEmitKind(options) + return getPendingEmitKind(newEmitKind, oldEmitKind) +} + +func getPendingEmitKind(emitKind FileEmitKind, oldEmitKind FileEmitKind) FileEmitKind { + if oldEmitKind == emitKind { + return FileEmitKindNone + } + if oldEmitKind == 0 || emitKind == 0 { + return emitKind + } + diff := oldEmitKind ^ emitKind + result := FileEmitKindNone + // If there is diff in Js emit, pending emit is js emit flags + if (diff & FileEmitKindAllJs) != 0 { + result |= emitKind & FileEmitKindAllJs + } + // If dts errors pending, add dts errors flag + if (diff & FileEmitKindDtsErrors) != 0 { + result |= emitKind & FileEmitKindDtsErrors + } + // If there is diff in Dts emit, pending emit is dts emit flags + if (diff & FileEmitKindAllDtsEmit) != 0 { + result |= emitKind & FileEmitKindAllDtsEmit + } + return result +} + +// Signature (Hash of d.ts emitted), is string if it was emitted using same d.ts.map option as what compilerOptions indicate, +// otherwise tuple of string +type emitSignature struct { + signature string + signatureWithDifferentOptions []string +} + +// Covert to Emit signature based on oldOptions and EmitSignature format +// If d.ts map options differ then swap the format, otherwise use as is +func (e *emitSignature) getNewEmitSignature(oldOptions *core.CompilerOptions, newOptions *core.CompilerOptions) *emitSignature { + if oldOptions.DeclarationMap.IsTrue() == newOptions.DeclarationMap.IsTrue() { + return e + } + if e.signatureWithDifferentOptions == nil { + return &emitSignature{ + signatureWithDifferentOptions: []string{e.signature}, + } + } else { + return &emitSignature{ + signature: e.signatureWithDifferentOptions[0], + } + } +} + +type buildInfoDiagnosticWithFileName struct { + // filename if it is for a File thats other than its stored for + file tspath.Path + noFile bool + pos int + end int + code int32 + category diagnostics.Category + message string + messageChain []*buildInfoDiagnosticWithFileName + relatedInformation []*buildInfoDiagnosticWithFileName + reportsUnnecessary bool + reportsDeprecated bool + skippedOnNoEmit bool +} + +type diagnosticsOrBuildInfoDiagnosticsWithFileName struct { + diagnostics []*ast.Diagnostic + buildInfoDiagnostics []*buildInfoDiagnosticWithFileName +} + +func (b *buildInfoDiagnosticWithFileName) toDiagnostic(p *compiler.Program, file *ast.SourceFile) *ast.Diagnostic { + var fileForDiagnostic *ast.SourceFile + if b.file != "" { + fileForDiagnostic = p.GetSourceFileByPath(b.file) + } else if !b.noFile { + fileForDiagnostic = file + } + var messageChain []*ast.Diagnostic + for _, msg := range b.messageChain { + messageChain = append(messageChain, msg.toDiagnostic(p, fileForDiagnostic)) + } + var relatedInformation []*ast.Diagnostic + for _, info := range b.relatedInformation { + relatedInformation = append(relatedInformation, info.toDiagnostic(p, fileForDiagnostic)) + } + return ast.NewDiagnosticWith( + fileForDiagnostic, + core.NewTextRange(b.pos, b.end), + b.code, + b.category, + b.message, + messageChain, + relatedInformation, + b.reportsUnnecessary, + b.reportsDeprecated, + b.skippedOnNoEmit, + ) +} + +func (d *diagnosticsOrBuildInfoDiagnosticsWithFileName) getDiagnostics(p *compiler.Program, file *ast.SourceFile) []*ast.Diagnostic { + if d.diagnostics != nil { + return d.diagnostics + } + // Convert and cache the diagnostics + d.diagnostics = core.Map(d.buildInfoDiagnostics, func(diag *buildInfoDiagnosticWithFileName) *ast.Diagnostic { + return diag.toDiagnostic(p, file) + }) + return d.diagnostics +} + +type snapshot struct { + // These are the fields that get serialized + + // Information of the file eg. its version, signature etc + fileInfos map[tspath.Path]*fileInfo + options *core.CompilerOptions + // Contains the map of ReferencedSet=Referenced files of the file if module emit is enabled + referencedMap collections.ManyToManyMap[tspath.Path, tspath.Path] + // Cache of semantic diagnostics for files with their Path being the key + semanticDiagnosticsPerFile map[tspath.Path]*diagnosticsOrBuildInfoDiagnosticsWithFileName + // Cache of dts emit diagnostics for files with their Path being the key + emitDiagnosticsPerFile map[tspath.Path]*diagnosticsOrBuildInfoDiagnosticsWithFileName + // The map has key by source file's path that has been changed + changedFilesSet *collections.Set[tspath.Path] + // Files pending to be emitted + affectedFilesPendingEmit map[tspath.Path]FileEmitKind + // Name of the file whose dts was the latest to change + latestChangedDtsFile string + // Hash of d.ts emitted for the file, use to track when emit of d.ts changes + emitSignatures map[tspath.Path]*emitSignature + // Recorded if program had errors + hasErrors core.Tristate + // If semantic diagnsotic check is pending + checkPending bool + + // Additional fields that are not serialized but needed to track state + + // true if build info emit is pending + buildInfoEmitPending bool + hasErrorsFromOldState core.Tristate + allFilesExcludingDefaultLibraryFileOnce sync.Once + // Cache of all files excluding default library file for the current program + allFilesExcludingDefaultLibraryFile []*ast.SourceFile +} + +func (s *snapshot) createEmitSignaturesMap() { + if s.emitSignatures == nil && s.options.Composite.IsTrue() { + s.emitSignatures = make(map[tspath.Path]*emitSignature) + } +} + +func (s *snapshot) addFileToChangeSet(filePath tspath.Path) { + s.changedFilesSet.Add(filePath) + s.buildInfoEmitPending = true +} + +func (s *snapshot) addFileToAffectedFilesPendingEmit(filePath tspath.Path, emitKind FileEmitKind) { + existingKind := s.affectedFilesPendingEmit[filePath] + if s.affectedFilesPendingEmit == nil { + s.affectedFilesPendingEmit = make(map[tspath.Path]FileEmitKind) + } + s.affectedFilesPendingEmit[filePath] = existingKind | emitKind + delete(s.emitDiagnosticsPerFile, filePath) + s.buildInfoEmitPending = true +} + +func (s *snapshot) getAllFilesExcludingDefaultLibraryFile(program *compiler.Program, firstSourceFile *ast.SourceFile) []*ast.SourceFile { + s.allFilesExcludingDefaultLibraryFileOnce.Do(func() { + files := program.GetSourceFiles() + s.allFilesExcludingDefaultLibraryFile = make([]*ast.SourceFile, 0, len(files)) + addSourceFile := func(file *ast.SourceFile) { + if !program.IsSourceFileDefaultLibrary(file.Path()) { + s.allFilesExcludingDefaultLibraryFile = append(s.allFilesExcludingDefaultLibraryFile, file) + } + } + if firstSourceFile != nil { + addSourceFile(firstSourceFile) + } + for _, file := range files { + if file != firstSourceFile { + addSourceFile(file) + } + } + }) + return s.allFilesExcludingDefaultLibraryFile +} + +func newSnapshotForProgram(program *compiler.Program, oldProgram *Program) *snapshot { + if oldProgram != nil && oldProgram.program == program { + return oldProgram.snapshot + } + files := program.GetSourceFiles() + snapshot := &snapshot{ + options: program.Options(), + semanticDiagnosticsPerFile: make(map[tspath.Path]*diagnosticsOrBuildInfoDiagnosticsWithFileName, len(files)), + } + if oldProgram != nil && snapshot.options.Composite.IsTrue() { + snapshot.latestChangedDtsFile = oldProgram.snapshot.latestChangedDtsFile + } + if snapshot.options.NoCheck.IsTrue() { + snapshot.checkPending = true + } + + if oldProgram != nil { + // Copy old snapshot's changed files set + snapshot.changedFilesSet = oldProgram.snapshot.changedFilesSet.Clone() + if len(oldProgram.snapshot.affectedFilesPendingEmit) != 0 { + snapshot.affectedFilesPendingEmit = maps.Clone(oldProgram.snapshot.affectedFilesPendingEmit) + } + snapshot.buildInfoEmitPending = oldProgram.snapshot.buildInfoEmitPending + snapshot.hasErrorsFromOldState = oldProgram.snapshot.hasErrors + } else { + snapshot.changedFilesSet = &collections.Set[tspath.Path]{} + snapshot.buildInfoEmitPending = snapshot.options.IsIncremental() + } + + canCopySemanticDiagnostics := oldProgram != nil && + !tsoptions.CompilerOptionsAffectSemanticDiagnostics(oldProgram.snapshot.options, program.Options()) + // We can only reuse emit signatures (i.e. .d.ts signatures) if the .d.ts file is unchanged, + // which will eg be depedent on change in options like declarationDir and outDir options are unchanged. + // We need to look in oldState.compilerOptions, rather than oldCompilerOptions (i.e.we need to disregard useOldState) because + // oldCompilerOptions can be undefined if there was change in say module from None to some other option + // which would make useOldState as false since we can now use reference maps that are needed to track what to emit, what to check etc + // but that option change does not affect d.ts file name so emitSignatures should still be reused. + canCopyEmitSignatures := snapshot.options.Composite.IsTrue() && + oldProgram != nil && + oldProgram.snapshot.emitSignatures != nil && + !tsoptions.CompilerOptionsAffectDeclarationPath(oldProgram.snapshot.options, program.Options()) + copyDeclarationFileDiagnostics := canCopySemanticDiagnostics && + snapshot.options.SkipLibCheck.IsTrue() == oldProgram.snapshot.options.SkipLibCheck.IsTrue() + copyLibFileDiagnostics := copyDeclarationFileDiagnostics && + snapshot.options.SkipDefaultLibCheck.IsTrue() == oldProgram.snapshot.options.SkipDefaultLibCheck.IsTrue() + snapshot.fileInfos = make(map[tspath.Path]*fileInfo, len(files)) + for _, file := range files { + version := computeHash(file.Text()) + impliedNodeFormat := program.GetSourceFileMetaData(file.Path()).ImpliedNodeFormat + affectsGlobalScope := fileAffectsGlobalScope(file) + var signature string + newReferences := getReferencedFiles(program, file) + if newReferences != nil { + snapshot.referencedMap.Add(file.Path(), newReferences) + } + if oldProgram != nil { + if oldFileInfo, ok := oldProgram.snapshot.fileInfos[file.Path()]; ok { + signature = oldFileInfo.signature + if oldFileInfo.version != version || oldFileInfo.affectsGlobalScope != affectsGlobalScope || oldFileInfo.impliedNodeFormat != impliedNodeFormat { + snapshot.addFileToChangeSet(file.Path()) + } else if oldReferences, _ := oldProgram.snapshot.referencedMap.GetValues(file.Path()); !newReferences.Equals(oldReferences) { + // Referenced files changed + snapshot.addFileToChangeSet(file.Path()) + } else if newReferences != nil { + for refPath := range newReferences.Keys() { + if program.GetSourceFileByPath(refPath) == nil && oldProgram.snapshot.fileInfos[refPath] != nil { + // Referenced file was deleted in the new program + snapshot.addFileToChangeSet(file.Path()) + break + } + } + } + } else { + snapshot.addFileToChangeSet(file.Path()) + } + if !snapshot.changedFilesSet.Has(file.Path()) { + if emitDiagnostics, ok := oldProgram.snapshot.emitDiagnosticsPerFile[file.Path()]; ok { + if snapshot.emitDiagnosticsPerFile == nil { + snapshot.emitDiagnosticsPerFile = make(map[tspath.Path]*diagnosticsOrBuildInfoDiagnosticsWithFileName, len(files)) + } + snapshot.emitDiagnosticsPerFile[file.Path()] = emitDiagnostics + } + if canCopySemanticDiagnostics { + if (!file.IsDeclarationFile || copyDeclarationFileDiagnostics) && + (!program.IsSourceFileDefaultLibrary(file.Path()) || copyLibFileDiagnostics) { + // Unchanged file copy diagnostics + if diagnostics, ok := oldProgram.snapshot.semanticDiagnosticsPerFile[file.Path()]; ok { + snapshot.semanticDiagnosticsPerFile[file.Path()] = diagnostics + } + } + } + } + if canCopyEmitSignatures { + if oldEmitSignature, ok := oldProgram.snapshot.emitSignatures[file.Path()]; ok { + snapshot.createEmitSignaturesMap() + snapshot.emitSignatures[file.Path()] = oldEmitSignature.getNewEmitSignature(oldProgram.snapshot.options, snapshot.options) + } + } + } else { + snapshot.addFileToAffectedFilesPendingEmit(file.Path(), GetFileEmitKind(snapshot.options)) + signature = version + } + snapshot.fileInfos[file.Path()] = &fileInfo{ + version: version, + signature: signature, + affectsGlobalScope: affectsGlobalScope, + impliedNodeFormat: impliedNodeFormat, + } + } + if oldProgram != nil { + // If the global file is removed, add all files as changed + allFilesExcludingDefaultLibraryFileAddedToChangeSet := false + for filePath, oldInfo := range oldProgram.snapshot.fileInfos { + if _, ok := snapshot.fileInfos[filePath]; !ok { + if oldInfo.affectsGlobalScope { + for _, file := range snapshot.getAllFilesExcludingDefaultLibraryFile(program, nil) { + snapshot.addFileToChangeSet(file.Path()) + } + allFilesExcludingDefaultLibraryFileAddedToChangeSet = true + } else { + snapshot.buildInfoEmitPending = true + } + break + } + } + if !allFilesExcludingDefaultLibraryFileAddedToChangeSet { + // If options affect emit, then we need to do complete emit per compiler options + // otherwise only the js or dts that needs to emitted because its different from previously emitted options + var pendingEmitKind FileEmitKind + if tsoptions.CompilerOptionsAffectEmit(oldProgram.snapshot.options, snapshot.options) { + pendingEmitKind = GetFileEmitKind(snapshot.options) + } else { + pendingEmitKind = getPendingEmitKindWithOptions(snapshot.options, oldProgram.snapshot.options) + } + if pendingEmitKind != FileEmitKindNone { + // Add all files to affectedFilesPendingEmit since emit changed + for _, file := range files { + // Add to affectedFilesPending emit only if not changed since any changed file will do full emit + if !snapshot.changedFilesSet.Has(file.Path()) { + snapshot.addFileToAffectedFilesPendingEmit(file.Path(), pendingEmitKind) + } + } + snapshot.buildInfoEmitPending = true + } + } + if len(snapshot.semanticDiagnosticsPerFile) != len(snapshot.fileInfos) && + oldProgram.snapshot.checkPending != snapshot.checkPending { + snapshot.buildInfoEmitPending = true + } + } + return snapshot +} + +func fileAffectsGlobalScope(file *ast.SourceFile) bool { + // if file contains anything that augments to global scope we need to build them as if + // they are global files as well as module + if core.Some(file.ModuleAugmentations, func(augmentation *ast.ModuleName) bool { + return ast.IsGlobalScopeAugmentation(augmentation.Parent) + }) { + return true + } + + if ast.IsExternalOrCommonJSModule(file) || ast.IsJsonSourceFile(file) { + return false + } + + // For script files that contains only ambient external modules, although they are not actually external module files, + // they can only be consumed via importing elements from them. Regular script files cannot consume them. Therefore, + // there are no point to rebuild all script files if these special files have changed. However, if any statement + // in the file is not ambient external module, we treat it as a regular script file. + return file.Statements != nil && + file.Statements.Nodes != nil && + core.Some(file.Statements.Nodes, func(stmt *ast.Node) bool { + return !ast.IsModuleWithStringLiteralName(stmt) + }) +} + +func addReferencedFilesFromSymbol(file *ast.SourceFile, referencedFiles *collections.Set[tspath.Path], symbol *ast.Symbol) { + if symbol == nil { + return + } + for _, declaration := range symbol.Declarations { + fileOfDecl := ast.GetSourceFileOfNode(declaration) + if fileOfDecl == nil { + continue + } + if file != fileOfDecl { + referencedFiles.Add(fileOfDecl.Path()) + } + } +} + +// Get the module source file and all augmenting files from the import name node from file +func addReferencedFilesFromImportLiteral(file *ast.SourceFile, referencedFiles *collections.Set[tspath.Path], checker *checker.Checker, importName *ast.LiteralLikeNode) { + symbol := checker.GetSymbolAtLocation(importName) + addReferencedFilesFromSymbol(file, referencedFiles, symbol) +} + +// Gets the path to reference file from file name, it could be resolvedPath if present otherwise path +func addReferencedFileFromFileName(program *compiler.Program, fileName string, referencedFiles *collections.Set[tspath.Path], sourceFileDirectory string) { + if redirect := program.GetParseFileRedirect(fileName); redirect != "" { + referencedFiles.Add(tspath.ToPath(redirect, program.GetCurrentDirectory(), program.UseCaseSensitiveFileNames())) + } else { + referencedFiles.Add(tspath.ToPath(fileName, sourceFileDirectory, program.UseCaseSensitiveFileNames())) + } +} + +// Gets the referenced files for a file from the program with values for the keys as referenced file's path to be true +func getReferencedFiles(program *compiler.Program, file *ast.SourceFile) *collections.Set[tspath.Path] { + referencedFiles := collections.Set[tspath.Path]{} + + // We need to use a set here since the code can contain the same import twice, + // but that will only be one dependency. + // To avoid invernal conversion, the key of the referencedFiles map must be of type Path + checker, done := program.GetTypeCheckerForFile(context.TODO(), file) + defer done() + for _, importName := range file.Imports() { + addReferencedFilesFromImportLiteral(file, &referencedFiles, checker, importName) + } + + sourceFileDirectory := tspath.GetDirectoryPath(file.FileName()) + // Handle triple slash references + for _, referencedFile := range file.ReferencedFiles { + addReferencedFileFromFileName(program, referencedFile.FileName, &referencedFiles, sourceFileDirectory) + } + + // Handle type reference directives + if typeRefsInFile, ok := program.GetResolvedTypeReferenceDirectives()[file.Path()]; ok { + for _, typeRef := range typeRefsInFile { + if typeRef.ResolvedFileName != "" { + addReferencedFileFromFileName(program, typeRef.ResolvedFileName, &referencedFiles, sourceFileDirectory) + } + } + } + + // Add module augmentation as references + for _, moduleName := range file.ModuleAugmentations { + if !ast.IsStringLiteral(moduleName) { + continue + } + addReferencedFilesFromImportLiteral(file, &referencedFiles, checker, moduleName) + } + + // From ambient modules + for _, ambientModule := range checker.GetAmbientModules() { + addReferencedFilesFromSymbol(file, &referencedFiles, ambientModule) + } + return core.IfElse(referencedFiles.Len() > 0, &referencedFiles, nil) +} diff --git a/internal/incremental/tobuildinfo.go b/internal/incremental/tobuildinfo.go new file mode 100644 index 0000000000..22345723a4 --- /dev/null +++ b/internal/incremental/tobuildinfo.go @@ -0,0 +1,291 @@ +package incremental + +import ( + "fmt" + "maps" + "reflect" + "slices" + "strings" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/tsoptions" + "github.com/microsoft/typescript-go/internal/tspath" +) + +func snapshotToBuildInfo(snapshot *snapshot, program *compiler.Program, buildInfoFileName string) *BuildInfo { + to := &toBuildInfo{ + snapshot: snapshot, + program: program, + buildInfoDirectory: tspath.GetDirectoryPath(buildInfoFileName), + comparePathsOptions: tspath.ComparePathsOptions{ + CurrentDirectory: program.GetCurrentDirectory(), + UseCaseSensitiveFileNames: program.UseCaseSensitiveFileNames(), + }, + fileNameToFileId: make(map[string]BuildInfoFileId), + fileNamesToFileIdListId: make(map[string]BuildInfoFileIdListId), + } + to.buildInfo.Version = core.Version() + if snapshot.options.IsIncremental() { + to.setFileInfoAndEmitSignatures() + to.setCompilerOptions() + to.setReferencedMap() + to.setChangeFileSet() + to.setSemanticDiagnostics() + to.setEmitDiagnostics() + to.setAffectedFilesPendingEmit() + if snapshot.latestChangedDtsFile != "" { + to.buildInfo.LatestChangedDtsFile = to.relativeToBuildInfo(snapshot.latestChangedDtsFile) + } + } + // else { + // const buildInfo: NonIncrementalBuildInfo = { + // root: arrayFrom(rootFileNames, r => relativeToBuildInfo(r)), + // }; + // } + to.buildInfo.Errors = snapshot.hasErrors.IsTrue() + to.buildInfo.CheckPending = snapshot.checkPending + return &to.buildInfo +} + +type toBuildInfo struct { + snapshot *snapshot + program *compiler.Program + buildInfo BuildInfo + buildInfoDirectory string + comparePathsOptions tspath.ComparePathsOptions + fileNameToFileId map[string]BuildInfoFileId + fileNamesToFileIdListId map[string]BuildInfoFileIdListId +} + +func (t *toBuildInfo) relativeToBuildInfo(path string) string { + return tspath.EnsurePathIsNonModuleName(tspath.GetRelativePathFromDirectory(t.buildInfoDirectory, path, t.comparePathsOptions)) +} + +func (t *toBuildInfo) toFileId(path tspath.Path) BuildInfoFileId { + fileId := t.fileNameToFileId[string(path)] + if fileId == 0 { + t.buildInfo.FileNames = append(t.buildInfo.FileNames, t.relativeToBuildInfo(string(path))) + fileId = BuildInfoFileId(len(t.buildInfo.FileNames)) + t.fileNameToFileId[string(path)] = fileId + } + return fileId +} + +func (t *toBuildInfo) toFileIdListId(set *collections.Set[tspath.Path]) BuildInfoFileIdListId { + fileIds := core.Map(slices.Collect(maps.Keys(set.Keys())), t.toFileId) + slices.Sort(fileIds) + key := strings.Join(core.Map(fileIds, func(id BuildInfoFileId) string { + return fmt.Sprintf("%d", id) + }), ",") + + fileIdListId := t.fileNamesToFileIdListId[key] + if fileIdListId == 0 { + t.buildInfo.FileIdsList = append(t.buildInfo.FileIdsList, fileIds) + fileIdListId = BuildInfoFileIdListId(len(t.buildInfo.FileIdsList)) + t.fileNamesToFileIdListId[key] = fileIdListId + } + return fileIdListId +} + +func (t *toBuildInfo) toRelativeToBuildInfoCompilerOptionValue(option *tsoptions.CommandLineOption, v any) any { + if !option.IsFilePath { + return v + } + if option.Kind == "list" { + if arr, ok := v.([]string); ok { + return core.Map(arr, t.relativeToBuildInfo) + } + } else if str, ok := v.(string); ok && str != "" { + return t.relativeToBuildInfo(v.(string)) + } + return v +} + +func (t *toBuildInfo) toBuildInfoDiagnosticsFromFileNameDiagnostics(diagnostics []*buildInfoDiagnosticWithFileName) []*BuildInfoDiagnostic { + return core.Map(diagnostics, func(d *buildInfoDiagnosticWithFileName) *BuildInfoDiagnostic { + var file BuildInfoFileId + if d.file != "" { + file = t.toFileId(d.file) + } + return &BuildInfoDiagnostic{ + File: file, + NoFile: d.noFile, + Pos: d.pos, + End: d.end, + Code: d.code, + Category: d.category, + Message: d.message, + MessageChain: t.toBuildInfoDiagnosticsFromFileNameDiagnostics(d.messageChain), + RelatedInformation: t.toBuildInfoDiagnosticsFromFileNameDiagnostics(d.relatedInformation), + ReportsUnnecessary: d.reportsUnnecessary, + ReportsDeprecated: d.reportsDeprecated, + SkippedOnNoEmit: d.skippedOnNoEmit, + } + }) +} + +func (t *toBuildInfo) toBuildInfoDiagnosticsFromDiagnostics(filePath tspath.Path, diagnostics []*ast.Diagnostic) []*BuildInfoDiagnostic { + return core.Map(diagnostics, func(d *ast.Diagnostic) *BuildInfoDiagnostic { + var file BuildInfoFileId + noFile := false + if d.File() == nil { + noFile = true + } else if d.File().Path() != filePath { + file = t.toFileId(d.File().Path()) + } + return &BuildInfoDiagnostic{ + File: file, + NoFile: noFile, + Pos: d.Loc().Pos(), + End: d.Loc().End(), + Code: d.Code(), + Category: d.Category(), + Message: d.Message(), + MessageChain: t.toBuildInfoDiagnosticsFromDiagnostics(filePath, d.MessageChain()), + RelatedInformation: t.toBuildInfoDiagnosticsFromDiagnostics(filePath, d.RelatedInformation()), + ReportsUnnecessary: d.ReportsUnnecessary(), + ReportsDeprecated: d.ReportsDeprecated(), + SkippedOnNoEmit: d.SkippedOnNoEmit(), + } + }) +} + +func (t *toBuildInfo) toBuildInfoDiagnosticsOfFile(filePath tspath.Path, diags *diagnosticsOrBuildInfoDiagnosticsWithFileName) *BuildInfoDiagnosticsOfFile { + if len(diags.diagnostics) > 0 { + return &BuildInfoDiagnosticsOfFile{ + FileId: t.toFileId(filePath), + Diagnostics: t.toBuildInfoDiagnosticsFromDiagnostics(filePath, diags.diagnostics), + } + } + if len(diags.buildInfoDiagnostics) > 0 { + return &BuildInfoDiagnosticsOfFile{ + FileId: t.toFileId(filePath), + Diagnostics: t.toBuildInfoDiagnosticsFromFileNameDiagnostics(diags.buildInfoDiagnostics), + } + } + return nil +} + +func (t *toBuildInfo) setFileInfoAndEmitSignatures() { + t.buildInfo.FileInfos = core.Map(t.program.GetSourceFiles(), func(file *ast.SourceFile) *BuildInfoFileInfo { + info := t.snapshot.fileInfos[file.Path()] + fileId := t.toFileId(file.Path()) + // tryAddRoot(key, fileId); + if t.buildInfo.FileNames[fileId-1] != t.relativeToBuildInfo(string(file.Path())) { + panic(fmt.Sprintf("File name at index %d does not match expected relative path: %s != %s", fileId-1, t.buildInfo.FileNames[fileId-1], t.relativeToBuildInfo(string(file.Path())))) + } + if t.snapshot.options.Composite.IsTrue() { + if !ast.IsJsonSourceFile(file) && t.program.SourceFileMayBeEmitted(file, false) { + emitSignature := t.snapshot.emitSignatures[file.Path()] + if emitSignature == nil { + t.buildInfo.EmitSignatures = append(t.buildInfo.EmitSignatures, &BuildInfoEmitSignature{ + FileId: fileId, + }) + } else if emitSignature.signature != info.signature { + incrementalEmitSignature := &BuildInfoEmitSignature{ + FileId: fileId, + } + if emitSignature.signature != "" { + incrementalEmitSignature.Signature = emitSignature.signature + } else if emitSignature.signatureWithDifferentOptions[0] == info.signature { + incrementalEmitSignature.DiffersOnlyInDtsMap = true + } else { + incrementalEmitSignature.Signature = emitSignature.signatureWithDifferentOptions[0] + incrementalEmitSignature.DiffersInOptions = true + } + t.buildInfo.EmitSignatures = append(t.buildInfo.EmitSignatures, incrementalEmitSignature) + } + } + } + return newBuildInfoFileInfo(info) + }) +} + +func (t *toBuildInfo) setCompilerOptions() { + tsoptions.ForEachCompilerOptionValue( + t.snapshot.options, + func(option *tsoptions.CommandLineOption) bool { + return option.AffectsBuildInfo + }, + func(option *tsoptions.CommandLineOption, value reflect.Value, i int) bool { + if value.IsZero() { + return false + } + // Make it relative to buildInfo directory if file path + if t.buildInfo.Options == nil { + t.buildInfo.Options = &collections.OrderedMap[string, any]{} + } + t.buildInfo.Options.Set(option.Name, t.toRelativeToBuildInfoCompilerOptionValue(option, value.Interface())) + return false + }, + ) +} + +func (t *toBuildInfo) setReferencedMap() { + keys := slices.Collect(maps.Keys(t.snapshot.referencedMap.Keys())) + slices.Sort(keys) + t.buildInfo.ReferencedMap = core.Map(keys, func(filePath tspath.Path) *BuildInfoReferenceMapEntry { + references, _ := t.snapshot.referencedMap.GetValues(filePath) + return &BuildInfoReferenceMapEntry{ + FileId: t.toFileId(filePath), + FileIdListId: t.toFileIdListId(references), + } + }) +} + +func (t *toBuildInfo) setChangeFileSet() { + files := slices.Collect(maps.Keys(t.snapshot.changedFilesSet.Keys())) + slices.Sort(files) + t.buildInfo.ChangeFileSet = core.Map(files, t.toFileId) +} + +func (t *toBuildInfo) setSemanticDiagnostics() { + for _, file := range t.program.GetSourceFiles() { + value, ok := t.snapshot.semanticDiagnosticsPerFile[file.Path()] + if !ok { + if !t.snapshot.changedFilesSet.Has(file.Path()) { + t.buildInfo.SemanticDiagnosticsPerFile = append(t.buildInfo.SemanticDiagnosticsPerFile, &BuildInfoSemanticDiagnostic{ + FileId: t.toFileId(file.Path()), + }) + } + } else { + diagnostics := t.toBuildInfoDiagnosticsOfFile(file.Path(), value) + if diagnostics != nil { + t.buildInfo.SemanticDiagnosticsPerFile = append(t.buildInfo.SemanticDiagnosticsPerFile, &BuildInfoSemanticDiagnostic{ + Diagnostics: diagnostics, + }) + } + } + } +} + +func (t *toBuildInfo) setEmitDiagnostics() { + files := slices.Collect(maps.Keys(t.snapshot.emitDiagnosticsPerFile)) + slices.Sort(files) + t.buildInfo.EmitDiagnosticsPerFile = core.Map(files, func(filePath tspath.Path) *BuildInfoDiagnosticsOfFile { + return t.toBuildInfoDiagnosticsOfFile(filePath, t.snapshot.emitDiagnosticsPerFile[filePath]) + }) +} + +func (t *toBuildInfo) setAffectedFilesPendingEmit() { + if len(t.snapshot.affectedFilesPendingEmit) == 0 { + return + } + files := slices.Collect(maps.Keys(t.snapshot.affectedFilesPendingEmit)) + slices.Sort(files) + fullEmitKind := GetFileEmitKind(t.snapshot.options) + for _, filePath := range files { + file := t.program.GetSourceFileByPath(filePath) + if file == nil || !t.program.SourceFileMayBeEmitted(file, false) { + continue + } + pendingEmit := t.snapshot.affectedFilesPendingEmit[filePath] + t.buildInfo.AffectedFilesPendingEmit = append(t.buildInfo.AffectedFilesPendingEmit, &BuildInfoFilePendingEmit{ + FileId: t.toFileId(filePath), + EmitKind: core.IfElse(pendingEmit == fullEmitKind, 0, pendingEmit), + }) + } +} diff --git a/internal/incremental/tosnapshot.go b/internal/incremental/tosnapshot.go new file mode 100644 index 0000000000..1992801302 --- /dev/null +++ b/internal/incremental/tosnapshot.go @@ -0,0 +1,168 @@ +package incremental + +import ( + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/tsoptions" + "github.com/microsoft/typescript-go/internal/tspath" +) + +func buildInfoToSnapshot(buildInfo *BuildInfo, buildInfoFileName string, config *tsoptions.ParsedCommandLine) *snapshot { + to := &toSnapshot{ + buildInfo: buildInfo, + buildInfoDirectory: tspath.GetDirectoryPath(tspath.GetNormalizedAbsolutePath(buildInfoFileName, config.GetCurrentDirectory())), + filePaths: make([]tspath.Path, 0, len(buildInfo.FileNames)), + filePathSet: make([]*collections.Set[tspath.Path], 0, len(buildInfo.FileIdsList)), + } + to.filePaths = core.Map(buildInfo.FileNames, func(fileName string) tspath.Path { + return tspath.ToPath(fileName, to.buildInfoDirectory, config.UseCaseSensitiveFileNames()) + }) + to.filePathSet = core.Map(buildInfo.FileIdsList, func(fileIdList []BuildInfoFileId) *collections.Set[tspath.Path] { + fileSet := collections.NewSetWithSizeHint[tspath.Path](len(fileIdList)) + for _, fileId := range fileIdList { + fileSet.Add(to.toFilePath(fileId)) + } + return fileSet + }) + to.setCompilerOptions() + to.setFileInfoAndEmitSignatures() + to.setReferencedMap() + to.setChangeFileSet() + to.setSemanticDiagnostics() + to.setEmitDiagnostics() + to.setAffectedFilesPendingEmit() + if buildInfo.LatestChangedDtsFile != "" { + to.snapshot.latestChangedDtsFile = to.toAbsolutePath(buildInfo.LatestChangedDtsFile) + } + to.snapshot.hasErrors = core.IfElse(buildInfo.Errors, core.TSTrue, core.TSFalse) + to.snapshot.checkPending = buildInfo.CheckPending + return &to.snapshot +} + +type toSnapshot struct { + buildInfo *BuildInfo + buildInfoDirectory string + snapshot snapshot + filePaths []tspath.Path + filePathSet []*collections.Set[tspath.Path] +} + +func (t *toSnapshot) toAbsolutePath(path string) string { + return tspath.GetNormalizedAbsolutePath(path, t.buildInfoDirectory) +} + +func (t *toSnapshot) toFilePath(fileId BuildInfoFileId) tspath.Path { + return t.filePaths[fileId-1] +} + +func (t *toSnapshot) toFilePathSet(fileIdListId BuildInfoFileIdListId) *collections.Set[tspath.Path] { + return t.filePathSet[fileIdListId-1] +} + +func (t *toSnapshot) toBuildInfoDiagnosticsWithFileName(diagnostics []*BuildInfoDiagnostic) []*buildInfoDiagnosticWithFileName { + return core.Map(diagnostics, func(d *BuildInfoDiagnostic) *buildInfoDiagnosticWithFileName { + var file tspath.Path + if d.File != 0 { + file = t.toFilePath(d.File) + } + return &buildInfoDiagnosticWithFileName{ + file: file, + noFile: d.NoFile, + pos: d.Pos, + end: d.End, + code: d.Code, + category: d.Category, + message: d.Message, + messageChain: t.toBuildInfoDiagnosticsWithFileName(d.MessageChain), + relatedInformation: t.toBuildInfoDiagnosticsWithFileName(d.RelatedInformation), + reportsUnnecessary: d.ReportsUnnecessary, + reportsDeprecated: d.ReportsDeprecated, + skippedOnNoEmit: d.SkippedOnNoEmit, + } + }) +} + +func (t *toSnapshot) toDiagnosticsOrBuildInfoDiagnosticsWithFileName(dig *BuildInfoDiagnosticsOfFile) *diagnosticsOrBuildInfoDiagnosticsWithFileName { + return &diagnosticsOrBuildInfoDiagnosticsWithFileName{ + buildInfoDiagnostics: t.toBuildInfoDiagnosticsWithFileName(dig.Diagnostics), + } +} + +func (t *toSnapshot) setCompilerOptions() { + t.snapshot.options = t.buildInfo.GetCompilerOptions(t.buildInfoDirectory) +} + +func (t *toSnapshot) setFileInfoAndEmitSignatures() { + t.snapshot.fileInfos = make(map[tspath.Path]*fileInfo, len(t.buildInfo.FileInfos)) + t.snapshot.createEmitSignaturesMap() + for index, buildInfoFileInfo := range t.buildInfo.FileInfos { + path := t.toFilePath(BuildInfoFileId(index + 1)) + info := buildInfoFileInfo.GetFileInfo() + t.snapshot.fileInfos[path] = info + // Add default emit signature as file's signature + if info.signature != "" && t.snapshot.emitSignatures != nil { + t.snapshot.emitSignatures[path] = &emitSignature{signature: info.signature} + } + } + // Fix up emit signatures + for _, value := range t.buildInfo.EmitSignatures { + if value.noEmitSignature() { + delete(t.snapshot.emitSignatures, t.toFilePath(value.FileId)) + } else { + path := t.toFilePath(value.FileId) + t.snapshot.emitSignatures[path] = value.toEmitSignature(path, t.snapshot.emitSignatures) + } + } +} + +func (t *toSnapshot) setReferencedMap() { + for _, entry := range t.buildInfo.ReferencedMap { + t.snapshot.referencedMap.Add(t.toFilePath(entry.FileId), t.toFilePathSet(entry.FileIdListId)) + } +} + +func (t *toSnapshot) setChangeFileSet() { + t.snapshot.changedFilesSet = collections.NewSetWithSizeHint[tspath.Path](len(t.buildInfo.ChangeFileSet)) + for _, fileId := range t.buildInfo.ChangeFileSet { + filePath := t.toFilePath(fileId) + t.snapshot.changedFilesSet.Add(filePath) + } +} + +func (t *toSnapshot) setSemanticDiagnostics() { + t.snapshot.semanticDiagnosticsPerFile = make(map[tspath.Path]*diagnosticsOrBuildInfoDiagnosticsWithFileName, len(t.snapshot.fileInfos)) + for path := range t.snapshot.fileInfos { + // Initialize to have no diagnostics if its not changed file + if !t.snapshot.changedFilesSet.Has(path) { + t.snapshot.semanticDiagnosticsPerFile[path] = &diagnosticsOrBuildInfoDiagnosticsWithFileName{} + } + } + for _, diagnostic := range t.buildInfo.SemanticDiagnosticsPerFile { + if diagnostic.FileId != 0 { + filePath := t.toFilePath(diagnostic.FileId) + delete(t.snapshot.semanticDiagnosticsPerFile, filePath) // does not have cached diagnostics + } else { + filePath := t.toFilePath(diagnostic.Diagnostics.FileId) + t.snapshot.semanticDiagnosticsPerFile[filePath] = t.toDiagnosticsOrBuildInfoDiagnosticsWithFileName(diagnostic.Diagnostics) + } + } +} + +func (t *toSnapshot) setEmitDiagnostics() { + t.snapshot.emitDiagnosticsPerFile = make(map[tspath.Path]*diagnosticsOrBuildInfoDiagnosticsWithFileName, len(t.snapshot.fileInfos)) + for _, diagnostic := range t.buildInfo.EmitDiagnosticsPerFile { + filePath := t.toFilePath(diagnostic.FileId) + t.snapshot.emitDiagnosticsPerFile[filePath] = t.toDiagnosticsOrBuildInfoDiagnosticsWithFileName(diagnostic) + } +} + +func (t *toSnapshot) setAffectedFilesPendingEmit() { + if len(t.buildInfo.AffectedFilesPendingEmit) == 0 { + return + } + ownOptionsEmitKind := GetFileEmitKind(t.snapshot.options) + t.snapshot.affectedFilesPendingEmit = make(map[tspath.Path]FileEmitKind, len(t.buildInfo.AffectedFilesPendingEmit)) + for _, pendingEmit := range t.buildInfo.AffectedFilesPendingEmit { + t.snapshot.affectedFilesPendingEmit[t.toFilePath(pendingEmit.FileId)] = core.IfElse(pendingEmit.EmitKind == 0, ownOptionsEmitKind, pendingEmit.EmitKind) + } +} diff --git a/internal/outputpaths/outputpaths.go b/internal/outputpaths/outputpaths.go index 60cac7d6e2..2adbdd3805 100644 --- a/internal/outputpaths/outputpaths.go +++ b/internal/outputpaths/outputpaths.go @@ -19,7 +19,6 @@ type OutputPaths struct { sourceMapFilePath string declarationFilePath string declarationMapPath string - buildInfoPath string } // DeclarationFilePath implements declarations.OutputPaths. @@ -40,10 +39,6 @@ func (o *OutputPaths) DeclarationMapPath() string { return o.declarationMapPath } -func (o *OutputPaths) BuildInfoPath() string { - return o.buildInfoPath -} - func GetOutputPathsFor(sourceFile *ast.SourceFile, options *core.CompilerOptions, host OutputPathsHost, forceDtsEmit bool) *OutputPaths { // !!! bundle not implemented, may be deprecated ownOutputFilePath := getOwnEmitOutputFilePath(sourceFile.FileName(), options, host, GetOutputExtension(sourceFile.FileName(), options.Jsx)) @@ -199,3 +194,27 @@ func getDeclarationEmitExtensionForPath(fileName string) string { } return tspath.ExtensionDts } + +func GetBuildInfoFileName(options *core.CompilerOptions, opts tspath.ComparePathsOptions) string { + if !options.IsIncremental() && !options.TscBuild.IsTrue() { + return "" + } + if options.TsBuildInfoFile != "" { + return options.TsBuildInfoFile + } + if options.ConfigFilePath == "" { + return "" + } + configFileExtensionLess := tspath.RemoveFileExtension(options.ConfigFilePath) + var buildInfoExtensionLess string + if options.OutDir != "" { + if options.RootDir != "" { + buildInfoExtensionLess = tspath.ResolvePath(options.OutDir, tspath.GetRelativePathFromDirectory(options.RootDir, configFileExtensionLess, opts)) + } else { + buildInfoExtensionLess = tspath.CombinePaths(options.OutDir, tspath.GetBaseFileName(configFileExtensionLess)) + } + } else { + buildInfoExtensionLess = configFileExtensionLess + } + return buildInfoExtensionLess + tspath.ExtensionTsBuildInfo +} diff --git a/internal/printer/emithost.go b/internal/printer/emithost.go index 121ac712fc..901598392f 100644 --- a/internal/printer/emithost.go +++ b/internal/printer/emithost.go @@ -7,14 +7,6 @@ import ( "github.com/microsoft/typescript-go/internal/tspath" ) -type WriteFileData struct { - SourceMapUrlPos int - // BuildInfo BuildInfo - Diagnostics []*ast.Diagnostic - DiffersOnlyInMap bool - SkippedDtsWrite bool -} - // NOTE: EmitHost operations must be thread-safe type EmitHost interface { Options() *core.CompilerOptions @@ -23,7 +15,7 @@ type EmitHost interface { GetCurrentDirectory() string CommonSourceDirectory() string IsEmitBlocked(file string) bool - WriteFile(fileName string, text string, writeByteOrderMark bool, relatedSourceFiles []*ast.SourceFile, data *WriteFileData) error + WriteFile(fileName string, text string, writeByteOrderMark bool) error GetEmitModuleFormatOfFile(file ast.HasFileName) core.ModuleKind GetEmitResolver() EmitResolver GetOutputAndProjectReference(path tspath.Path) *tsoptions.OutputDtsAndProjectReference diff --git a/internal/testutil/harnessutil/harnessutil.go b/internal/testutil/harnessutil/harnessutil.go index 043bfa27cb..fe64f8fe1a 100644 --- a/internal/testutil/harnessutil/harnessutil.go +++ b/internal/testutil/harnessutil/harnessutil.go @@ -585,7 +585,7 @@ func compileFilesWithHost( if harnessOptions.CaptureSuggestions { diagnostics = append(diagnostics, program.GetSuggestionDiagnostics(ctx, nil)...) } - emitResult := program.Emit(compiler.EmitOptions{}) + emitResult := program.Emit(ctx, compiler.EmitOptions{}) return newCompilationResult(config.CompilerOptions(), program, emitResult, diagnostics, harnessOptions) } diff --git a/internal/testutil/incrementaltestutil/fs.go b/internal/testutil/incrementaltestutil/fs.go new file mode 100644 index 0000000000..51ce6caf2e --- /dev/null +++ b/internal/testutil/incrementaltestutil/fs.go @@ -0,0 +1,59 @@ +package incrementaltestutil + +import ( + "encoding/json" + "fmt" + + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/incremental" + "github.com/microsoft/typescript-go/internal/tspath" + "github.com/microsoft/typescript-go/internal/vfs" +) + +var fakeTsVersion = "FakeTSVersion" + +type FsHandlingBuildInfo struct { + vfs.FS +} + +// ReadFile reads the file specified by path and returns the content. +// If the file fails to be read, ok will be false. +func (f *FsHandlingBuildInfo) ReadFile(path string) (contents string, ok bool) { + contents, ok = f.FS.ReadFile(path) + if ok && tspath.FileExtensionIs(path, tspath.ExtensionTsBuildInfo) { + // read buildinfo and modify version + var buildInfo incremental.BuildInfo + err := json.Unmarshal([]byte(contents), &buildInfo) + if err == nil && buildInfo.Version == fakeTsVersion { + buildInfo.Version = core.Version() + newContents, err := json.Marshal(&buildInfo) + if err != nil { + panic("testFs.ReadFile: failed to marshal build info after fixing version: " + err.Error()) + } + contents = string(newContents) + } + } + return contents, ok +} + +func (f *FsHandlingBuildInfo) WriteFile(path string, data string, writeByteOrderMark bool) error { + if tspath.FileExtensionIs(path, tspath.ExtensionTsBuildInfo) { + var buildInfo incremental.BuildInfo + if err := json.Unmarshal([]byte(data), &buildInfo); err == nil { + if buildInfo.Version == core.Version() { + // Change it to fakeTsVersion + buildInfo.Version = fakeTsVersion + newData, err := json.Marshal(&buildInfo) + if err != nil { + return fmt.Errorf("testFs.WriteFile: failed to marshal build info after fixing version: %w", err) + } + data = string(newData) + } + // Write readable build info version + if err := f.FS.WriteFile(path+".readable.baseline.txt", toReadableBuildInfo(&buildInfo, data), false); err != nil { + return fmt.Errorf("testFs.WriteFile: failed to write readable build info: %w", err) + } + } + } + return f.FS.WriteFile(path, data, writeByteOrderMark) +} diff --git a/internal/testutil/incrementaltestutil/readablebuildinfo.go b/internal/testutil/incrementaltestutil/readablebuildinfo.go new file mode 100644 index 0000000000..b6d4b6dcd9 --- /dev/null +++ b/internal/testutil/incrementaltestutil/readablebuildinfo.go @@ -0,0 +1,359 @@ +package incrementaltestutil + +import ( + "encoding/json" + "fmt" + "strings" + + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/incremental" +) + +type readableBuildInfo struct { + buildInfo *incremental.BuildInfo + Version string `json:"version,omitzero"` + + // Common between incremental and tsc -b buildinfo for non incremental programs + Errors bool `json:"errors,omitzero"` + CheckPending bool `json:"checkPending,omitzero"` + // Root []BuildInfoRoot `json:"root,omitzero"` + + // IncrementalProgram info + FileNames []string `json:"fileNames,omitzero"` + FileInfos []*readableBuildInfoFileInfo `json:"fileInfos,omitzero"` + FileIdsList [][]string `json:"fileIdsList,omitzero"` + Options *collections.OrderedMap[string, any] `json:"options,omitzero"` + ReferencedMap *collections.OrderedMap[string, []string] `json:"referencedMap,omitzero"` + SemanticDiagnosticsPerFile []*readableBuildInfoSemanticDiagnostic `json:"semanticDiagnosticsPerFile,omitzero"` + EmitDiagnosticsPerFile []*readableBuildInfoDiagnosticsOfFile `json:"emitDiagnosticsPerFile,omitzero"` + ChangeFileSet []string `json:"changeFileSet,omitzero"` // List of changed files in the program, not the whole set of files + AffectedFilesPendingEmit []*readableBuildInfoFilePendingEmit `json:"affectedFilesPendingEmit,omitzero"` + LatestChangedDtsFile string `json:"latestChangedDtsFile,omitzero"` // Because this is only output file in the program, we dont need fileId to deduplicate name + EmitSignatures []*readableBuildInfoEmitSignature `json:"emitSignatures,omitzero"` + // resolvedRoot: readonly IncrementalBuildInfoResolvedRoot[] | undefined; + Size int `json:"size,omitzero"` // Size of the build info file +} + +type readableBuildInfoFileInfo struct { + FileName string `json:"fileName,omitzero"` + Version string `json:"version,omitzero"` + Signature string `json:"signature,omitzero"` + AffectsGlobalScope bool `json:"affectsGlobalScope,omitzero"` + ImpliedNodeFormat string `json:"impliedNodeFormat,omitzero"` + Original *incremental.BuildInfoFileInfo `json:"original,omitzero"` // Original file path, if available +} + +type readableBuildInfoDiagnostic struct { + // incrementalBuildInfoFileId if it is for a File thats other than its stored for + File string `json:"file,omitzero"` + NoFile bool `json:"noFile,omitzero"` + Pos int `json:"pos,omitzero"` + End int `json:"end,omitzero"` + Code int32 `json:"code,omitzero"` + Category diagnostics.Category `json:"category,omitzero"` + Message string `json:"message,omitzero"` + MessageChain []*readableBuildInfoDiagnostic `json:"messageChain,omitzero"` + RelatedInformation []*readableBuildInfoDiagnostic `json:"relatedInformation,omitzero"` + ReportsUnnecessary bool `json:"reportsUnnecessary,omitzero"` + ReportsDeprecated bool `json:"reportsDeprecated,omitzero"` + SkippedOnNoEmit bool `json:"skippedOnNoEmit,omitzero"` +} + +type readableBuildInfoDiagnosticsOfFile struct { + file string + diagnostics []*readableBuildInfoDiagnostic +} + +func (r *readableBuildInfoDiagnosticsOfFile) MarshalJSON() ([]byte, error) { + fileIdAndDiagnostics := make([]any, 0, 2) + fileIdAndDiagnostics = append(fileIdAndDiagnostics, r.file) + fileIdAndDiagnostics = append(fileIdAndDiagnostics, r.diagnostics) + return json.Marshal(fileIdAndDiagnostics) +} + +func (r *readableBuildInfoDiagnosticsOfFile) UnmarshalJSON(data []byte) error { + var fileIdAndDiagnostics []any + if err := json.Unmarshal(data, &fileIdAndDiagnostics); err != nil { + return fmt.Errorf("invalid readableBuildInfoDiagnosticsOfFile: %s", data) + } + if len(fileIdAndDiagnostics) != 2 { + return fmt.Errorf("invalid readableBuildInfoDiagnosticsOfFile: expected 2 elements, got %d", len(fileIdAndDiagnostics)) + } + file, ok := fileIdAndDiagnostics[0].(string) + if !ok { + return fmt.Errorf("invalid fileId in readableBuildInfoDiagnosticsOfFile: expected string, got %T", fileIdAndDiagnostics[0]) + } + if diagnostics, ok := fileIdAndDiagnostics[1].([]*readableBuildInfoDiagnostic); ok { + *r = readableBuildInfoDiagnosticsOfFile{ + file: file, + diagnostics: diagnostics, + } + return nil + } + return fmt.Errorf("invalid diagnostics in readableBuildInfoDiagnosticsOfFile: expected []*readableBuildInfoDiagnostic, got %T", fileIdAndDiagnostics[1]) +} + +type readableBuildInfoSemanticDiagnostic struct { + file string // File is not in changedSet and still doesnt have cached diagnostics + diagnostics *readableBuildInfoDiagnosticsOfFile // Diagnostics for file +} + +func (r *readableBuildInfoSemanticDiagnostic) MarshalJSON() ([]byte, error) { + if r.file != "" { + return json.Marshal(r.file) + } + return json.Marshal(r.diagnostics) +} + +func (r *readableBuildInfoSemanticDiagnostic) UnmarshalJSON(data []byte) error { + var file string + if err := json.Unmarshal(data, &file); err == nil { + *r = readableBuildInfoSemanticDiagnostic{ + file: file, + } + return nil + } + var diagnostics readableBuildInfoDiagnosticsOfFile + if err := json.Unmarshal(data, &diagnostics); err == nil { + *r = readableBuildInfoSemanticDiagnostic{ + diagnostics: &diagnostics, + } + return nil + } + return fmt.Errorf("invalid readableBuildInfoSemanticDiagnostic: %s", data) +} + +type readableBuildInfoFilePendingEmit struct { + file string + emitKind string + original *incremental.BuildInfoFilePendingEmit +} + +func (b *readableBuildInfoFilePendingEmit) MarshalJSON() ([]byte, error) { + return json.Marshal([]any{b.file, b.emitKind, b.original}) +} + +func (b *readableBuildInfoFilePendingEmit) UnmarshalJSON(data []byte) error { + var fileIdAndEmitKind []any + if err := json.Unmarshal(data, &fileIdAndEmitKind); err != nil { + return fmt.Errorf("invalid readableBuildInfoFilePendingEmit: %s", data) + } + if len(fileIdAndEmitKind) != 3 { + return fmt.Errorf("invalid readableBuildInfoFilePendingEmit: expected 3 elements, got %d", len(fileIdAndEmitKind)) + } + file, ok := fileIdAndEmitKind[0].(string) + if !ok { + return fmt.Errorf("invalid fileId in readableBuildInfoFilePendingEmit: expected string, got %T", fileIdAndEmitKind[0]) + } + var emitKind string + emitKind, ok = fileIdAndEmitKind[1].(string) + if !ok { + return fmt.Errorf("invalid emitKind in readableBuildInfoFilePendingEmit: expected string, got %T", fileIdAndEmitKind[1]) + } + var original *incremental.BuildInfoFilePendingEmit + original, ok = fileIdAndEmitKind[2].(*incremental.BuildInfoFilePendingEmit) + if !ok { + return fmt.Errorf("invalid original in readableBuildInfoFilePendingEmit: expected *incremental.BuildInfoFilePendingEmit, got %T", fileIdAndEmitKind[2]) + } + *b = readableBuildInfoFilePendingEmit{ + file: file, + emitKind: emitKind, + original: original, + } + return nil +} + +type readableBuildInfoEmitSignature struct { + File string `json:"file,omitzero"` + Signature string `json:"signature,omitzero"` + DiffersOnlyInDtsMap bool `json:"differsOnlyInDtsMap,omitzero"` + DiffersInOptions bool `json:"differsInOptions,omitzero"` + Original *incremental.BuildInfoEmitSignature `json:"original,omitzero"` +} + +func toReadableBuildInfo(buildInfo *incremental.BuildInfo, buildInfoText string) string { + readable := readableBuildInfo{ + buildInfo: buildInfo, + Version: buildInfo.Version, + Errors: buildInfo.Errors, + CheckPending: buildInfo.CheckPending, + FileNames: buildInfo.FileNames, + Options: buildInfo.Options, + LatestChangedDtsFile: buildInfo.LatestChangedDtsFile, + Size: len(buildInfoText), + } + readable.setFileInfos() + readable.setFileIdsList() + readable.setReferencedMap() + readable.setChangeFileSet() + readable.setSemanticDiagnostics() + readable.setEmitDiagnostics() + readable.setAffectedFilesPendingEmit() + readable.setEmitSignatures() + contents, err := json.MarshalIndent(&readable, "", " ") + if err != nil { + panic("readableBuildInfo: failed to marshal readable build info: " + err.Error()) + } + return string(contents) +} + +func (r *readableBuildInfo) toFilePath(fileId incremental.BuildInfoFileId) string { + return r.buildInfo.FileNames[fileId-1] +} + +func (r *readableBuildInfo) toFilePathSet(fileIdListId incremental.BuildInfoFileIdListId) []string { + return r.FileIdsList[fileIdListId-1] +} + +func (r *readableBuildInfo) toReadableBuildInfoDiagnostic(diagnostics []*incremental.BuildInfoDiagnostic) []*readableBuildInfoDiagnostic { + return core.Map(diagnostics, func(d *incremental.BuildInfoDiagnostic) *readableBuildInfoDiagnostic { + var file string + if d.File != 0 { + file = r.toFilePath(d.File) + } + return &readableBuildInfoDiagnostic{ + File: file, + NoFile: d.NoFile, + Pos: d.Pos, + End: d.End, + Code: d.Code, + Category: d.Category, + Message: d.Message, + MessageChain: r.toReadableBuildInfoDiagnostic(d.MessageChain), + RelatedInformation: r.toReadableBuildInfoDiagnostic(d.RelatedInformation), + ReportsUnnecessary: d.ReportsUnnecessary, + ReportsDeprecated: d.ReportsDeprecated, + SkippedOnNoEmit: d.SkippedOnNoEmit, + } + }) +} + +func (r *readableBuildInfo) toReadableBuildInfoDiagnosticsOfFile(diagnostics *incremental.BuildInfoDiagnosticsOfFile) *readableBuildInfoDiagnosticsOfFile { + return &readableBuildInfoDiagnosticsOfFile{ + file: r.toFilePath(diagnostics.FileId), + diagnostics: r.toReadableBuildInfoDiagnostic(diagnostics.Diagnostics), + } +} + +func (r *readableBuildInfo) setFileInfos() { + r.FileInfos = core.MapIndex(r.buildInfo.FileInfos, func(original *incremental.BuildInfoFileInfo, index int) *readableBuildInfoFileInfo { + fileInfo := original.GetFileInfo() + // Dont set original for string encoding + if original.HasSignature() { + original = nil + } + return &readableBuildInfoFileInfo{ + FileName: r.toFilePath(incremental.BuildInfoFileId(index + 1)), + Version: fileInfo.Version(), + Signature: fileInfo.Signature(), + AffectsGlobalScope: fileInfo.AffectsGlobalScope(), + ImpliedNodeFormat: fileInfo.ImpliedNodeFormat().String(), + Original: original, + } + }) +} + +func (r *readableBuildInfo) setFileIdsList() { + r.FileIdsList = core.Map(r.buildInfo.FileIdsList, func(ids []incremental.BuildInfoFileId) []string { + return core.Map(ids, r.toFilePath) + }) +} + +func (r *readableBuildInfo) setReferencedMap() { + if r.buildInfo.ReferencedMap != nil { + r.ReferencedMap = &collections.OrderedMap[string, []string]{} + for _, entry := range r.buildInfo.ReferencedMap { + r.ReferencedMap.Set(r.toFilePath(entry.FileId), r.toFilePathSet(entry.FileIdListId)) + } + } +} + +func (r *readableBuildInfo) setChangeFileSet() { + r.ChangeFileSet = core.Map(r.buildInfo.ChangeFileSet, r.toFilePath) +} + +func (r *readableBuildInfo) setSemanticDiagnostics() { + r.SemanticDiagnosticsPerFile = core.Map(r.buildInfo.SemanticDiagnosticsPerFile, func(diagnostics *incremental.BuildInfoSemanticDiagnostic) *readableBuildInfoSemanticDiagnostic { + if diagnostics.FileId != 0 { + return &readableBuildInfoSemanticDiagnostic{ + file: r.toFilePath(diagnostics.FileId), + } + } + return &readableBuildInfoSemanticDiagnostic{ + diagnostics: r.toReadableBuildInfoDiagnosticsOfFile(diagnostics.Diagnostics), + } + }) +} + +func (r *readableBuildInfo) setEmitDiagnostics() { + r.EmitDiagnosticsPerFile = core.Map(r.buildInfo.EmitDiagnosticsPerFile, r.toReadableBuildInfoDiagnosticsOfFile) +} + +func (r *readableBuildInfo) setAffectedFilesPendingEmit() { + if r.buildInfo.AffectedFilesPendingEmit == nil { + return + } + fullEmitKind := incremental.GetFileEmitKind(r.buildInfo.GetCompilerOptions("")) + r.AffectedFilesPendingEmit = core.Map(r.buildInfo.AffectedFilesPendingEmit, func(pendingEmit *incremental.BuildInfoFilePendingEmit) *readableBuildInfoFilePendingEmit { + emitKind := core.IfElse(pendingEmit.EmitKind == 0, fullEmitKind, pendingEmit.EmitKind) + return &readableBuildInfoFilePendingEmit{ + file: r.toFilePath(pendingEmit.FileId), + emitKind: toReadableFileEmitKind(emitKind), + original: pendingEmit, + } + }) +} + +func toReadableFileEmitKind(fileEmitKind incremental.FileEmitKind) string { + var builder strings.Builder + addFlags := func(flags string) { + if builder.Len() == 0 { + builder.WriteString(flags) + } else { + builder.WriteString("|") + builder.WriteString(flags) + } + } + if fileEmitKind != 0 { + if (fileEmitKind & incremental.FileEmitKindJs) != 0 { + addFlags("Js") + } + if (fileEmitKind & incremental.FileEmitKindJsMap) != 0 { + addFlags("JsMap") + } + if (fileEmitKind & incremental.FileEmitKindJsInlineMap) != 0 { + addFlags("JsInlineMap") + } + if (fileEmitKind & incremental.FileEmitKindDts) == incremental.FileEmitKindDts { + addFlags("Dts") + } else { + if (fileEmitKind & incremental.FileEmitKindDtsEmit) != 0 { + addFlags("DtsEmit") + } + if (fileEmitKind & incremental.FileEmitKindDtsErrors) != 0 { + addFlags("DtsErrors") + } + } + if (fileEmitKind & incremental.FileEmitKindDtsMap) != 0 { + addFlags("DtsMap") + } + } + if builder.Len() != 0 { + return builder.String() + } + return "None" +} + +func (r *readableBuildInfo) setEmitSignatures() { + r.EmitSignatures = core.Map(r.buildInfo.EmitSignatures, func(signature *incremental.BuildInfoEmitSignature) *readableBuildInfoEmitSignature { + return &readableBuildInfoEmitSignature{ + File: r.toFilePath(signature.FileId), + Signature: signature.Signature, + DiffersOnlyInDtsMap: signature.DiffersOnlyInDtsMap, + DiffersInOptions: signature.DiffersInOptions, + Original: signature, + } + }) +} diff --git a/internal/testutil/stringtestutil/stringtestutil.go b/internal/testutil/stringtestutil/stringtestutil.go new file mode 100644 index 0000000000..80db676be1 --- /dev/null +++ b/internal/testutil/stringtestutil/stringtestutil.go @@ -0,0 +1,43 @@ +package stringtestutil + +import ( + "strings" + + "github.com/microsoft/typescript-go/internal/stringutil" +) + +func Dedent(text string) string { + lines := strings.Split(text, "\n") + // Remove blank lines in the beginning and end + // and convert all tabs in the beginning of line to spaces + startLine := -1 + lastLine := 0 + for i, line := range lines { + firstNonTab := strings.IndexFunc(line, func(r rune) bool { + return r != '\t' + }) + if firstNonTab > 0 { + line = strings.Repeat(" ", firstNonTab) + line[firstNonTab:] + lines[i] = line + } + line = strings.TrimSpace(line) + if line != "" { + if startLine == -1 { + startLine = i + } + lastLine = i + } + } + lines = lines[startLine : lastLine+1] + indentation := stringutil.GuessIndentation(lines) + if indentation > 0 { + for i := range lines { + if len(lines[i]) > indentation { + lines[i] = lines[i][indentation:] + } else { + lines[i] = "" + } + } + } + return strings.Join(lines, "\n") +} diff --git a/internal/tsoptions/commandlineoption.go b/internal/tsoptions/commandlineoption.go index 3997c0aebe..35b7541031 100644 --- a/internal/tsoptions/commandlineoption.go +++ b/internal/tsoptions/commandlineoption.go @@ -23,7 +23,7 @@ type CommandLineOption struct { Kind CommandLineOptionKind // used in parsing - isFilePath bool + IsFilePath bool IsTSConfigOnly bool IsCommandLineOnly bool @@ -62,7 +62,7 @@ type CommandLineOption struct { // used for CommandLineOptionTypeList listPreserveFalsyValues bool // used for compilerOptionsDeclaration - ElementOptions map[string]*CommandLineOption + ElementOptions CommandLineOptionNameMap } func (o *CommandLineOption) DeprecatedKeys() *collections.Set[string] { @@ -100,12 +100,12 @@ var commandLineOptionElements = map[string]*CommandLineOption{ "rootDirs": { Name: "rootDirs", Kind: CommandLineOptionTypeString, - isFilePath: true, + IsFilePath: true, }, "typeRoots": { Name: "typeRoots", Kind: CommandLineOptionTypeString, - isFilePath: true, + IsFilePath: true, }, "types": { Name: "types", @@ -148,13 +148,13 @@ var commandLineOptionElements = map[string]*CommandLineOption{ "excludeDirectories": { Name: "excludeDirectory", Kind: CommandLineOptionTypeString, - isFilePath: true, + IsFilePath: true, extraValidation: true, }, "excludeFiles": { Name: "excludeFile", Kind: CommandLineOptionTypeString, - isFilePath: true, + IsFilePath: true, extraValidation: true, }, // Test infra options diff --git a/internal/tsoptions/commandlineparser.go b/internal/tsoptions/commandlineparser.go index e7dc88696b..4064cad038 100644 --- a/internal/tsoptions/commandlineparser.go +++ b/internal/tsoptions/commandlineparser.go @@ -46,7 +46,7 @@ func ParseCommandLine( commandLine = []string{} } parser := parseCommandLineWorker(CompilerOptionsDidYouMeanDiagnostics, commandLine, host.FS()) - optionsWithAbsolutePaths := convertToOptionsWithAbsolutePaths(parser.options, commandLineCompilerOptionsMap, host.GetCurrentDirectory()) + optionsWithAbsolutePaths := convertToOptionsWithAbsolutePaths(parser.options, CommandLineCompilerOptionsMap, host.GetCurrentDirectory()) compilerOptions := convertMapToOptions(optionsWithAbsolutePaths, &compilerOptionsParser{&core.CompilerOptions{}}).CompilerOptions watchOptions := convertMapToOptions(optionsWithAbsolutePaths, &watchOptionsParser{&core.WatchOptions{}}).WatchOptions return &ParsedCommandLine{ diff --git a/internal/tsoptions/declscompiler.go b/internal/tsoptions/declscompiler.go index c378ad896a..818abd75e4 100644 --- a/internal/tsoptions/declscompiler.go +++ b/internal/tsoptions/declscompiler.go @@ -1,6 +1,7 @@ package tsoptions import ( + "reflect" "slices" "github.com/microsoft/typescript-go/internal/core" @@ -100,7 +101,7 @@ var optionsForCompiler = []*CommandLineOption{ { Name: "generateCpuProfile", Kind: CommandLineOptionTypeString, - isFilePath: true, + IsFilePath: true, Category: diagnostics.Compiler_Diagnostics, Description: diagnostics.Emit_a_v8_CPU_profile_of_the_compiler_run_for_debugging, DefaultValueDescription: "profile.cpuprofile", @@ -109,7 +110,7 @@ var optionsForCompiler = []*CommandLineOption{ { Name: "generateTrace", Kind: CommandLineOptionTypeString, - isFilePath: true, + IsFilePath: true, Category: diagnostics.Compiler_Diagnostics, Description: diagnostics.Generates_an_event_trace_and_a_list_of_types, }, @@ -228,7 +229,7 @@ var optionsForCompiler = []*CommandLineOption{ { Name: "pprofDir", Kind: CommandLineOptionTypeString, - isFilePath: true, + IsFilePath: true, Category: diagnostics.Command_line_Options, Description: diagnostics.Generate_pprof_CPU_Slashmemory_profiles_to_the_given_directory, }, @@ -267,7 +268,7 @@ var commonOptionsWithBuild = []*CommandLineOption{ Name: "project", ShortName: "p", Kind: CommandLineOptionTypeString, - isFilePath: true, + IsFilePath: true, ShowInSimplifiedHelpView: true, Category: diagnostics.Command_line_Options, Description: diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, @@ -376,7 +377,7 @@ var commonOptionsWithBuild = []*CommandLineOption{ AffectsEmit: true, AffectsBuildInfo: true, AffectsDeclarationPath: true, - isFilePath: true, + IsFilePath: true, ShowInSimplifiedHelpView: true, Category: diagnostics.Emit, Description: diagnostics.Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designates_a_file_that_bundles_all_d_ts_output, @@ -388,7 +389,7 @@ var commonOptionsWithBuild = []*CommandLineOption{ AffectsEmit: true, AffectsBuildInfo: true, AffectsDeclarationPath: true, - isFilePath: true, + IsFilePath: true, ShowInSimplifiedHelpView: true, Category: diagnostics.Emit, Description: diagnostics.Specify_an_output_folder_for_all_emitted_files, @@ -399,7 +400,7 @@ var commonOptionsWithBuild = []*CommandLineOption{ AffectsEmit: true, AffectsBuildInfo: true, AffectsDeclarationPath: true, - isFilePath: true, + IsFilePath: true, Category: diagnostics.Modules, Description: diagnostics.Specify_the_root_folder_within_your_source_files, DefaultValueDescription: diagnostics.Computed_from_the_list_of_input_files, @@ -420,7 +421,7 @@ var commonOptionsWithBuild = []*CommandLineOption{ Kind: CommandLineOptionTypeString, AffectsEmit: true, AffectsBuildInfo: true, - isFilePath: true, + IsFilePath: true, Category: diagnostics.Projects, transpileOptionValue: core.TSUnknown, DefaultValueDescription: ".tsbuildinfo", @@ -704,7 +705,7 @@ var commonOptionsWithBuild = []*CommandLineOption{ Name: "baseUrl", Kind: CommandLineOptionTypeString, AffectsModuleResolution: true, - isFilePath: true, + IsFilePath: true, Category: diagnostics.Modules, Description: diagnostics.Specify_the_base_directory_to_resolve_non_relative_module_names, }, @@ -945,7 +946,7 @@ var commonOptionsWithBuild = []*CommandLineOption{ AffectsEmit: true, AffectsBuildInfo: true, AffectsDeclarationPath: true, - isFilePath: false, // This is intentionally broken to support compatibility with existing tsconfig files + IsFilePath: false, // This is intentionally broken to support compatibility with existing tsconfig files // for correct behaviour, please use outFile Category: diagnostics.Backwards_Compatibility, transpileOptionValue: core.TSUnknown, @@ -1109,7 +1110,7 @@ var commonOptionsWithBuild = []*CommandLineOption{ AffectsEmit: true, AffectsBuildInfo: true, AffectsDeclarationPath: true, - isFilePath: true, + IsFilePath: true, Category: diagnostics.Emit, transpileOptionValue: core.TSUnknown, Description: diagnostics.Specify_the_output_directory_for_generated_declaration_files, @@ -1236,3 +1237,58 @@ var commonOptionsWithBuild = []*CommandLineOption{ DefaultValueDescription: core.TSUnknown, }, } + +var optionsType = reflect.TypeFor[core.CompilerOptions]() + +func optionsHaveChanges(oldOptions *core.CompilerOptions, newOptions *core.CompilerOptions, declFilter func(*CommandLineOption) bool) bool { + if oldOptions == newOptions { + return false + } + if oldOptions == nil || newOptions == nil { + return true + } + oldOptionsValue := reflect.ValueOf(oldOptions).Elem() + return ForEachCompilerOptionValue(newOptions, declFilter, func(option *CommandLineOption, value reflect.Value, i int) bool { + return !reflect.DeepEqual(value.Interface(), oldOptionsValue.Field(i).Interface()) + }) +} + +func ForEachCompilerOptionValue(options *core.CompilerOptions, declFilter func(*CommandLineOption) bool, fn func(option *CommandLineOption, value reflect.Value, i int) bool) bool { + optionsValue := reflect.ValueOf(options).Elem() + for i := range optionsValue.NumField() { + field := optionsType.Field(i) + if !field.IsExported() { + continue + } + if optionDeclaration := CommandLineCompilerOptionsMap.Get(field.Name); optionDeclaration != nil && declFilter(optionDeclaration) { + if fn(optionDeclaration, optionsValue.Field(i), i) { + return true + } + } + } + return false +} + +func CompilerOptionsAffectSemanticDiagnostics( + oldOptions *core.CompilerOptions, + newOptions *core.CompilerOptions, +) bool { + return optionsHaveChanges(oldOptions, newOptions, func(option *CommandLineOption) bool { + return option.AffectsSemanticDiagnostics + }) +} + +func CompilerOptionsAffectDeclarationPath( + oldOptions *core.CompilerOptions, + newOptions *core.CompilerOptions, +) bool { + return optionsHaveChanges(oldOptions, newOptions, func(option *CommandLineOption) bool { + return option.AffectsDeclarationPath + }) +} + +func CompilerOptionsAffectEmit(oldOptions *core.CompilerOptions, newOptions *core.CompilerOptions) bool { + return optionsHaveChanges(oldOptions, newOptions, func(option *CommandLineOption) bool { + return option.AffectsEmit + }) +} diff --git a/internal/tsoptions/enummaps.go b/internal/tsoptions/enummaps.go index 3c16cfad03..977ee9ef33 100644 --- a/internal/tsoptions/enummaps.go +++ b/internal/tsoptions/enummaps.go @@ -206,6 +206,11 @@ var targetToLibMap = map[core.ScriptTarget]string{ core.ScriptTargetES2015: "lib.es6.d.ts", // We don't use lib.es2015.full.d.ts due to breaking change. } +// Used for test to add the files +func TargetToLibMap() map[core.ScriptTarget]string { + return targetToLibMap +} + func GetDefaultLibFileName(options *core.CompilerOptions) string { name, ok := targetToLibMap[options.GetEmitScriptTarget()] if !ok { diff --git a/internal/tsoptions/parsinghelpers.go b/internal/tsoptions/parsinghelpers.go index 6f4dd7466e..c827978a95 100644 --- a/internal/tsoptions/parsinghelpers.go +++ b/internal/tsoptions/parsinghelpers.go @@ -168,6 +168,10 @@ func ParseCompilerOptions(key string, value any, allOptions *core.CompilerOption } func parseCompilerOptions(key string, value any, allOptions *core.CompilerOptions) (foundKey bool) { + option := CommandLineCompilerOptionsMap.Get(key) + if option != nil { + key = option.Name + } switch key { case "allowJs": allOptions.AllowJs = parseTristate(value) @@ -258,7 +262,7 @@ func parseCompilerOptions(key string, value any, allOptions *core.CompilerOption case "isolatedDeclarations": allOptions.IsolatedDeclarations = parseTristate(value) case "jsx": - allOptions.Jsx = value.(core.JsxEmit) + allOptions.Jsx = floatOrInt32ToFlag[core.JsxEmit](value) case "jsxFactory": allOptions.JsxFactory = parseString(value) case "jsxFragmentFactory": @@ -286,15 +290,15 @@ func parseCompilerOptions(key string, value any, allOptions *core.CompilerOption case "mapRoot": allOptions.MapRoot = parseString(value) case "module": - allOptions.Module = value.(core.ModuleKind) + allOptions.Module = floatOrInt32ToFlag[core.ModuleKind](value) case "moduleDetectionKind": - allOptions.ModuleDetection = value.(core.ModuleDetectionKind) + allOptions.ModuleDetection = floatOrInt32ToFlag[core.ModuleDetectionKind](value) case "moduleResolution": - allOptions.ModuleResolution = value.(core.ModuleResolutionKind) + allOptions.ModuleResolution = floatOrInt32ToFlag[core.ModuleResolutionKind](value) case "moduleSuffixes": allOptions.ModuleSuffixes = parseStringArray(value) case "moduleDetection": - allOptions.ModuleDetection = value.(core.ModuleDetectionKind) + allOptions.ModuleDetection = floatOrInt32ToFlag[core.ModuleDetectionKind](value) case "noCheck": allOptions.NoCheck = parseTristate(value) case "noFallthroughCasesInSwitch": @@ -384,7 +388,7 @@ func parseCompilerOptions(key string, value any, allOptions *core.CompilerOption case "suppressOutputPathCheck": allOptions.SuppressOutputPathCheck = parseTristate(value) case "target": - allOptions.Target = value.(core.ScriptTarget) + allOptions.Target = floatOrInt32ToFlag[core.ScriptTarget](value) case "traceResolution": allOptions.TraceResolution = parseTristate(value) case "tsBuildInfoFile": @@ -424,7 +428,7 @@ func parseCompilerOptions(key string, value any, allOptions *core.CompilerOption case "outDir": allOptions.OutDir = parseString(value) case "newLine": - allOptions.NewLine = value.(core.NewLineKind) + allOptions.NewLine = floatOrInt32ToFlag[core.NewLineKind](value) case "watch": allOptions.Watch = parseTristate(value) case "pprofDir": @@ -440,6 +444,13 @@ func parseCompilerOptions(key string, value any, allOptions *core.CompilerOption return true } +func floatOrInt32ToFlag[T ~int32](value any) T { + if v, ok := value.(T); ok { + return v + } + return T(value.(float64)) +} + func ParseWatchOptions(key string, value any, allOptions *core.WatchOptions) []*ast.Diagnostic { if allOptions == nil { return nil @@ -540,26 +551,34 @@ func mergeCompilerOptions(targetOptions, sourceOptions *core.CompilerOptions, ra return targetOptions } -func convertToOptionsWithAbsolutePaths(optionsBase *collections.OrderedMap[string, any], optionMap map[string]*CommandLineOption, cwd string) *collections.OrderedMap[string, any] { +func convertToOptionsWithAbsolutePaths(optionsBase *collections.OrderedMap[string, any], optionMap CommandLineOptionNameMap, cwd string) *collections.OrderedMap[string, any] { // !!! convert to options with absolute paths was previously done with `CompilerOptions` object, but for ease of implementation, we do it pre-conversion. // !!! Revisit this choice if/when refactoring when conversion is done in tsconfig parsing if optionsBase == nil { return nil } for o, v := range optionsBase.Entries() { - option := optionMap[o] - if option == nil || !option.isFilePath { - continue - } - if option.Kind == "list" { - if arr, ok := v.([]string); ok { - optionsBase.Set(o, core.Map(arr, func(item string) string { - return tspath.GetNormalizedAbsolutePath(item, cwd) - })) - } - } else { - optionsBase.Set(o, tspath.GetNormalizedAbsolutePath(v.(string), cwd)) + result, ok := ConvertOptionToAbsolutePath(o, v, optionMap, cwd) + if ok { + optionsBase.Set(o, result) } } return optionsBase } + +func ConvertOptionToAbsolutePath(o string, v any, optionMap CommandLineOptionNameMap, cwd string) (any, bool) { + option := optionMap.Get(o) + if option == nil || !option.IsFilePath { + return nil, false + } + if option.Kind == "list" { + if arr, ok := v.([]string); ok { + return core.Map(arr, func(item string) string { + return tspath.GetNormalizedAbsolutePath(item, cwd) + }), true + } + } else { + return tspath.GetNormalizedAbsolutePath(v.(string), cwd), true + } + return nil, false +} diff --git a/internal/tsoptions/tsconfigparsing.go b/internal/tsoptions/tsconfigparsing.go index 5204f58e80..ca1f87b18d 100644 --- a/internal/tsoptions/tsconfigparsing.go +++ b/internal/tsoptions/tsconfigparsing.go @@ -34,7 +34,7 @@ type extendsResult struct { var compilerOptionsDeclaration = &CommandLineOption{ Name: "compilerOptions", Kind: CommandLineOptionTypeObject, - ElementOptions: commandLineCompilerOptionsMap, + ElementOptions: CommandLineCompilerOptionsMap, } var compileOnSaveCommandLineOption = &CommandLineOption{ @@ -47,9 +47,9 @@ var extendsOptionDeclaration = &CommandLineOption{ Name: "extends", Kind: CommandLineOptionTypeListOrElement, Category: diagnostics.File_Management, - ElementOptions: map[string]*CommandLineOption{ - "extends": {Name: "extends", Kind: CommandLineOptionTypeString}, - }, + ElementOptions: commandLineOptionsToMap([]*CommandLineOption{ + {Name: "extends", Kind: CommandLineOptionTypeString}, + }), } var tsconfigRootOptionsMap = &CommandLineOption{ @@ -391,7 +391,7 @@ func startsWithConfigDirTemplate(value any) bool { } func normalizeNonListOptionValue(option *CommandLineOption, basePath string, value any) any { - if option.isFilePath { + if option.IsFilePath { value = tspath.NormalizeSlashes(value.(string)) if !startsWithConfigDirTemplate(value) { value = tspath.GetNormalizedAbsolutePath(value.(string), basePath) @@ -535,15 +535,26 @@ type tsConfigOptions struct { notDefined string } -func commandLineOptionsToMap(compilerOptions []*CommandLineOption) map[string]*CommandLineOption { - result := make(map[string]*CommandLineOption) +type CommandLineOptionNameMap map[string]*CommandLineOption + +func (m CommandLineOptionNameMap) Get(name string) *CommandLineOption { + opt, ok := m[name] + if !ok { + opt, _ = m[strings.ToLower(name)] + } + return opt +} + +func commandLineOptionsToMap(compilerOptions []*CommandLineOption) CommandLineOptionNameMap { + result := make(map[string]*CommandLineOption, len(compilerOptions)*2) for i := range compilerOptions { - result[(compilerOptions[i]).Name] = compilerOptions[i] + result[compilerOptions[i].Name] = compilerOptions[i] + result[strings.ToLower(compilerOptions[i].Name)] = compilerOptions[i] } return result } -var commandLineCompilerOptionsMap map[string]*CommandLineOption = commandLineOptionsToMap(OptionsDeclarations) +var CommandLineCompilerOptionsMap CommandLineOptionNameMap = commandLineOptionsToMap(OptionsDeclarations) func convertMapToOptions[O optionParser](compilerOptions *collections.OrderedMap[string, any], result O) O { // this assumes any `key`, `value` pair in `options` will have `value` already be the correct type. this function should no error handling @@ -553,7 +564,7 @@ func convertMapToOptions[O optionParser](compilerOptions *collections.OrderedMap return result } -func convertOptionsFromJson[O optionParser](optionsNameMap map[string]*CommandLineOption, jsonOptions any, basePath string, result O) (O, []*ast.Diagnostic) { +func convertOptionsFromJson[O optionParser](optionsNameMap CommandLineOptionNameMap, jsonOptions any, basePath string, result O) (O, []*ast.Diagnostic) { if jsonOptions == nil { return result, nil } @@ -564,8 +575,8 @@ func convertOptionsFromJson[O optionParser](optionsNameMap map[string]*CommandLi } var errors []*ast.Diagnostic for key, value := range jsonMap.Entries() { - opt, ok := optionsNameMap[key] - if !ok { + opt := optionsNameMap.Get(key) + if opt == nil { // !!! TODO?: support suggestion errors = append(errors, createUnknownOptionError(key, result.UnknownOptionDiagnostic(), "", nil, nil, nil)) continue @@ -698,7 +709,7 @@ func convertObjectLiteralExpressionToJson( keyText := textOfKey var option *CommandLineOption = nil if keyText != "" && objectOption != nil && objectOption.ElementOptions != nil { - option = objectOption.ElementOptions[keyText] + option = objectOption.ElementOptions.Get(keyText) } value, err := convertPropertyValueToJson(sourceFile, element.AsPropertyAssignment().Initializer, option, returnValue, jsonConversionNotifier) errors = append(errors, err...) @@ -836,7 +847,7 @@ func getDefaultTypeAcquisition(configFileName string) *core.TypeAcquisition { func convertCompilerOptionsFromJsonWorker(jsonOptions any, basePath string, configFileName string) (*core.CompilerOptions, []*ast.Diagnostic) { options := getDefaultCompilerOptions(configFileName) - _, errors := convertOptionsFromJson(commandLineCompilerOptionsMap, jsonOptions, basePath, &compilerOptionsParser{options}) + _, errors := convertOptionsFromJson(CommandLineCompilerOptionsMap, jsonOptions, basePath, &compilerOptionsParser{options}) if configFileName != "" { options.ConfigFilePath = tspath.NormalizeSlashes(configFileName) } diff --git a/testdata/baselines/reference/submodule/compiler/es5-commonjs8.errors.txt b/testdata/baselines/reference/submodule/compiler/es5-commonjs8.errors.txt deleted file mode 100644 index 1d0e812db4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es5-commonjs8.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -es5-commonjs8.ts(2,12): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. - - -==== es5-commonjs8.ts (1 errors) ==== - export default "test"; - export var __esModule = 1; - ~~~~~~~~~~ -!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es5-commonjs8.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es5-commonjs8.errors.txt.diff deleted file mode 100644 index 6df1127517..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es5-commonjs8.errors.txt.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.es5-commonjs8.errors.txt -+++ new.es5-commonjs8.errors.txt -@@= skipped -0, +0 lines =@@ -- -+es5-commonjs8.ts(2,12): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. -+ -+ -+==== es5-commonjs8.ts (1 errors) ==== -+ export default "test"; -+ export var __esModule = 1; -+ ~~~~~~~~~~ -+!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/isolatedModulesNoEmitOnError.js b/testdata/baselines/reference/submodule/compiler/isolatedModulesNoEmitOnError.js index 525567b2a5..80851e5cff 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedModulesNoEmitOnError.js +++ b/testdata/baselines/reference/submodule/compiler/isolatedModulesNoEmitOnError.js @@ -3,5 +3,8 @@ //// [file1.ts] export const x: string = 3; + + +!!!! File file1.js missing from original emit, but present in noCheck emit //// [file1.js] export const x = 3; diff --git a/testdata/baselines/reference/submodule/compiler/isolatedModulesNoEmitOnError.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedModulesNoEmitOnError.js.diff deleted file mode 100644 index f033a66fa5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/isolatedModulesNoEmitOnError.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.isolatedModulesNoEmitOnError.js -+++ new.isolatedModulesNoEmitOnError.js -@@= skipped -2, +2 lines =@@ - //// [file1.ts] - export const x: string = 3; - -- -- --!!!! File file1.js missing from original emit, but present in noCheck emit - //// [file1.js] - export const x = 3; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/noEmitOnError.js b/testdata/baselines/reference/submodule/compiler/noEmitOnError.js index dbd430da6d..844d502f03 100644 --- a/testdata/baselines/reference/submodule/compiler/noEmitOnError.js +++ b/testdata/baselines/reference/submodule/compiler/noEmitOnError.js @@ -4,9 +4,14 @@ var x: number = ""; -//// [noEmitOnError.js] -var x = ""; -//# sourceMappingURL=noEmitOnError.js.map + +!!!! File noEmitOnError.d.ts missing from original emit, but present in noCheck emit //// [noEmitOnError.d.ts] declare var x: number; + + +!!!! File noEmitOnError.js missing from original emit, but present in noCheck emit +//// [noEmitOnError.js] +var x = ""; +//# sourceMappingURL=noEmitOnError.js.map \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/noEmitOnError.js.diff b/testdata/baselines/reference/submodule/compiler/noEmitOnError.js.diff deleted file mode 100644 index 5643c0234e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/noEmitOnError.js.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.noEmitOnError.js -+++ new.noEmitOnError.js -@@= skipped -3, +3 lines =@@ - var x: number = ""; - - -- -- --!!!! File noEmitOnError.d.ts missing from original emit, but present in noCheck emit --//// [noEmitOnError.d.ts] --declare var x: number; -- -- --!!!! File noEmitOnError.js missing from original emit, but present in noCheck emit - //// [noEmitOnError.js] - var x = ""; - //# sourceMappingURL=noEmitOnError.js.map -+ -+//// [noEmitOnError.d.ts] -+declare var x: number; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/shadowedReservedCompilerDeclarationsWithNoEmit.errors.txt b/testdata/baselines/reference/submodule/compiler/shadowedReservedCompilerDeclarationsWithNoEmit.errors.txt index e766c8e475..c3b0e5b0e9 100644 --- a/testdata/baselines/reference/submodule/compiler/shadowedReservedCompilerDeclarationsWithNoEmit.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/shadowedReservedCompilerDeclarationsWithNoEmit.errors.txt @@ -1,9 +1,7 @@ shadowedReservedCompilerDeclarationsWithNoEmit.ts(23,13): error TS1215: Invalid use of 'arguments'. Modules are automatically in strict mode. -shadowedReservedCompilerDeclarationsWithNoEmit.ts(44,5): error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. -shadowedReservedCompilerDeclarationsWithNoEmit.ts(47,5): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. -==== shadowedReservedCompilerDeclarationsWithNoEmit.ts (3 errors) ==== +==== shadowedReservedCompilerDeclarationsWithNoEmit.ts (1 errors) ==== // Shadowed captured this and super class Base { } class C extends Base { @@ -50,13 +48,9 @@ shadowedReservedCompilerDeclarationsWithNoEmit.ts(47,5): error TS2441: Duplicate // shadowed require var require = 0; - ~~~~~~~ -!!! error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. // shadowed exports var exports = 0; - ~~~~~~~ -!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. export { }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/shadowedReservedCompilerDeclarationsWithNoEmit.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/shadowedReservedCompilerDeclarationsWithNoEmit.errors.txt.diff deleted file mode 100644 index 214129fc4c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/shadowedReservedCompilerDeclarationsWithNoEmit.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.shadowedReservedCompilerDeclarationsWithNoEmit.errors.txt -+++ new.shadowedReservedCompilerDeclarationsWithNoEmit.errors.txt -@@= skipped -0, +0 lines =@@ - shadowedReservedCompilerDeclarationsWithNoEmit.ts(23,13): error TS1215: Invalid use of 'arguments'. Modules are automatically in strict mode. -- -- --==== shadowedReservedCompilerDeclarationsWithNoEmit.ts (1 errors) ==== -+shadowedReservedCompilerDeclarationsWithNoEmit.ts(44,5): error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. -+shadowedReservedCompilerDeclarationsWithNoEmit.ts(47,5): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. -+ -+ -+==== shadowedReservedCompilerDeclarationsWithNoEmit.ts (3 errors) ==== - // Shadowed captured this and super - class Base { } - class C extends Base { -@@= skipped -47, +49 lines =@@ - - // shadowed require - var require = 0; -+ ~~~~~~~ -+!!! error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. - - // shadowed exports - var exports = 0; -+ ~~~~~~~ -+!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. - - - export { }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/autoAccessor1(target=es5).js b/testdata/baselines/reference/submodule/conformance/autoAccessor1(target=es5).js index 7be10ab1fe..477576343d 100644 --- a/testdata/baselines/reference/submodule/conformance/autoAccessor1(target=es5).js +++ b/testdata/baselines/reference/submodule/conformance/autoAccessor1(target=es5).js @@ -9,6 +9,9 @@ class C1 { } + + +!!!! File autoAccessor1.js missing from original emit, but present in noCheck emit //// [autoAccessor1.js] class C1 { accessor a; diff --git a/testdata/baselines/reference/submodule/conformance/autoAccessor1(target=es5).js.diff b/testdata/baselines/reference/submodule/conformance/autoAccessor1(target=es5).js.diff index 85bece0ce9..854cb8158c 100644 --- a/testdata/baselines/reference/submodule/conformance/autoAccessor1(target=es5).js.diff +++ b/testdata/baselines/reference/submodule/conformance/autoAccessor1(target=es5).js.diff @@ -1,12 +1,8 @@ --- old.autoAccessor1(target=es5).js +++ new.autoAccessor1(target=es5).js -@@= skipped -8, +8 lines =@@ - } +@@= skipped -12, +12 lines =@@ - -- -- --!!!! File autoAccessor1.js missing from original emit, but present in noCheck emit + !!!! File autoAccessor1.js missing from original emit, but present in noCheck emit //// [autoAccessor1.js] -var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); diff --git a/testdata/baselines/reference/submodule/conformance/autoAccessor3(target=es5).js b/testdata/baselines/reference/submodule/conformance/autoAccessor3(target=es5).js index cb2e729e0d..c702a35eba 100644 --- a/testdata/baselines/reference/submodule/conformance/autoAccessor3(target=es5).js +++ b/testdata/baselines/reference/submodule/conformance/autoAccessor3(target=es5).js @@ -9,6 +9,9 @@ class C1 { } + + +!!!! File autoAccessor3.js missing from original emit, but present in noCheck emit //// [autoAccessor3.js] class C1 { accessor "w"; diff --git a/testdata/baselines/reference/submodule/conformance/autoAccessor3(target=es5).js.diff b/testdata/baselines/reference/submodule/conformance/autoAccessor3(target=es5).js.diff index cb69c9a637..c470bc2b27 100644 --- a/testdata/baselines/reference/submodule/conformance/autoAccessor3(target=es5).js.diff +++ b/testdata/baselines/reference/submodule/conformance/autoAccessor3(target=es5).js.diff @@ -1,12 +1,8 @@ --- old.autoAccessor3(target=es5).js +++ new.autoAccessor3(target=es5).js -@@= skipped -8, +8 lines =@@ - } +@@= skipped -12, +12 lines =@@ - -- -- --!!!! File autoAccessor3.js missing from original emit, but present in noCheck emit + !!!! File autoAccessor3.js missing from original emit, but present in noCheck emit //// [autoAccessor3.js] -var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); diff --git a/testdata/baselines/reference/submodule/conformance/autoAccessor4(target=es5).js b/testdata/baselines/reference/submodule/conformance/autoAccessor4(target=es5).js index 1e0ae8b496..7678436f1f 100644 --- a/testdata/baselines/reference/submodule/conformance/autoAccessor4(target=es5).js +++ b/testdata/baselines/reference/submodule/conformance/autoAccessor4(target=es5).js @@ -9,6 +9,9 @@ class C1 { } + + +!!!! File autoAccessor4.js missing from original emit, but present in noCheck emit //// [autoAccessor4.js] class C1 { accessor 0; diff --git a/testdata/baselines/reference/submodule/conformance/autoAccessor4(target=es5).js.diff b/testdata/baselines/reference/submodule/conformance/autoAccessor4(target=es5).js.diff index d5df0bdb3e..e68e9559aa 100644 --- a/testdata/baselines/reference/submodule/conformance/autoAccessor4(target=es5).js.diff +++ b/testdata/baselines/reference/submodule/conformance/autoAccessor4(target=es5).js.diff @@ -1,12 +1,8 @@ --- old.autoAccessor4(target=es5).js +++ new.autoAccessor4(target=es5).js -@@= skipped -8, +8 lines =@@ - } +@@= skipped -12, +12 lines =@@ - -- -- --!!!! File autoAccessor4.js missing from original emit, but present in noCheck emit + !!!! File autoAccessor4.js missing from original emit, but present in noCheck emit //// [autoAccessor4.js] -var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); diff --git a/testdata/baselines/reference/tsbuild/commandLine/when-build-not-first-argument.js b/testdata/baselines/reference/tsbuild/commandLine/when-build-not-first-argument.js new file mode 100644 index 0000000000..608553534e --- /dev/null +++ b/testdata/baselines/reference/tsbuild/commandLine/when-build-not-first-argument.js @@ -0,0 +1,9 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: + +tsgo --verbose --build +ExitStatus:: DiagnosticsPresent_OutputsSkipped +Output:: +error TS5093: Compiler option '--verbose' may only be used with '--build'. +error TS6369: Option '--build' must be the first command line argument. diff --git a/testdata/baselines/reference/tsc/commandLine/Parse---lib-option-with-file-name.js b/testdata/baselines/reference/tsc/commandLine/Parse---lib-option-with-file-name.js index 7bac418a03..b1eb1890c2 100644 --- a/testdata/baselines/reference/tsc/commandLine/Parse---lib-option-with-file-name.js +++ b/testdata/baselines/reference/tsc/commandLine/Parse---lib-option-with-file-name.js @@ -1,49 +1,39 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::--lib es6 first.ts -//// [/home/src/workspaces/project/first.ts] new file +Input:: +//// [/home/src/workspaces/project/first.ts] *new* export const Key = Symbol() -ExitStatus:: 0 - -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": { - "lib": [ - "lib.es2015.d.ts" - ] - }, - "watchOptions": { - "watchInterval": null, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [ - "first.ts" - ], - "projectReferences": null - }, - "configFile": null, - "errors": [], - "raw": { - "lib": [ - "lib.es2015.d.ts" - ] - }, - "compileOnSave": null -} +tsgo --lib es6 first.ts +ExitStatus:: Success Output:: -//// [/home/src/workspaces/project/first.js] new file +//// [/home/src/tslibs/TS/Lib/lib.es2015.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/first.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Key = void 0; exports.Key = Symbol(); -//// [/home/src/workspaces/project/first.ts] no change diff --git a/testdata/baselines/reference/tsc/commandLine/Parse--p-with-path-to-tsconfig-file.js b/testdata/baselines/reference/tsc/commandLine/Parse--p-with-path-to-tsconfig-file.js index 6b0b1cfb56..52684620e4 100644 --- a/testdata/baselines/reference/tsc/commandLine/Parse--p-with-path-to-tsconfig-file.js +++ b/testdata/baselines/reference/tsc/commandLine/Parse--p-with-path-to-tsconfig-file.js @@ -1,40 +1,40 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::-p /home/src/workspaces/project/tsconfig.json -//// [/home/src/workspaces/project/first.ts] new file +Input:: +//// [/home/src/workspaces/project/first.ts] *new* export const a = 1 -//// [/home/src/workspaces/project/tsconfig.json] new file -{ "compilerOptions": { "strict": true, "noEmit": true } } - -ExitStatus:: 0 - -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": { - "project": "/home/src/workspaces/project/tsconfig.json" - }, - "watchOptions": { - "watchInterval": null, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [], - "projectReferences": null - }, - "configFile": null, - "errors": [], - "raw": { - "project": "/home/src/workspaces/project/tsconfig.json" - }, - "compileOnSave": null +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "strict": true, + "noEmit": true + } } + +tsgo -p /home/src/workspaces/project/tsconfig.json +ExitStatus:: Success Output:: -//// [/home/src/workspaces/project/first.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] no change +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; diff --git a/testdata/baselines/reference/tsc/commandLine/Parse--p-with-path-to-tsconfig-folder.js b/testdata/baselines/reference/tsc/commandLine/Parse--p-with-path-to-tsconfig-folder.js index 989c52f54b..2a5fd6fe78 100644 --- a/testdata/baselines/reference/tsc/commandLine/Parse--p-with-path-to-tsconfig-folder.js +++ b/testdata/baselines/reference/tsc/commandLine/Parse--p-with-path-to-tsconfig-folder.js @@ -1,40 +1,40 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::-p /home/src/workspaces/project -//// [/home/src/workspaces/project/first.ts] new file +Input:: +//// [/home/src/workspaces/project/first.ts] *new* export const a = 1 -//// [/home/src/workspaces/project/tsconfig.json] new file -{ "compilerOptions": { "strict": true, "noEmit": true } } - -ExitStatus:: 0 - -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": { - "project": "/home/src/workspaces/project" - }, - "watchOptions": { - "watchInterval": null, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [], - "projectReferences": null - }, - "configFile": null, - "errors": [], - "raw": { - "project": "/home/src/workspaces/project" - }, - "compileOnSave": null +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "strict": true, + "noEmit": true + } } + +tsgo -p /home/src/workspaces/project +ExitStatus:: Success Output:: -//// [/home/src/workspaces/project/first.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] no change +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; diff --git a/testdata/baselines/reference/tsc/commandLine/Parse--p.js b/testdata/baselines/reference/tsc/commandLine/Parse--p.js index fbb2710c6e..9e5937f459 100644 --- a/testdata/baselines/reference/tsc/commandLine/Parse--p.js +++ b/testdata/baselines/reference/tsc/commandLine/Parse--p.js @@ -1,40 +1,40 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::-p . -//// [/home/src/workspaces/project/first.ts] new file +Input:: +//// [/home/src/workspaces/project/first.ts] *new* export const a = 1 -//// [/home/src/workspaces/project/tsconfig.json] new file -{ "compilerOptions": { "strict": true, "noEmit": true } } - -ExitStatus:: 0 - -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": { - "project": "/home/src/workspaces/project" - }, - "watchOptions": { - "watchInterval": null, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [], - "projectReferences": null - }, - "configFile": null, - "errors": [], - "raw": { - "project": "/home/src/workspaces/project" - }, - "compileOnSave": null +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "strict": true, + "noEmit": true + } } + +tsgo -p . +ExitStatus:: Success Output:: -//// [/home/src/workspaces/project/first.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] no change +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; diff --git a/testdata/baselines/reference/tsc/commandLine/Parse-enum-type-options.js b/testdata/baselines/reference/tsc/commandLine/Parse-enum-type-options.js index 40579d601f..b7c372258f 100644 --- a/testdata/baselines/reference/tsc/commandLine/Parse-enum-type-options.js +++ b/testdata/baselines/reference/tsc/commandLine/Parse-enum-type-options.js @@ -1,46 +1,31 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::--moduleResolution nodenext first.ts --module nodenext --target esnext --moduleDetection auto --jsx react --newLine crlf - -ExitStatus:: 0 +Input:: -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": { - "jsx": 3, - "module": 199, - "moduleResolution": 99, - "moduleDetection": 1, - "newLine": 1, - "target": 99 - }, - "watchOptions": { - "watchInterval": null, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [ - "first.ts" - ], - "projectReferences": null - }, - "configFile": null, - "errors": [], - "raw": { - "moduleResolution": 99, - "module": 199, - "target": 99, - "moduleDetection": 1, - "jsx": 3, - "newLine": 1 - }, - "compileOnSave": null -} +tsgo --moduleResolution nodenext first.ts --module nodenext --target esnext --moduleDetection auto --jsx react --newLine crlf +ExitStatus:: Success Output:: +//// [/home/src/tslibs/TS/Lib/lib.esnext.full.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; diff --git a/testdata/baselines/reference/tsc/commandLine/Parse-watch-interval-option.js b/testdata/baselines/reference/tsc/commandLine/Parse-watch-interval-option.js deleted file mode 100644 index edac2bb8e7..0000000000 --- a/testdata/baselines/reference/tsc/commandLine/Parse-watch-interval-option.js +++ /dev/null @@ -1,42 +0,0 @@ - -currentDirectory::/home/src/workspaces/project -useCaseSensitiveFileNames::true -Input::-w --watchInterval 1000 -//// [/home/src/workspaces/project/first.ts] new file -export const a = 1 -//// [/home/src/workspaces/project/tsconfig.json] new file -{ "compilerOptions": { "strict": true, "noEmit": true } } - -ExitStatus:: 0 - -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": { - "watch": true - }, - "watchOptions": { - "watchInterval": 1000, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [], - "projectReferences": null - }, - "configFile": null, - "errors": [], - "raw": { - "watch": true, - "watchInterval": 1000 - }, - "compileOnSave": null -} -Output:: -No output -//// [/home/src/workspaces/project/first.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] no change - diff --git a/testdata/baselines/reference/tsc/commandLine/Project-is-empty-string.js b/testdata/baselines/reference/tsc/commandLine/Project-is-empty-string.js index 4124c4aa4c..a7a5a65dce 100644 --- a/testdata/baselines/reference/tsc/commandLine/Project-is-empty-string.js +++ b/testdata/baselines/reference/tsc/commandLine/Project-is-empty-string.js @@ -1,36 +1,40 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true Input:: -//// [/home/src/workspaces/project/first.ts] new file +//// [/home/src/workspaces/project/first.ts] *new* export const a = 1 -//// [/home/src/workspaces/project/tsconfig.json] new file -{ "compilerOptions": { "strict": true, "noEmit": true } } - -ExitStatus:: 0 - -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": {}, - "watchOptions": { - "watchInterval": null, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [], - "projectReferences": null - }, - "configFile": null, - "errors": [], - "raw": {}, - "compileOnSave": null +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "strict": true, + "noEmit": true + } } + +tsgo +ExitStatus:: Success Output:: -//// [/home/src/workspaces/project/first.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] no change +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; diff --git a/testdata/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set.js b/testdata/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set.js index a71f17d969..d5682e767f 100644 --- a/testdata/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set.js +++ b/testdata/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set.js @@ -1,35 +1,13 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true Input:: -ExitStatus:: 1 - -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": {}, - "watchOptions": { - "watchInterval": null, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [], - "projectReferences": null - }, - "configFile": null, - "errors": [], - "raw": {}, - "compileOnSave": null -} +tsgo +ExitStatus:: DiagnosticsPresent_OutputsSkipped Output:: -Version 7.0.0-dev +Version FakeTSVersion -tsc: The TypeScript Compiler - Version 7.0.0-dev +tsc: The TypeScript Compiler - Version FakeTSVersion COMMON COMMANDS diff --git a/testdata/baselines/reference/tsc/commandLine/help-all.js b/testdata/baselines/reference/tsc/commandLine/help-all.js index fb8a975db6..ece14ddbf0 100644 --- a/testdata/baselines/reference/tsc/commandLine/help-all.js +++ b/testdata/baselines/reference/tsc/commandLine/help-all.js @@ -1,37 +1,9 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::--help --all - -ExitStatus:: 0 +Input:: -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": { - "help": true, - "all": true - }, - "watchOptions": { - "watchInterval": null, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [], - "projectReferences": null - }, - "configFile": null, - "errors": [], - "raw": { - "help": true, - "all": true - }, - "compileOnSave": null -} +tsgo --help --all +ExitStatus:: Success Output:: No output diff --git a/testdata/baselines/reference/tsc/commandLine/help.js b/testdata/baselines/reference/tsc/commandLine/help.js index 8e0c5470d3..3aa7b708d2 100644 --- a/testdata/baselines/reference/tsc/commandLine/help.js +++ b/testdata/baselines/reference/tsc/commandLine/help.js @@ -1,37 +1,11 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::--help - -ExitStatus:: 0 - -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": { - "help": true - }, - "watchOptions": { - "watchInterval": null, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [], - "projectReferences": null - }, - "configFile": null, - "errors": [], - "raw": { - "help": true - }, - "compileOnSave": null -} +Input:: + +tsgo --help +ExitStatus:: Success Output:: -tsc: The TypeScript Compiler - Version 7.0.0-dev +tsc: The TypeScript Compiler - Version FakeTSVersion COMMON COMMANDS diff --git a/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-cannot-provide-terminal-width.js b/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-cannot-provide-terminal-width.js index a71f17d969..d5682e767f 100644 --- a/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-cannot-provide-terminal-width.js +++ b/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-cannot-provide-terminal-width.js @@ -1,35 +1,13 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true Input:: -ExitStatus:: 1 - -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": {}, - "watchOptions": { - "watchInterval": null, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [], - "projectReferences": null - }, - "configFile": null, - "errors": [], - "raw": {}, - "compileOnSave": null -} +tsgo +ExitStatus:: DiagnosticsPresent_OutputsSkipped Output:: -Version 7.0.0-dev +Version FakeTSVersion -tsc: The TypeScript Compiler - Version 7.0.0-dev +tsc: The TypeScript Compiler - Version FakeTSVersion COMMON COMMANDS diff --git a/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js index a71f17d969..d5682e767f 100644 --- a/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js +++ b/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js @@ -1,35 +1,13 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true Input:: -ExitStatus:: 1 - -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": {}, - "watchOptions": { - "watchInterval": null, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [], - "projectReferences": null - }, - "configFile": null, - "errors": [], - "raw": {}, - "compileOnSave": null -} +tsgo +ExitStatus:: DiagnosticsPresent_OutputsSkipped Output:: -Version 7.0.0-dev +Version FakeTSVersion -tsc: The TypeScript Compiler - Version 7.0.0-dev +tsc: The TypeScript Compiler - Version FakeTSVersion COMMON COMMANDS diff --git a/testdata/baselines/reference/tsc/commandLine/when-build-not-first-argument.js b/testdata/baselines/reference/tsc/commandLine/when-build-not-first-argument.js deleted file mode 100644 index 59ece03c20..0000000000 --- a/testdata/baselines/reference/tsc/commandLine/when-build-not-first-argument.js +++ /dev/null @@ -1,34 +0,0 @@ - -currentDirectory::/home/src/workspaces/project -useCaseSensitiveFileNames::true -Input::--verbose --build - -ExitStatus:: 1 - -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": {}, - "watchOptions": { - "watchInterval": null, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [], - "projectReferences": null - }, - "configFile": null, - "errors": [ - {}, - {} - ], - "raw": {}, - "compileOnSave": null -} -Output:: -error TS5093: Compiler option '--verbose' may only be used with '--build'. -error TS6369: Option '--build' must be the first command line argument. diff --git a/testdata/baselines/reference/tsc/extends/configDir-template-showConfig.js b/testdata/baselines/reference/tsc/extends/configDir-template-showConfig.js index eb990ee303..b32d38fcc4 100644 --- a/testdata/baselines/reference/tsc/extends/configDir-template-showConfig.js +++ b/testdata/baselines/reference/tsc/extends/configDir-template-showConfig.js @@ -1,73 +1,55 @@ - currentDirectory::/home/src/projects/myproject useCaseSensitiveFileNames::true -Input::--showConfig -//// [/home/src/projects/configs/first/tsconfig.json] new file +Input:: +//// [/home/src/projects/configs/first/tsconfig.json] *new* { - "extends": "../second/tsconfig.json", - "include": ["${configDir}/src"], - "compilerOptions": { - "typeRoots": ["root1", "${configDir}/root2", "root3"], - "types": [], - }, + "extends": "../second/tsconfig.json", + "include": ["${configDir}/src"], + "compilerOptions": { + "typeRoots": ["root1", "${configDir}/root2", "root3"], + "types": [], + } } -//// [/home/src/projects/configs/second/tsconfig.json] new file +//// [/home/src/projects/configs/second/tsconfig.json] *new* { - "files": ["${configDir}/main.ts"], - "compilerOptions": { - "declarationDir": "${configDir}/decls", - "paths": { - "@myscope/*": ["${configDir}/types/*"], - "other/*": ["other/*"], - }, - "baseUrl": "${configDir}", - }, - "watchOptions": { - "excludeFiles": ["${configDir}/main.ts"], - }, + "files": ["${configDir}/main.ts"], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "paths": { + "@myscope/*": ["${configDir}/types/*"], + "other/*": ["other/*"], + }, + "baseUrl": "${configDir}", + }, + "watchOptions": { + "excludeFiles": ["${configDir}/main.ts"], + }, } -//// [/home/src/projects/myproject/main.ts] new file - - // some comment - export const y = 10; - import { x } from "@myscope/sometype"; - -//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] new file - - export const k = 10; - -//// [/home/src/projects/myproject/src/secondary.ts] new file - - // some comment - export const z = 10; - import { k } from "other/sometype2"; - -//// [/home/src/projects/myproject/tsconfig.json] new file +//// [/home/src/projects/myproject/main.ts] *new* +// some comment +export const y = 10; +import { x } from "@myscope/sometype"; +//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] *new* +export const k = 10; +//// [/home/src/projects/myproject/src/secondary.ts] *new* +// some comment +export const z = 10; +import { k } from "other/sometype2"; +//// [/home/src/projects/myproject/tsconfig.json] *new* { - "extends": "../configs/first/tsconfig.json", - "compilerOptions": { - "declaration": true, - "outDir": "outDir", - "traceResolution": true, - }, + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true, + }, } -//// [/home/src/projects/myproject/types/sometype.ts] new file - - export const x = 10; - +//// [/home/src/projects/myproject/types/sometype.ts] *new* +// some comment +export const x = 10; -ExitStatus:: 0 - -CompilerOptions::{ - "showConfig": true -} +tsgo --showConfig +ExitStatus:: Success Output:: No output -//// [/home/src/projects/configs/first/tsconfig.json] no change -//// [/home/src/projects/configs/second/tsconfig.json] no change -//// [/home/src/projects/myproject/main.ts] no change -//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] no change -//// [/home/src/projects/myproject/src/secondary.ts] no change -//// [/home/src/projects/myproject/tsconfig.json] no change -//// [/home/src/projects/myproject/types/sometype.ts] no change diff --git a/testdata/baselines/reference/tsc/extends/configDir-template-with-commandline.js b/testdata/baselines/reference/tsc/extends/configDir-template-with-commandline.js index 9b9bc68483..ba5b22a61c 100644 --- a/testdata/baselines/reference/tsc/extends/configDir-template-with-commandline.js +++ b/testdata/baselines/reference/tsc/extends/configDir-template-with-commandline.js @@ -1,112 +1,118 @@ - currentDirectory::/home/src/projects/myproject useCaseSensitiveFileNames::true -Input::--explainFiles --outDir ${configDir}/outDir -//// [/home/src/projects/configs/first/tsconfig.json] new file +Input:: +//// [/home/src/projects/configs/first/tsconfig.json] *new* { - "extends": "../second/tsconfig.json", - "include": ["${configDir}/src"], - "compilerOptions": { - "typeRoots": ["root1", "${configDir}/root2", "root3"], - "types": [], - }, + "extends": "../second/tsconfig.json", + "include": ["${configDir}/src"], + "compilerOptions": { + "typeRoots": ["root1", "${configDir}/root2", "root3"], + "types": [], + } } -//// [/home/src/projects/configs/second/tsconfig.json] new file +//// [/home/src/projects/configs/second/tsconfig.json] *new* { - "files": ["${configDir}/main.ts"], - "compilerOptions": { - "declarationDir": "${configDir}/decls", - "paths": { - "@myscope/*": ["${configDir}/types/*"], - "other/*": ["other/*"], - }, - "baseUrl": "${configDir}", - }, - "watchOptions": { - "excludeFiles": ["${configDir}/main.ts"], - }, + "files": ["${configDir}/main.ts"], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "paths": { + "@myscope/*": ["${configDir}/types/*"], + "other/*": ["other/*"], + }, + "baseUrl": "${configDir}", + }, + "watchOptions": { + "excludeFiles": ["${configDir}/main.ts"], + }, } -//// [/home/src/projects/myproject/main.ts] new file - - // some comment - export const y = 10; - import { x } from "@myscope/sometype"; - -//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] new file - - export const k = 10; - -//// [/home/src/projects/myproject/src/secondary.ts] new file - - // some comment - export const z = 10; - import { k } from "other/sometype2"; - -//// [/home/src/projects/myproject/tsconfig.json] new file +//// [/home/src/projects/myproject/main.ts] *new* +// some comment +export const y = 10; +import { x } from "@myscope/sometype"; +//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] *new* +export const k = 10; +//// [/home/src/projects/myproject/src/secondary.ts] *new* +// some comment +export const z = 10; +import { k } from "other/sometype2"; +//// [/home/src/projects/myproject/tsconfig.json] *new* { - "extends": "../configs/first/tsconfig.json", - "compilerOptions": { - "declaration": true, - "outDir": "outDir", - "traceResolution": true, - }, + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true, + }, } -//// [/home/src/projects/myproject/types/sometype.ts] new file - - export const x = 10; - - -ExitStatus:: 2 +//// [/home/src/projects/myproject/types/sometype.ts] *new* +// some comment +export const x = 10; -CompilerOptions::{ - "outDir": "/home/src/projects/myproject/${configDir}/outDir", - "explainFiles": true -} +tsgo --explainFiles --outDir ${configDir}/outDir +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: -src/secondary.ts:4:20 - error TS2307: Cannot find module 'other/sometype2' or its corresponding type declarations. +src/secondary.ts:3:19 - error TS2307: Cannot find module 'other/sometype2' or its corresponding type declarations. -4 import { k } from "other/sometype2"; -   ~~~~~~~~~~~~~~~~~ +3 import { k } from "other/sometype2"; +   ~~~~~~~~~~~~~~~~~ -Found 1 error in src/secondary.ts:4 +Found 1 error in src/secondary.ts:3 -//// [/home/src/projects/configs/first/tsconfig.json] no change -//// [/home/src/projects/configs/second/tsconfig.json] no change -//// [/home/src/projects/myproject/${configDir}/outDir/main.js] new file +//// [/home/src/projects/myproject/${configDir}/outDir/main.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.y = void 0; // some comment exports.y = 10; -//// [/home/src/projects/myproject/${configDir}/outDir/src/secondary.js] new file +//// [/home/src/projects/myproject/${configDir}/outDir/src/secondary.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.z = void 0; // some comment exports.z = 10; -//// [/home/src/projects/myproject/${configDir}/outDir/types/sometype.js] new file +//// [/home/src/projects/myproject/${configDir}/outDir/types/sometype.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.x = void 0; +// some comment exports.x = 10; -//// [/home/src/projects/myproject/decls/main.d.ts] new file +//// [/home/src/projects/myproject/decls/main.d.ts] *new* // some comment export declare const y = 10; -//// [/home/src/projects/myproject/decls/src/secondary.d.ts] new file +//// [/home/src/projects/myproject/decls/src/secondary.d.ts] *new* // some comment export declare const z = 10; -//// [/home/src/projects/myproject/decls/types/sometype.d.ts] new file +//// [/home/src/projects/myproject/decls/types/sometype.d.ts] *new* +// some comment export declare const x = 10; -//// [/home/src/projects/myproject/main.ts] no change -//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] no change -//// [/home/src/projects/myproject/src/secondary.ts] no change -//// [/home/src/projects/myproject/tsconfig.json] no change -//// [/home/src/projects/myproject/types/sometype.ts] no change +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; diff --git a/testdata/baselines/reference/tsc/extends/configDir-template.js b/testdata/baselines/reference/tsc/extends/configDir-template.js index b9bf5ed030..1e9821fe2b 100644 --- a/testdata/baselines/reference/tsc/extends/configDir-template.js +++ b/testdata/baselines/reference/tsc/extends/configDir-template.js @@ -1,111 +1,118 @@ - currentDirectory::/home/src/projects/myproject useCaseSensitiveFileNames::true -Input::--explainFiles -//// [/home/src/projects/configs/first/tsconfig.json] new file +Input:: +//// [/home/src/projects/configs/first/tsconfig.json] *new* { - "extends": "../second/tsconfig.json", - "include": ["${configDir}/src"], - "compilerOptions": { - "typeRoots": ["root1", "${configDir}/root2", "root3"], - "types": [], - }, + "extends": "../second/tsconfig.json", + "include": ["${configDir}/src"], + "compilerOptions": { + "typeRoots": ["root1", "${configDir}/root2", "root3"], + "types": [], + } } -//// [/home/src/projects/configs/second/tsconfig.json] new file +//// [/home/src/projects/configs/second/tsconfig.json] *new* { - "files": ["${configDir}/main.ts"], - "compilerOptions": { - "declarationDir": "${configDir}/decls", - "paths": { - "@myscope/*": ["${configDir}/types/*"], - "other/*": ["other/*"], - }, - "baseUrl": "${configDir}", - }, - "watchOptions": { - "excludeFiles": ["${configDir}/main.ts"], - }, + "files": ["${configDir}/main.ts"], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "paths": { + "@myscope/*": ["${configDir}/types/*"], + "other/*": ["other/*"], + }, + "baseUrl": "${configDir}", + }, + "watchOptions": { + "excludeFiles": ["${configDir}/main.ts"], + }, } -//// [/home/src/projects/myproject/main.ts] new file - - // some comment - export const y = 10; - import { x } from "@myscope/sometype"; - -//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] new file - - export const k = 10; - -//// [/home/src/projects/myproject/src/secondary.ts] new file - - // some comment - export const z = 10; - import { k } from "other/sometype2"; - -//// [/home/src/projects/myproject/tsconfig.json] new file +//// [/home/src/projects/myproject/main.ts] *new* +// some comment +export const y = 10; +import { x } from "@myscope/sometype"; +//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] *new* +export const k = 10; +//// [/home/src/projects/myproject/src/secondary.ts] *new* +// some comment +export const z = 10; +import { k } from "other/sometype2"; +//// [/home/src/projects/myproject/tsconfig.json] *new* { - "extends": "../configs/first/tsconfig.json", - "compilerOptions": { - "declaration": true, - "outDir": "outDir", - "traceResolution": true, - }, + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true, + }, } -//// [/home/src/projects/myproject/types/sometype.ts] new file - - export const x = 10; - - -ExitStatus:: 2 +//// [/home/src/projects/myproject/types/sometype.ts] *new* +// some comment +export const x = 10; -CompilerOptions::{ - "explainFiles": true -} +tsgo --explainFiles +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: -src/secondary.ts:4:20 - error TS2307: Cannot find module 'other/sometype2' or its corresponding type declarations. +src/secondary.ts:3:19 - error TS2307: Cannot find module 'other/sometype2' or its corresponding type declarations. -4 import { k } from "other/sometype2"; -   ~~~~~~~~~~~~~~~~~ +3 import { k } from "other/sometype2"; +   ~~~~~~~~~~~~~~~~~ -Found 1 error in src/secondary.ts:4 +Found 1 error in src/secondary.ts:3 -//// [/home/src/projects/configs/first/tsconfig.json] no change -//// [/home/src/projects/configs/second/tsconfig.json] no change -//// [/home/src/projects/myproject/decls/main.d.ts] new file +//// [/home/src/projects/myproject/decls/main.d.ts] *new* // some comment export declare const y = 10; -//// [/home/src/projects/myproject/decls/src/secondary.d.ts] new file +//// [/home/src/projects/myproject/decls/src/secondary.d.ts] *new* // some comment export declare const z = 10; -//// [/home/src/projects/myproject/decls/types/sometype.d.ts] new file +//// [/home/src/projects/myproject/decls/types/sometype.d.ts] *new* +// some comment export declare const x = 10; -//// [/home/src/projects/myproject/main.ts] no change -//// [/home/src/projects/myproject/outDir/main.js] new file +//// [/home/src/projects/myproject/outDir/main.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.y = void 0; // some comment exports.y = 10; -//// [/home/src/projects/myproject/outDir/src/secondary.js] new file +//// [/home/src/projects/myproject/outDir/src/secondary.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.z = void 0; // some comment exports.z = 10; -//// [/home/src/projects/myproject/outDir/types/sometype.js] new file +//// [/home/src/projects/myproject/outDir/types/sometype.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.x = void 0; +// some comment exports.x = 10; -//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] no change -//// [/home/src/projects/myproject/src/secondary.ts] no change -//// [/home/src/projects/myproject/tsconfig.json] no change -//// [/home/src/projects/myproject/types/sometype.ts] no change +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; diff --git a/testdata/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled.js b/testdata/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled.js new file mode 100644 index 0000000000..d443641a9e --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled.js @@ -0,0 +1,439 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *new* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +type ReturnType any> = T extends (...args: any) => infer R ? R : any; +type InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any; +//// [/home/src/workspaces/project/MessageablePerson.ts] *new* +const Messageable = () => { + return class MessageableClass { + public message = 'hello'; + } +}; +const wrapper = () => Messageable(); +type MessageablePerson = InstanceType>; +export default MessageablePerson; +//// [/home/src/workspaces/project/main.ts] *new* +import MessageablePerson from './MessageablePerson.js'; +function logMessage( person: MessageablePerson ) { + console.log( person.message ); +} +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "module": "esnext", + "declaration": true + } +} + +tsgo --incremental +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/MessageablePerson.d.ts] *new* +declare const wrapper: () => { + new (): { + message: string; + }; +}; +type MessageablePerson = InstanceType>; +export default MessageablePerson; + +//// [/home/src/workspaces/project/MessageablePerson.js] *new* +const Messageable = () => { + return class MessageableClass { + message = 'hello'; + }; +}; +const wrapper = () => Messageable(); +export {}; + +//// [/home/src/workspaces/project/main.d.ts] *new* +export {}; + +//// [/home/src/workspaces/project/main.js] *new* +function logMessage(person) { + console.log(person.message); +} +export {}; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./MessageablePerson.ts","./main.ts"],"fileInfos":[{"version":"4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3be6695caa91776ec738c01ffbc1250eb86f9bca0c22b02335b5e5c7c63bcbaa","signature":"6ec1f7bdc192ba06258caff3fa202fd577f8f354d676f548500eeb232155cbbe","impliedNodeFormat":1},{"version":"1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"declaration":true,"module":99},"referencedMap":[[3,1]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./MessageablePerson.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "signature": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./MessageablePerson.ts", + "version": "3be6695caa91776ec738c01ffbc1250eb86f9bca0c22b02335b5e5c7c63bcbaa", + "signature": "6ec1f7bdc192ba06258caff3fa202fd577f8f354d676f548500eeb232155cbbe", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "3be6695caa91776ec738c01ffbc1250eb86f9bca0c22b02335b5e5c7c63bcbaa", + "signature": "6ec1f7bdc192ba06258caff3fa202fd577f8f354d676f548500eeb232155cbbe", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./main.ts", + "version": "1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./MessageablePerson.ts" + ] + ], + "options": { + "declaration": true, + "module": 99 + }, + "referencedMap": { + "./main.ts": [ + "./MessageablePerson.ts" + ] + }, + "size": 697 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/MessageablePerson.ts +*refresh* /home/src/workspaces/project/main.ts +Signatures:: +(stored at emit) /home/src/workspaces/project/MessageablePerson.ts +(stored at emit) /home/src/workspaces/project/main.ts + + +Edit [0]:: no change + +tsgo --incremental +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [1]:: modify public to protected +//// [/home/src/workspaces/project/MessageablePerson.ts] *modified* +const Messageable = () => { + return class MessageableClass { + protected message = 'hello'; + } +}; +const wrapper = () => Messageable(); +type MessageablePerson = InstanceType>; +export default MessageablePerson; + +tsgo --incremental +ExitStatus:: DiagnosticsPresent_OutputsGenerated +Output:: +MessageablePerson.ts:6:7 - error TS4094: Property 'message' of exported anonymous class type may not be private or protected. + +6 const wrapper = () => Messageable(); +   ~~~~~~~ + + MessageablePerson.ts:6:7 - Add a type annotation to the variable wrapper. + 6 const wrapper = () => Messageable(); +    ~~~~~~~ + +main.ts:3:25 - error TS2445: Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses. + +3 console.log( person.message ); +   ~~~~~~~ + + +Found 2 errors in 2 files. + +Errors Files + 1 MessageablePerson.ts:6 + 1 main.ts:3 + +//// [/home/src/workspaces/project/MessageablePerson.d.ts] *modified time* +//// [/home/src/workspaces/project/MessageablePerson.js] *modified time* +//// [/home/src/workspaces/project/main.d.ts] *modified time* +//// [/home/src/workspaces/project/main.js] *modified time* +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./MessageablePerson.ts","./main.ts"],"fileInfos":[{"version":"4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"7605d26cb18fccfe18cf0d5b1771a538d665f6b2bb331c9617ebdf38d7c93b29","signature":"34f86a1082929a2d2c6b784bde116fadfb61a9ee55f5141d4906ef4ce16a89c9","impliedNodeFormat":1},{"version":"1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"declaration":true,"module":99},"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[[3,[{"pos":131,"end":138,"code":2445,"category":1,"message":"Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses."}]]],"emitDiagnosticsPerFile":[[2,[{"pos":116,"end":123,"code":4094,"category":1,"message":"Property 'message' of exported anonymous class type may not be private or protected.","relatedInformation":[{"pos":116,"end":123,"code":9027,"category":1,"message":"Add a type annotation to the variable wrapper."}]}]]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./MessageablePerson.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "signature": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./MessageablePerson.ts", + "version": "7605d26cb18fccfe18cf0d5b1771a538d665f6b2bb331c9617ebdf38d7c93b29", + "signature": "34f86a1082929a2d2c6b784bde116fadfb61a9ee55f5141d4906ef4ce16a89c9", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7605d26cb18fccfe18cf0d5b1771a538d665f6b2bb331c9617ebdf38d7c93b29", + "signature": "34f86a1082929a2d2c6b784bde116fadfb61a9ee55f5141d4906ef4ce16a89c9", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./main.ts", + "version": "1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./MessageablePerson.ts" + ] + ], + "options": { + "declaration": true, + "module": 99 + }, + "referencedMap": { + "./main.ts": [ + "./MessageablePerson.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + [ + "./main.ts", + [ + { + "pos": 131, + "end": 138, + "code": 2445, + "category": 1, + "message": "Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses." + } + ] + ] + ], + "emitDiagnosticsPerFile": [ + [ + "./MessageablePerson.ts", + [ + { + "pos": 116, + "end": 123, + "code": 4094, + "category": 1, + "message": "Property 'message' of exported anonymous class type may not be private or protected.", + "relatedInformation": [ + { + "pos": 116, + "end": 123, + "code": 9027, + "category": 1, + "message": "Add a type annotation to the variable wrapper." + } + ] + } + ] + ] + ], + "size": 1203 +} + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/MessageablePerson.ts +*refresh* /home/src/workspaces/project/main.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/MessageablePerson.ts +(computed .d.ts) /home/src/workspaces/project/main.ts + + +Edit [2]:: no change + +tsgo --incremental +ExitStatus:: DiagnosticsPresent_OutputsSkipped +Output:: +MessageablePerson.ts:6:7 - error TS4094: Property 'message' of exported anonymous class type may not be private or protected. + +6 const wrapper = () => Messageable(); +   ~~~~~~~ + + MessageablePerson.ts:6:7 - Add a type annotation to the variable wrapper. + 6 const wrapper = () => Messageable(); +    ~~~~~~~ + +main.ts:3:25 - error TS2445: Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses. + +3 console.log( person.message ); +   ~~~~~~~ + + +Found 2 errors in 2 files. + +Errors Files + 1 MessageablePerson.ts:6 + 1 main.ts:3 + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified time* +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified time* + +SemanticDiagnostics:: +Signatures:: + + +Edit [3]:: modify protected to public +//// [/home/src/workspaces/project/MessageablePerson.ts] *modified* +const Messageable = () => { + return class MessageableClass { + public message = 'hello'; + } +}; +const wrapper = () => Messageable(); +type MessageablePerson = InstanceType>; +export default MessageablePerson; + +tsgo --incremental +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/MessageablePerson.d.ts] *modified time* +//// [/home/src/workspaces/project/MessageablePerson.js] *modified time* +//// [/home/src/workspaces/project/main.d.ts] *modified time* +//// [/home/src/workspaces/project/main.js] *modified time* +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./MessageablePerson.ts","./main.ts"],"fileInfos":[{"version":"4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3be6695caa91776ec738c01ffbc1250eb86f9bca0c22b02335b5e5c7c63bcbaa","signature":"6ec1f7bdc192ba06258caff3fa202fd577f8f354d676f548500eeb232155cbbe","impliedNodeFormat":1},{"version":"1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"declaration":true,"module":99},"referencedMap":[[3,1]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./MessageablePerson.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "signature": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./MessageablePerson.ts", + "version": "3be6695caa91776ec738c01ffbc1250eb86f9bca0c22b02335b5e5c7c63bcbaa", + "signature": "6ec1f7bdc192ba06258caff3fa202fd577f8f354d676f548500eeb232155cbbe", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "3be6695caa91776ec738c01ffbc1250eb86f9bca0c22b02335b5e5c7c63bcbaa", + "signature": "6ec1f7bdc192ba06258caff3fa202fd577f8f354d676f548500eeb232155cbbe", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./main.ts", + "version": "1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./MessageablePerson.ts" + ] + ], + "options": { + "declaration": true, + "module": 99 + }, + "referencedMap": { + "./main.ts": [ + "./MessageablePerson.ts" + ] + }, + "size": 697 +} + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/MessageablePerson.ts +*refresh* /home/src/workspaces/project/main.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/MessageablePerson.ts +(computed .d.ts) /home/src/workspaces/project/main.ts + + +Edit [4]:: no change + +tsgo --incremental +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: diff --git a/testdata/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field.js b/testdata/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field.js new file mode 100644 index 0000000000..4c23251b15 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field.js @@ -0,0 +1,356 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *new* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +type ReturnType any> = T extends (...args: any) => infer R ? R : any; +type InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any; +//// [/home/src/workspaces/project/MessageablePerson.ts] *new* +const Messageable = () => { + return class MessageableClass { + public message = 'hello'; + } +}; +const wrapper = () => Messageable(); +type MessageablePerson = InstanceType>; +export default MessageablePerson; +//// [/home/src/workspaces/project/main.ts] *new* +import MessageablePerson from './MessageablePerson.js'; +function logMessage( person: MessageablePerson ) { + console.log( person.message ); +} +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "module": "esnext" + } +} + +tsgo --incremental +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/MessageablePerson.js] *new* +const Messageable = () => { + return class MessageableClass { + message = 'hello'; + }; +}; +const wrapper = () => Messageable(); +export {}; + +//// [/home/src/workspaces/project/main.js] *new* +function logMessage(person) { + console.log(person.message); +} +export {}; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./MessageablePerson.ts","./main.ts"],"fileInfos":[{"version":"4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21","affectsGlobalScope":true,"impliedNodeFormat":1},"3be6695caa91776ec738c01ffbc1250eb86f9bca0c22b02335b5e5c7c63bcbaa","1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de"],"fileIdsList":[[2]],"options":{"module":99},"referencedMap":[[3,1]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./MessageablePerson.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "signature": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./MessageablePerson.ts", + "version": "3be6695caa91776ec738c01ffbc1250eb86f9bca0c22b02335b5e5c7c63bcbaa", + "signature": "3be6695caa91776ec738c01ffbc1250eb86f9bca0c22b02335b5e5c7c63bcbaa", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./main.ts", + "version": "1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de", + "signature": "1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./MessageablePerson.ts" + ] + ], + "options": { + "module": 99 + }, + "referencedMap": { + "./main.ts": [ + "./MessageablePerson.ts" + ] + }, + "size": 452 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/MessageablePerson.ts +*refresh* /home/src/workspaces/project/main.ts +Signatures:: + + +Edit [0]:: no change + +tsgo --incremental +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [1]:: modify public to protected +//// [/home/src/workspaces/project/MessageablePerson.ts] *modified* +const Messageable = () => { + return class MessageableClass { + protected message = 'hello'; + } +}; +const wrapper = () => Messageable(); +type MessageablePerson = InstanceType>; +export default MessageablePerson; + +tsgo --incremental +ExitStatus:: DiagnosticsPresent_OutputsGenerated +Output:: +main.ts:3:25 - error TS2445: Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses. + +3 console.log( person.message ); +   ~~~~~~~ + + +Found 1 error in main.ts:3 + +//// [/home/src/workspaces/project/MessageablePerson.js] *modified time* +//// [/home/src/workspaces/project/main.js] *modified time* +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./MessageablePerson.ts","./main.ts"],"fileInfos":[{"version":"4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"7605d26cb18fccfe18cf0d5b1771a538d665f6b2bb331c9617ebdf38d7c93b29","signature":"34f86a1082929a2d2c6b784bde116fadfb61a9ee55f5141d4906ef4ce16a89c9","impliedNodeFormat":1},{"version":"1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"module":99},"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[[3,[{"pos":131,"end":138,"code":2445,"category":1,"message":"Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses."}]]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./MessageablePerson.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "signature": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./MessageablePerson.ts", + "version": "7605d26cb18fccfe18cf0d5b1771a538d665f6b2bb331c9617ebdf38d7c93b29", + "signature": "34f86a1082929a2d2c6b784bde116fadfb61a9ee55f5141d4906ef4ce16a89c9", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7605d26cb18fccfe18cf0d5b1771a538d665f6b2bb331c9617ebdf38d7c93b29", + "signature": "34f86a1082929a2d2c6b784bde116fadfb61a9ee55f5141d4906ef4ce16a89c9", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./main.ts", + "version": "1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./MessageablePerson.ts" + ] + ], + "options": { + "module": 99 + }, + "referencedMap": { + "./main.ts": [ + "./MessageablePerson.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + [ + "./main.ts", + [ + { + "pos": 131, + "end": 138, + "code": 2445, + "category": 1, + "message": "Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses." + } + ] + ] + ], + "size": 878 +} + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/MessageablePerson.ts +*refresh* /home/src/workspaces/project/main.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/MessageablePerson.ts +(computed .d.ts) /home/src/workspaces/project/main.ts + + +Edit [2]:: no change + +tsgo --incremental +ExitStatus:: DiagnosticsPresent_OutputsGenerated +Output:: +main.ts:3:25 - error TS2445: Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses. + +3 console.log( person.message ); +   ~~~~~~~ + + +Found 1 error in main.ts:3 + + +SemanticDiagnostics:: +Signatures:: + + +Edit [3]:: modify protected to public +//// [/home/src/workspaces/project/MessageablePerson.ts] *modified* +const Messageable = () => { + return class MessageableClass { + public message = 'hello'; + } +}; +const wrapper = () => Messageable(); +type MessageablePerson = InstanceType>; +export default MessageablePerson; + +tsgo --incremental +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/MessageablePerson.js] *modified time* +//// [/home/src/workspaces/project/main.js] *modified time* +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./MessageablePerson.ts","./main.ts"],"fileInfos":[{"version":"4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3be6695caa91776ec738c01ffbc1250eb86f9bca0c22b02335b5e5c7c63bcbaa","signature":"6ec1f7bdc192ba06258caff3fa202fd577f8f354d676f548500eeb232155cbbe","impliedNodeFormat":1},{"version":"1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"module":99},"referencedMap":[[3,1]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./MessageablePerson.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "signature": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "4454fdb8db546b8967485a3a7254c948e6876fb850a20e51972933eaf60b5b21", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./MessageablePerson.ts", + "version": "3be6695caa91776ec738c01ffbc1250eb86f9bca0c22b02335b5e5c7c63bcbaa", + "signature": "6ec1f7bdc192ba06258caff3fa202fd577f8f354d676f548500eeb232155cbbe", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "3be6695caa91776ec738c01ffbc1250eb86f9bca0c22b02335b5e5c7c63bcbaa", + "signature": "6ec1f7bdc192ba06258caff3fa202fd577f8f354d676f548500eeb232155cbbe", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./main.ts", + "version": "1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "1fe1ef024191a0efa3b3b0ec73ee8e703a58d44f6d62caf49268591964dce1de", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./MessageablePerson.ts" + ] + ], + "options": { + "module": 99 + }, + "referencedMap": { + "./main.ts": [ + "./MessageablePerson.ts" + ] + }, + "size": 678 +} + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/MessageablePerson.ts +*refresh* /home/src/workspaces/project/main.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/MessageablePerson.ts +(computed .d.ts) /home/src/workspaces/project/main.ts + + +Edit [4]:: no change + +tsgo --incremental +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: diff --git a/testdata/baselines/reference/tsc/incremental/change-to-type-that-gets-used-as-global-through-export-in-another-file-through-indirect-import.js b/testdata/baselines/reference/tsc/incremental/change-to-type-that-gets-used-as-global-through-export-in-another-file-through-indirect-import.js new file mode 100644 index 0000000000..9bf1968b23 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/change-to-type-that-gets-used-as-global-through-export-in-another-file-through-indirect-import.js @@ -0,0 +1,291 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/class1.ts] *new* +const a: MagicNumber = 1; +console.log(a); +//// [/home/src/workspaces/project/constants.ts] *new* +export default 1; +//// [/home/src/workspaces/project/reexport.ts] *new* +export { default as ConstantNumber } from "./constants" +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true + } +} +//// [/home/src/workspaces/project/types.d.ts] *new* +type MagicNumber = typeof import('./reexport').ConstantNumber + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/class1.d.ts] *new* +declare const a = 1; + +//// [/home/src/workspaces/project/class1.js] *new* +const a = 1; +console.log(a); + +//// [/home/src/workspaces/project/constants.d.ts] *new* +declare const _default: number; +export default _default; + +//// [/home/src/workspaces/project/constants.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = 1; + +//// [/home/src/workspaces/project/reexport.d.ts] *new* +export { default as ConstantNumber } from "./constants"; + +//// [/home/src/workspaces/project/reexport.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ConstantNumber = void 0; +const constants_1 = require("./constants"); +Object.defineProperty(exports, "ConstantNumber", { enumerable: true, get: function () { return constants_1.default; } }); + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./class1.ts","./constants.ts","./reexport.ts","./types.d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e23285158ce57995e96701e24b3979513455090a1acd8091dfcc03759c20f3a7","signature":"48becb2a5e6a58c58a56481b0edb338fd157be16188619433b47b766a8a71b60","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"56332e0a55734bc2b73df56a2df8635ed5c5b24b6d7a456b41de7cab9a2f3814","signature":"36b18171f705a4860606c23c78134f2e86f6e695d994dc8c849df608075d2e5a","impliedNodeFormat":1},{"version":"d358f9090c6427d5f6dd68671cba18871b08d2fcb193da8e979e324d68000cb3","signature":"84ff27208288e3f7379462f8745935fe8205e24ac2e2ef7c9ddef2dc2fbfeb39","impliedNodeFormat":1},{"version":"4364705e72bd2d53c70faabaa6d59be927f81efc6cb62cdfb1b7b18c72ec95f2","affectsGlobalScope":true,"impliedNodeFormat":1}],"fileIdsList":[[3],[4]],"options":{"composite":true},"referencedMap":[[4,1],[5,2]],"latestChangedDtsFile":"./reexport.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./class1.ts", + "./constants.ts", + "./reexport.ts", + "./types.d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./class1.ts", + "version": "e23285158ce57995e96701e24b3979513455090a1acd8091dfcc03759c20f3a7", + "signature": "48becb2a5e6a58c58a56481b0edb338fd157be16188619433b47b766a8a71b60", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "e23285158ce57995e96701e24b3979513455090a1acd8091dfcc03759c20f3a7", + "signature": "48becb2a5e6a58c58a56481b0edb338fd157be16188619433b47b766a8a71b60", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./constants.ts", + "version": "56332e0a55734bc2b73df56a2df8635ed5c5b24b6d7a456b41de7cab9a2f3814", + "signature": "36b18171f705a4860606c23c78134f2e86f6e695d994dc8c849df608075d2e5a", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "56332e0a55734bc2b73df56a2df8635ed5c5b24b6d7a456b41de7cab9a2f3814", + "signature": "36b18171f705a4860606c23c78134f2e86f6e695d994dc8c849df608075d2e5a", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./reexport.ts", + "version": "d358f9090c6427d5f6dd68671cba18871b08d2fcb193da8e979e324d68000cb3", + "signature": "84ff27208288e3f7379462f8745935fe8205e24ac2e2ef7c9ddef2dc2fbfeb39", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d358f9090c6427d5f6dd68671cba18871b08d2fcb193da8e979e324d68000cb3", + "signature": "84ff27208288e3f7379462f8745935fe8205e24ac2e2ef7c9ddef2dc2fbfeb39", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./types.d.ts", + "version": "4364705e72bd2d53c70faabaa6d59be927f81efc6cb62cdfb1b7b18c72ec95f2", + "signature": "4364705e72bd2d53c70faabaa6d59be927f81efc6cb62cdfb1b7b18c72ec95f2", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "4364705e72bd2d53c70faabaa6d59be927f81efc6cb62cdfb1b7b18c72ec95f2", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./constants.ts" + ], + [ + "./reexport.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./reexport.ts": [ + "./constants.ts" + ], + "./types.d.ts": [ + "./reexport.ts" + ] + }, + "latestChangedDtsFile": "./reexport.d.ts", + "size": 1092 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/class1.ts +*refresh* /home/src/workspaces/project/constants.ts +*refresh* /home/src/workspaces/project/reexport.ts +*refresh* /home/src/workspaces/project/types.d.ts +Signatures:: +(stored at emit) /home/src/workspaces/project/class1.ts +(stored at emit) /home/src/workspaces/project/constants.ts +(stored at emit) /home/src/workspaces/project/reexport.ts + + +Edit [0]:: Modify imports used in global file +//// [/home/src/workspaces/project/constants.ts] *modified* +export default 2; + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/constants.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = 2; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./class1.ts","./constants.ts","./reexport.ts","./types.d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e23285158ce57995e96701e24b3979513455090a1acd8091dfcc03759c20f3a7","signature":"48becb2a5e6a58c58a56481b0edb338fd157be16188619433b47b766a8a71b60","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a903ba200e1d43efd9a49f4a8f57c622efb2ca72b9a00222dacd16d6ba6f3ba0","signature":"36b18171f705a4860606c23c78134f2e86f6e695d994dc8c849df608075d2e5a","impliedNodeFormat":1},{"version":"d358f9090c6427d5f6dd68671cba18871b08d2fcb193da8e979e324d68000cb3","signature":"84ff27208288e3f7379462f8745935fe8205e24ac2e2ef7c9ddef2dc2fbfeb39","impliedNodeFormat":1},{"version":"4364705e72bd2d53c70faabaa6d59be927f81efc6cb62cdfb1b7b18c72ec95f2","affectsGlobalScope":true,"impliedNodeFormat":1}],"fileIdsList":[[3],[4]],"options":{"composite":true},"referencedMap":[[4,1],[5,2]],"latestChangedDtsFile":"./reexport.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./class1.ts", + "./constants.ts", + "./reexport.ts", + "./types.d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./class1.ts", + "version": "e23285158ce57995e96701e24b3979513455090a1acd8091dfcc03759c20f3a7", + "signature": "48becb2a5e6a58c58a56481b0edb338fd157be16188619433b47b766a8a71b60", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "e23285158ce57995e96701e24b3979513455090a1acd8091dfcc03759c20f3a7", + "signature": "48becb2a5e6a58c58a56481b0edb338fd157be16188619433b47b766a8a71b60", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./constants.ts", + "version": "a903ba200e1d43efd9a49f4a8f57c622efb2ca72b9a00222dacd16d6ba6f3ba0", + "signature": "36b18171f705a4860606c23c78134f2e86f6e695d994dc8c849df608075d2e5a", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "a903ba200e1d43efd9a49f4a8f57c622efb2ca72b9a00222dacd16d6ba6f3ba0", + "signature": "36b18171f705a4860606c23c78134f2e86f6e695d994dc8c849df608075d2e5a", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./reexport.ts", + "version": "d358f9090c6427d5f6dd68671cba18871b08d2fcb193da8e979e324d68000cb3", + "signature": "84ff27208288e3f7379462f8745935fe8205e24ac2e2ef7c9ddef2dc2fbfeb39", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d358f9090c6427d5f6dd68671cba18871b08d2fcb193da8e979e324d68000cb3", + "signature": "84ff27208288e3f7379462f8745935fe8205e24ac2e2ef7c9ddef2dc2fbfeb39", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./types.d.ts", + "version": "4364705e72bd2d53c70faabaa6d59be927f81efc6cb62cdfb1b7b18c72ec95f2", + "signature": "4364705e72bd2d53c70faabaa6d59be927f81efc6cb62cdfb1b7b18c72ec95f2", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "4364705e72bd2d53c70faabaa6d59be927f81efc6cb62cdfb1b7b18c72ec95f2", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./constants.ts" + ], + [ + "./reexport.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./reexport.ts": [ + "./constants.ts" + ], + "./types.d.ts": [ + "./reexport.ts" + ] + }, + "latestChangedDtsFile": "./reexport.d.ts", + "size": 1092 +} + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/constants.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/constants.ts diff --git a/testdata/baselines/reference/tsc/incremental/change-to-type-that-gets-used-as-global-through-export-in-another-file.js b/testdata/baselines/reference/tsc/incremental/change-to-type-that-gets-used-as-global-through-export-in-another-file.js new file mode 100644 index 0000000000..0b096011e9 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/change-to-type-that-gets-used-as-global-through-export-in-another-file.js @@ -0,0 +1,241 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/class1.ts] *new* +const a: MagicNumber = 1; +console.log(a); +//// [/home/src/workspaces/project/constants.ts] *new* +export default 1; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true + } +} +//// [/home/src/workspaces/project/types.d.ts] *new* +type MagicNumber = typeof import('./constants').default + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/class1.d.ts] *new* +declare const a = 1; + +//// [/home/src/workspaces/project/class1.js] *new* +const a = 1; +console.log(a); + +//// [/home/src/workspaces/project/constants.d.ts] *new* +declare const _default: number; +export default _default; + +//// [/home/src/workspaces/project/constants.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = 1; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./class1.ts","./constants.ts","./types.d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e23285158ce57995e96701e24b3979513455090a1acd8091dfcc03759c20f3a7","signature":"48becb2a5e6a58c58a56481b0edb338fd157be16188619433b47b766a8a71b60","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"56332e0a55734bc2b73df56a2df8635ed5c5b24b6d7a456b41de7cab9a2f3814","signature":"36b18171f705a4860606c23c78134f2e86f6e695d994dc8c849df608075d2e5a","impliedNodeFormat":1},{"version":"7446c53e84d9f941bf984ee4e804958d5e85677eb176c7bb33301814c98fba28","affectsGlobalScope":true,"impliedNodeFormat":1}],"fileIdsList":[[3]],"options":{"composite":true},"referencedMap":[[4,1]],"latestChangedDtsFile":"./constants.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./class1.ts", + "./constants.ts", + "./types.d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./class1.ts", + "version": "e23285158ce57995e96701e24b3979513455090a1acd8091dfcc03759c20f3a7", + "signature": "48becb2a5e6a58c58a56481b0edb338fd157be16188619433b47b766a8a71b60", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "e23285158ce57995e96701e24b3979513455090a1acd8091dfcc03759c20f3a7", + "signature": "48becb2a5e6a58c58a56481b0edb338fd157be16188619433b47b766a8a71b60", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./constants.ts", + "version": "56332e0a55734bc2b73df56a2df8635ed5c5b24b6d7a456b41de7cab9a2f3814", + "signature": "36b18171f705a4860606c23c78134f2e86f6e695d994dc8c849df608075d2e5a", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "56332e0a55734bc2b73df56a2df8635ed5c5b24b6d7a456b41de7cab9a2f3814", + "signature": "36b18171f705a4860606c23c78134f2e86f6e695d994dc8c849df608075d2e5a", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./types.d.ts", + "version": "7446c53e84d9f941bf984ee4e804958d5e85677eb176c7bb33301814c98fba28", + "signature": "7446c53e84d9f941bf984ee4e804958d5e85677eb176c7bb33301814c98fba28", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7446c53e84d9f941bf984ee4e804958d5e85677eb176c7bb33301814c98fba28", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./constants.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./types.d.ts": [ + "./constants.ts" + ] + }, + "latestChangedDtsFile": "./constants.d.ts", + "size": 887 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/class1.ts +*refresh* /home/src/workspaces/project/constants.ts +*refresh* /home/src/workspaces/project/types.d.ts +Signatures:: +(stored at emit) /home/src/workspaces/project/class1.ts +(stored at emit) /home/src/workspaces/project/constants.ts + + +Edit [0]:: Modify imports used in global file +//// [/home/src/workspaces/project/constants.ts] *modified* +export default 2; + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/constants.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = 2; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./class1.ts","./constants.ts","./types.d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e23285158ce57995e96701e24b3979513455090a1acd8091dfcc03759c20f3a7","signature":"48becb2a5e6a58c58a56481b0edb338fd157be16188619433b47b766a8a71b60","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a903ba200e1d43efd9a49f4a8f57c622efb2ca72b9a00222dacd16d6ba6f3ba0","signature":"36b18171f705a4860606c23c78134f2e86f6e695d994dc8c849df608075d2e5a","impliedNodeFormat":1},{"version":"7446c53e84d9f941bf984ee4e804958d5e85677eb176c7bb33301814c98fba28","affectsGlobalScope":true,"impliedNodeFormat":1}],"fileIdsList":[[3]],"options":{"composite":true},"referencedMap":[[4,1]],"latestChangedDtsFile":"./constants.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./class1.ts", + "./constants.ts", + "./types.d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./class1.ts", + "version": "e23285158ce57995e96701e24b3979513455090a1acd8091dfcc03759c20f3a7", + "signature": "48becb2a5e6a58c58a56481b0edb338fd157be16188619433b47b766a8a71b60", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "e23285158ce57995e96701e24b3979513455090a1acd8091dfcc03759c20f3a7", + "signature": "48becb2a5e6a58c58a56481b0edb338fd157be16188619433b47b766a8a71b60", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./constants.ts", + "version": "a903ba200e1d43efd9a49f4a8f57c622efb2ca72b9a00222dacd16d6ba6f3ba0", + "signature": "36b18171f705a4860606c23c78134f2e86f6e695d994dc8c849df608075d2e5a", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "a903ba200e1d43efd9a49f4a8f57c622efb2ca72b9a00222dacd16d6ba6f3ba0", + "signature": "36b18171f705a4860606c23c78134f2e86f6e695d994dc8c849df608075d2e5a", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./types.d.ts", + "version": "7446c53e84d9f941bf984ee4e804958d5e85677eb176c7bb33301814c98fba28", + "signature": "7446c53e84d9f941bf984ee4e804958d5e85677eb176c7bb33301814c98fba28", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7446c53e84d9f941bf984ee4e804958d5e85677eb176c7bb33301814c98fba28", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./constants.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./types.d.ts": [ + "./constants.ts" + ] + }, + "latestChangedDtsFile": "./constants.d.ts", + "size": 887 +} + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/constants.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/constants.ts diff --git a/testdata/baselines/reference/tsc/incremental/const-enums-aliased-in-different-file.js b/testdata/baselines/reference/tsc/incremental/const-enums-aliased-in-different-file.js new file mode 100644 index 0000000000..84089129ff --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/const-enums-aliased-in-different-file.js @@ -0,0 +1,548 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/a.ts] *new* +import {A} from "./c" +let a = A.ONE +//// [/home/src/workspaces/project/b.d.ts] *new* +export { AWorker as A } from "./worker"; +//// [/home/src/workspaces/project/c.ts] *new* +import {A} from "./b" +let b = A.ONE +export {A} +//// [/home/src/workspaces/project/worker.d.ts] *new* +export const enum AWorker { + ONE = 1 +} + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/a.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let a = c_1.A.ONE; + +//// [/home/src/workspaces/project/a.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./worker.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"6bbf56b58e48a1823a06aa76603127859d31869809dab154ab8c5903d6465602","d1cae7e0884009696a49cf892aeb5da4fc8bc6050db4bce9ee30b657ccba9636","f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09"],"fileIdsList":[[4],[2],[3]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[5,1],[3,2],[4,3]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./worker.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./worker.d.ts", + "version": "6bbf56b58e48a1823a06aa76603127859d31869809dab154ab8c5903d6465602", + "signature": "6bbf56b58e48a1823a06aa76603127859d31869809dab154ab8c5903d6465602", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./b.d.ts", + "version": "d1cae7e0884009696a49cf892aeb5da4fc8bc6050db4bce9ee30b657ccba9636", + "signature": "d1cae7e0884009696a49cf892aeb5da4fc8bc6050db4bce9ee30b657ccba9636", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./worker.d.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./b.d.ts": [ + "./worker.d.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 638 +} +//// [/home/src/workspaces/project/c.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let b = b_1.A.ONE; + + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/worker.d.ts +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: + + +Edit [0]:: change enum value +//// [/home/src/workspaces/project/worker.d.ts] *modified* +export const enum AWorker { + ONE = 2 +} + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified time* +//// [/home/src/workspaces/project/a.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./worker.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"4749e1d328fb4b3d350a6fd1629b976d85cb877d3fb71070eef63605206f3a60","d1cae7e0884009696a49cf892aeb5da4fc8bc6050db4bce9ee30b657ccba9636","f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09"],"fileIdsList":[[4],[2],[3]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[5,1],[3,2],[4,3]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./worker.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./worker.d.ts", + "version": "4749e1d328fb4b3d350a6fd1629b976d85cb877d3fb71070eef63605206f3a60", + "signature": "4749e1d328fb4b3d350a6fd1629b976d85cb877d3fb71070eef63605206f3a60", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./b.d.ts", + "version": "d1cae7e0884009696a49cf892aeb5da4fc8bc6050db4bce9ee30b657ccba9636", + "signature": "d1cae7e0884009696a49cf892aeb5da4fc8bc6050db4bce9ee30b657ccba9636", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./worker.d.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./b.d.ts": [ + "./worker.d.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 638 +} +//// [/home/src/workspaces/project/c.js] *modified time* + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/worker.d.ts +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(used version) /home/src/workspaces/project/worker.d.ts +(used version) /home/src/workspaces/project/b.d.ts +(used version) /home/src/workspaces/project/c.ts +(used version) /home/src/workspaces/project/a.ts + + +Edit [1]:: change enum value again +//// [/home/src/workspaces/project/worker.d.ts] *modified* +export const enum AWorker { + ONE = 3 +} + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified time* +//// [/home/src/workspaces/project/a.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./worker.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"9429bb2451db350f9bceba9041b64c9b80446ebfd5c423802bdee3ac2cd0fccc","d1cae7e0884009696a49cf892aeb5da4fc8bc6050db4bce9ee30b657ccba9636","f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09"],"fileIdsList":[[4],[2],[3]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[5,1],[3,2],[4,3]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./worker.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./worker.d.ts", + "version": "9429bb2451db350f9bceba9041b64c9b80446ebfd5c423802bdee3ac2cd0fccc", + "signature": "9429bb2451db350f9bceba9041b64c9b80446ebfd5c423802bdee3ac2cd0fccc", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./b.d.ts", + "version": "d1cae7e0884009696a49cf892aeb5da4fc8bc6050db4bce9ee30b657ccba9636", + "signature": "d1cae7e0884009696a49cf892aeb5da4fc8bc6050db4bce9ee30b657ccba9636", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./worker.d.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./b.d.ts": [ + "./worker.d.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 638 +} +//// [/home/src/workspaces/project/c.js] *modified time* + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/worker.d.ts +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(used version) /home/src/workspaces/project/worker.d.ts +(used version) /home/src/workspaces/project/b.d.ts +(used version) /home/src/workspaces/project/c.ts +(used version) /home/src/workspaces/project/a.ts + + +Edit [2]:: something else changes in b.d.ts +//// [/home/src/workspaces/project/b.d.ts] *modified* +export { AWorker as A } from "./worker";export const randomThing = 10; + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified time* +//// [/home/src/workspaces/project/a.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./worker.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"9429bb2451db350f9bceba9041b64c9b80446ebfd5c423802bdee3ac2cd0fccc","eececfa518b405636ca59764618daf54087efc29f152e951a20f543569bc9da6",{"version":"f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","signature":"1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732","impliedNodeFormat":1},{"version":"f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","impliedNodeFormat":1}],"fileIdsList":[[4],[2],[3]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[5,1],[3,2],[4,3]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./worker.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./worker.d.ts", + "version": "9429bb2451db350f9bceba9041b64c9b80446ebfd5c423802bdee3ac2cd0fccc", + "signature": "9429bb2451db350f9bceba9041b64c9b80446ebfd5c423802bdee3ac2cd0fccc", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./b.d.ts", + "version": "eececfa518b405636ca59764618daf54087efc29f152e951a20f543569bc9da6", + "signature": "eececfa518b405636ca59764618daf54087efc29f152e951a20f543569bc9da6", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./worker.d.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./b.d.ts": [ + "./worker.d.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 864 +} +//// [/home/src/workspaces/project/c.js] *modified time* + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(used version) /home/src/workspaces/project/b.d.ts +(computed .d.ts) /home/src/workspaces/project/c.ts +(computed .d.ts) /home/src/workspaces/project/a.ts + + +Edit [3]:: something else changes in b.d.ts again +//// [/home/src/workspaces/project/b.d.ts] *modified* +export { AWorker as A } from "./worker";export const randomThing = 10;export const randomThing2 = 10; + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./worker.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"9429bb2451db350f9bceba9041b64c9b80446ebfd5c423802bdee3ac2cd0fccc","fc3df7c9dd67a05ea3329c1a9ef9c5f81ddb2109cc13c2089aef6c5dbef34340",{"version":"f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","signature":"1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732","impliedNodeFormat":1},"f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09"],"fileIdsList":[[4],[2],[3]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[5,1],[3,2],[4,3]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./worker.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./worker.d.ts", + "version": "9429bb2451db350f9bceba9041b64c9b80446ebfd5c423802bdee3ac2cd0fccc", + "signature": "9429bb2451db350f9bceba9041b64c9b80446ebfd5c423802bdee3ac2cd0fccc", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./b.d.ts", + "version": "fc3df7c9dd67a05ea3329c1a9ef9c5f81ddb2109cc13c2089aef6c5dbef34340", + "signature": "fc3df7c9dd67a05ea3329c1a9ef9c5f81ddb2109cc13c2089aef6c5dbef34340", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./worker.d.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./b.d.ts": [ + "./worker.d.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 751 +} +//// [/home/src/workspaces/project/c.js] *modified time* + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(used version) /home/src/workspaces/project/b.d.ts +(computed .d.ts) /home/src/workspaces/project/c.ts +(used version) /home/src/workspaces/project/a.ts diff --git a/testdata/baselines/reference/tsc/incremental/const-enums-aliased.js b/testdata/baselines/reference/tsc/incremental/const-enums-aliased.js new file mode 100644 index 0000000000..0854a823a3 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/const-enums-aliased.js @@ -0,0 +1,500 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/a.ts] *new* +import {A} from "./c" +let a = A.ONE +//// [/home/src/workspaces/project/b.d.ts] *new* +export const enum AWorker { + ONE = 1 +} +export { AWorker as A }; +//// [/home/src/workspaces/project/c.ts] *new* +import {A} from "./b" +let b = A.ONE +export {A} +//// [/home/src/workspaces/project/worker.d.ts] *new* +export const enum AWorker { + ONE = 1 +} + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/a.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let a = c_1.A.ONE; + +//// [/home/src/workspaces/project/a.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"aefe0c976f3560d1dc94c0cd48015c353590ad36544e20b63343660251f2dda0","f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09"],"fileIdsList":[[3],[2]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[4,1],[3,2]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.d.ts", + "version": "aefe0c976f3560d1dc94c0cd48015c353590ad36544e20b63343660251f2dda0", + "signature": "aefe0c976f3560d1dc94c0cd48015c353590ad36544e20b63343660251f2dda0", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 545 +} +//// [/home/src/workspaces/project/c.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let b = b_1.A.ONE; + + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: + + +Edit [0]:: change enum value +//// [/home/src/workspaces/project/b.d.ts] *modified* +export const enum AWorker { + ONE = 2 +} +export { AWorker as A }; + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified time* +//// [/home/src/workspaces/project/a.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"14d71e969881a8c0811d42cfe653ed85464878ffea9da23fc600354f69c7ce0a",{"version":"f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","signature":"1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732","impliedNodeFormat":1},{"version":"f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","impliedNodeFormat":1}],"fileIdsList":[[3],[2]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[4,1],[3,2]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.d.ts", + "version": "14d71e969881a8c0811d42cfe653ed85464878ffea9da23fc600354f69c7ce0a", + "signature": "14d71e969881a8c0811d42cfe653ed85464878ffea9da23fc600354f69c7ce0a", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 771 +} +//// [/home/src/workspaces/project/c.js] *modified time* + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(used version) /home/src/workspaces/project/b.d.ts +(computed .d.ts) /home/src/workspaces/project/c.ts +(computed .d.ts) /home/src/workspaces/project/a.ts + + +Edit [1]:: change enum value again +//// [/home/src/workspaces/project/b.d.ts] *modified* +export const enum AWorker { + ONE = 3 +} +export { AWorker as A }; + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified time* +//// [/home/src/workspaces/project/a.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"fd596fa8534f245082284882486d12dcbbac11bddd318142255e4263cfc8caee",{"version":"f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","signature":"1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732","impliedNodeFormat":1},"f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09"],"fileIdsList":[[3],[2]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[4,1],[3,2]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.d.ts", + "version": "fd596fa8534f245082284882486d12dcbbac11bddd318142255e4263cfc8caee", + "signature": "fd596fa8534f245082284882486d12dcbbac11bddd318142255e4263cfc8caee", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 658 +} +//// [/home/src/workspaces/project/c.js] *modified time* + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(used version) /home/src/workspaces/project/b.d.ts +(computed .d.ts) /home/src/workspaces/project/c.ts +(used version) /home/src/workspaces/project/a.ts + + +Edit [2]:: something else changes in b.d.ts +//// [/home/src/workspaces/project/b.d.ts] *modified* +export const enum AWorker { + ONE = 3 +} +export { AWorker as A };export const randomThing = 10; + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified time* +//// [/home/src/workspaces/project/a.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"da86c0aef231d210deabded52a8d06f690f831df02245fda8366c42fe1a8256b",{"version":"f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","signature":"1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732","impliedNodeFormat":1},"f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09"],"fileIdsList":[[3],[2]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[4,1],[3,2]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.d.ts", + "version": "da86c0aef231d210deabded52a8d06f690f831df02245fda8366c42fe1a8256b", + "signature": "da86c0aef231d210deabded52a8d06f690f831df02245fda8366c42fe1a8256b", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 658 +} +//// [/home/src/workspaces/project/c.js] *modified time* + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(used version) /home/src/workspaces/project/b.d.ts +(computed .d.ts) /home/src/workspaces/project/c.ts +(used version) /home/src/workspaces/project/a.ts + + +Edit [3]:: something else changes in b.d.ts again +//// [/home/src/workspaces/project/b.d.ts] *modified* +export const enum AWorker { + ONE = 3 +} +export { AWorker as A };export const randomThing = 10;export const randomThing2 = 10; + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified time* +//// [/home/src/workspaces/project/a.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"553c61a4c56cd4ff8a6e8d257be96bb2bf38cee5d52a5b44b9084f92da5b8c27",{"version":"f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","signature":"1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732","impliedNodeFormat":1},"f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09"],"fileIdsList":[[3],[2]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[4,1],[3,2]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.d.ts", + "version": "553c61a4c56cd4ff8a6e8d257be96bb2bf38cee5d52a5b44b9084f92da5b8c27", + "signature": "553c61a4c56cd4ff8a6e8d257be96bb2bf38cee5d52a5b44b9084f92da5b8c27", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 658 +} +//// [/home/src/workspaces/project/c.js] *modified time* + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(used version) /home/src/workspaces/project/b.d.ts +(computed .d.ts) /home/src/workspaces/project/c.ts +(used version) /home/src/workspaces/project/a.ts diff --git a/testdata/baselines/reference/tsc/incremental/const-enums.js b/testdata/baselines/reference/tsc/incremental/const-enums.js new file mode 100644 index 0000000000..b8cedf72a4 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/const-enums.js @@ -0,0 +1,495 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/a.ts] *new* +import {A} from "./c" +let a = A.ONE +//// [/home/src/workspaces/project/b.d.ts] *new* +export const enum A { + ONE = 1 +} +//// [/home/src/workspaces/project/c.ts] *new* +import {A} from "./b" +let b = A.ONE +export {A} +//// [/home/src/workspaces/project/worker.d.ts] *new* +export const enum AWorker { + ONE = 1 +} + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/a.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let a = c_1.A.ONE; + +//// [/home/src/workspaces/project/a.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"c00e44762baea954363536f3ccceae15fd84bf2b246f8cb077164d106cd5c9ae","f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09"],"fileIdsList":[[3],[2]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[4,1],[3,2]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.d.ts", + "version": "c00e44762baea954363536f3ccceae15fd84bf2b246f8cb077164d106cd5c9ae", + "signature": "c00e44762baea954363536f3ccceae15fd84bf2b246f8cb077164d106cd5c9ae", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 545 +} +//// [/home/src/workspaces/project/c.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let b = b_1.A.ONE; + + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: + + +Edit [0]:: change enum value +//// [/home/src/workspaces/project/b.d.ts] *modified* +export const enum A { + ONE = 2 +} + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified time* +//// [/home/src/workspaces/project/a.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"6ab9b377a00d6157a880e7be8f490a45f91a751d3aab7a46a21fd0169189e21c",{"version":"f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","signature":"1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732","impliedNodeFormat":1},{"version":"f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","impliedNodeFormat":1}],"fileIdsList":[[3],[2]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[4,1],[3,2]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.d.ts", + "version": "6ab9b377a00d6157a880e7be8f490a45f91a751d3aab7a46a21fd0169189e21c", + "signature": "6ab9b377a00d6157a880e7be8f490a45f91a751d3aab7a46a21fd0169189e21c", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 771 +} +//// [/home/src/workspaces/project/c.js] *modified time* + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(used version) /home/src/workspaces/project/b.d.ts +(computed .d.ts) /home/src/workspaces/project/c.ts +(computed .d.ts) /home/src/workspaces/project/a.ts + + +Edit [1]:: change enum value again +//// [/home/src/workspaces/project/b.d.ts] *modified* +export const enum A { + ONE = 3 +} + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified time* +//// [/home/src/workspaces/project/a.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"9b7fcb1de7abaa3bee27ad197ab712966678462da9b016fd18a98202a022e062",{"version":"f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","signature":"1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732","impliedNodeFormat":1},"f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09"],"fileIdsList":[[3],[2]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[4,1],[3,2]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.d.ts", + "version": "9b7fcb1de7abaa3bee27ad197ab712966678462da9b016fd18a98202a022e062", + "signature": "9b7fcb1de7abaa3bee27ad197ab712966678462da9b016fd18a98202a022e062", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 658 +} +//// [/home/src/workspaces/project/c.js] *modified time* + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(used version) /home/src/workspaces/project/b.d.ts +(computed .d.ts) /home/src/workspaces/project/c.ts +(used version) /home/src/workspaces/project/a.ts + + +Edit [2]:: something else changes in b.d.ts +//// [/home/src/workspaces/project/b.d.ts] *modified* +export const enum A { + ONE = 3 +}export const randomThing = 10; + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified time* +//// [/home/src/workspaces/project/a.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"8eb5f9388406068b4f938250bc5ba6c8f62cb17db7bd81dad8d2b8e411d344ed",{"version":"f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","signature":"1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732","impliedNodeFormat":1},"f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09"],"fileIdsList":[[3],[2]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[4,1],[3,2]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.d.ts", + "version": "8eb5f9388406068b4f938250bc5ba6c8f62cb17db7bd81dad8d2b8e411d344ed", + "signature": "8eb5f9388406068b4f938250bc5ba6c8f62cb17db7bd81dad8d2b8e411d344ed", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 658 +} +//// [/home/src/workspaces/project/c.js] *modified time* + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(used version) /home/src/workspaces/project/b.d.ts +(computed .d.ts) /home/src/workspaces/project/c.ts +(used version) /home/src/workspaces/project/a.ts + + +Edit [3]:: something else changes in b.d.ts again +//// [/home/src/workspaces/project/b.d.ts] *modified* +export const enum A { + ONE = 3 +}export const randomThing = 10;export const randomThing2 = 10; + +tsgo -i a.ts --tsbuildinfofile a.tsbuildinfo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified time* +//// [/home/src/workspaces/project/a.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./b.d.ts","./c.ts","./a.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"0e2a47b6ac5d1eb00a443643049e47e98f3bcacb8852a925f600902222323516",{"version":"f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a","signature":"1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732","impliedNodeFormat":1},"f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09"],"fileIdsList":[[3],[2]],"options":{"tsBuildInfoFile":"./a.tsbuildinfo"},"referencedMap":[[4,1],[3,2]]} +//// [/home/src/workspaces/project/a.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./b.d.ts", + "./c.ts", + "./a.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.d.ts", + "version": "0e2a47b6ac5d1eb00a443643049e47e98f3bcacb8852a925f600902222323516", + "signature": "0e2a47b6ac5d1eb00a443643049e47e98f3bcacb8852a925f600902222323516", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f96307fd3b2531524ba186a0b7862e9605da65828664c51363d0b608f8141c8a", + "signature": "1affdd1113604735d4499c03d6271d13972094ddab6991610e72d53c00d14732", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "signature": "f5a433d8f46180a7988f1820c3e70520cbbc864a870e4f6cdd4857edf3688e09", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./c.ts" + ], + [ + "./b.d.ts" + ] + ], + "options": { + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": { + "./a.ts": [ + "./c.ts" + ], + "./c.ts": [ + "./b.d.ts" + ] + }, + "size": 658 +} +//// [/home/src/workspaces/project/c.js] *modified time* + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/b.d.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(used version) /home/src/workspaces/project/b.d.ts +(computed .d.ts) /home/src/workspaces/project/c.ts +(used version) /home/src/workspaces/project/a.ts diff --git a/testdata/baselines/reference/tsc/incremental/generates-typerefs-correctly.js b/testdata/baselines/reference/tsc/incremental/generates-typerefs-correctly.js new file mode 100644 index 0000000000..446b0f8ce4 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/generates-typerefs-correctly.js @@ -0,0 +1,339 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/src/box.ts] *new* +export interface Box { + unbox(): T +} +//// [/home/src/workspaces/project/src/bug.js] *new* +import * as B from "./box.js" +import * as W from "./wrap.js" + +/** + * @template {object} C + * @param {C} source + * @returns {W.Wrap} + */ +const wrap = source => { +throw source +} + +/** + * @returns {B.Box} + */ +const box = (n = 0) => ({ unbox: () => n }) + +export const bug = wrap({ n: box(1) }); +//// [/home/src/workspaces/project/src/wrap.ts] *new* +export type Wrap = { + [K in keyof C]: { wrapped: C[K] } +} +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "outDir", + "checkJs": true + }, + "include": ["src"], +} + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/outDir/src/box.d.ts] *new* +export interface Box { + unbox(): T; +} + +//// [/home/src/workspaces/project/outDir/src/box.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + +//// [/home/src/workspaces/project/outDir/src/bug.d.ts] *new* +import * as B from "./box.js"; +import * as W from "./wrap.js"; +export declare const bug: W.Wrap<{ + n: B.Box; +}>; + +//// [/home/src/workspaces/project/outDir/src/bug.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bug = void 0; +const B = require("./box.js"); +const W = require("./wrap.js"); +/** + * @template {object} C + * @param {C} source + * @returns {W.Wrap} + */ +const wrap = source => { + throw source; +}; +/** + * @returns {B.Box} + */ +const box = (n = 0) => ({ unbox: () => n }); +exports.bug = wrap({ n: box(1) }); + +//// [/home/src/workspaces/project/outDir/src/wrap.d.ts] *new* +export type Wrap = { + [K in keyof C]: { + wrapped: C[K]; + }; +}; + +//// [/home/src/workspaces/project/outDir/src/wrap.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + +//// [/home/src/workspaces/project/outDir/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../../tslibs/TS/Lib/lib.d.ts","../src/box.ts","../src/wrap.ts","../src/bug.js"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0368ea83346f71eb3a3ca19fa727980a0456898b66b88a4c998681504e53158e","signature":"5869e012eabb24957b3b2a27561b2b2717204cde82b935ea3195bf53b2217448","impliedNodeFormat":1},{"version":"a3491cb9265a4ed19398a6a100ae6e6789c7272cfe887c80b4c439101afd7dc7","signature":"4c8e88aa97caafb769b257fcde8ff8a50ef3e962fc7f3c51fba1c7c7e905dc3b","impliedNodeFormat":1},{"version":"f4375ea4700b8e5e8d2c1cc7552de717928f9b5333a1be759bc15f196daea88e","signature":"d50883e16164d399f0e9534640b44ee6c05a7c690534d0201a645262e7caab22","impliedNodeFormat":1}],"fileIdsList":[[2,3]],"options":{"checkJs":true,"composite":true,"outDir":"./"},"referencedMap":[[4,1]],"latestChangedDtsFile":"./src/wrap.d.ts"} +//// [/home/src/workspaces/project/outDir/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../../tslibs/TS/Lib/lib.d.ts", + "../src/box.ts", + "../src/wrap.ts", + "../src/bug.js" + ], + "fileInfos": [ + { + "fileName": "../../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/box.ts", + "version": "0368ea83346f71eb3a3ca19fa727980a0456898b66b88a4c998681504e53158e", + "signature": "5869e012eabb24957b3b2a27561b2b2717204cde82b935ea3195bf53b2217448", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "0368ea83346f71eb3a3ca19fa727980a0456898b66b88a4c998681504e53158e", + "signature": "5869e012eabb24957b3b2a27561b2b2717204cde82b935ea3195bf53b2217448", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/wrap.ts", + "version": "a3491cb9265a4ed19398a6a100ae6e6789c7272cfe887c80b4c439101afd7dc7", + "signature": "4c8e88aa97caafb769b257fcde8ff8a50ef3e962fc7f3c51fba1c7c7e905dc3b", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "a3491cb9265a4ed19398a6a100ae6e6789c7272cfe887c80b4c439101afd7dc7", + "signature": "4c8e88aa97caafb769b257fcde8ff8a50ef3e962fc7f3c51fba1c7c7e905dc3b", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/bug.js", + "version": "f4375ea4700b8e5e8d2c1cc7552de717928f9b5333a1be759bc15f196daea88e", + "signature": "d50883e16164d399f0e9534640b44ee6c05a7c690534d0201a645262e7caab22", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "f4375ea4700b8e5e8d2c1cc7552de717928f9b5333a1be759bc15f196daea88e", + "signature": "d50883e16164d399f0e9534640b44ee6c05a7c690534d0201a645262e7caab22", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../src/box.ts", + "../src/wrap.ts" + ] + ], + "options": { + "checkJs": true, + "composite": true, + "outDir": "./" + }, + "referencedMap": { + "../src/bug.js": [ + "../src/box.ts", + "../src/wrap.ts" + ] + }, + "latestChangedDtsFile": "./src/wrap.d.ts", + "size": 950 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/src/box.ts +*refresh* /home/src/workspaces/project/src/wrap.ts +*refresh* /home/src/workspaces/project/src/bug.js +Signatures:: +(stored at emit) /home/src/workspaces/project/src/box.ts +(stored at emit) /home/src/workspaces/project/src/wrap.ts +(stored at emit) /home/src/workspaces/project/src/bug.js + + +Edit [0]:: modify js file +//// [/home/src/workspaces/project/src/bug.js] *modified* +import * as B from "./box.js" +import * as W from "./wrap.js" + +/** + * @template {object} C + * @param {C} source + * @returns {W.Wrap} + */ +const wrap = source => { +throw source +} + +/** + * @returns {B.Box} + */ +const box = (n = 0) => ({ unbox: () => n }) + +export const bug = wrap({ n: box(1) });export const something = 1; + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/outDir/src/bug.d.ts] *modified* +import * as B from "./box.js"; +import * as W from "./wrap.js"; +export declare const bug: W.Wrap<{ + n: B.Box; +}>; +export declare const something = 1; + +//// [/home/src/workspaces/project/outDir/src/bug.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.something = exports.bug = void 0; +const B = require("./box.js"); +const W = require("./wrap.js"); +/** + * @template {object} C + * @param {C} source + * @returns {W.Wrap} + */ +const wrap = source => { + throw source; +}; +/** + * @returns {B.Box} + */ +const box = (n = 0) => ({ unbox: () => n }); +exports.bug = wrap({ n: box(1) }); +exports.something = 1; + +//// [/home/src/workspaces/project/outDir/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../../tslibs/TS/Lib/lib.d.ts","../src/box.ts","../src/wrap.ts","../src/bug.js"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0368ea83346f71eb3a3ca19fa727980a0456898b66b88a4c998681504e53158e","signature":"5869e012eabb24957b3b2a27561b2b2717204cde82b935ea3195bf53b2217448","impliedNodeFormat":1},{"version":"a3491cb9265a4ed19398a6a100ae6e6789c7272cfe887c80b4c439101afd7dc7","signature":"4c8e88aa97caafb769b257fcde8ff8a50ef3e962fc7f3c51fba1c7c7e905dc3b","impliedNodeFormat":1},{"version":"676e1613c74cee0aa880dc1108ce9e0a07e184e35a7d78282bf4a480bf6124db","signature":"6a80e6a4e41ee496beaac682ed90a523d5f8b87987da12ca01326156d552d025","impliedNodeFormat":1}],"fileIdsList":[[2,3]],"options":{"checkJs":true,"composite":true,"outDir":"./"},"referencedMap":[[4,1]],"latestChangedDtsFile":"./src/bug.d.ts"} +//// [/home/src/workspaces/project/outDir/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../../tslibs/TS/Lib/lib.d.ts", + "../src/box.ts", + "../src/wrap.ts", + "../src/bug.js" + ], + "fileInfos": [ + { + "fileName": "../../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/box.ts", + "version": "0368ea83346f71eb3a3ca19fa727980a0456898b66b88a4c998681504e53158e", + "signature": "5869e012eabb24957b3b2a27561b2b2717204cde82b935ea3195bf53b2217448", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "0368ea83346f71eb3a3ca19fa727980a0456898b66b88a4c998681504e53158e", + "signature": "5869e012eabb24957b3b2a27561b2b2717204cde82b935ea3195bf53b2217448", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/wrap.ts", + "version": "a3491cb9265a4ed19398a6a100ae6e6789c7272cfe887c80b4c439101afd7dc7", + "signature": "4c8e88aa97caafb769b257fcde8ff8a50ef3e962fc7f3c51fba1c7c7e905dc3b", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "a3491cb9265a4ed19398a6a100ae6e6789c7272cfe887c80b4c439101afd7dc7", + "signature": "4c8e88aa97caafb769b257fcde8ff8a50ef3e962fc7f3c51fba1c7c7e905dc3b", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/bug.js", + "version": "676e1613c74cee0aa880dc1108ce9e0a07e184e35a7d78282bf4a480bf6124db", + "signature": "6a80e6a4e41ee496beaac682ed90a523d5f8b87987da12ca01326156d552d025", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "676e1613c74cee0aa880dc1108ce9e0a07e184e35a7d78282bf4a480bf6124db", + "signature": "6a80e6a4e41ee496beaac682ed90a523d5f8b87987da12ca01326156d552d025", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../src/box.ts", + "../src/wrap.ts" + ] + ], + "options": { + "checkJs": true, + "composite": true, + "outDir": "./" + }, + "referencedMap": { + "../src/bug.js": [ + "../src/box.ts", + "../src/wrap.ts" + ] + }, + "latestChangedDtsFile": "./src/bug.d.ts", + "size": 949 +} + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/src/bug.js +Signatures:: +(computed .d.ts) /home/src/workspaces/project/src/bug.js diff --git a/testdata/baselines/reference/tsc/incremental/option-changes-with-composite.js b/testdata/baselines/reference/tsc/incremental/option-changes-with-composite.js new file mode 100644 index 0000000000..22b04fff53 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/option-changes-with-composite.js @@ -0,0 +1,1414 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/a.ts] *new* +export const a = 10;const aLocal = 10; +//// [/home/src/workspaces/project/b.ts] *new* +export const b = 10;const bLocal = 10; +//// [/home/src/workspaces/project/c.ts] *new* +import { a } from "./a";export const c = a; +//// [/home/src/workspaces/project/d.ts] *new* +import { b } from "./b";export const d = b; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + } +} + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/a.d.ts] *new* +export declare const a = 10; + +//// [/home/src/workspaces/project/a.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 10; + +//// [/home/src/workspaces/project/b.d.ts] *new* +export declare const b = 10; + +//// [/home/src/workspaces/project/b.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; +const bLocal = 10; + +//// [/home/src/workspaces/project/c.d.ts] *new* +export declare const c = 10; + +//// [/home/src/workspaces/project/c.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +const a_1 = require("./a"); +exports.c = a_1.a; + +//// [/home/src/workspaces/project/d.d.ts] *new* +export declare const d = 10; + +//// [/home/src/workspaces/project/d.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.d = void 0; +const b_1 = require("./b"); +exports.d = b_1.b; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"composite":true},"referencedMap":[[4,1],[5,2]],"latestChangedDtsFile":"./d.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "latestChangedDtsFile": "./d.d.ts", + "size": 1086 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/a.ts +*refresh* /home/src/workspaces/project/b.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/d.ts +Signatures:: +(stored at emit) /home/src/workspaces/project/a.ts +(stored at emit) /home/src/workspaces/project/b.ts +(stored at emit) /home/src/workspaces/project/c.ts +(stored at emit) /home/src/workspaces/project/d.ts + + +Edit [0]:: with sourceMap + +tsgo --sourceMap +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 10; +//# sourceMappingURL=a.js.map +//// [/home/src/workspaces/project/a.js.map] *new* +{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":[],"mappings":";;;AAAa,QAAA,CAAC,GAAG,EAAE,CAAC;AAAA,MAAM,MAAM,GAAG,EAAE,CAAC"} +//// [/home/src/workspaces/project/b.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; +const bLocal = 10; +//# sourceMappingURL=b.js.map +//// [/home/src/workspaces/project/b.js.map] *new* +{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":[],"mappings":";;;AAAa,QAAA,CAAC,GAAG,EAAE,CAAC;AAAA,MAAM,MAAM,GAAG,EAAE,CAAC"} +//// [/home/src/workspaces/project/c.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +const a_1 = require("./a"); +exports.c = a_1.a; +//# sourceMappingURL=c.js.map +//// [/home/src/workspaces/project/c.js.map] *new* +{"version":3,"file":"c.js","sourceRoot":"","sources":["c.ts"],"names":[],"mappings":";;;AAAA,2BAAwB;AAAa,QAAA,CAAC,GAAG,KAAC,CAAC"} +//// [/home/src/workspaces/project/d.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.d = void 0; +const b_1 = require("./b"); +exports.d = b_1.b; +//# sourceMappingURL=d.js.map +//// [/home/src/workspaces/project/d.js.map] *new* +{"version":3,"file":"d.js","sourceRoot":"","sources":["d.ts"],"names":[],"mappings":";;;AAAA,2BAAwB;AAAa,QAAA,CAAC,GAAG,KAAC,CAAC"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"composite":true,"sourceMap":true},"referencedMap":[[4,1],[5,2]],"latestChangedDtsFile":"./d.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "composite": true, + "sourceMap": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "latestChangedDtsFile": "./d.d.ts", + "size": 1103 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [1]:: should re-emit only js so they dont contain sourcemap + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 10; + +//// [/home/src/workspaces/project/b.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; +const bLocal = 10; + +//// [/home/src/workspaces/project/c.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +const a_1 = require("./a"); +exports.c = a_1.a; + +//// [/home/src/workspaces/project/d.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.d = void 0; +const b_1 = require("./b"); +exports.d = b_1.b; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"composite":true},"referencedMap":[[4,1],[5,2]],"latestChangedDtsFile":"./d.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "latestChangedDtsFile": "./d.d.ts", + "size": 1086 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [2]:: with declaration should not emit anything + +tsgo --declaration +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [3]:: no change + +tsgo +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [4]:: with declaration and declarationMap + +tsgo --declaration --declarationMap +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.d.ts] *modified* +export declare const a = 10; +//# sourceMappingURL=a.d.ts.map +//// [/home/src/workspaces/project/a.d.ts.map] *new* +{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["a.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,CAAC,KAAK,CAAC"} +//// [/home/src/workspaces/project/b.d.ts] *modified* +export declare const b = 10; +//# sourceMappingURL=b.d.ts.map +//// [/home/src/workspaces/project/b.d.ts.map] *new* +{"version":3,"file":"b.d.ts","sourceRoot":"","sources":["b.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,CAAC,KAAK,CAAC"} +//// [/home/src/workspaces/project/c.d.ts] *modified* +export declare const c = 10; +//# sourceMappingURL=c.d.ts.map +//// [/home/src/workspaces/project/c.d.ts.map] *new* +{"version":3,"file":"c.d.ts","sourceRoot":"","sources":["c.ts"],"names":[],"mappings":"AAAwB,eAAO,MAAM,CAAC,KAAI,CAAC"} +//// [/home/src/workspaces/project/d.d.ts] *modified* +export declare const d = 10; +//# sourceMappingURL=d.d.ts.map +//// [/home/src/workspaces/project/d.d.ts.map] *new* +{"version":3,"file":"d.d.ts","sourceRoot":"","sources":["d.ts"],"names":[],"mappings":"AAAwB,eAAO,MAAM,CAAC,KAAI,CAAC"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"composite":true,"declaration":true,"declarationMap":true},"referencedMap":[[4,1],[5,2]],"latestChangedDtsFile":"./d.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "composite": true, + "declaration": true, + "declarationMap": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "latestChangedDtsFile": "./d.d.ts", + "size": 1127 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [5]:: should re-emit only dts so they dont contain sourcemap + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.d.ts] *modified* +export declare const a = 10; + +//// [/home/src/workspaces/project/b.d.ts] *modified* +export declare const b = 10; + +//// [/home/src/workspaces/project/c.d.ts] *modified* +export declare const c = 10; + +//// [/home/src/workspaces/project/d.d.ts] *modified* +export declare const d = 10; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"composite":true},"referencedMap":[[4,1],[5,2]],"latestChangedDtsFile":"./d.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "latestChangedDtsFile": "./d.d.ts", + "size": 1086 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [6]:: with emitDeclarationOnly should not emit anything + +tsgo --emitDeclarationOnly +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [7]:: no change + +tsgo +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [8]:: local change +//// [/home/src/workspaces/project/a.ts] *modified* +export const a = 10;const aLocal = 100; + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 100; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"composite":true},"referencedMap":[[4,1],[5,2]],"latestChangedDtsFile":"./d.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "latestChangedDtsFile": "./d.d.ts", + "size": 1086 +} + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/a.ts + + +Edit [9]:: with declaration should not emit anything + +tsgo --declaration +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [10]:: with inlineSourceMap + +tsgo --inlineSourceMap +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 100; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQWEsUUFBQSxDQUFDLEdBQUcsRUFBRSxDQUFDO0FBQUEsTUFBTSxNQUFNLEdBQUcsR0FBRyxDQUFDIn0= +//// [/home/src/workspaces/project/b.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; +const bLocal = 10; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQWEsUUFBQSxDQUFDLEdBQUcsRUFBRSxDQUFDO0FBQUEsTUFBTSxNQUFNLEdBQUcsRUFBRSxDQUFDIn0= +//// [/home/src/workspaces/project/c.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +const a_1 = require("./a"); +exports.c = a_1.a; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsMkJBQXdCO0FBQWEsUUFBQSxDQUFDLEdBQUcsS0FBQyxDQUFDIn0= +//// [/home/src/workspaces/project/d.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.d = void 0; +const b_1 = require("./b"); +exports.d = b_1.b; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsMkJBQXdCO0FBQWEsUUFBQSxDQUFDLEdBQUcsS0FBQyxDQUFDIn0= +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"composite":true,"inlineSourceMap":true},"referencedMap":[[4,1],[5,2]],"latestChangedDtsFile":"./d.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "composite": true, + "inlineSourceMap": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "latestChangedDtsFile": "./d.d.ts", + "size": 1109 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [11]:: with sourceMap + +tsgo --sourceMap +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 100; +//# sourceMappingURL=a.js.map +//// [/home/src/workspaces/project/a.js.map] *modified* +{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":[],"mappings":";;;AAAa,QAAA,CAAC,GAAG,EAAE,CAAC;AAAA,MAAM,MAAM,GAAG,GAAG,CAAC"} +//// [/home/src/workspaces/project/b.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; +const bLocal = 10; +//# sourceMappingURL=b.js.map +//// [/home/src/workspaces/project/b.js.map] *modified time* +//// [/home/src/workspaces/project/c.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +const a_1 = require("./a"); +exports.c = a_1.a; +//# sourceMappingURL=c.js.map +//// [/home/src/workspaces/project/c.js.map] *modified time* +//// [/home/src/workspaces/project/d.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.d = void 0; +const b_1 = require("./b"); +exports.d = b_1.b; +//# sourceMappingURL=d.js.map +//// [/home/src/workspaces/project/d.js.map] *modified time* +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"composite":true,"sourceMap":true},"referencedMap":[[4,1],[5,2]],"latestChangedDtsFile":"./d.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "composite": true, + "sourceMap": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "latestChangedDtsFile": "./d.d.ts", + "size": 1103 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [12]:: declarationMap enabling +//// [/home/src/workspaces/project/tsconfig.json] *modified* +{ + "compilerOptions": { + "composite": true, "declarationMap": true + } +} + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.d.ts] *modified* +export declare const a = 10; +//# sourceMappingURL=a.d.ts.map +//// [/home/src/workspaces/project/a.d.ts.map] *modified time* +//// [/home/src/workspaces/project/a.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 100; + +//// [/home/src/workspaces/project/b.d.ts] *modified* +export declare const b = 10; +//# sourceMappingURL=b.d.ts.map +//// [/home/src/workspaces/project/b.d.ts.map] *modified time* +//// [/home/src/workspaces/project/b.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; +const bLocal = 10; + +//// [/home/src/workspaces/project/c.d.ts] *modified* +export declare const c = 10; +//# sourceMappingURL=c.d.ts.map +//// [/home/src/workspaces/project/c.d.ts.map] *modified time* +//// [/home/src/workspaces/project/c.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +const a_1 = require("./a"); +exports.c = a_1.a; + +//// [/home/src/workspaces/project/d.d.ts] *modified* +export declare const d = 10; +//# sourceMappingURL=d.d.ts.map +//// [/home/src/workspaces/project/d.d.ts.map] *modified time* +//// [/home/src/workspaces/project/d.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.d = void 0; +const b_1 = require("./b"); +exports.d = b_1.b; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"composite":true,"declarationMap":true},"referencedMap":[[4,1],[5,2]],"latestChangedDtsFile":"./d.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "latestChangedDtsFile": "./d.d.ts", + "size": 1108 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [13]:: with sourceMap should not emit d.ts + +tsgo --sourceMap +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 100; +//# sourceMappingURL=a.js.map +//// [/home/src/workspaces/project/a.js.map] *modified time* +//// [/home/src/workspaces/project/b.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; +const bLocal = 10; +//# sourceMappingURL=b.js.map +//// [/home/src/workspaces/project/b.js.map] *modified time* +//// [/home/src/workspaces/project/c.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +const a_1 = require("./a"); +exports.c = a_1.a; +//# sourceMappingURL=c.js.map +//// [/home/src/workspaces/project/c.js.map] *modified time* +//// [/home/src/workspaces/project/d.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.d = void 0; +const b_1 = require("./b"); +exports.d = b_1.b; +//# sourceMappingURL=d.js.map +//// [/home/src/workspaces/project/d.js.map] *modified time* +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"composite":true,"declarationMap":true,"sourceMap":true},"referencedMap":[[4,1],[5,2]],"latestChangedDtsFile":"./d.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true, + "sourceMap": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "latestChangedDtsFile": "./d.d.ts", + "size": 1125 +} + +SemanticDiagnostics:: +Signatures:: diff --git a/testdata/baselines/reference/tsc/incremental/option-changes-with-incremental.js b/testdata/baselines/reference/tsc/incremental/option-changes-with-incremental.js new file mode 100644 index 0000000000..14cb4655a7 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/option-changes-with-incremental.js @@ -0,0 +1,1358 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/a.ts] *new* +export const a = 10;const aLocal = 10; +//// [/home/src/workspaces/project/b.ts] *new* +export const b = 10;const bLocal = 10; +//// [/home/src/workspaces/project/c.ts] *new* +import { a } from "./a";export const c = a; +//// [/home/src/workspaces/project/d.ts] *new* +import { b } from "./b";export const d = b; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "incremental": true, + } +} + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/a.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 10; + +//// [/home/src/workspaces/project/b.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; +const bLocal = 10; + +//// [/home/src/workspaces/project/c.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +const a_1 = require("./a"); +exports.c = a_1.a; + +//// [/home/src/workspaces/project/d.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.d = void 0; +const b_1 = require("./b"); +exports.d = b_1.b; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0","32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe"],"fileIdsList":[[2],[3]],"referencedMap":[[4,1],[5,2]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "size": 571 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/a.ts +*refresh* /home/src/workspaces/project/b.ts +*refresh* /home/src/workspaces/project/c.ts +*refresh* /home/src/workspaces/project/d.ts +Signatures:: + + +Edit [0]:: with sourceMap + +tsgo --sourceMap +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 10; +//# sourceMappingURL=a.js.map +//// [/home/src/workspaces/project/a.js.map] *new* +{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":[],"mappings":";;;AAAa,QAAA,CAAC,GAAG,EAAE,CAAC;AAAA,MAAM,MAAM,GAAG,EAAE,CAAC"} +//// [/home/src/workspaces/project/b.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; +const bLocal = 10; +//# sourceMappingURL=b.js.map +//// [/home/src/workspaces/project/b.js.map] *new* +{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":[],"mappings":";;;AAAa,QAAA,CAAC,GAAG,EAAE,CAAC;AAAA,MAAM,MAAM,GAAG,EAAE,CAAC"} +//// [/home/src/workspaces/project/c.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +const a_1 = require("./a"); +exports.c = a_1.a; +//# sourceMappingURL=c.js.map +//// [/home/src/workspaces/project/c.js.map] *new* +{"version":3,"file":"c.js","sourceRoot":"","sources":["c.ts"],"names":[],"mappings":";;;AAAA,2BAAwB;AAAa,QAAA,CAAC,GAAG,KAAC,CAAC"} +//// [/home/src/workspaces/project/d.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.d = void 0; +const b_1 = require("./b"); +exports.d = b_1.b; +//# sourceMappingURL=d.js.map +//// [/home/src/workspaces/project/d.js.map] *new* +{"version":3,"file":"d.js","sourceRoot":"","sources":["d.ts"],"names":[],"mappings":";;;AAAA,2BAAwB;AAAa,QAAA,CAAC,GAAG,KAAC,CAAC"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0","32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe"],"fileIdsList":[[2],[3]],"options":{"sourceMap":true},"referencedMap":[[4,1],[5,2]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "sourceMap": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "size": 600 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [1]:: should re-emit only js so they dont contain sourcemap + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 10; + +//// [/home/src/workspaces/project/b.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; +const bLocal = 10; + +//// [/home/src/workspaces/project/c.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +const a_1 = require("./a"); +exports.c = a_1.a; + +//// [/home/src/workspaces/project/d.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.d = void 0; +const b_1 = require("./b"); +exports.d = b_1.b; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0","32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe"],"fileIdsList":[[2],[3]],"referencedMap":[[4,1],[5,2]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "size": 571 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [2]:: with declaration, emit Dts and should not emit js + +tsgo --declaration +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.d.ts] *new* +export declare const a = 10; + +//// [/home/src/workspaces/project/b.d.ts] *new* +export declare const b = 10; + +//// [/home/src/workspaces/project/c.d.ts] *new* +export declare const c = 10; + +//// [/home/src/workspaces/project/d.d.ts] *new* +export declare const d = 10; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"declaration":true},"referencedMap":[[4,1],[5,2]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "declaration": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "size": 1054 +} + +SemanticDiagnostics:: +Signatures:: +(stored at emit) /home/src/workspaces/project/a.ts +(stored at emit) /home/src/workspaces/project/b.ts +(stored at emit) /home/src/workspaces/project/c.ts +(stored at emit) /home/src/workspaces/project/d.ts + + +Edit [3]:: with declaration and declarationMap + +tsgo --declaration --declarationMap +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.d.ts] *modified* +export declare const a = 10; +//# sourceMappingURL=a.d.ts.map +//// [/home/src/workspaces/project/a.d.ts.map] *new* +{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["a.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,CAAC,KAAK,CAAC"} +//// [/home/src/workspaces/project/b.d.ts] *modified* +export declare const b = 10; +//# sourceMappingURL=b.d.ts.map +//// [/home/src/workspaces/project/b.d.ts.map] *new* +{"version":3,"file":"b.d.ts","sourceRoot":"","sources":["b.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,CAAC,KAAK,CAAC"} +//// [/home/src/workspaces/project/c.d.ts] *modified* +export declare const c = 10; +//# sourceMappingURL=c.d.ts.map +//// [/home/src/workspaces/project/c.d.ts.map] *new* +{"version":3,"file":"c.d.ts","sourceRoot":"","sources":["c.ts"],"names":[],"mappings":"AAAwB,eAAO,MAAM,CAAC,KAAI,CAAC"} +//// [/home/src/workspaces/project/d.d.ts] *modified* +export declare const d = 10; +//# sourceMappingURL=d.d.ts.map +//// [/home/src/workspaces/project/d.d.ts.map] *new* +{"version":3,"file":"d.d.ts","sourceRoot":"","sources":["d.ts"],"names":[],"mappings":"AAAwB,eAAO,MAAM,CAAC,KAAI,CAAC"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"declaration":true,"declarationMap":true},"referencedMap":[[4,1],[5,2]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "96a22151ab87189568fe787d7ca9a7901c65d3d9789f77588629bfb0c01886c0", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "declaration": true, + "declarationMap": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "size": 1076 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [4]:: no change + +tsgo +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [5]:: local change +//// [/home/src/workspaces/project/a.ts] *modified* +export const a = 10;const aLocal = 100; + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 100; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"referencedMap":[[4,1],[5,2]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "size": 1023 +} + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/a.ts + + +Edit [6]:: with declaration and declarationMap + +tsgo --declaration --declarationMap +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.d.ts] *modified time* +//// [/home/src/workspaces/project/a.d.ts.map] *modified time* +//// [/home/src/workspaces/project/b.d.ts] *modified time* +//// [/home/src/workspaces/project/b.d.ts.map] *modified time* +//// [/home/src/workspaces/project/c.d.ts] *modified time* +//// [/home/src/workspaces/project/c.d.ts.map] *modified time* +//// [/home/src/workspaces/project/d.d.ts] *modified time* +//// [/home/src/workspaces/project/d.d.ts.map] *modified time* +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"declaration":true,"declarationMap":true},"referencedMap":[[4,1],[5,2]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "declaration": true, + "declarationMap": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "size": 1076 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [7]:: no change + +tsgo +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [8]:: with inlineSourceMap + +tsgo --inlineSourceMap +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 100; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQWEsUUFBQSxDQUFDLEdBQUcsRUFBRSxDQUFDO0FBQUEsTUFBTSxNQUFNLEdBQUcsR0FBRyxDQUFDIn0= +//// [/home/src/workspaces/project/b.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; +const bLocal = 10; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQWEsUUFBQSxDQUFDLEdBQUcsRUFBRSxDQUFDO0FBQUEsTUFBTSxNQUFNLEdBQUcsRUFBRSxDQUFDIn0= +//// [/home/src/workspaces/project/c.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +const a_1 = require("./a"); +exports.c = a_1.a; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsMkJBQXdCO0FBQWEsUUFBQSxDQUFDLEdBQUcsS0FBQyxDQUFDIn0= +//// [/home/src/workspaces/project/d.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.d = void 0; +const b_1 = require("./b"); +exports.d = b_1.b; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsMkJBQXdCO0FBQWEsUUFBQSxDQUFDLEdBQUcsS0FBQyxDQUFDIn0= +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"inlineSourceMap":true},"referencedMap":[[4,1],[5,2]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "inlineSourceMap": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "size": 1058 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [9]:: with sourceMap + +tsgo --sourceMap +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 100; +//# sourceMappingURL=a.js.map +//// [/home/src/workspaces/project/a.js.map] *modified* +{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":[],"mappings":";;;AAAa,QAAA,CAAC,GAAG,EAAE,CAAC;AAAA,MAAM,MAAM,GAAG,GAAG,CAAC"} +//// [/home/src/workspaces/project/b.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; +const bLocal = 10; +//# sourceMappingURL=b.js.map +//// [/home/src/workspaces/project/b.js.map] *modified time* +//// [/home/src/workspaces/project/c.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +const a_1 = require("./a"); +exports.c = a_1.a; +//# sourceMappingURL=c.js.map +//// [/home/src/workspaces/project/c.js.map] *modified time* +//// [/home/src/workspaces/project/d.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.d = void 0; +const b_1 = require("./b"); +exports.d = b_1.b; +//# sourceMappingURL=d.js.map +//// [/home/src/workspaces/project/d.js.map] *modified time* +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"sourceMap":true},"referencedMap":[[4,1],[5,2]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "sourceMap": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "size": 1052 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [10]:: emit js files + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; +const aLocal = 100; + +//// [/home/src/workspaces/project/b.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; +const bLocal = 10; + +//// [/home/src/workspaces/project/c.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +const a_1 = require("./a"); +exports.c = a_1.a; + +//// [/home/src/workspaces/project/d.js] *modified* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.d = void 0; +const b_1 = require("./b"); +exports.d = b_1.b; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"referencedMap":[[4,1],[5,2]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "size": 1023 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [11]:: with declaration and declarationMap + +tsgo --declaration --declarationMap +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/a.d.ts] *modified time* +//// [/home/src/workspaces/project/a.d.ts.map] *modified time* +//// [/home/src/workspaces/project/b.d.ts] *modified time* +//// [/home/src/workspaces/project/b.d.ts.map] *modified time* +//// [/home/src/workspaces/project/c.d.ts] *modified time* +//// [/home/src/workspaces/project/c.d.ts.map] *modified time* +//// [/home/src/workspaces/project/d.d.ts] *modified time* +//// [/home/src/workspaces/project/d.d.ts.map] *modified time* +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./a.ts","./b.ts","./c.ts","./d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8","signature":"0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff","impliedNodeFormat":1},{"version":"32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c","signature":"ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94","impliedNodeFormat":1},{"version":"35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28","signature":"24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058","impliedNodeFormat":1},{"version":"d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe","signature":"a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"declaration":true,"declarationMap":true},"referencedMap":[[4,1],[5,2]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./a.ts", + "./b.ts", + "./c.ts", + "./d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "cbaad6c0b570d95cb0de11d496cbcd960ddb6152b5de5556b85c9ea4b534aef8", + "signature": "0294d0461fc808c98674b1a1a77c26cc9b2958e26ddda58d3e9ee7b806b1d8ff", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./b.ts", + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "32fe266f005e277f5202e590b14e89cb739c383bde7023723c733cd6ea51078c", + "signature": "ba43aba9e71b3a4d220f005a5c1ec7f11ca438d3f3638626d9f13d0fa36cef94", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./c.ts", + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "35c02fa2cf84a9292fe046276ac7aaee79b6335851c67de7218b84d604624c28", + "signature": "24f027dec9d58d543081d86b05f3c4eb7b97eaf877bbb857a5091eb542bbd058", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./d.ts", + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "d7d9eaee18bfcd1d2fe8ea902607b6dc29457bfe9ef7c2f0a86ac101074b64fe", + "signature": "a7d8244d51b9b6a74f3b3e19a8ebe49786ee8736039a7c03ddb43448a17e7bf5", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./a.ts" + ], + [ + "./b.ts" + ] + ], + "options": { + "declaration": true, + "declarationMap": true + }, + "referencedMap": { + "./c.ts": [ + "./a.ts" + ], + "./d.ts": [ + "./b.ts" + ] + }, + "size": 1076 +} + +SemanticDiagnostics:: +Signatures:: + + +Edit [12]:: with declaration and declarationMap, should not re-emit + +tsgo --declaration --declarationMap +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: diff --git a/testdata/baselines/reference/tsc/incremental/react-jsx-emit-mode-with-no-backing-types-found-doesnt-crash-under---strict.js b/testdata/baselines/reference/tsc/incremental/react-jsx-emit-mode-with-no-backing-types-found-doesnt-crash-under---strict.js new file mode 100644 index 0000000000..230eac62a4 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/react-jsx-emit-mode-with-no-backing-types-found-doesnt-crash-under---strict.js @@ -0,0 +1,141 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/node_modules/@types/react/index.d.ts] *new* +export {}; +declare global { + namespace JSX { + interface Element {} + interface IntrinsicElements { + div: { + propA?: boolean; + }; + } + } +} +//// [/home/src/workspaces/project/node_modules/react/jsx-runtime.js] *new* +export {} +//// [/home/src/workspaces/project/src/index.tsx] *new* +export const App = () =>
; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "module": "commonjs", + "jsx": "react-jsx", + "incremental": true, + "jsxImportSource": "react" + } +} + +tsgo --strict +ExitStatus:: DiagnosticsPresent_OutputsGenerated +Output:: +src/index.tsx:1:26 - error TS7016: Could not find a declaration file for module 'react/jsx-runtime'. '/home/src/workspaces/project/node_modules/react/jsx-runtime.js' implicitly has an 'any' type. + +1 export const App = () =>
; +   ~~~~~~~~~~~~~~~~~~~~~~~~ + + +Found 1 error in src/index.tsx:1 + +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/src/index.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.App = void 0; +const jsx_runtime_1 = require("react/jsx-runtime"); +const App = () => jsx_runtime_1.jsx("div", { propA: true }); +exports.App = App; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./src/index.tsx","./node_modules/@types/react/index.d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"0f825b9ea7708adb1fe25efed7859af428d3ceb0d5df7f67f0a8c9eed854825a",{"version":"3301e1e26bf8906b220ec647394a80968ea8de76669750be485eeb41cf9e8679","affectsGlobalScope":true,"impliedNodeFormat":1}],"options":{"jsx":4,"jsxImportSource":"react","module":1,"strict":true},"semanticDiagnosticsPerFile":[[2,[{"pos":25,"end":49,"code":7016,"category":1,"message":"Could not find a declaration file for module 'react/jsx-runtime'. '/home/src/workspaces/project/node_modules/react/jsx-runtime.js' implicitly has an 'any' type."}]]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./src/index.tsx", + "./node_modules/@types/react/index.d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/index.tsx", + "version": "0f825b9ea7708adb1fe25efed7859af428d3ceb0d5df7f67f0a8c9eed854825a", + "signature": "0f825b9ea7708adb1fe25efed7859af428d3ceb0d5df7f67f0a8c9eed854825a", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./node_modules/@types/react/index.d.ts", + "version": "3301e1e26bf8906b220ec647394a80968ea8de76669750be485eeb41cf9e8679", + "signature": "3301e1e26bf8906b220ec647394a80968ea8de76669750be485eeb41cf9e8679", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "3301e1e26bf8906b220ec647394a80968ea8de76669750be485eeb41cf9e8679", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "options": { + "jsx": 4, + "jsxImportSource": "react", + "module": 1, + "strict": true + }, + "semanticDiagnosticsPerFile": [ + [ + "./src/index.tsx", + [ + { + "pos": 25, + "end": 49, + "code": 7016, + "category": 1, + "message": "Could not find a declaration file for module 'react/jsx-runtime'. '/home/src/workspaces/project/node_modules/react/jsx-runtime.js' implicitly has an 'any' type." + } + ] + ] + ], + "size": 792 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/src/index.tsx +*refresh* /home/src/workspaces/project/node_modules/@types/react/index.d.ts +Signatures:: diff --git a/testdata/baselines/reference/tsc/incremental/react-jsx-emit-mode-with-no-backing-types-found-doesnt-crash.js b/testdata/baselines/reference/tsc/incremental/react-jsx-emit-mode-with-no-backing-types-found-doesnt-crash.js new file mode 100644 index 0000000000..091c815849 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/react-jsx-emit-mode-with-no-backing-types-found-doesnt-crash.js @@ -0,0 +1,118 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/node_modules/@types/react/index.d.ts] *new* +export {}; +declare global { + namespace JSX { + interface Element {} + interface IntrinsicElements { + div: { + propA?: boolean; + }; + } + } +} +//// [/home/src/workspaces/project/node_modules/react/jsx-runtime.js] *new* +export {} +//// [/home/src/workspaces/project/src/index.tsx] *new* +export const App = () =>
; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "module": "commonjs", + "jsx": "react-jsx", + "incremental": true, + "jsxImportSource": "react" + } +} + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/src/index.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.App = void 0; +const jsx_runtime_1 = require("react/jsx-runtime"); +const App = () => jsx_runtime_1.jsx("div", { propA: true }); +exports.App = App; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./src/index.tsx","./node_modules/@types/react/index.d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"0f825b9ea7708adb1fe25efed7859af428d3ceb0d5df7f67f0a8c9eed854825a",{"version":"3301e1e26bf8906b220ec647394a80968ea8de76669750be485eeb41cf9e8679","affectsGlobalScope":true,"impliedNodeFormat":1}],"options":{"jsx":4,"jsxImportSource":"react","module":1}} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./src/index.tsx", + "./node_modules/@types/react/index.d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/index.tsx", + "version": "0f825b9ea7708adb1fe25efed7859af428d3ceb0d5df7f67f0a8c9eed854825a", + "signature": "0f825b9ea7708adb1fe25efed7859af428d3ceb0d5df7f67f0a8c9eed854825a", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./node_modules/@types/react/index.d.ts", + "version": "3301e1e26bf8906b220ec647394a80968ea8de76669750be485eeb41cf9e8679", + "signature": "3301e1e26bf8906b220ec647394a80968ea8de76669750be485eeb41cf9e8679", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "3301e1e26bf8906b220ec647394a80968ea8de76669750be485eeb41cf9e8679", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "options": { + "jsx": 4, + "jsxImportSource": "react", + "module": 1 + }, + "size": 523 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/src/index.tsx +*refresh* /home/src/workspaces/project/node_modules/@types/react/index.d.ts +Signatures:: diff --git a/testdata/baselines/reference/tsc/incremental/serializing-composite-project.js b/testdata/baselines/reference/tsc/incremental/serializing-composite-project.js new file mode 100644 index 0000000000..a148974652 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/serializing-composite-project.js @@ -0,0 +1,116 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/index.tsx] *new* +export const a = 1; +//// [/home/src/workspaces/project/other.ts] *new* +export const b = 2; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "strict": true, + "module": "esnext", + }, +} + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/index.d.ts] *new* +export declare const a = 1; + +//// [/home/src/workspaces/project/index.js] *new* +export const a = 1; + +//// [/home/src/workspaces/project/other.d.ts] *new* +export declare const b = 2; + +//// [/home/src/workspaces/project/other.js] *new* +export const b = 2; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./index.tsx","./other.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"683314ed22112e8dea8095c8c6173afa2c61279f5fe07968ebe0e21fff16871d","signature":"f0f1286d442f3c09fa07d37db7d31755cb3761daed3c8008fbfce412770425c6","impliedNodeFormat":1},{"version":"34f0f66ce649a0df0d3d5bad537c3b867b11b2fbeb5eee37e1c75a795544a4ed","signature":"0fb7bb75ad82d403bd7ba1f151c0297ef6a9167d0039e90a9067289387a719a7","impliedNodeFormat":1}],"options":{"composite":true,"module":99,"strict":true},"latestChangedDtsFile":"./other.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./index.tsx", + "./other.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./index.tsx", + "version": "683314ed22112e8dea8095c8c6173afa2c61279f5fe07968ebe0e21fff16871d", + "signature": "f0f1286d442f3c09fa07d37db7d31755cb3761daed3c8008fbfce412770425c6", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "683314ed22112e8dea8095c8c6173afa2c61279f5fe07968ebe0e21fff16871d", + "signature": "f0f1286d442f3c09fa07d37db7d31755cb3761daed3c8008fbfce412770425c6", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./other.ts", + "version": "34f0f66ce649a0df0d3d5bad537c3b867b11b2fbeb5eee37e1c75a795544a4ed", + "signature": "0fb7bb75ad82d403bd7ba1f151c0297ef6a9167d0039e90a9067289387a719a7", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "34f0f66ce649a0df0d3d5bad537c3b867b11b2fbeb5eee37e1c75a795544a4ed", + "signature": "0fb7bb75ad82d403bd7ba1f151c0297ef6a9167d0039e90a9067289387a719a7", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "module": 99, + "strict": true + }, + "latestChangedDtsFile": "./other.d.ts", + "size": 693 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/index.tsx +*refresh* /home/src/workspaces/project/other.ts +Signatures:: +(stored at emit) /home/src/workspaces/project/index.tsx +(stored at emit) /home/src/workspaces/project/other.ts diff --git a/testdata/baselines/reference/tsc/incremental/serializing-error-chain.js b/testdata/baselines/reference/tsc/incremental/serializing-error-chain.js new file mode 100644 index 0000000000..3b08685838 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/serializing-error-chain.js @@ -0,0 +1,204 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/index.tsx] *new* +declare namespace JSX { + interface ElementChildrenAttribute { children: {}; } + interface IntrinsicElements { div: {} } +} + +declare var React: any; + +declare function Component(props: never): any; +declare function Component(props: { children?: number }): any; +( +
+
+) +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "incremental": true, + "strict": true, + "jsx": "react", + "module": "esnext", + }, +} + +tsgo +ExitStatus:: DiagnosticsPresent_OutputsGenerated +Output:: +index.tsx:10:3 - error TS2769: No overload matches this call. + The last overload gave the following error. + Type '{ children: any[]; }' is not assignable to type '{ children?: number | undefined; }'. + Types of property 'children' are incompatible. + Type 'any[]' is not assignable to type 'number'. + +10 ( +   ~~~~~~~~~ + + index.tsx:9:18 - The last overload is declared here. + 9 declare function Component(props: { children?: number }): any; +    ~~~~~~~~~ + + +Found 1 error in index.tsx:10 + +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/index.js] *new* +(React.createElement(Component, null, React.createElement("div", null), React.createElement("div", null))); + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./index.tsx"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"cbfe2ae7fcc8b0f6fb65b0cfded75399938c02edb19173808c499187b76be6cb","affectsGlobalScope":true,"impliedNodeFormat":1}],"options":{"jsx":3,"module":99,"strict":true},"semanticDiagnosticsPerFile":[[2,[{"pos":265,"end":274,"code":2769,"category":1,"message":"No overload matches this call.","messageChain":[{"pos":265,"end":274,"code":2770,"category":1,"message":"The last overload gave the following error.","messageChain":[{"pos":265,"end":274,"code":2322,"category":1,"message":"Type '{ children: any[]; }' is not assignable to type '{ children?: number | undefined; }'.","messageChain":[{"pos":265,"end":274,"code":2326,"category":1,"message":"Types of property 'children' are incompatible.","messageChain":[{"pos":265,"end":274,"code":2322,"category":1,"message":"Type 'any[]' is not assignable to type 'number'."}]}]}]}],"relatedInformation":[{"pos":217,"end":226,"code":2771,"category":1,"message":"The last overload is declared here."}]}]]]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./index.tsx" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./index.tsx", + "version": "cbfe2ae7fcc8b0f6fb65b0cfded75399938c02edb19173808c499187b76be6cb", + "signature": "cbfe2ae7fcc8b0f6fb65b0cfded75399938c02edb19173808c499187b76be6cb", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "cbfe2ae7fcc8b0f6fb65b0cfded75399938c02edb19173808c499187b76be6cb", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "options": { + "jsx": 3, + "module": 99, + "strict": true + }, + "semanticDiagnosticsPerFile": [ + [ + "./index.tsx", + [ + { + "pos": 265, + "end": 274, + "code": 2769, + "category": 1, + "message": "No overload matches this call.", + "messageChain": [ + { + "pos": 265, + "end": 274, + "code": 2770, + "category": 1, + "message": "The last overload gave the following error.", + "messageChain": [ + { + "pos": 265, + "end": 274, + "code": 2322, + "category": 1, + "message": "Type '{ children: any[]; }' is not assignable to type '{ children?: number | undefined; }'.", + "messageChain": [ + { + "pos": 265, + "end": 274, + "code": 2326, + "category": 1, + "message": "Types of property 'children' are incompatible.", + "messageChain": [ + { + "pos": 265, + "end": 274, + "code": 2322, + "category": 1, + "message": "Type 'any[]' is not assignable to type 'number'." + } + ] + } + ] + } + ] + } + ], + "relatedInformation": [ + { + "pos": 217, + "end": 226, + "code": 2771, + "category": 1, + "message": "The last overload is declared here." + } + ] + } + ] + ] + ], + "size": 1181 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/index.tsx +Signatures:: + + +Edit [0]:: no change + +tsgo +ExitStatus:: DiagnosticsPresent_OutputsGenerated +Output:: +index.tsx:10:3 - error TS2769: No overload matches this call. + The last overload gave the following error. + Type '{ children: any[]; }' is not assignable to type '{ children?: number | undefined; }'. + Types of property 'children' are incompatible. + Type 'any[]' is not assignable to type 'number'. + +10 ( +   ~~~~~~~~~ + + index.tsx:9:18 - The last overload is declared here. + 9 declare function Component(props: { children?: number }): any; +    ~~~~~~~~~ + + +Found 1 error in index.tsx:10 + + +SemanticDiagnostics:: +Signatures:: diff --git a/testdata/baselines/reference/tsc/incremental/tsbuildinfo-has-error.js b/testdata/baselines/reference/tsc/incremental/tsbuildinfo-has-error.js new file mode 100644 index 0000000000..5cc8b88155 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/tsbuildinfo-has-error.js @@ -0,0 +1,96 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/main.ts] *new* +export const x = 10; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +Some random string + +tsgo -i +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +exports.x = 10; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./main.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6"]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./main.ts", + "version": "03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6", + "signature": "03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6", + "impliedNodeFormat": "CommonJS" + } + ], + "size": 292 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/main.ts +Signatures:: + + +Edit [0]:: tsbuildinfo written has error +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +Some random string{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./main.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6"]} + +tsgo -i +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/main.js] *modified time* +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./main.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6"]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified time* + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/main.ts +Signatures:: diff --git a/testdata/baselines/reference/tsc/incremental/when-file-is-deleted.js b/testdata/baselines/reference/tsc/incremental/when-file-is-deleted.js new file mode 100644 index 0000000000..c61ce7ee47 --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/when-file-is-deleted.js @@ -0,0 +1,178 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/file1.ts] *new* +export class C { } +//// [/home/src/workspaces/project/file2.ts] *new* +export class D { } +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "outDir" + } +} + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/outDir/file1.d.ts] *new* +export declare class C { +} + +//// [/home/src/workspaces/project/outDir/file1.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +class C { +} +exports.C = C; + +//// [/home/src/workspaces/project/outDir/file2.d.ts] *new* +export declare class D { +} + +//// [/home/src/workspaces/project/outDir/file2.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.D = void 0; +class D { +} +exports.D = D; + +//// [/home/src/workspaces/project/outDir/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../../tslibs/TS/Lib/lib.d.ts","../file1.ts","../file2.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e8197812b523db314f9f43881cab045172bec1a6893c27b62a52b128afbb19da","signature":"33031a47f740dde897da491c7c6ac0ef2224f9c807448ba058aadba8abd00433","impliedNodeFormat":1},{"version":"2d42470676839be6ca4923b34e799e3a318398eb2ff7c6273c676358d80093e6","signature":"f7f62800d2d53e363dcd48e24d95af396e4f0bbafc1713aca098f7644aeb0331","impliedNodeFormat":1}],"options":{"composite":true,"outDir":"./"},"latestChangedDtsFile":"./file2.d.ts"} +//// [/home/src/workspaces/project/outDir/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../../tslibs/TS/Lib/lib.d.ts", + "../file1.ts", + "../file2.ts" + ], + "fileInfos": [ + { + "fileName": "../../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../file1.ts", + "version": "e8197812b523db314f9f43881cab045172bec1a6893c27b62a52b128afbb19da", + "signature": "33031a47f740dde897da491c7c6ac0ef2224f9c807448ba058aadba8abd00433", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "e8197812b523db314f9f43881cab045172bec1a6893c27b62a52b128afbb19da", + "signature": "33031a47f740dde897da491c7c6ac0ef2224f9c807448ba058aadba8abd00433", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../file2.ts", + "version": "2d42470676839be6ca4923b34e799e3a318398eb2ff7c6273c676358d80093e6", + "signature": "f7f62800d2d53e363dcd48e24d95af396e4f0bbafc1713aca098f7644aeb0331", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "2d42470676839be6ca4923b34e799e3a318398eb2ff7c6273c676358d80093e6", + "signature": "f7f62800d2d53e363dcd48e24d95af396e4f0bbafc1713aca098f7644aeb0331", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "outDir": "./" + }, + "latestChangedDtsFile": "./file2.d.ts", + "size": 685 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/file1.ts +*refresh* /home/src/workspaces/project/file2.ts +Signatures:: +(stored at emit) /home/src/workspaces/project/file1.ts +(stored at emit) /home/src/workspaces/project/file2.ts + + +Edit [0]:: delete file with imports +//// [/home/src/workspaces/project/file2.ts] *deleted* + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/outDir/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../../tslibs/TS/Lib/lib.d.ts","../file1.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e8197812b523db314f9f43881cab045172bec1a6893c27b62a52b128afbb19da","signature":"33031a47f740dde897da491c7c6ac0ef2224f9c807448ba058aadba8abd00433","impliedNodeFormat":1}],"options":{"composite":true,"outDir":"./"},"latestChangedDtsFile":"./file2.d.ts"} +//// [/home/src/workspaces/project/outDir/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../../tslibs/TS/Lib/lib.d.ts", + "../file1.ts" + ], + "fileInfos": [ + { + "fileName": "../../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../file1.ts", + "version": "e8197812b523db314f9f43881cab045172bec1a6893c27b62a52b128afbb19da", + "signature": "33031a47f740dde897da491c7c6ac0ef2224f9c807448ba058aadba8abd00433", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "e8197812b523db314f9f43881cab045172bec1a6893c27b62a52b128afbb19da", + "signature": "33031a47f740dde897da491c7c6ac0ef2224f9c807448ba058aadba8abd00433", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "outDir": "./" + }, + "latestChangedDtsFile": "./file2.d.ts", + "size": 491 +} + +SemanticDiagnostics:: +Signatures:: diff --git a/testdata/baselines/reference/tsc/incremental/when-global-file-is-added,-the-signatures-are-updated.js b/testdata/baselines/reference/tsc/incremental/when-global-file-is-added,-the-signatures-are-updated.js new file mode 100644 index 0000000000..0f911b20fe --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/when-global-file-is-added,-the-signatures-are-updated.js @@ -0,0 +1,831 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/src/anotherFileWithSameReferenes.ts] *new* +/// +/// +function anotherFileWithSameReferenes() { } +//// [/home/src/workspaces/project/src/filePresent.ts] *new* +function something() { return 10; } +//// [/home/src/workspaces/project/src/main.ts] *new* +/// +/// +function main() { } +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { "composite": true }, + "include": ["src/**/*.ts"], +} + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/src/anotherFileWithSameReferenes.d.ts] *new* +declare function anotherFileWithSameReferenes(): void; + +//// [/home/src/workspaces/project/src/anotherFileWithSameReferenes.js] *new* +/// +/// +function anotherFileWithSameReferenes() { } + +//// [/home/src/workspaces/project/src/filePresent.d.ts] *new* +declare function something(): number; + +//// [/home/src/workspaces/project/src/filePresent.js] *new* +function something() { return 10; } + +//// [/home/src/workspaces/project/src/main.d.ts] *new* +declare function main(): void; + +//// [/home/src/workspaces/project/src/main.js] *new* +/// +/// +function main() { } + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./src/filePresent.ts","./src/anotherFileWithSameReferenes.ts","./src/main.ts","./src/fileNotFound.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5","signature":"4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d","signature":"d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"9f4be7f0076e4a80708374aafbed16d8c40107ca5556a6155e1c3b9d2a4bfd1c","signature":"ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896","affectsGlobalScope":true,"impliedNodeFormat":1}],"fileIdsList":[[2,5]],"options":{"composite":true},"referencedMap":[[3,1],[4,1]],"latestChangedDtsFile":"./src/main.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./src/filePresent.ts", + "./src/anotherFileWithSameReferenes.ts", + "./src/main.ts", + "./src/fileNotFound.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/filePresent.ts", + "version": "8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5", + "signature": "4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5", + "signature": "4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/anotherFileWithSameReferenes.ts", + "version": "552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d", + "signature": "d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d", + "signature": "d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/main.ts", + "version": "9f4be7f0076e4a80708374aafbed16d8c40107ca5556a6155e1c3b9d2a4bfd1c", + "signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "9f4be7f0076e4a80708374aafbed16d8c40107ca5556a6155e1c3b9d2a4bfd1c", + "signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./src/anotherFileWithSameReferenes.ts": [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ], + "./src/main.ts": [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ] + }, + "latestChangedDtsFile": "./src/main.d.ts", + "size": 1056 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/src/filePresent.ts +*refresh* /home/src/workspaces/project/src/anotherFileWithSameReferenes.ts +*refresh* /home/src/workspaces/project/src/main.ts +Signatures:: +(stored at emit) /home/src/workspaces/project/src/filePresent.ts +(stored at emit) /home/src/workspaces/project/src/anotherFileWithSameReferenes.ts +(stored at emit) /home/src/workspaces/project/src/main.ts + + +Edit [0]:: no change + +tsgo +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [1]:: Modify main file +//// [/home/src/workspaces/project/src/main.ts] *modified* +/// +/// +function main() { }something(); + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/src/main.js] *modified* +/// +/// +function main() { } +something(); + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./src/filePresent.ts","./src/anotherFileWithSameReferenes.ts","./src/main.ts","./src/fileNotFound.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5","signature":"4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d","signature":"d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"958bd60a28f4c68b48b6efabb4498a30aae1c5f7207bbc2ef3e6b639a76075e3","signature":"ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896","affectsGlobalScope":true,"impliedNodeFormat":1}],"fileIdsList":[[2,5]],"options":{"composite":true},"referencedMap":[[3,1],[4,1]],"latestChangedDtsFile":"./src/main.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./src/filePresent.ts", + "./src/anotherFileWithSameReferenes.ts", + "./src/main.ts", + "./src/fileNotFound.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/filePresent.ts", + "version": "8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5", + "signature": "4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5", + "signature": "4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/anotherFileWithSameReferenes.ts", + "version": "552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d", + "signature": "d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d", + "signature": "d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/main.ts", + "version": "958bd60a28f4c68b48b6efabb4498a30aae1c5f7207bbc2ef3e6b639a76075e3", + "signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "958bd60a28f4c68b48b6efabb4498a30aae1c5f7207bbc2ef3e6b639a76075e3", + "signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./src/anotherFileWithSameReferenes.ts": [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ], + "./src/main.ts": [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ] + }, + "latestChangedDtsFile": "./src/main.d.ts", + "size": 1056 +} + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/src/main.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/src/main.ts + + +Edit [2]:: Modify main file again +//// [/home/src/workspaces/project/src/main.ts] *modified* +/// +/// +function main() { }something();something(); + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/src/main.js] *modified* +/// +/// +function main() { } +something(); +something(); + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./src/filePresent.ts","./src/anotherFileWithSameReferenes.ts","./src/main.ts","./src/fileNotFound.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5","signature":"4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d","signature":"d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b6d6648dd2368dd226aaed824ed05d767f851bc8c7346baf6478588fc8c53f6d","signature":"ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896","affectsGlobalScope":true,"impliedNodeFormat":1}],"fileIdsList":[[2,5]],"options":{"composite":true},"referencedMap":[[3,1],[4,1]],"latestChangedDtsFile":"./src/main.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./src/filePresent.ts", + "./src/anotherFileWithSameReferenes.ts", + "./src/main.ts", + "./src/fileNotFound.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/filePresent.ts", + "version": "8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5", + "signature": "4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5", + "signature": "4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/anotherFileWithSameReferenes.ts", + "version": "552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d", + "signature": "d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d", + "signature": "d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/main.ts", + "version": "b6d6648dd2368dd226aaed824ed05d767f851bc8c7346baf6478588fc8c53f6d", + "signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "b6d6648dd2368dd226aaed824ed05d767f851bc8c7346baf6478588fc8c53f6d", + "signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./src/anotherFileWithSameReferenes.ts": [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ], + "./src/main.ts": [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ] + }, + "latestChangedDtsFile": "./src/main.d.ts", + "size": 1056 +} + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/src/main.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/src/main.ts + + +Edit [3]:: Add new file and update main file +//// [/home/src/workspaces/project/src/main.ts] *modified* +/// +/// +/// +function main() { }something();something();foo(); +//// [/home/src/workspaces/project/src/newFile.ts] *new* +function foo() { return 20; } + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/src/main.js] *modified* +/// +/// +/// +function main() { } +something(); +something(); +foo(); + +//// [/home/src/workspaces/project/src/newFile.d.ts] *new* +declare function foo(): number; + +//// [/home/src/workspaces/project/src/newFile.js] *new* +function foo() { return 20; } + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./src/filePresent.ts","./src/anotherFileWithSameReferenes.ts","./src/newFile.ts","./src/main.ts","./src/fileNotFound.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5","signature":"4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d","signature":"d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a4c88e3619994da0f5e4da2dc210f6038e710b9bb831003767da68c882137fb1","signature":"f0d67d5e01f8fff5f52028627fc0fb5a78b24df03e482ddac513fa1f873934ee","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"930f3c7023d87506648db3c352e86f7a2baf38e91f743773fddf4a520aff393a","signature":"ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896","affectsGlobalScope":true,"impliedNodeFormat":1}],"fileIdsList":[[2,6],[2,4,6]],"options":{"composite":true},"referencedMap":[[3,1],[5,2]],"latestChangedDtsFile":"./src/newFile.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./src/filePresent.ts", + "./src/anotherFileWithSameReferenes.ts", + "./src/newFile.ts", + "./src/main.ts", + "./src/fileNotFound.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/filePresent.ts", + "version": "8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5", + "signature": "4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5", + "signature": "4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/anotherFileWithSameReferenes.ts", + "version": "552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d", + "signature": "d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d", + "signature": "d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/newFile.ts", + "version": "a4c88e3619994da0f5e4da2dc210f6038e710b9bb831003767da68c882137fb1", + "signature": "f0d67d5e01f8fff5f52028627fc0fb5a78b24df03e482ddac513fa1f873934ee", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "a4c88e3619994da0f5e4da2dc210f6038e710b9bb831003767da68c882137fb1", + "signature": "f0d67d5e01f8fff5f52028627fc0fb5a78b24df03e482ddac513fa1f873934ee", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/main.ts", + "version": "930f3c7023d87506648db3c352e86f7a2baf38e91f743773fddf4a520aff393a", + "signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "930f3c7023d87506648db3c352e86f7a2baf38e91f743773fddf4a520aff393a", + "signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ], + [ + "./src/filePresent.ts", + "./src/newFile.ts", + "./src/fileNotFound.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./src/anotherFileWithSameReferenes.ts": [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ], + "./src/main.ts": [ + "./src/filePresent.ts", + "./src/newFile.ts", + "./src/fileNotFound.ts" + ] + }, + "latestChangedDtsFile": "./src/newFile.d.ts", + "size": 1292 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/src/newFile.ts +*refresh* /home/src/workspaces/project/src/main.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/src/newFile.ts +(computed .d.ts) /home/src/workspaces/project/src/main.ts + + +Edit [4]:: Write file that could not be resolved +//// [/home/src/workspaces/project/src/fileNotFound.ts] *new* +function something2() { return 20; } + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/src/anotherFileWithSameReferenes.js] *modified time* +//// [/home/src/workspaces/project/src/fileNotFound.d.ts] *new* +declare function something2(): number; + +//// [/home/src/workspaces/project/src/fileNotFound.js] *new* +function something2() { return 20; } + +//// [/home/src/workspaces/project/src/main.js] *modified time* +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./src/filePresent.ts","./src/fileNotFound.ts","./src/anotherFileWithSameReferenes.ts","./src/newFile.ts","./src/main.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5","signature":"4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6c5b229cbf53b2c6867ab14b139eeac37ed3ec0c1564ba561f7faa869aaba32c","signature":"14ba6a62cd6d3e47b343358b2c3e1b7e34b488b489f0d9b915c796cd2e61bbad","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d","signature":"d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a4c88e3619994da0f5e4da2dc210f6038e710b9bb831003767da68c882137fb1","signature":"f0d67d5e01f8fff5f52028627fc0fb5a78b24df03e482ddac513fa1f873934ee","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"930f3c7023d87506648db3c352e86f7a2baf38e91f743773fddf4a520aff393a","signature":"ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896","affectsGlobalScope":true,"impliedNodeFormat":1}],"fileIdsList":[[2,3],[2,3,5]],"options":{"composite":true},"referencedMap":[[4,1],[6,2]],"latestChangedDtsFile":"./src/fileNotFound.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./src/filePresent.ts", + "./src/fileNotFound.ts", + "./src/anotherFileWithSameReferenes.ts", + "./src/newFile.ts", + "./src/main.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/filePresent.ts", + "version": "8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5", + "signature": "4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5", + "signature": "4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/fileNotFound.ts", + "version": "6c5b229cbf53b2c6867ab14b139eeac37ed3ec0c1564ba561f7faa869aaba32c", + "signature": "14ba6a62cd6d3e47b343358b2c3e1b7e34b488b489f0d9b915c796cd2e61bbad", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "6c5b229cbf53b2c6867ab14b139eeac37ed3ec0c1564ba561f7faa869aaba32c", + "signature": "14ba6a62cd6d3e47b343358b2c3e1b7e34b488b489f0d9b915c796cd2e61bbad", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/anotherFileWithSameReferenes.ts", + "version": "552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d", + "signature": "d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d", + "signature": "d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/newFile.ts", + "version": "a4c88e3619994da0f5e4da2dc210f6038e710b9bb831003767da68c882137fb1", + "signature": "f0d67d5e01f8fff5f52028627fc0fb5a78b24df03e482ddac513fa1f873934ee", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "a4c88e3619994da0f5e4da2dc210f6038e710b9bb831003767da68c882137fb1", + "signature": "f0d67d5e01f8fff5f52028627fc0fb5a78b24df03e482ddac513fa1f873934ee", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/main.ts", + "version": "930f3c7023d87506648db3c352e86f7a2baf38e91f743773fddf4a520aff393a", + "signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "930f3c7023d87506648db3c352e86f7a2baf38e91f743773fddf4a520aff393a", + "signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ], + [ + "./src/filePresent.ts", + "./src/fileNotFound.ts", + "./src/newFile.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./src/anotherFileWithSameReferenes.ts": [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ], + "./src/main.ts": [ + "./src/filePresent.ts", + "./src/fileNotFound.ts", + "./src/newFile.ts" + ] + }, + "latestChangedDtsFile": "./src/fileNotFound.d.ts", + "size": 1503 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/src/fileNotFound.ts +*refresh* /home/src/workspaces/project/src/anotherFileWithSameReferenes.ts +*refresh* /home/src/workspaces/project/src/main.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/src/fileNotFound.ts +(computed .d.ts) /home/src/workspaces/project/src/anotherFileWithSameReferenes.ts +(computed .d.ts) /home/src/workspaces/project/src/main.ts + + +Edit [5]:: Modify main file +//// [/home/src/workspaces/project/src/main.ts] *modified* +/// +/// +/// +function main() { }something();something();foo();something(); + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/src/main.js] *modified* +/// +/// +/// +function main() { } +something(); +something(); +foo(); +something(); + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./src/filePresent.ts","./src/fileNotFound.ts","./src/anotherFileWithSameReferenes.ts","./src/newFile.ts","./src/main.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5","signature":"4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6c5b229cbf53b2c6867ab14b139eeac37ed3ec0c1564ba561f7faa869aaba32c","signature":"14ba6a62cd6d3e47b343358b2c3e1b7e34b488b489f0d9b915c796cd2e61bbad","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d","signature":"d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a4c88e3619994da0f5e4da2dc210f6038e710b9bb831003767da68c882137fb1","signature":"f0d67d5e01f8fff5f52028627fc0fb5a78b24df03e482ddac513fa1f873934ee","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a8ae65557452d18998812e950c84bacd81f817ef323ccfe777c3b5450519c167","signature":"ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896","affectsGlobalScope":true,"impliedNodeFormat":1}],"fileIdsList":[[2,3],[2,3,5]],"options":{"composite":true},"referencedMap":[[4,1],[6,2]],"latestChangedDtsFile":"./src/fileNotFound.d.ts"} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./src/filePresent.ts", + "./src/fileNotFound.ts", + "./src/anotherFileWithSameReferenes.ts", + "./src/newFile.ts", + "./src/main.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/filePresent.ts", + "version": "8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5", + "signature": "4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8f597c315d3bba69a79551601042fdcfe05d35f763762db4908b255c7f17c7d5", + "signature": "4f3eeb0c183707d474ecb20d55e49f78d8a3fa3ac388d3b7a318d603ad8478c2", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/fileNotFound.ts", + "version": "6c5b229cbf53b2c6867ab14b139eeac37ed3ec0c1564ba561f7faa869aaba32c", + "signature": "14ba6a62cd6d3e47b343358b2c3e1b7e34b488b489f0d9b915c796cd2e61bbad", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "6c5b229cbf53b2c6867ab14b139eeac37ed3ec0c1564ba561f7faa869aaba32c", + "signature": "14ba6a62cd6d3e47b343358b2c3e1b7e34b488b489f0d9b915c796cd2e61bbad", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/anotherFileWithSameReferenes.ts", + "version": "552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d", + "signature": "d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "552b902790cfbb88a7ed6a7b04b24bb18c58a7f52bcfe7808912e126359e258d", + "signature": "d4dbe375786b0b36d5425a70f140bbb3d377883027d2fa29aa022a2bd446fbda", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/newFile.ts", + "version": "a4c88e3619994da0f5e4da2dc210f6038e710b9bb831003767da68c882137fb1", + "signature": "f0d67d5e01f8fff5f52028627fc0fb5a78b24df03e482ddac513fa1f873934ee", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "a4c88e3619994da0f5e4da2dc210f6038e710b9bb831003767da68c882137fb1", + "signature": "f0d67d5e01f8fff5f52028627fc0fb5a78b24df03e482ddac513fa1f873934ee", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/main.ts", + "version": "a8ae65557452d18998812e950c84bacd81f817ef323ccfe777c3b5450519c167", + "signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "a8ae65557452d18998812e950c84bacd81f817ef323ccfe777c3b5450519c167", + "signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ], + [ + "./src/filePresent.ts", + "./src/fileNotFound.ts", + "./src/newFile.ts" + ] + ], + "options": { + "composite": true + }, + "referencedMap": { + "./src/anotherFileWithSameReferenes.ts": [ + "./src/filePresent.ts", + "./src/fileNotFound.ts" + ], + "./src/main.ts": [ + "./src/filePresent.ts", + "./src/fileNotFound.ts", + "./src/newFile.ts" + ] + }, + "latestChangedDtsFile": "./src/fileNotFound.d.ts", + "size": 1503 +} + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/src/main.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/src/main.ts diff --git a/testdata/baselines/reference/tsc/incremental/when-passing-filename-for-buildinfo-on-commandline.js b/testdata/baselines/reference/tsc/incremental/when-passing-filename-for-buildinfo-on-commandline.js new file mode 100644 index 0000000000..bfb383dd4d --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/when-passing-filename-for-buildinfo-on-commandline.js @@ -0,0 +1,99 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/src/main.ts] *new* +export const x = 10; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs" + }, + "include": [ + "src/**/*.ts" + ], +} + +tsgo --incremental --tsBuildInfoFile .tsbuildinfo --explainFiles +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./src/main.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6"],"options":{"module":1,"target":1,"tsBuildInfoFile":"./.tsbuildinfo"}} +//// [/home/src/workspaces/project/.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./src/main.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/main.ts", + "version": "03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6", + "signature": "03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6", + "impliedNodeFormat": "CommonJS" + } + ], + "options": { + "module": 1, + "target": 1, + "tsBuildInfoFile": "./.tsbuildinfo" + }, + "size": 365 +} +//// [/home/src/workspaces/project/src/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +exports.x = 10; + + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/src/main.ts +Signatures:: + + +Edit [0]:: no change + +tsgo --incremental --tsBuildInfoFile .tsbuildinfo --explainFiles +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: diff --git a/testdata/baselines/reference/tsc/incremental/when-passing-rootDir-from-commandline.js b/testdata/baselines/reference/tsc/incremental/when-passing-rootDir-from-commandline.js new file mode 100644 index 0000000000..1fef30924b --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/when-passing-rootDir-from-commandline.js @@ -0,0 +1,95 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/src/main.ts] *new* +export const x = 10; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "incremental": true, + "outDir": "dist" + } +} + +tsgo --rootDir src +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/dist/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +exports.x = 10; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./src/main.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6"],"options":{"outDir":"./dist","rootDir":"./src"}} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./src/main.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/main.ts", + "version": "03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6", + "signature": "03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6", + "impliedNodeFormat": "CommonJS" + } + ], + "options": { + "outDir": "./dist", + "rootDir": "./src" + }, + "size": 344 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/src/main.ts +Signatures:: + + +Edit [0]:: no change + +tsgo --rootDir src +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: diff --git a/testdata/baselines/reference/tsc/incremental/when-passing-rootDir-is-in-the-tsconfig.js b/testdata/baselines/reference/tsc/incremental/when-passing-rootDir-is-in-the-tsconfig.js new file mode 100644 index 0000000000..c8d109fbdc --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/when-passing-rootDir-is-in-the-tsconfig.js @@ -0,0 +1,96 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/src/main.ts] *new* +export const x = 10; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "incremental": true, + "outDir": "dist", + "rootDir": "./" + } +} + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/dist/src/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +exports.x = 10; + +//// [/home/src/workspaces/project/dist/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../../tslibs/TS/Lib/lib.d.ts","../src/main.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6"],"options":{"outDir":"./","rootDir":".."}} +//// [/home/src/workspaces/project/dist/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../../tslibs/TS/Lib/lib.d.ts", + "../src/main.ts" + ], + "fileInfos": [ + { + "fileName": "../../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/main.ts", + "version": "03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6", + "signature": "03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6", + "impliedNodeFormat": "CommonJS" + } + ], + "options": { + "outDir": "./", + "rootDir": ".." + }, + "size": 341 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/src/main.ts +Signatures:: + + +Edit [0]:: no change + +tsgo +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: diff --git a/testdata/baselines/reference/tsc/incremental/with-only-dts-files.js b/testdata/baselines/reference/tsc/incremental/with-only-dts-files.js new file mode 100644 index 0000000000..9799c50afd --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/with-only-dts-files.js @@ -0,0 +1,142 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/src/another.d.ts] *new* +export const y = 10; +//// [/home/src/workspaces/project/src/main.d.ts] *new* +export const x = 10; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{} + +tsgo --incremental +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./src/another.d.ts","./src/main.d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"4aa16e9a67a4820d1dc51507221b4c73b5626b3a759d79d7147ad4eabe37ef49","03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6"]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./src/another.d.ts", + "./src/main.d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/another.d.ts", + "version": "4aa16e9a67a4820d1dc51507221b4c73b5626b3a759d79d7147ad4eabe37ef49", + "signature": "4aa16e9a67a4820d1dc51507221b4c73b5626b3a759d79d7147ad4eabe37ef49", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./src/main.d.ts", + "version": "03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6", + "signature": "03da4d6a46cc7950ba861120c64b47c14bc80b3c64f47ef17b61cb454358afd6", + "impliedNodeFormat": "CommonJS" + } + ], + "size": 386 +} + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/src/another.d.ts +*refresh* /home/src/workspaces/project/src/main.d.ts +Signatures:: + + +Edit [0]:: no change + +tsgo --incremental +ExitStatus:: Success +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [1]:: modify d.ts file +//// [/home/src/workspaces/project/src/main.d.ts] *modified* +export const x = 10;export const xy = 100; + +tsgo --incremental +ExitStatus:: Success +Output:: +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./src/another.d.ts","./src/main.d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"4aa16e9a67a4820d1dc51507221b4c73b5626b3a759d79d7147ad4eabe37ef49","a701af2196ad5afd5fe2fb1f6c1c9ad538b85b9e4c37d747738ecc7f5d609540"]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./src/another.d.ts", + "./src/main.d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./src/another.d.ts", + "version": "4aa16e9a67a4820d1dc51507221b4c73b5626b3a759d79d7147ad4eabe37ef49", + "signature": "4aa16e9a67a4820d1dc51507221b4c73b5626b3a759d79d7147ad4eabe37ef49", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./src/main.d.ts", + "version": "a701af2196ad5afd5fe2fb1f6c1c9ad538b85b9e4c37d747738ecc7f5d609540", + "signature": "a701af2196ad5afd5fe2fb1f6c1c9ad538b85b9e4c37d747738ecc7f5d609540", + "impliedNodeFormat": "CommonJS" + } + ], + "size": 386 +} + +SemanticDiagnostics:: +*refresh* /home/src/workspaces/project/src/main.d.ts +Signatures:: +(used version) /home/src/workspaces/project/src/main.d.ts diff --git a/testdata/baselines/reference/tsc/noCheck/dts-errors.js b/testdata/baselines/reference/tsc/noCheck/dts-errors.js new file mode 100644 index 0000000000..bb4c9ed306 --- /dev/null +++ b/testdata/baselines/reference/tsc/noCheck/dts-errors.js @@ -0,0 +1,78 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/a.ts] *new* +export const a = class { private p = 10; }; +//// [/home/src/workspaces/project/b.ts] *new* +export const b = 10; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "declaration": true, + } +} + +tsgo --noCheck --outFile built +ExitStatus:: DiagnosticsPresent_OutputsGenerated +Output:: +a.ts:1:14 - error TS4094: Property 'p' of exported anonymous class type may not be private or protected. + +1 export const a = class { private p = 10; }; +   ~ + + a.ts:1:14 - Add a type annotation to the variable a. + 1 export const a = class { private p = 10; }; +    ~ + + +Found 1 error in a.ts:1 + +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/a.d.ts] *new* +export declare const a: { + new (): { + p: number; + }; +}; + +//// [/home/src/workspaces/project/a.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +const a = class { + p = 10; +}; +exports.a = a; + +//// [/home/src/workspaces/project/b.d.ts] *new* +export declare const b = 10; + +//// [/home/src/workspaces/project/b.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; + + diff --git a/testdata/baselines/reference/tsc/noCheck/outFile/dts-errors.js b/testdata/baselines/reference/tsc/noCheck/outFile/dts-errors.js deleted file mode 100644 index 145824660a..0000000000 --- a/testdata/baselines/reference/tsc/noCheck/outFile/dts-errors.js +++ /dev/null @@ -1,63 +0,0 @@ - -currentDirectory::/home/src/workspaces/project -useCaseSensitiveFileNames::true -Input::--noCheck --outFile built -//// [/home/src/workspaces/project/a.ts] new file -export const a = class { private p = 10; }; -//// [/home/src/workspaces/project/b.ts] new file -export const b = 10; -//// [/home/src/workspaces/project/tsconfig.json] new file -{ - "compilerOptions": { - "declaration": true, - } -} - -ExitStatus:: 2 - -CompilerOptions::{ - "noCheck": true, - "outFile": "/home/src/workspaces/project/built" -} -Output:: -a.ts:1:14 - error TS4094: Property 'p' of exported anonymous class type may not be private or protected. - -1 export const a = class { private p = 10; }; -   ~ - - a.ts:1:14 - Add a type annotation to the variable a. - 1 export const a = class { private p = 10; }; -    ~ - - -Found 1 error in a.ts:1 - -//// [/home/src/workspaces/project/a.d.ts] new file -export declare const a: { - new (): { - p: number; - }; -}; - -//// [/home/src/workspaces/project/a.js] new file -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -const a = class { - p = 10; -}; -exports.a = a; - -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/b.d.ts] new file -export declare const b = 10; - -//// [/home/src/workspaces/project/b.js] new file -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.b = void 0; -exports.b = 10; - -//// [/home/src/workspaces/project/b.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] no change - diff --git a/testdata/baselines/reference/tsc/noCheck/outFile/semantic-errors.js b/testdata/baselines/reference/tsc/noCheck/outFile/semantic-errors.js deleted file mode 100644 index 02a350977c..0000000000 --- a/testdata/baselines/reference/tsc/noCheck/outFile/semantic-errors.js +++ /dev/null @@ -1,44 +0,0 @@ - -currentDirectory::/home/src/workspaces/project -useCaseSensitiveFileNames::true -Input::--noCheck --outFile built -//// [/home/src/workspaces/project/a.ts] new file -export const a: number = "hello"; -//// [/home/src/workspaces/project/b.ts] new file -export const b = 10; -//// [/home/src/workspaces/project/tsconfig.json] new file -{ - "compilerOptions": { - "declaration": true, - } -} - -ExitStatus:: 0 - -CompilerOptions::{ - "noCheck": true, - "outFile": "/home/src/workspaces/project/built" -} -Output:: -//// [/home/src/workspaces/project/a.d.ts] new file -export declare const a: number; - -//// [/home/src/workspaces/project/a.js] new file -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -exports.a = "hello"; - -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/b.d.ts] new file -export declare const b = 10; - -//// [/home/src/workspaces/project/b.js] new file -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.b = void 0; -exports.b = 10; - -//// [/home/src/workspaces/project/b.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] no change - diff --git a/testdata/baselines/reference/tsc/noCheck/outFile/syntax-errors.js b/testdata/baselines/reference/tsc/noCheck/outFile/syntax-errors.js deleted file mode 100644 index 55c3efc93d..0000000000 --- a/testdata/baselines/reference/tsc/noCheck/outFile/syntax-errors.js +++ /dev/null @@ -1,52 +0,0 @@ - -currentDirectory::/home/src/workspaces/project -useCaseSensitiveFileNames::true -Input::--noCheck --outFile built -//// [/home/src/workspaces/project/a.ts] new file -export const a = "hello -//// [/home/src/workspaces/project/b.ts] new file -export const b = 10; -//// [/home/src/workspaces/project/tsconfig.json] new file -{ - "compilerOptions": { - "declaration": true, - } -} - -ExitStatus:: 2 - -CompilerOptions::{ - "noCheck": true, - "outFile": "/home/src/workspaces/project/built" -} -Output:: -a.ts:1:24 - error TS1002: Unterminated string literal. - -1 export const a = "hello -   ~ - - -Found 1 error in a.ts:1 - -//// [/home/src/workspaces/project/a.d.ts] new file -export declare const a = "hello"; - -//// [/home/src/workspaces/project/a.js] new file -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -exports.a = "hello; - -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/b.d.ts] new file -export declare const b = 10; - -//// [/home/src/workspaces/project/b.js] new file -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.b = void 0; -exports.b = 10; - -//// [/home/src/workspaces/project/b.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] no change - diff --git a/testdata/baselines/reference/tsc/noCheck/semantic-errors.js b/testdata/baselines/reference/tsc/noCheck/semantic-errors.js new file mode 100644 index 0000000000..4d4ac5b7ce --- /dev/null +++ b/testdata/baselines/reference/tsc/noCheck/semantic-errors.js @@ -0,0 +1,59 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/a.ts] *new* +export const a: number = "hello"; +//// [/home/src/workspaces/project/b.ts] *new* +export const b = 10; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "declaration": true, + } +} + +tsgo --noCheck --outFile built +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/a.d.ts] *new* +export declare const a: number; + +//// [/home/src/workspaces/project/a.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = "hello"; + +//// [/home/src/workspaces/project/b.d.ts] *new* +export declare const b = 10; + +//// [/home/src/workspaces/project/b.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; + + diff --git a/testdata/baselines/reference/tsc/noCheck/syntax-errors.js b/testdata/baselines/reference/tsc/noCheck/syntax-errors.js new file mode 100644 index 0000000000..157206b286 --- /dev/null +++ b/testdata/baselines/reference/tsc/noCheck/syntax-errors.js @@ -0,0 +1,67 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/a.ts] *new* +export const a = "hello +//// [/home/src/workspaces/project/b.ts] *new* +export const b = 10; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "declaration": true, + } +} + +tsgo --noCheck --outFile built +ExitStatus:: DiagnosticsPresent_OutputsGenerated +Output:: +a.ts:1:24 - error TS1002: Unterminated string literal. + +1 export const a = "hello +   ~ + + +Found 1 error in a.ts:1 + +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/a.d.ts] *new* +export declare const a = "hello"; + +//// [/home/src/workspaces/project/a.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = "hello; + +//// [/home/src/workspaces/project/b.d.ts] *new* +export declare const b = 10; + +//// [/home/src/workspaces/project/b.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +exports.b = 10; + + diff --git a/testdata/baselines/reference/tsc/noEmit/when-project-has-strict-true.js b/testdata/baselines/reference/tsc/noEmit/when-project-has-strict-true.js index 1a7e68f680..861a304540 100644 --- a/testdata/baselines/reference/tsc/noEmit/when-project-has-strict-true.js +++ b/testdata/baselines/reference/tsc/noEmit/when-project-has-strict-true.js @@ -1,23 +1,85 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::--noEmit -//// [/home/src/workspaces/project/class1.ts] new file +Input:: +//// [/home/src/workspaces/project/class1.ts] *new* export class class1 {} -//// [/home/src/workspaces/project/tsconfig.json] new file +//// [/home/src/workspaces/project/tsconfig.json] *new* { - "compilerOptions": { - "incremental": true, - "strict": true, - }, + "compilerOptions": { + "incremental": true, + "strict": true + } } -ExitStatus:: 0 - -CompilerOptions::{ - "noEmit": true -} +tsgo --noEmit +ExitStatus:: Success Output:: -//// [/home/src/workspaces/project/class1.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] no change +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts","./class1.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"a7765a20d4489ae259632d5fe609919af401c278b7a90516894ef2774ce3bc97"],"options":{"strict":true},"affectedFilesPendingEmit":[2]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts", + "./class1.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./class1.ts", + "version": "a7765a20d4489ae259632d5fe609919af401c278b7a90516894ef2774ce3bc97", + "signature": "a7765a20d4489ae259632d5fe609919af401c278b7a90516894ef2774ce3bc97", + "impliedNodeFormat": "CommonJS" + } + ], + "options": { + "strict": true + }, + "affectedFilesPendingEmit": [ + [ + "./class1.ts", + "Js", + 2 + ] + ], + "size": 351 +} +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/class1.ts +Signatures:: diff --git a/testdata/baselines/reference/tsc/projectReferences/default-import-interop-uses-referenced-project-settings.js b/testdata/baselines/reference/tsc/projectReferences/default-import-interop-uses-referenced-project-settings.js index 48869ca558..abc2590be1 100644 --- a/testdata/baselines/reference/tsc/projectReferences/default-import-interop-uses-referenced-project-settings.js +++ b/testdata/baselines/reference/tsc/projectReferences/default-import-interop-uses-referenced-project-settings.js @@ -1,78 +1,90 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::--p app --pretty false -//// [/home/src/workspaces/project/app/src/index.ts] new file - - import local from "./local"; // Error - import esm from "esm-package"; // Error - import referencedSource from "../../lib/src/a"; // Error - import referencedDeclaration from "../../lib/dist/a"; // Error - import ambiguous from "ambiguous-package"; // Ok -//// [/home/src/workspaces/project/app/src/local.ts] new file +Input:: +//// [/home/src/workspaces/project/app/src/index.ts] *new* +import local from "./local"; // Error +import esm from "esm-package"; // Error +import referencedSource from "../../lib/src/a"; // Error +import referencedDeclaration from "../../lib/dist/a"; // Error +import ambiguous from "ambiguous-package"; // Ok +//// [/home/src/workspaces/project/app/src/local.ts] *new* export const local = 0; -//// [/home/src/workspaces/project/app/tsconfig.json] new file +//// [/home/src/workspaces/project/app/tsconfig.json] *new* { - "compilerOptions": { - "module": "esnext", - "moduleResolution": "bundler", - "rootDir": "src", - "outDir": "dist", - }, - "include": ["src"], - "references": [ - { "path": "../lib" }, - ], - } -//// [/home/src/workspaces/project/lib/dist/a.d.ts] new file + "compilerOptions": { + "module": "esnext", + "moduleResolution": "bundler", + "rootDir": "src", + "outDir": "dist", + }, + "include": ["src"], + "references": [ + { "path": "../lib" }, + ], +} +//// [/home/src/workspaces/project/lib/dist/a.d.ts] *new* export declare const a = 0; -//// [/home/src/workspaces/project/lib/src/a.ts] new file +//// [/home/src/workspaces/project/lib/src/a.ts] *new* export const a = 0; -//// [/home/src/workspaces/project/lib/tsconfig.json] new file +//// [/home/src/workspaces/project/lib/tsconfig.json] *new* { - "compilerOptions": { - "composite": true, - "declaration": true, - "rootDir": "src", - "outDir": "dist", - "module": "esnext", - "moduleResolution": "bundler", - }, - "include": ["src"], - } -//// [/home/src/workspaces/project/node_modules/ambiguous-package/index.d.ts] new file + "compilerOptions": { + "composite": true, + "declaration": true, + "rootDir": "src", + "outDir": "dist", + "module": "esnext", + "moduleResolution": "bundler", + }, + "include": ["src"], +} +//// [/home/src/workspaces/project/node_modules/ambiguous-package/index.d.ts] *new* export declare const ambiguous: number; -//// [/home/src/workspaces/project/node_modules/ambiguous-package/package.json] new file -{ "name": "ambiguous-package" } -//// [/home/src/workspaces/project/node_modules/esm-package/index.d.ts] new file +//// [/home/src/workspaces/project/node_modules/ambiguous-package/package.json] *new* +{ + "name": "ambiguous-package" +} +//// [/home/src/workspaces/project/node_modules/esm-package/index.d.ts] *new* export declare const esm: number; -//// [/home/src/workspaces/project/node_modules/esm-package/package.json] new file -{ "name": "esm-package", "type": "module" } - -ExitStatus:: 2 - -CompilerOptions::{ - "project": "/home/src/workspaces/project/app", - "pretty": false +//// [/home/src/workspaces/project/node_modules/esm-package/package.json] *new* +{ + "name": "esm-package", + "type": "module" } + +tsgo --p app --pretty false +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: -app/src/index.ts(2,13): error TS2613: Module '"/home/src/workspaces/project/app/src/local"' has no default export. Did you mean to use 'import { local } from "/home/src/workspaces/project/app/src/local"' instead? +app/src/index.ts(1,8): error TS2613: Module '"/home/src/workspaces/project/app/src/local"' has no default export. Did you mean to use 'import { local } from "/home/src/workspaces/project/app/src/local"' instead? -app/src/index.ts(3,13): error TS2613: Module '"/home/src/workspaces/project/node_modules/esm-package/index"' has no default export. Did you mean to use 'import { esm } from "/home/src/workspaces/project/node_modules/esm-package/index"' instead? -//// [/home/src/workspaces/project/app/dist/index.js] new file +app/src/index.ts(2,8): error TS2613: Module '"/home/src/workspaces/project/node_modules/esm-package/index"' has no default export. Did you mean to use 'import { esm } from "/home/src/workspaces/project/node_modules/esm-package/index"' instead? +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/app/dist/index.js] *new* export {}; -//// [/home/src/workspaces/project/app/dist/local.js] new file +//// [/home/src/workspaces/project/app/dist/local.js] *new* export const local = 0; -//// [/home/src/workspaces/project/app/src/index.ts] no change -//// [/home/src/workspaces/project/app/src/local.ts] no change -//// [/home/src/workspaces/project/app/tsconfig.json] no change -//// [/home/src/workspaces/project/lib/dist/a.d.ts] no change -//// [/home/src/workspaces/project/lib/src/a.ts] no change -//// [/home/src/workspaces/project/lib/tsconfig.json] no change -//// [/home/src/workspaces/project/node_modules/ambiguous-package/index.d.ts] no change -//// [/home/src/workspaces/project/node_modules/ambiguous-package/package.json] no change -//// [/home/src/workspaces/project/node_modules/esm-package/index.d.ts] no change -//// [/home/src/workspaces/project/node_modules/esm-package/package.json] no change diff --git a/testdata/baselines/reference/tsc/projectReferences/importing-const-enum-from-referenced-project-with-preserveConstEnums-and-verbatimModuleSyntax.js b/testdata/baselines/reference/tsc/projectReferences/importing-const-enum-from-referenced-project-with-preserveConstEnums-and-verbatimModuleSyntax.js index 7086c37045..1bb030b983 100644 --- a/testdata/baselines/reference/tsc/projectReferences/importing-const-enum-from-referenced-project-with-preserveConstEnums-and-verbatimModuleSyntax.js +++ b/testdata/baselines/reference/tsc/projectReferences/importing-const-enum-from-referenced-project-with-preserveConstEnums-and-verbatimModuleSyntax.js @@ -1,69 +1,78 @@ - currentDirectory::/home/src/workspaces/solution useCaseSensitiveFileNames::true -Input::--p project --pretty false -//// [/home/src/workspaces/solution/no-preserve/index.d.ts] new file +Input:: +//// [/home/src/workspaces/solution/no-preserve/index.d.ts] *new* export declare const enum F { A = 1 } -//// [/home/src/workspaces/solution/no-preserve/index.ts] new file +//// [/home/src/workspaces/solution/no-preserve/index.ts] *new* export const enum E { A = 1 } -//// [/home/src/workspaces/solution/no-preserve/tsconfig.json] new file +//// [/home/src/workspaces/solution/no-preserve/tsconfig.json] *new* { - "compilerOptions": { - "composite": true, - "declaration": true, - "preserveConstEnums": false, - }, - } -//// [/home/src/workspaces/solution/preserve/index.d.ts] new file + "compilerOptions": { + "composite": true, + "declaration": true, + "preserveConstEnums": false, + }, +} +//// [/home/src/workspaces/solution/preserve/index.d.ts] *new* export declare const enum E { A = 1 } -//// [/home/src/workspaces/solution/preserve/index.ts] new file +//// [/home/src/workspaces/solution/preserve/index.ts] *new* export const enum E { A = 1 } -//// [/home/src/workspaces/solution/preserve/tsconfig.json] new file +//// [/home/src/workspaces/solution/preserve/tsconfig.json] *new* { - "compilerOptions": { - "composite": true, - "declaration": true, - "preserveConstEnums": true, - }, - } -//// [/home/src/workspaces/solution/project/index.ts] new file - - import { E } from "../preserve"; - import { F } from "../no-preserve"; - E.A; - F.A; -//// [/home/src/workspaces/solution/project/tsconfig.json] new file + "compilerOptions": { + "composite": true, + "declaration": true, + "preserveConstEnums": true, + }, +} +//// [/home/src/workspaces/solution/project/index.ts] *new* +import { E } from "../preserve"; +import { F } from "../no-preserve"; +E.A; +F.A; +//// [/home/src/workspaces/solution/project/tsconfig.json] *new* { - "compilerOptions": { - "module": "preserve", - "verbatimModuleSyntax": true, - }, - "references": [ - { "path": "../preserve" }, - { "path": "../no-preserve" }, - ], - } - -ExitStatus:: 2 - -CompilerOptions::{ - "project": "/home/src/workspaces/solution/project", - "pretty": false + "compilerOptions": { + "module": "preserve", + "verbatimModuleSyntax": true, + }, + "references": [ + { "path": "../preserve" }, + { "path": "../no-preserve" }, + ], } + +tsgo --p project --pretty false +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: -project/index.ts(3,14): error TS2748: Cannot access ambient const enums when 'verbatimModuleSyntax' is enabled. -//// [/home/src/workspaces/solution/no-preserve/index.d.ts] no change -//// [/home/src/workspaces/solution/no-preserve/index.ts] no change -//// [/home/src/workspaces/solution/no-preserve/tsconfig.json] no change -//// [/home/src/workspaces/solution/preserve/index.d.ts] no change -//// [/home/src/workspaces/solution/preserve/index.ts] no change -//// [/home/src/workspaces/solution/preserve/tsconfig.json] no change -//// [/home/src/workspaces/solution/project/index.js] new file +project/index.ts(2,10): error TS2748: Cannot access ambient const enums when 'verbatimModuleSyntax' is enabled. +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/solution/project/index.js] *new* import { E } from "../preserve"; import { F } from "../no-preserve"; E.A; F.A; -//// [/home/src/workspaces/solution/project/index.ts] no change -//// [/home/src/workspaces/solution/project/tsconfig.json] no change diff --git a/testdata/baselines/reference/tsc/projectReferences/referencing-ambient-const-enum-from-referenced-project-with-preserveConstEnums.js b/testdata/baselines/reference/tsc/projectReferences/referencing-ambient-const-enum-from-referenced-project-with-preserveConstEnums.js index bd7c02a633..378f04e0d4 100644 --- a/testdata/baselines/reference/tsc/projectReferences/referencing-ambient-const-enum-from-referenced-project-with-preserveConstEnums.js +++ b/testdata/baselines/reference/tsc/projectReferences/referencing-ambient-const-enum-from-referenced-project-with-preserveConstEnums.js @@ -1,46 +1,60 @@ - currentDirectory::/home/src/workspaces/solution useCaseSensitiveFileNames::true -Input::--p project -//// [/home/src/workspaces/solution/project/index.ts] new file +Input:: +//// [/home/src/workspaces/solution/project/index.ts] *new* import { E } from "../utils"; E.A; -//// [/home/src/workspaces/solution/project/tsconfig.json] new file +//// [/home/src/workspaces/solution/project/tsconfig.json] *new* { - "compilerOptions": { - "isolatedModules": true, - }, - "references": [ - { "path": "../utils" }, - ], - } -//// [/home/src/workspaces/solution/utils/index.d.ts] new file + "compilerOptions": { + "isolatedModules": true, + }, + "references": [ + { "path": "../utils" }, + ], +} +//// [/home/src/workspaces/solution/utils/index.d.ts] *new* export declare const enum E { A = 1 } -//// [/home/src/workspaces/solution/utils/index.ts] new file +//// [/home/src/workspaces/solution/utils/index.ts] *new* export const enum E { A = 1 } -//// [/home/src/workspaces/solution/utils/tsconfig.json] new file +//// [/home/src/workspaces/solution/utils/tsconfig.json] *new* { - "compilerOptions": { - "composite": true, - "declaration": true, - "preserveConstEnums": true, - }, - } - -ExitStatus:: 0 - -CompilerOptions::{ - "project": "/home/src/workspaces/solution/project" + "compilerOptions": { + "composite": true, + "declaration": true, + "preserveConstEnums": true, + }, } + +tsgo --p project +ExitStatus:: Success Output:: -//// [/home/src/workspaces/solution/project/index.js] new file +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/solution/project/index.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const utils_1 = require("../utils"); utils_1.E.A; -//// [/home/src/workspaces/solution/project/index.ts] no change -//// [/home/src/workspaces/solution/project/tsconfig.json] no change -//// [/home/src/workspaces/solution/utils/index.d.ts] no change -//// [/home/src/workspaces/solution/utils/index.ts] no change -//// [/home/src/workspaces/solution/utils/tsconfig.json] no change diff --git a/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences1.js b/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences1.js index 473498303d..b0b402f89e 100644 --- a/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences1.js +++ b/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences1.js @@ -1,65 +1,78 @@ - currentDirectory::/home/src/workspaces useCaseSensitiveFileNames::true -Input::-p packages/main --pretty false -//// [/home/src/workspaces/packages/common/dist/index.d.ts] new file +Input:: +//// [/home/src/workspaces/packages/common/dist/index.d.ts] *new* export {}; -//// [/home/src/workspaces/packages/common/package.json] new file +//// [/home/src/workspaces/packages/common/package.json] *new* { - "name": "common", - "version": "1.0.0", - "type": "module", - "exports": { - ".": { - "source": "./src/index.ts", - "default": "./dist/index.js" - } - } - } -//// [/home/src/workspaces/packages/common/src/index.ts] new file + "name": "common", + "version": "1.0.0", + "type": "module", + "exports": { + ".": { + "source": "./src/index.ts", + "default": "./dist/index.js" + } + } +} +//// [/home/src/workspaces/packages/common/src/index.ts] *new* export {}; -//// [/home/src/workspaces/packages/common/tsconfig.json] new file +//// [/home/src/workspaces/packages/common/tsconfig.json] *new* { - "compilerOptions": { - "composite": true, - "rootDir": "src", - "outDir": "dist", - "module": "nodenext" - } - } -//// [/home/src/workspaces/packages/main/package.json] new file -{ "type": "module" } -//// [/home/src/workspaces/packages/main/src/index.ts] new file + "compilerOptions": { + "composite": true, + "rootDir": "src", + "outDir": "dist", + "module": "nodenext" + } +} +//// [/home/src/workspaces/packages/main/package.json] *new* +{ + "type": "module" +} +//// [/home/src/workspaces/packages/main/src/index.ts] *new* import {} from "../../common/src/index.ts"; -//// [/home/src/workspaces/packages/main/tsconfig.json] new file +//// [/home/src/workspaces/packages/main/tsconfig.json] *new* { - "compilerOptions": { - "module": "nodenext", - "rewriteRelativeImportExtensions": true, - "rootDir": "src", - "outDir": "dist" - }, - "references": [ - { "path": "../common" } - ] - } - -ExitStatus:: 2 - -CompilerOptions::{ - "project": "/home/src/workspaces/packages/main", - "pretty": false + "compilerOptions": { + "module": "nodenext", + "rewriteRelativeImportExtensions": true, + "rootDir": "src", + "outDir": "dist" + }, + "references": [ + { "path": "../common" } + ] } + +tsgo -p packages/main --pretty false +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: packages/main/src/index.ts(1,16): error TS2878: This import path is unsafe to rewrite because it resolves to another project, and the relative path between the projects' output files is not the same as the relative path between its input files. -//// [/home/src/workspaces/packages/common/dist/index.d.ts] no change -//// [/home/src/workspaces/packages/common/package.json] no change -//// [/home/src/workspaces/packages/common/src/index.ts] no change -//// [/home/src/workspaces/packages/common/tsconfig.json] no change -//// [/home/src/workspaces/packages/main/dist/index.js] new file +//// [/home/src/tslibs/TS/Lib/lib.esnext.full.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/packages/main/dist/index.js] *new* export {}; -//// [/home/src/workspaces/packages/main/package.json] no change -//// [/home/src/workspaces/packages/main/src/index.ts] no change -//// [/home/src/workspaces/packages/main/tsconfig.json] no change diff --git a/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences2.js b/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences2.js index a61dbcf2e3..5b453dfe1b 100644 --- a/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences2.js +++ b/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences2.js @@ -1,56 +1,135 @@ - currentDirectory::/home/src/workspaces/solution useCaseSensitiveFileNames::true -Input::--p src/services --pretty false -//// [/home/src/workspaces/solution/dist/compiler/parser.d.ts] new file +Input:: +//// [/home/src/workspaces/solution/dist/compiler/parser.d.ts] *new* export {}; -//// [/home/src/workspaces/solution/src/compiler/parser.ts] new file +//// [/home/src/workspaces/solution/src/compiler/parser.ts] *new* export {}; -//// [/home/src/workspaces/solution/src/compiler/tsconfig.json] new file +//// [/home/src/workspaces/solution/src/compiler/tsconfig.json] *new* { - "extends": "../tsconfig-base.json", - "compilerOptions": {} - } -//// [/home/src/workspaces/solution/src/services/services.ts] new file + "extends": "../tsconfig-base.json", + "compilerOptions": {} +} +//// [/home/src/workspaces/solution/src/services/services.ts] *new* import {} from "../compiler/parser.ts"; -//// [/home/src/workspaces/solution/src/services/tsconfig.json] new file +//// [/home/src/workspaces/solution/src/services/tsconfig.json] *new* { - "extends": "../tsconfig-base.json", - "compilerOptions": {}, - "references": [ - { "path": "../compiler" } - ] - } -//// [/home/src/workspaces/solution/src/tsconfig-base.json] new file + "extends": "../tsconfig-base.json", + "compilerOptions": {}, + "references": [ + { "path": "../compiler" } + ] +} +//// [/home/src/workspaces/solution/src/tsconfig-base.json] *new* { - "compilerOptions": { - "module": "nodenext", - "composite": true, - "rootDir": ".", - "outDir": "../dist", - "rewriteRelativeImportExtensions": true - } - } - -ExitStatus:: 0 - -CompilerOptions::{ - "project": "/home/src/workspaces/solution/src/services", - "pretty": false + "compilerOptions": { + "module": "nodenext", + "composite": true, + "rootDir": ".", + "outDir": "../dist", + "rewriteRelativeImportExtensions": true + } } + +tsgo --p src/services --pretty false +ExitStatus:: Success Output:: No output -//// [/home/src/workspaces/solution/dist/compiler/parser.d.ts] no change -//// [/home/src/workspaces/solution/dist/services/services.d.ts] new file +//// [/home/src/tslibs/TS/Lib/lib.esnext.full.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/solution/dist/services/services.d.ts] *new* export {}; -//// [/home/src/workspaces/solution/dist/services/services.js] new file +//// [/home/src/workspaces/solution/dist/services/services.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/workspaces/solution/src/compiler/parser.ts] no change -//// [/home/src/workspaces/solution/src/compiler/tsconfig.json] no change -//// [/home/src/workspaces/solution/src/services/services.ts] no change -//// [/home/src/workspaces/solution/src/services/tsconfig.json] no change -//// [/home/src/workspaces/solution/src/tsconfig-base.json] no change +//// [/home/src/workspaces/solution/dist/services/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../../../tslibs/TS/Lib/lib.esnext.full.d.ts","../compiler/parser.d.ts","../../src/services/services.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"2e29cd9a98755c46896f7a2d56524db2d6d96b248e36db46de14c30bf47c8d05",{"version":"407537635fda1a543a422ecdd456c1402aaa2083cde5acfb4eb424ab02fc0612","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"module":199,"outDir":"..","rewriteRelativeImportExtensions":true,"rootDir":"../../src"},"referencedMap":[[3,1]],"latestChangedDtsFile":"./services.d.ts"} +//// [/home/src/workspaces/solution/dist/services/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../../../tslibs/TS/Lib/lib.esnext.full.d.ts", + "../compiler/parser.d.ts", + "../../src/services/services.ts" + ], + "fileInfos": [ + { + "fileName": "../../../../tslibs/TS/Lib/lib.esnext.full.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../compiler/parser.d.ts", + "version": "2e29cd9a98755c46896f7a2d56524db2d6d96b248e36db46de14c30bf47c8d05", + "signature": "2e29cd9a98755c46896f7a2d56524db2d6d96b248e36db46de14c30bf47c8d05", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "../../src/services/services.ts", + "version": "407537635fda1a543a422ecdd456c1402aaa2083cde5acfb4eb424ab02fc0612", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "407537635fda1a543a422ecdd456c1402aaa2083cde5acfb4eb424ab02fc0612", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../compiler/parser.d.ts" + ] + ], + "options": { + "composite": true, + "module": 199, + "outDir": "..", + "rewriteRelativeImportExtensions": true, + "rootDir": "../../src" + }, + "referencedMap": { + "../../src/services/services.ts": [ + "../compiler/parser.d.ts" + ] + }, + "latestChangedDtsFile": "./services.d.ts", + "size": 739 +} +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.esnext.full.d.ts +*refresh* /home/src/workspaces/solution/dist/compiler/parser.d.ts +*refresh* /home/src/workspaces/solution/src/services/services.ts +Signatures:: +(stored at emit) /home/src/workspaces/solution/src/services/services.ts diff --git a/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences3.js b/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences3.js index 06f119bd43..0befe5286d 100644 --- a/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences3.js +++ b/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences3.js @@ -1,60 +1,139 @@ - currentDirectory::/home/src/workspaces/solution useCaseSensitiveFileNames::true -Input::--p src/services --pretty false -//// [/home/src/workspaces/solution/dist/compiler/parser.d.ts] new file +Input:: +//// [/home/src/workspaces/solution/dist/compiler/parser.d.ts] *new* export {}; -//// [/home/src/workspaces/solution/src/compiler/parser.ts] new file +//// [/home/src/workspaces/solution/src/compiler/parser.ts] *new* export {}; -//// [/home/src/workspaces/solution/src/compiler/tsconfig.json] new file +//// [/home/src/workspaces/solution/src/compiler/tsconfig.json] *new* { - "extends": "../tsconfig-base.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "../../dist/compiler" - } - } -//// [/home/src/workspaces/solution/src/services/services.ts] new file + "extends": "../tsconfig-base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "../../dist/compiler" + } +} +//// [/home/src/workspaces/solution/src/services/services.ts] *new* import {} from "../compiler/parser.ts"; -//// [/home/src/workspaces/solution/src/services/tsconfig.json] new file +//// [/home/src/workspaces/solution/src/services/tsconfig.json] *new* { - "extends": "../tsconfig-base.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "../../dist/services" - }, - "references": [ - { "path": "../compiler" } - ] - } -//// [/home/src/workspaces/solution/src/tsconfig-base.json] new file + "extends": "../tsconfig-base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "../../dist/services" + }, + "references": [ + { "path": "../compiler" } + ] +} +//// [/home/src/workspaces/solution/src/tsconfig-base.json] *new* { - "compilerOptions": { - "module": "nodenext", - "composite": true, - "rewriteRelativeImportExtensions": true - } - } - -ExitStatus:: 0 - -CompilerOptions::{ - "project": "/home/src/workspaces/solution/src/services", - "pretty": false + "compilerOptions": { + "module": "nodenext", + "composite": true, + "rewriteRelativeImportExtensions": true + } } + +tsgo --p src/services --pretty false +ExitStatus:: Success Output:: No output -//// [/home/src/workspaces/solution/dist/compiler/parser.d.ts] no change -//// [/home/src/workspaces/solution/dist/services/services.d.ts] new file +//// [/home/src/tslibs/TS/Lib/lib.esnext.full.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/solution/dist/services/services.d.ts] *new* export {}; -//// [/home/src/workspaces/solution/dist/services/services.js] new file +//// [/home/src/workspaces/solution/dist/services/services.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/workspaces/solution/src/compiler/parser.ts] no change -//// [/home/src/workspaces/solution/src/compiler/tsconfig.json] no change -//// [/home/src/workspaces/solution/src/services/services.ts] no change -//// [/home/src/workspaces/solution/src/services/tsconfig.json] no change -//// [/home/src/workspaces/solution/src/tsconfig-base.json] no change +//// [/home/src/workspaces/solution/dist/services/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../../../tslibs/TS/Lib/lib.esnext.full.d.ts","../compiler/parser.d.ts","../../src/services/services.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1},"2e29cd9a98755c46896f7a2d56524db2d6d96b248e36db46de14c30bf47c8d05",{"version":"407537635fda1a543a422ecdd456c1402aaa2083cde5acfb4eb424ab02fc0612","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"module":199,"outDir":"./","rewriteRelativeImportExtensions":true,"rootDir":"../../src/services"},"referencedMap":[[3,1]],"latestChangedDtsFile":"./services.d.ts"} +//// [/home/src/workspaces/solution/dist/services/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../../../tslibs/TS/Lib/lib.esnext.full.d.ts", + "../compiler/parser.d.ts", + "../../src/services/services.ts" + ], + "fileInfos": [ + { + "fileName": "../../../../tslibs/TS/Lib/lib.esnext.full.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../compiler/parser.d.ts", + "version": "2e29cd9a98755c46896f7a2d56524db2d6d96b248e36db46de14c30bf47c8d05", + "signature": "2e29cd9a98755c46896f7a2d56524db2d6d96b248e36db46de14c30bf47c8d05", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "../../src/services/services.ts", + "version": "407537635fda1a543a422ecdd456c1402aaa2083cde5acfb4eb424ab02fc0612", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "407537635fda1a543a422ecdd456c1402aaa2083cde5acfb4eb424ab02fc0612", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../compiler/parser.d.ts" + ] + ], + "options": { + "composite": true, + "module": 199, + "outDir": "./", + "rewriteRelativeImportExtensions": true, + "rootDir": "../../src/services" + }, + "referencedMap": { + "../../src/services/services.ts": [ + "../compiler/parser.d.ts" + ] + }, + "latestChangedDtsFile": "./services.d.ts", + "size": 748 +} +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.esnext.full.d.ts +*refresh* /home/src/workspaces/solution/dist/compiler/parser.d.ts +*refresh* /home/src/workspaces/solution/src/services/services.ts +Signatures:: +(stored at emit) /home/src/workspaces/solution/src/services/services.ts diff --git a/testdata/baselines/reference/tsc/projectReferences/when-project-contains-invalid-project-reference.js b/testdata/baselines/reference/tsc/projectReferences/when-project-contains-invalid-project-reference.js index 6e080dcb55..de6b4ec1f6 100644 --- a/testdata/baselines/reference/tsc/projectReferences/when-project-contains-invalid-project-reference.js +++ b/testdata/baselines/reference/tsc/projectReferences/when-project-contains-invalid-project-reference.js @@ -1,28 +1,45 @@ - currentDirectory::/home/src/workspaces/solution useCaseSensitiveFileNames::true -Input::--p project -//// [/home/src/workspaces/solution/project/index.ts] new file +Input:: +//// [/home/src/workspaces/solution/project/index.ts] *new* export const x = 10; -//// [/home/src/workspaces/solution/project/tsconfig.json] new file +//// [/home/src/workspaces/solution/project/tsconfig.json] *new* { - "references": [ - { "path": "../utils" }, - ], + "references": [ + { "path": "../utils" }, + ], } -ExitStatus:: 0 - -CompilerOptions::{ - "project": "/home/src/workspaces/solution/project" -} +tsgo --p project +ExitStatus:: Success Output:: -//// [/home/src/workspaces/solution/project/index.js] new file +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/solution/project/index.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.x = void 0; exports.x = 10; -//// [/home/src/workspaces/solution/project/index.ts] no change -//// [/home/src/workspaces/solution/project/tsconfig.json] no change diff --git a/testdata/baselines/reference/tsc/projectReferences/when-project-reference-is-not-built.js b/testdata/baselines/reference/tsc/projectReferences/when-project-reference-is-not-built.js index 193090cc44..b7ebae5101 100644 --- a/testdata/baselines/reference/tsc/projectReferences/when-project-reference-is-not-built.js +++ b/testdata/baselines/reference/tsc/projectReferences/when-project-reference-is-not-built.js @@ -1,29 +1,25 @@ - currentDirectory::/home/src/workspaces/solution useCaseSensitiveFileNames::true -Input::--p project -//// [/home/src/workspaces/solution/project/index.ts] new file +Input:: +//// [/home/src/workspaces/solution/project/index.ts] *new* import { x } from "../utils"; -//// [/home/src/workspaces/solution/project/tsconfig.json] new file +//// [/home/src/workspaces/solution/project/tsconfig.json] *new* { - "references": [ - { "path": "../utils" }, - ], + "references": [ + { "path": "../utils" }, + ], } -//// [/home/src/workspaces/solution/utils/index.ts] new file +//// [/home/src/workspaces/solution/utils/index.ts] *new* export const x = 10; -//// [/home/src/workspaces/solution/utils/tsconfig.json] new file +//// [/home/src/workspaces/solution/utils/tsconfig.json] *new* { - "compilerOptions": { - "composite": true, - }, + "compilerOptions": { + "composite": true + } } -ExitStatus:: 2 - -CompilerOptions::{ - "project": "/home/src/workspaces/solution/project" -} +tsgo --p project +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: project/index.ts:1:19 - error TS6305: Output file '/home/src/workspaces/solution/utils/index.d.ts' has not been built from source file '/home/src/workspaces/solution/utils/index.ts'. @@ -33,12 +29,31 @@ Output:: Found 1 error in project/index.ts:1 -//// [/home/src/workspaces/solution/project/index.js] new file +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/solution/project/index.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/workspaces/solution/project/index.ts] no change -//// [/home/src/workspaces/solution/project/tsconfig.json] no change -//// [/home/src/workspaces/solution/utils/index.ts] no change -//// [/home/src/workspaces/solution/utils/tsconfig.json] no change diff --git a/testdata/baselines/reference/tsc/projectReferences/when-project-references-composite-project-with-noEmit.js b/testdata/baselines/reference/tsc/projectReferences/when-project-references-composite-project-with-noEmit.js index efb89c0c40..d7310b8cb3 100644 --- a/testdata/baselines/reference/tsc/projectReferences/when-project-references-composite-project-with-noEmit.js +++ b/testdata/baselines/reference/tsc/projectReferences/when-project-references-composite-project-with-noEmit.js @@ -1,30 +1,26 @@ - currentDirectory::/home/src/workspaces/solution useCaseSensitiveFileNames::true -Input::--p project -//// [/home/src/workspaces/solution/project/index.ts] new file +Input:: +//// [/home/src/workspaces/solution/project/index.ts] *new* import { x } from "../utils"; -//// [/home/src/workspaces/solution/project/tsconfig.json] new file +//// [/home/src/workspaces/solution/project/tsconfig.json] *new* { - "references": [ - { "path": "../utils" }, - ], - } -//// [/home/src/workspaces/solution/utils/index.ts] new file + "references": [ + { "path": "../utils" }, + ], +} +//// [/home/src/workspaces/solution/utils/index.ts] *new* export const x = 10; -//// [/home/src/workspaces/solution/utils/tsconfig.json] new file +//// [/home/src/workspaces/solution/utils/tsconfig.json] *new* { - "compilerOptions": { - "composite": true, - "noEmit": true, - }, - } - -ExitStatus:: 2 - -CompilerOptions::{ - "project": "/home/src/workspaces/solution/project" + "compilerOptions": { + "composite": true, + "noEmit": true + } } + +tsgo --p project +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: project/index.ts:1:19 - error TS6305: Output file '/home/src/workspaces/solution/utils/index.d.ts' has not been built from source file '/home/src/workspaces/solution/utils/index.ts'. @@ -34,12 +30,31 @@ Output:: Found 1 error in project/index.ts:1 -//// [/home/src/workspaces/solution/project/index.js] new file +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/solution/project/index.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/workspaces/solution/project/index.ts] no change -//// [/home/src/workspaces/solution/project/tsconfig.json] no change -//// [/home/src/workspaces/solution/utils/index.ts] no change -//// [/home/src/workspaces/solution/utils/tsconfig.json] no change diff --git a/testdata/baselines/reference/tsc/projectReferences/when-project-references-composite.js b/testdata/baselines/reference/tsc/projectReferences/when-project-references-composite.js index d0d15de884..8d701b99f7 100644 --- a/testdata/baselines/reference/tsc/projectReferences/when-project-references-composite.js +++ b/testdata/baselines/reference/tsc/projectReferences/when-project-references-composite.js @@ -1,39 +1,53 @@ - currentDirectory::/home/src/workspaces/solution useCaseSensitiveFileNames::true -Input::--p project -//// [/home/src/workspaces/solution/project/index.ts] new file +Input:: +//// [/home/src/workspaces/solution/project/index.ts] *new* import { x } from "../utils"; -//// [/home/src/workspaces/solution/project/tsconfig.json] new file +//// [/home/src/workspaces/solution/project/tsconfig.json] *new* { - "references": [ - { "path": "../utils" }, - ], + "references": [ + { "path": "../utils" }, + ], } -//// [/home/src/workspaces/solution/utils/index.d.ts] new file +//// [/home/src/workspaces/solution/utils/index.d.ts] *new* export declare const x = 10; -//// [/home/src/workspaces/solution/utils/index.ts] new file +//// [/home/src/workspaces/solution/utils/index.ts] *new* export const x = 10; -//// [/home/src/workspaces/solution/utils/tsconfig.json] new file +//// [/home/src/workspaces/solution/utils/tsconfig.json] *new* { - "compilerOptions": { - "composite": true, - }, + "compilerOptions": { + "composite": true + } } -ExitStatus:: 0 - -CompilerOptions::{ - "project": "/home/src/workspaces/solution/project" -} +tsgo --p project +ExitStatus:: Success Output:: -//// [/home/src/workspaces/solution/project/index.js] new file +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/solution/project/index.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/workspaces/solution/project/index.ts] no change -//// [/home/src/workspaces/solution/project/tsconfig.json] no change -//// [/home/src/workspaces/solution/utils/index.d.ts] no change -//// [/home/src/workspaces/solution/utils/index.ts] no change -//// [/home/src/workspaces/solution/utils/tsconfig.json] no change diff --git a/testdata/baselines/reference/tsc/typeAcquisition/parse-tsconfig-with-typeAcquisition.js b/testdata/baselines/reference/tsc/typeAcquisition/parse-tsconfig-with-typeAcquisition.js index a7992e5aa1..afadeecb5e 100644 --- a/testdata/baselines/reference/tsc/typeAcquisition/parse-tsconfig-with-typeAcquisition.js +++ b/testdata/baselines/reference/tsc/typeAcquisition/parse-tsconfig-with-typeAcquisition.js @@ -1,28 +1,81 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true Input:: -//// [/home/src/workspaces/project/tsconfig.json] new file +//// [/home/src/workspaces/project/tsconfig.json] *new* { - "compilerOptions": { - "composite": true, - "noEmit": true, - }, - "typeAcquisition": { - "enable": true, - "include": ["0.d.ts", "1.d.ts"], - "exclude": ["0.js", "1.js"], - "disableFilenameBasedTypeAcquisition": true, - }, + "compilerOptions": { + "composite": true, + "noEmit": true, + }, + "typeAcquisition": { + "enable": true, + "include": ["0.d.ts", "1.d.ts"], + "exclude": ["0.js", "1.js"], + "disableFilenameBasedTypeAcquisition": true, + }, } -ExitStatus:: 2 - -CompilerOptions::{} +tsgo +ExitStatus:: DiagnosticsPresent_OutputsSkipped Output:: error TS18003: No inputs were found in config file '/home/src/workspaces/project/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '[]'. Found 1 error. -//// [/home/src/workspaces/project/tsconfig.json] no change +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","fileNames":["../../tslibs/TS/Lib/lib.d.ts"],"fileInfos":[{"version":"7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e","affectsGlobalScope":true,"impliedNodeFormat":1}],"options":{"composite":true},"semanticDiagnosticsPerFile":[1]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "fileNames": [ + "../../tslibs/TS/Lib/lib.d.ts" + ], + "fileInfos": [ + { + "fileName": "../../tslibs/TS/Lib/lib.d.ts", + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "signature": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "7dee939514de4bde7a51760a39e2b3bfa068bfc4a2939e1dbad2bfdf2dc4662e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true + }, + "semanticDiagnosticsPerFile": [ + "../../tslibs/TS/Lib/lib.d.ts" + ], + "size": 275 +} +SemanticDiagnostics:: +*not cached* /home/src/tslibs/TS/Lib/lib.d.ts +Signatures:: diff --git a/testdata/baselines/reference/tsc/commandLine/Parse-watch-interval-option-without-tsconfig.json.js b/testdata/baselines/reference/tscWatch/commandLine/Parse-watch-interval-option-without-tsconfig.json.js similarity index 86% rename from testdata/baselines/reference/tsc/commandLine/Parse-watch-interval-option-without-tsconfig.json.js rename to testdata/baselines/reference/tscWatch/commandLine/Parse-watch-interval-option-without-tsconfig.json.js index 8d561acc81..d7bf239951 100644 --- a/testdata/baselines/reference/tsc/commandLine/Parse-watch-interval-option-without-tsconfig.json.js +++ b/testdata/baselines/reference/tscWatch/commandLine/Parse-watch-interval-option-without-tsconfig.json.js @@ -1,40 +1,13 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::-w --watchInterval 1000 - -ExitStatus:: 1 - -ParsedCommandLine::{ - "parsedConfig": { - "compilerOptions": { - "watch": true - }, - "watchOptions": { - "watchInterval": 1000, - "watchFile": 0, - "watchDirectory": 0, - "fallbackPolling": 0, - "synchronousWatchDirectory": null, - "excludeDirectories": null, - "excludeFiles": null - }, - "typeAcquisition": null, - "fileNames": [], - "projectReferences": null - }, - "configFile": null, - "errors": [], - "raw": { - "watch": true, - "watchInterval": 1000 - }, - "compileOnSave": null -} +Input:: + +tsgo -w --watchInterval 1000 +ExitStatus:: DiagnosticsPresent_OutputsSkipped Output:: -Version 7.0.0-dev +Version FakeTSVersion -tsc: The TypeScript Compiler - Version 7.0.0-dev +tsc: The TypeScript Compiler - Version FakeTSVersion COMMON COMMANDS diff --git a/testdata/baselines/reference/tscWatch/commandLine/Parse-watch-interval-option.js b/testdata/baselines/reference/tscWatch/commandLine/Parse-watch-interval-option.js new file mode 100644 index 0000000000..fbff1dd2bb --- /dev/null +++ b/testdata/baselines/reference/tscWatch/commandLine/Parse-watch-interval-option.js @@ -0,0 +1,44 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/first.ts] *new* +export const a = 1 +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "strict": true, + "noEmit": true + } +} + +tsgo -w --watchInterval 1000 +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/first.ts +Signatures:: diff --git a/testdata/baselines/reference/tscWatch/commandLineWatch/watch-with-no-tsconfig.js b/testdata/baselines/reference/tscWatch/commandLineWatch/watch-with-no-tsconfig.js index 4e81e06b4e..fcf71f7645 100644 --- a/testdata/baselines/reference/tscWatch/commandLineWatch/watch-with-no-tsconfig.js +++ b/testdata/baselines/reference/tscWatch/commandLineWatch/watch-with-no-tsconfig.js @@ -1,19 +1,39 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::index.ts --watch -//// [/home/src/workspaces/project/index.ts] new file - - - - -CompilerOptions::{ - "watch": true -} +Input:: +//// [/home/src/workspaces/project/index.ts] *new* +tsgo index.ts --watch +ExitStatus:: Success Output:: -No output -//// [/home/src/workspaces/project/index.ts] new file +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/index.js] *new* +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/index.ts +Signatures:: diff --git a/testdata/baselines/reference/tscWatch/noEmit/dts-errors-without-dts-enabled.js b/testdata/baselines/reference/tscWatch/noEmit/dts-errors-without-dts-enabled.js index 847e9edd27..a426806d75 100644 --- a/testdata/baselines/reference/tscWatch/noEmit/dts-errors-without-dts-enabled.js +++ b/testdata/baselines/reference/tscWatch/noEmit/dts-errors-without-dts-enabled.js @@ -1,108 +1,141 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::-w -//// [/home/src/workspaces/project/a.ts] new file +Input:: +//// [/home/src/workspaces/project/a.ts] *new* const a = class { private p = 10; }; -//// [/home/src/workspaces/project/tsconfig.json] new file +//// [/home/src/workspaces/project/tsconfig.json] *new* { "compilerOptions": { - "noEmit": true, - "outFile": "../outFile.js" + "noEmit": true } } - - -CompilerOptions::{ - "watch": true -} - - +tsgo -w +ExitStatus:: Success Output:: -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] no change - +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: -Edit:: fix syntax error -Output:: -//// [/home/src/workspaces/project/a.ts] modified. new content: +Edit [0]:: fix error +//// [/home/src/workspaces/project/a.ts] *modified* const a = "hello"; -//// [/home/src/workspaces/project/tsconfig.json] no change +Output:: -Edit:: emit after fixing error +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/a.ts -Output:: -//// [/home/src/workspaces/project/a.js] new file -const a = "hello"; -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: +Edit [1]:: emit after fixing error +//// [/home/src/workspaces/project/tsconfig.json] *modified* { "compilerOptions": { - "outFile": "../outFile.js" + } } +Output:: +//// [/home/src/workspaces/project/a.js] *new* +const a = "hello"; -Edit:: no emit run after fixing error -Output:: -//// [/home/src/workspaces/project/a.js] no change -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: +SemanticDiagnostics:: +Signatures:: + + +Edit [2]:: no emit run after fixing error +//// [/home/src/workspaces/project/tsconfig.json] *modified* { "compilerOptions": { "noEmit": true, - "outFile": "../outFile.js" + } } +Output:: -Edit:: introduce error +SemanticDiagnostics:: +Signatures:: -Output:: -//// [/home/src/workspaces/project/a.js] no change -//// [/home/src/workspaces/project/a.ts] modified. new content: + +Edit [3]:: introduce error +//// [/home/src/workspaces/project/a.ts] *modified* const a = class { private p = 10; }; -//// [/home/src/workspaces/project/tsconfig.json] no change +Output:: -Edit:: emit when error +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/a.ts -Output:: -//// [/home/src/workspaces/project/a.js] modified. new content: -const a = class { - p = 10; -}; -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: +Edit [4]:: emit when error +//// [/home/src/workspaces/project/tsconfig.json] *modified* { "compilerOptions": { - "outFile": "../outFile.js" + } } +Output:: +//// [/home/src/workspaces/project/a.js] *modified* +const a = class { + p = 10; +}; + -Edit:: no emit run when error +SemanticDiagnostics:: +Signatures:: -Output:: -//// [/home/src/workspaces/project/a.js] no change -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: + +Edit [5]:: no emit run when error +//// [/home/src/workspaces/project/tsconfig.json] *modified* { "compilerOptions": { "noEmit": true, - "outFile": "../outFile.js" + } } + +Output:: + +SemanticDiagnostics:: +Signatures:: diff --git a/testdata/baselines/reference/tscWatch/noEmit/dts-errors.js b/testdata/baselines/reference/tscWatch/noEmit/dts-errors.js index 66365eafbd..633939b3e4 100644 --- a/testdata/baselines/reference/tscWatch/noEmit/dts-errors.js +++ b/testdata/baselines/reference/tscWatch/noEmit/dts-errors.js @@ -1,25 +1,18 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::-w -//// [/home/src/workspaces/project/a.ts] new file +Input:: +//// [/home/src/workspaces/project/a.ts] *new* const a = class { private p = 10; }; -//// [/home/src/workspaces/project/tsconfig.json] new file +//// [/home/src/workspaces/project/tsconfig.json] *new* { "compilerOptions": { "noEmit": true, - "outFile": "../outFile.js", "declaration": true } } - - -CompilerOptions::{ - "watch": true -} - - +tsgo -w +ExitStatus:: Success Output:: a.ts:1:7 - error TS4094: Property 'p' of exported anonymous class type may not be private or protected. @@ -33,58 +26,91 @@ Output:: Found 1 error in a.ts:1 -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] no change - +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: -Edit:: fix syntax error -Output:: -//// [/home/src/workspaces/project/a.ts] modified. new content: +Edit [0]:: fix error +//// [/home/src/workspaces/project/a.ts] *modified* const a = "hello"; -//// [/home/src/workspaces/project/tsconfig.json] no change - - -Edit:: emit after fixing error Output:: -//// [/home/src/workspaces/project/a.d.ts] new file -declare const a = "hello"; -//// [/home/src/workspaces/project/a.js] new file -const a = "hello"; +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/a.ts + -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: +Edit [1]:: emit after fixing error +//// [/home/src/workspaces/project/tsconfig.json] *modified* { "compilerOptions": { - "outFile": "../outFile.js", "declaration": true } } +Output:: +//// [/home/src/workspaces/project/a.d.ts] *new* +declare const a = "hello"; -Edit:: no emit run after fixing error +//// [/home/src/workspaces/project/a.js] *new* +const a = "hello"; -Output:: -//// [/home/src/workspaces/project/a.d.ts] no change -//// [/home/src/workspaces/project/a.js] no change -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: + +SemanticDiagnostics:: +Signatures:: + + +Edit [2]:: no emit run after fixing error +//// [/home/src/workspaces/project/tsconfig.json] *modified* { "compilerOptions": { "noEmit": true, - "outFile": "../outFile.js", "declaration": true } } +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [3]:: introduce error +//// [/home/src/workspaces/project/a.ts] *modified* +const a = class { private p = 10; }; -Edit:: introduce error Output:: a.ts:1:7 - error TS4094: Property 'p' of exported anonymous class type may not be private or protected. @@ -99,15 +125,22 @@ Output:: Found 1 error in a.ts:1 -//// [/home/src/workspaces/project/a.d.ts] no change -//// [/home/src/workspaces/project/a.js] no change -//// [/home/src/workspaces/project/a.ts] modified. new content: -const a = class { private p = 10; }; -//// [/home/src/workspaces/project/tsconfig.json] no change + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/a.ts +Edit [4]:: emit when error +//// [/home/src/workspaces/project/tsconfig.json] *modified* +{ + "compilerOptions": { + "declaration": true + } +} -Edit:: emit when error Output:: a.ts:1:7 - error TS4094: Property 'p' of exported anonymous class type may not be private or protected. @@ -122,31 +155,33 @@ Output:: Found 1 error in a.ts:1 -//// [/home/src/workspaces/project/a.d.ts] modified. new content: +//// [/home/src/workspaces/project/a.d.ts] *modified* declare const a: { new (): { p: number; }; }; -//// [/home/src/workspaces/project/a.js] modified. new content: +//// [/home/src/workspaces/project/a.js] *modified* const a = class { p = 10; }; -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: + +SemanticDiagnostics:: +Signatures:: + + +Edit [5]:: no emit run when error +//// [/home/src/workspaces/project/tsconfig.json] *modified* { "compilerOptions": { - "outFile": "../outFile.js", + "noEmit": true, "declaration": true } } - -Edit:: no emit run when error - Output:: a.ts:1:7 - error TS4094: Property 'p' of exported anonymous class type may not be private or protected. @@ -160,15 +195,6 @@ Output:: Found 1 error in a.ts:1 -//// [/home/src/workspaces/project/a.d.ts] no change -//// [/home/src/workspaces/project/a.js] no change -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: -{ - "compilerOptions": { - "noEmit": true, - "outFile": "../outFile.js", - "declaration": true - } -} +SemanticDiagnostics:: +Signatures:: diff --git a/testdata/baselines/reference/tscWatch/noEmit/semantic-errors.js b/testdata/baselines/reference/tscWatch/noEmit/semantic-errors.js index a0eacfa2e0..7c8b9c8e80 100644 --- a/testdata/baselines/reference/tscWatch/noEmit/semantic-errors.js +++ b/testdata/baselines/reference/tscWatch/noEmit/semantic-errors.js @@ -1,24 +1,17 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::-w -//// [/home/src/workspaces/project/a.ts] new file +Input:: +//// [/home/src/workspaces/project/a.ts] *new* const a: number = "hello" -//// [/home/src/workspaces/project/tsconfig.json] new file +//// [/home/src/workspaces/project/tsconfig.json] *new* { "compilerOptions": { - "noEmit": true, - "outFile": "../outFile.js" + "noEmit": true } } - - -CompilerOptions::{ - "watch": true -} - - +tsgo -w +ExitStatus:: Success Output:: a.ts:1:7 - error TS2322: Type 'string' is not assignable to type 'number'. @@ -28,52 +21,88 @@ Output:: Found 1 error in a.ts:1 -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] no change - +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: -Edit:: fix syntax error -Output:: -//// [/home/src/workspaces/project/a.ts] modified. new content: +Edit [0]:: fix error +//// [/home/src/workspaces/project/a.ts] *modified* const a = "hello"; -//// [/home/src/workspaces/project/tsconfig.json] no change +Output:: -Edit:: emit after fixing error +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/a.ts -Output:: -//// [/home/src/workspaces/project/a.js] new file -const a = "hello"; -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: +Edit [1]:: emit after fixing error +//// [/home/src/workspaces/project/tsconfig.json] *modified* { "compilerOptions": { - "outFile": "../outFile.js" + } } +Output:: +//// [/home/src/workspaces/project/a.js] *new* +const a = "hello"; + + +SemanticDiagnostics:: +Signatures:: -Edit:: no emit run after fixing error -Output:: -//// [/home/src/workspaces/project/a.js] no change -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: +Edit [2]:: no emit run after fixing error +//// [/home/src/workspaces/project/tsconfig.json] *modified* { "compilerOptions": { "noEmit": true, - "outFile": "../outFile.js" + } } +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [3]:: introduce error +//// [/home/src/workspaces/project/a.ts] *modified* +const a: number = "hello" -Edit:: introduce error Output:: a.ts:1:7 - error TS2322: Type 'string' is not assignable to type 'number'. @@ -84,14 +113,22 @@ Output:: Found 1 error in a.ts:1 -//// [/home/src/workspaces/project/a.js] no change -//// [/home/src/workspaces/project/a.ts] modified. new content: -const a: number = "hello" -//// [/home/src/workspaces/project/tsconfig.json] no change + +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/a.ts +Edit [4]:: emit when error +//// [/home/src/workspaces/project/tsconfig.json] *modified* +{ + "compilerOptions": { + + } +} -Edit:: emit when error Output:: a.ts:1:7 - error TS2322: Type 'string' is not assignable to type 'number'. @@ -102,19 +139,22 @@ Output:: Found 1 error in a.ts:1 -//// [/home/src/workspaces/project/a.js] no change -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: +//// [/home/src/workspaces/project/a.js] *modified time* + +SemanticDiagnostics:: +Signatures:: + + +Edit [5]:: no emit run when error +//// [/home/src/workspaces/project/tsconfig.json] *modified* { "compilerOptions": { - "outFile": "../outFile.js" + "noEmit": true, + } } - -Edit:: no emit run when error - Output:: a.ts:1:7 - error TS2322: Type 'string' is not assignable to type 'number'. @@ -124,13 +164,6 @@ Output:: Found 1 error in a.ts:1 -//// [/home/src/workspaces/project/a.js] no change -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: -{ - "compilerOptions": { - "noEmit": true, - "outFile": "../outFile.js" - } -} +SemanticDiagnostics:: +Signatures:: diff --git a/testdata/baselines/reference/tscWatch/noEmit/syntax-errors.js b/testdata/baselines/reference/tscWatch/noEmit/syntax-errors.js index c2616d28af..ce5b5071b0 100644 --- a/testdata/baselines/reference/tscWatch/noEmit/syntax-errors.js +++ b/testdata/baselines/reference/tscWatch/noEmit/syntax-errors.js @@ -1,24 +1,17 @@ - currentDirectory::/home/src/workspaces/project useCaseSensitiveFileNames::true -Input::-w -//// [/home/src/workspaces/project/a.ts] new file +Input:: +//// [/home/src/workspaces/project/a.ts] *new* const a = "hello -//// [/home/src/workspaces/project/tsconfig.json] new file +//// [/home/src/workspaces/project/tsconfig.json] *new* { "compilerOptions": { - "noEmit": true, - "outFile": "../outFile.js" + "noEmit": true } } - - -CompilerOptions::{ - "watch": true -} - - +tsgo -w +ExitStatus:: Success Output:: a.ts:1:17 - error TS1002: Unterminated string literal. @@ -28,52 +21,88 @@ Output:: Found 1 error in a.ts:1 -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] no change - +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +SemanticDiagnostics:: +*not cached* /home/src/tslibs/TS/Lib/lib.d.ts +*not cached* /home/src/workspaces/project/a.ts +Signatures:: -Edit:: fix syntax error -Output:: -//// [/home/src/workspaces/project/a.ts] modified. new content: +Edit [0]:: fix error +//// [/home/src/workspaces/project/a.ts] *modified* const a = "hello"; -//// [/home/src/workspaces/project/tsconfig.json] no change +Output:: -Edit:: emit after fixing error +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/a.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/a.ts -Output:: -//// [/home/src/workspaces/project/a.js] new file -const a = "hello"; -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: +Edit [1]:: emit after fixing error +//// [/home/src/workspaces/project/tsconfig.json] *modified* { "compilerOptions": { - "outFile": "../outFile.js" + } } +Output:: +//// [/home/src/workspaces/project/a.js] *new* +const a = "hello"; + + +SemanticDiagnostics:: +Signatures:: -Edit:: no emit run after fixing error -Output:: -//// [/home/src/workspaces/project/a.js] no change -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: +Edit [2]:: no emit run after fixing error +//// [/home/src/workspaces/project/tsconfig.json] *modified* { "compilerOptions": { "noEmit": true, - "outFile": "../outFile.js" + } } +Output:: + +SemanticDiagnostics:: +Signatures:: + + +Edit [3]:: introduce error +//// [/home/src/workspaces/project/a.ts] *modified* +const a = "hello -Edit:: introduce error Output:: a.ts:1:17 - error TS1002: Unterminated string literal. @@ -84,14 +113,20 @@ Output:: Found 1 error in a.ts:1 -//// [/home/src/workspaces/project/a.js] no change -//// [/home/src/workspaces/project/a.ts] modified. new content: -const a = "hello -//// [/home/src/workspaces/project/tsconfig.json] no change + +SemanticDiagnostics:: +*not cached* /home/src/workspaces/project/a.ts +Signatures:: +Edit [4]:: emit when error +//// [/home/src/workspaces/project/tsconfig.json] *modified* +{ + "compilerOptions": { + + } +} -Edit:: emit when error Output:: a.ts:1:17 - error TS1002: Unterminated string literal. @@ -102,21 +137,26 @@ Output:: Found 1 error in a.ts:1 -//// [/home/src/workspaces/project/a.js] modified. new content: +//// [/home/src/workspaces/project/a.js] *modified* const a = "hello; -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: + +SemanticDiagnostics:: +*not cached* /home/src/workspaces/project/a.ts +Signatures:: +(computed .d.ts) /home/src/workspaces/project/a.ts + + +Edit [5]:: no emit run when error +//// [/home/src/workspaces/project/tsconfig.json] *modified* { "compilerOptions": { - "outFile": "../outFile.js" + "noEmit": true, + } } - -Edit:: no emit run when error - Output:: a.ts:1:17 - error TS1002: Unterminated string literal. @@ -126,13 +166,7 @@ Output:: Found 1 error in a.ts:1 -//// [/home/src/workspaces/project/a.js] no change -//// [/home/src/workspaces/project/a.ts] no change -//// [/home/src/workspaces/project/tsconfig.json] modified. new content: -{ - "compilerOptions": { - "noEmit": true, - "outFile": "../outFile.js" - } -} +SemanticDiagnostics:: +*not cached* /home/src/workspaces/project/a.ts +Signatures::