diff --git a/internal/execute/tsctests/extract.go b/internal/execute/tsctests/extract.go new file mode 100644 index 00000000000..d9f14b3bf24 --- /dev/null +++ b/internal/execute/tsctests/extract.go @@ -0,0 +1,355 @@ +package tsctests + +import ( + "crypto/sha1" + "encoding/hex" + "fmt" + "go/format" + "io/fs" + "maps" + "os" + "path/filepath" + "regexp" + "slices" + "strconv" + "strings" + "sync" + "testing/fstest" + "time" + + "github.com/microsoft/typescript-go/internal/repo" +) + +// capturedFsEntry is a comparable snapshot of a single entry on the test file +// system. Exactly one of content or symlink is non-empty. mtime is included +// so that "touch without content change" edits can be detected. +type capturedFsEntry struct { + content string + symlink string + mtime time.Time +} + +// capturedEditOp describes one observed effect of running a tscEdit's edit +// function, used to generate equivalent calls in the extracted test file. +type capturedEditOp struct { + op string // "write", "remove", "symlink" + path string + content string // for "write" (file content) or "symlink" (target path) +} + +// captureFsSnapshot returns a comparable map of the current user-visible +// state of the test file system, excluding files that were auto-injected as +// default library files. +func captureFsSnapshot(sys *TestSys) map[string]capturedFsEntry { + snap := map[string]capturedFsEntry{} + libs := sys.fs.defaultLibs + m := sys.mapFs() + for path, file := range m.Entries() { + if libs != nil && libs.Has(path) { + continue + } + if file.Mode&fs.ModeSymlink != 0 { + target, _ := m.GetTargetOfSymlink(path) + snap[path] = capturedFsEntry{symlink: target, mtime: file.ModTime} + } else if file.Mode.IsRegular() { + snap[path] = capturedFsEntry{content: string(file.Data), mtime: file.ModTime} + } + } + return snap +} + +// diffFsSnapshots reports the operations needed to transform before into +// after. Removals come first, then writes (sorted by path), so the generated +// code is deterministic. +func diffFsSnapshots(before, after map[string]capturedFsEntry) []capturedEditOp { + var ops []capturedEditOp + removed := make([]string, 0) + for path := range before { + if _, ok := after[path]; !ok { + removed = append(removed, path) + } + } + slices.Sort(removed) + for _, p := range removed { + ops = append(ops, capturedEditOp{op: "remove", path: p}) + } + changed := make([]string, 0) + for path, ae := range after { + if be, ok := before[path]; !ok || be != ae { + changed = append(changed, path) + } + } + slices.Sort(changed) + for _, p := range changed { + e := after[p] + if e.symlink != "" { + ops = append(ops, capturedEditOp{op: "symlink", path: p, content: e.symlink}) + } else { + ops = append(ops, capturedEditOp{op: "write", path: p, content: e.content}) + } + } + return ops +} + +// writeTestSourceFile emits a standalone _test.go file under +// internal/execute/tsctests/tests/ that, when executed, reproduces the given +// test scenario by constructing an equivalent [TestSpec] and invoking Run on +// it. Edit functions are reconstructed from the observed file system effects +// captured during the original run. +func (test *tscInput) writeTestSourceFile(scenario string, editOps [][]capturedEditOp) { + funcName := makeTestFuncName(test.getBaselineSubFolder(), scenario, test.subScenario) + source := test.renderTestSource(scenario, funcName, editOps) + if formatted, err := format.Source([]byte(source)); err == nil { + source = string(formatted) + } + + outDir := filepath.Join(repo.RootPath(), "internal", "execute", "tsctests", "tests") + if err := os.MkdirAll(outDir, 0o755); err != nil { + panic(fmt.Errorf("tsctests: failed to create %s: %w", outDir, err)) + } + testFileName := funcName + "_test.go" + testFileName = strings.ToLower(testFileName[:1]) + testFileName[1:] + outPath := filepath.Join(outDir, testFileName) + if existing, err := os.ReadFile(outPath); err == nil && string(existing) == source { + return + } + if err := os.WriteFile(outPath, []byte(source), 0o644); err != nil { + panic(fmt.Errorf("tsctests: failed to write %s: %w", outPath, err)) + } +} + +func (test *tscInput) renderTestSource(scenario string, funcName string, editOps [][]capturedEditOp) string { + needsVfstest := fileMapNeedsVfstest(test.files) || editOpsNeedVfstest(editOps) + + var b strings.Builder + b.WriteString("// Code generated by tsctests; DO NOT EDIT.\n") + b.WriteString("\n") + b.WriteString("package tests\n") + b.WriteString("\n") + b.WriteString("import (\n") + b.WriteString("\t\"testing\"\n") + b.WriteString("\n") + b.WriteString("\t\"github.com/microsoft/typescript-go/internal/execute/tsctests\"\n") + if needsVfstest { + b.WriteString("\t\"github.com/microsoft/typescript-go/internal/vfs/vfstest\"\n") + } + b.WriteString(")\n") + b.WriteString("\n") + + fmt.Fprintf(&b, "func Test%s(t *testing.T) {\n", funcName) + b.WriteString("\ttest := &tsctests.TestSpec{\n") + fmt.Fprintf(&b, "\t\tScenario: %s,\n", strconv.Quote(scenario)) + fmt.Fprintf(&b, "\t\tSubScenario: %s,\n", strconv.Quote(test.subScenario)) + if test.commandLineArgs != nil { + fmt.Fprintf(&b, "\t\tCommandLineArgs: %s,\n", formatStringSlice(test.commandLineArgs)) + } + if test.cwd != "" { + fmt.Fprintf(&b, "\t\tCwd: %s,\n", strconv.Quote(test.cwd)) + } + if test.ignoreCase { + b.WriteString("\t\tIgnoreCase: true,\n") + } + if test.windowsStyleRoot != "" { + fmt.Fprintf(&b, "\t\tWindowsStyleRoot: %s,\n", strconv.Quote(test.windowsStyleRoot)) + } + if len(test.env) > 0 { + writeEnvField(&b, test.env, "\t\t") + } + if len(test.files) > 0 { + writeFilesField(&b, test.files, "\t\t") + } + b.WriteString("\t}\n") + b.WriteString("\ttest.Start(t)\n") + if len(test.edits) > 0 { + writeEditCalls(&b, test.edits, editOps, "\t") + } + b.WriteString("\ttest.End()\n") + b.WriteString("}\n") + + return b.String() +} + +func fileMapNeedsVfstest(files FileMap) bool { + for _, v := range files { + if mf, ok := v.(*fstest.MapFile); ok && mf.Mode&fs.ModeSymlink != 0 { + return true + } + } + return false +} + +func editOpsNeedVfstest(editOps [][]capturedEditOp) bool { + for _, ops := range editOps { + for _, op := range ops { + if op.op == "symlink" { + return true + } + } + } + return false +} + +func writeEnvField(b *strings.Builder, env map[string]string, indent string) { + fmt.Fprintf(b, "%sEnv: map[string]string{\n", indent) + keys := slices.Sorted(maps.Keys(env)) + for _, k := range keys { + fmt.Fprintf(b, "%s\t%s: %s,\n", indent, strconv.Quote(k), strconv.Quote(env[k])) + } + fmt.Fprintf(b, "%s},\n", indent) +} + +func writeFilesField(b *strings.Builder, files FileMap, indent string) { + fmt.Fprintf(b, "%sFiles: tsctests.FileMap{\n", indent) + keys := slices.Sorted(maps.Keys(files)) + for _, k := range keys { + fmt.Fprintf(b, "%s\t%s: %s,\n", indent, strconv.Quote(k), formatFileMapValue(files[k])) + } + fmt.Fprintf(b, "%s},\n", indent) +} + +func formatFileMapValue(v any) string { + switch tv := v.(type) { + case string: + return formatStringLiteral(tv) + case []byte: + return formatStringLiteral(string(tv)) + case *fstest.MapFile: + if tv.Mode&fs.ModeSymlink != 0 { + target := string(tv.Data) + if !strings.HasPrefix(target, "/") { + target = "/" + target + } + return fmt.Sprintf("vfstest.Symlink(%s)", strconv.Quote(target)) + } + return formatStringLiteral(string(tv.Data)) + default: + return fmt.Sprintf("%q /* unsupported FileMap value type %T */", fmt.Sprintf("%v", v), v) + } +} + +func writeEditCalls(b *strings.Builder, edits []*tscEdit, editOps [][]capturedEditOp, indent string) { + for i, e := range edits { + b.WriteString("\n") + fmt.Fprintf(b, "%stest.Edit(&tsctests.TestEdit{\n", indent) + if e.caption != "" { + fmt.Fprintf(b, "%s\tCaption: %s,\n", indent, strconv.Quote(e.caption)) + } + if e.commandLineArgs != nil { + fmt.Fprintf(b, "%s\tCommandLineArgs: %s,\n", indent, formatStringSlice(e.commandLineArgs)) + } + if e.expectedDiff != "" { + fmt.Fprintf(b, "%s\tExpectedDiff: %s,\n", indent, strconv.Quote(e.expectedDiff)) + } + if i < len(editOps) && len(editOps[i]) > 0 { + fmt.Fprintf(b, "%s\tEdit: func(sys *tsctests.TestSys) {\n", indent) + for _, op := range editOps[i] { + switch op.op { + case "write": + fmt.Fprintf(b, "%s\t\tsys.WriteFile(%s, %s)\n", indent, strconv.Quote(op.path), formatStringLiteral(op.content)) + case "remove": + fmt.Fprintf(b, "%s\t\tsys.Remove(%s)\n", indent, strconv.Quote(op.path)) + case "symlink": + // TestSys does not yet expose a way to create symlinks at + // runtime; record the intent so a human can finish the + // edit by hand if needed. + fmt.Fprintf(b, "%s\t\t_ = vfstest.Symlink(%s) // TODO: create symlink at %s\n", indent, strconv.Quote(op.content), strconv.Quote(op.path)) + } + } + fmt.Fprintf(b, "%s\t},\n", indent) + } + fmt.Fprintf(b, "%s})\n", indent) + } +} + +// formatStringLiteral picks the most readable Go string literal for s. Raw +// string literals are preferred for multi-line content, falling back to +// double-quoted strings when the content contains characters that cannot +// appear in a raw literal (e.g. a backtick). +func formatStringLiteral(s string) string { + if shouldUseRawLiteral(s) { + return "`" + s + "`" + } + return strconv.Quote(s) +} + +func shouldUseRawLiteral(s string) bool { + if strings.ContainsAny(s, "`\r") { + return false + } + if !strings.Contains(s, "\n") { + return false + } + for _, r := range s { + // Raw strings preserve every byte literally, but they must contain + // only valid printable runes plus tab/newline to round-trip cleanly. + if r == '\t' || r == '\n' { + continue + } + if r < 0x20 || r == 0x7f { + return false + } + } + return true +} + +func formatStringSlice(slice []string) string { + parts := make([]string, len(slice)) + for i, s := range slice { + parts[i] = strconv.Quote(s) + } + return "[]string{" + strings.Join(parts, ", ") + "}" +} + +var ( + identSanitizer = regexp.MustCompile(`[^A-Za-z0-9]+`) + + // usedFuncNames tracks generated test function names within this process + // so that two distinct (scenario, subScenario) pairs that sanitize to the + // same identifier do not silently overwrite each other. + usedFuncNames = map[string]struct{}{} + usedFuncNamesMu sync.Mutex +) + +// makeTestFuncName produces a unique, valid Go identifier suitable for use as +// a test function name. It joins the supplied parts with underscores and +// appends a short hash suffix when the sanitized result would be ambiguous. +func makeTestFuncName(parts ...string) string { + var b strings.Builder + joinedRaw := strings.Join(parts, "/") + for i, p := range parts { + sanitized := identSanitizer.ReplaceAllString(p, "_") + sanitized = strings.Trim(sanitized, "_") + if sanitized == "" { + continue + } + if i != 0 { + b.WriteByte('_') + } else { + sanitized = strings.ToUpper(sanitized[:1]) + sanitized[1:] // Test function must start with uppercase + } + + b.WriteString(sanitized) + } + + const maxLen = 160 + name := b.String() + if len(name) > maxLen { + sum := sha1.Sum([]byte(joinedRaw)) + suffix := "_" + hex.EncodeToString(sum[:4]) + name = name[:maxLen-len(suffix)] + suffix + } + + usedFuncNamesMu.Lock() + defer usedFuncNamesMu.Unlock() + if _, taken := usedFuncNames[name]; taken { + sum := sha1.Sum([]byte(joinedRaw)) + suffix := "_" + hex.EncodeToString(sum[:4]) + candidate := name + suffix + if len(candidate) > maxLen { + candidate = name[:maxLen-len(suffix)] + suffix + } + name = candidate + } + usedFuncNames[name] = struct{}{} + return name +} diff --git a/internal/execute/tsctests/runner.go b/internal/execute/tsctests/runner.go index 8adfca02233..7e4de4bcb1e 100644 --- a/internal/execute/tsctests/runner.go +++ b/internal/execute/tsctests/runner.go @@ -38,6 +38,10 @@ type tscInput struct { env map[string]string ignoreCase bool windowsStyleRoot string + // extracted is true when this tscInput was constructed from a [TestSpec] + // (e.g. by a generated test file). When true, run() skips the call to + // writeTestSourceFile to avoid re-emitting the same generated file. + extracted bool } func (test *tscInput) executeCommand(sys *TestSys, baselineBuilder *strings.Builder, commandLineArgs []string) tsc.CommandLineResult { @@ -66,74 +70,146 @@ func (test *tscInput) run(t *testing.T, scenario string) { t.Helper() t.Run(test.getBaselineSubFolder()+"/"+test.subScenario, func(t *testing.T) { t.Parallel() - // initial test tsc compile - baselineBuilder := &strings.Builder{} - sys := newTestSys(test, false) - fmt.Fprint( - baselineBuilder, - "currentDirectory::", - sys.GetCurrentDirectory(), - "\nuseCaseSensitiveFileNames::", - sys.FS().UseCaseSensitiveFileNames(), - "\nInput::\n", - ) - sys.baselineFSwithDiff(baselineBuilder) - result := test.executeCommand(sys, baselineBuilder, test.commandLineArgs) - sys.serializeState(baselineBuilder) - var unexpectedDiff strings.Builder - unexpectedDiff.WriteString(sys.baselinePrograms(baselineBuilder, "Initial build")) - - 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) - - if result.Watcher == nil { - test.executeCommand(sys, baselineBuilder, commandLineArgs) - } else { - result.Watcher.DoCycle() - } - sys.serializeState(baselineBuilder) - unexpectedDiff.WriteString(sys.baselinePrograms(baselineBuilder, fmt.Sprintf("Edit [%d]:: %s\n", index, do.caption))) - }) - wg.Queue(func() { - // Compute build with all the edits - nonIncrementalSys = newTestSys(test, true) - for i := range index + 1 { - if test.edits[i].edit != nil { - test.edits[i].edit(nonIncrementalSys) - } - } - execute.CommandLine(nonIncrementalSys, commandLineArgs, nonIncrementalSys) - }) - wg.RunAndWait() - - diff := getDiffForIncremental(sys, nonIncrementalSys) - if diff != "" { - baselineBuilder.WriteString(fmt.Sprintf("\n\nDiff:: %s\n", core.IfElse(do.expectedDiff == "", "!!! Unexpected diff, please review and either fix or write explanation as expectedDiff !!!", do.expectedDiff))) - baselineBuilder.WriteString(diff) - if do.expectedDiff == "" { - unexpectedDiff.WriteString(fmt.Sprintf("Edit [%d]:: %s\n!!! Unexpected diff, please review and either fix or write explanation as expectedDiff !!!\n%s\n", index, do.caption, diff)) - } - } else if do.expectedDiff != "" { - baselineBuilder.WriteString(fmt.Sprintf("\n\nDiff:: %s !!! Diff not found but explanation present, please review and remove the explanation !!!\n", do.expectedDiff)) - unexpectedDiff.WriteString(fmt.Sprintf("Edit [%d]:: %s\n!!! Diff not found but explanation present, please review and remove the explanation !!!\n", index, do.caption)) - } - } - baseline.Run(t, strings.ReplaceAll(test.subScenario, " ", "-")+".js", baselineBuilder.String(), baseline.Options{Subfolder: filepath.Join(test.getBaselineSubFolder(), scenario)}) - if unexpectedDiff.String() != "" { - t.Errorf("Test %s has unexpected diff %s with incremental build, please review the baseline file", test.subScenario, unexpectedDiff.String()) + state := test.start(t, scenario) + for _, do := range test.edits { + test.runEdit(state, do) } + test.end(state) }) } +// tscInputState holds the per-run state created by [tscInput.start] and +// threaded through [tscInput.runEdit] and [tscInput.end]. It is used both by +// the legacy declarative [tscInput.run] entry point and by the imperative +// Start/Edit/End methods on [TestSpec] used by generated test files. +type tscInputState struct { + t *testing.T + scenario string + sys *TestSys + result tsc.CommandLineResult + baselineBuilder *strings.Builder + unexpectedDiff *strings.Builder + // editOps records the file-system operations observed while running each + // edit. Only populated when the test was not loaded from an extracted + // source file, since generated tests do not need to re-emit themselves. + editOps [][]capturedEditOp + // appliedEdits is the list of edits that have been run so far (in order). + // The non-incremental comparison build needs to replay every preceding + // edit before applying the current one, so we keep them around for the + // lifetime of the test. + appliedEdits []*tscEdit + // editIndex is the 0-based index of the next edit to be run. + editIndex int + // ended indicates that [tscInput.end] has already run, so subsequent + // Edit/End calls can be rejected. + ended bool +} + +// start performs the initial build for a test and returns the in-progress +// state. Callers must invoke runEdit zero or more times followed by end. +func (test *tscInput) start(t *testing.T, scenario string) *tscInputState { + t.Helper() + state := &tscInputState{ + t: t, + scenario: scenario, + baselineBuilder: &strings.Builder{}, + unexpectedDiff: &strings.Builder{}, + } + state.sys = newTestSys(test, false) + fmt.Fprint( + state.baselineBuilder, + "currentDirectory::", + state.sys.GetCurrentDirectory(), + "\nuseCaseSensitiveFileNames::", + state.sys.FS().UseCaseSensitiveFileNames(), + "\nInput::\n", + ) + state.sys.baselineFSwithDiff(state.baselineBuilder) + state.result = test.executeCommand(state.sys, state.baselineBuilder, test.commandLineArgs) + state.sys.serializeState(state.baselineBuilder) + state.unexpectedDiff.WriteString(state.sys.baselinePrograms(state.baselineBuilder, "Initial build")) + return state +} + +// runEdit applies a single edit to the in-progress state, runs the +// incremental and non-incremental builds, and appends the result to the +// baseline being accumulated. +func (test *tscInput) runEdit(state *tscInputState, do *tscEdit) { + if state.ended { + panic("tscInput.runEdit called after end") + } + index := state.editIndex + state.editIndex++ + state.appliedEdits = append(state.appliedEdits, do) + extractEdits := !test.extracted + + sys := state.sys + sys.clearOutput() + var nonIncrementalSys *TestSys + commandLineArgs := core.IfElse(do.commandLineArgs == nil, test.commandLineArgs, do.commandLineArgs) + state.baselineBuilder.WriteString(fmt.Sprintf("\n\nEdit [%d]:: %s\n", index, do.caption)) + var beforeSnap map[string]capturedFsEntry + if extractEdits { + beforeSnap = captureFsSnapshot(sys) + } + if do.edit != nil { + do.edit(sys) + } + if extractEdits { + for len(state.editOps) <= index { + state.editOps = append(state.editOps, nil) + } + state.editOps[index] = diffFsSnapshots(beforeSnap, captureFsSnapshot(sys)) + } + sys.baselineFSwithDiff(state.baselineBuilder) + + if state.result.Watcher == nil { + test.executeCommand(sys, state.baselineBuilder, commandLineArgs) + } else { + state.result.Watcher.DoCycle() + } + sys.serializeState(state.baselineBuilder) + state.unexpectedDiff.WriteString(sys.baselinePrograms(state.baselineBuilder, fmt.Sprintf("Edit [%d]:: %s\n", index, do.caption))) + + // Compute build with all the edits applied so far in order. + nonIncrementalSys = newTestSys(test, true) + for _, e := range state.appliedEdits { + if e.edit != nil { + e.edit(nonIncrementalSys) + } + } + execute.CommandLine(nonIncrementalSys, commandLineArgs, nonIncrementalSys) + + diff := getDiffForIncremental(sys, nonIncrementalSys) + if diff != "" { + state.baselineBuilder.WriteString(fmt.Sprintf("\n\nDiff:: %s\n", core.IfElse(do.expectedDiff == "", "!!! Unexpected diff, please review and either fix or write explanation as expectedDiff !!!", do.expectedDiff))) + state.baselineBuilder.WriteString(diff) + if do.expectedDiff == "" { + state.unexpectedDiff.WriteString(fmt.Sprintf("Edit [%d]:: %s\n!!! Unexpected diff, please review and either fix or write explanation as expectedDiff !!!\n%s\n", index, do.caption, diff)) + } + } else if do.expectedDiff != "" { + state.baselineBuilder.WriteString(fmt.Sprintf("\n\nDiff:: %s !!! Diff not found but explanation present, please review and remove the explanation !!!\n", do.expectedDiff)) + state.unexpectedDiff.WriteString(fmt.Sprintf("Edit [%d]:: %s\n!!! Diff not found but explanation present, please review and remove the explanation !!!\n", index, do.caption)) + } +} + +// end finalises the run by writing the extracted test source file (when +// applicable), running the baseline comparison, and reporting unexpected +// diffs against the non-incremental build. +func (test *tscInput) end(state *tscInputState) { + if state.ended { + panic("tscInput.end called twice") + } + state.ended = true + if !test.extracted { + test.writeTestSourceFile(state.scenario, state.editOps) + } + baseline.Run(state.t, strings.ReplaceAll(test.subScenario, " ", "-")+".js", state.baselineBuilder.String(), baseline.Options{Subfolder: filepath.Join(test.getBaselineSubFolder(), state.scenario)}) + if state.unexpectedDiff.String() != "" { + state.t.Errorf("Test %s has unexpected diff %s with incremental build, please review the baseline file", test.subScenario, state.unexpectedDiff.String()) + } +} + func getDiffForIncremental(incrementalSys *TestSys, nonIncrementalSys *TestSys) string { var diffBuilder strings.Builder diff --git a/internal/execute/tsctests/spec.go b/internal/execute/tsctests/spec.go new file mode 100644 index 00000000000..3f3c44f3135 --- /dev/null +++ b/internal/execute/tsctests/spec.go @@ -0,0 +1,98 @@ +package tsctests + +import "testing" + +// TestSpec is the exported representation of a tscInput. It exists so that +// generated test files in subpackages can construct and drive a single test +// scenario through the [TestSpec.Start], [TestSpec.Edit], and [TestSpec.End] +// methods. +type TestSpec struct { + // Scenario is the grouping label normally passed to (*tscInput).run, e.g. + // "commandLine", "noEmit", or "extends". Used as part of the baseline path. + Scenario string + + // SubScenario is the per-test sub-name used by the baseline runner. + SubScenario string + + CommandLineArgs []string + Files FileMap + Cwd string + Env map[string]string + IgnoreCase bool + WindowsStyleRoot string + + // input and state are populated by Start and consumed by Edit/End. + input *tscInput + state *tscInputState +} + +// TestEdit is the exported representation of a tscEdit. +type TestEdit struct { + Caption string + CommandLineArgs []string + Edit func(*TestSys) + ExpectedDiff string +} + +// Start performs the initial build for the spec on the provided testing.T. +// It must be called exactly once before any call to Edit or End, and is +// responsible for calling t.Parallel so the extracted tests run concurrently. +func (s *TestSpec) Start(t *testing.T) { + t.Helper() + if s.input != nil { + panic("TestSpec.Start called twice") + } + s.input = &tscInput{ + subScenario: s.SubScenario, + commandLineArgs: s.CommandLineArgs, + files: s.Files, + cwd: s.Cwd, + env: s.Env, + ignoreCase: s.IgnoreCase, + windowsStyleRoot: s.WindowsStyleRoot, + extracted: true, + } + t.Parallel() + s.state = s.input.start(t, s.Scenario) +} + +// Edit applies the given edit to the running test and runs the incremental +// and non-incremental builds, accumulating the result into the baseline. +// Passing nil is treated as a "no change" edit. +func (s *TestSpec) Edit(e *TestEdit) { + if s.state == nil { + panic("TestSpec.Edit called before Start") + } + if e == nil { + s.input.runEdit(s.state, noChange) + return + } + s.input.runEdit(s.state, &tscEdit{ + caption: e.Caption, + commandLineArgs: e.CommandLineArgs, + edit: e.Edit, + expectedDiff: e.ExpectedDiff, + }) +} + +// End finalises the run, writing the accumulated baseline and reporting any +// unexpected diffs against the non-incremental build. +func (s *TestSpec) End() { + if s.state == nil { + panic("TestSpec.End called before Start") + } + s.input.end(s.state) +} + +// WriteFile writes content to the given path on the test file system, +// panicking on error. Exposed so generated tests can describe edits as a +// series of file system operations. +func (s *TestSys) WriteFile(path string, content string) { + s.writeFileNoError(path, content) +} + +// Remove removes the file or directory at path on the test file system, +// panicking on error. Exposed for generated edit functions. +func (s *TestSys) Remove(path string) { + s.removeNoError(path) +} diff --git a/internal/execute/tsctests/tests/testmain_test.go b/internal/execute/tsctests/tests/testmain_test.go new file mode 100644 index 00000000000..126a6539d7c --- /dev/null +++ b/internal/execute/tsctests/tests/testmain_test.go @@ -0,0 +1,14 @@ +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/testutil/baseline" +) + +func TestMain(m *testing.M) { + core.ApplyDebugStackLimit() + defer baseline.Track()() + m.Run() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_configFileErrors_reports_syntax_errors_in_config_file_test.go b/internal/execute/tsctests/tests/tsbuildWatch_configFileErrors_reports_syntax_errors_in_config_file_test.go new file mode 100644 index 00000000000..43687b754c5 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_configFileErrors_reports_syntax_errors_in_config_file_test.go @@ -0,0 +1,84 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_configFileErrors_reports_syntax_errors_in_config_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "configFileErrors", + SubScenario: "reports syntax errors in config file", + CommandLineArgs: []string{"--b", "-w"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export function foo() { }", + "/home/src/workspaces/project/b.ts": "export function bar() { }", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + }, + "files": [ + "a.ts" + "b.ts" + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "reports syntax errors after change to config file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "composite": true, "declaration": true + }, + "files": [ + "a.ts" + "b.ts" + ] +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "reports syntax errors after change to ts file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export function foo() { }export function fooBar() { }") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "reports error when there is no change to tsconfig file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "composite": true, "declaration": true + }, + "files": [ + "a.ts" + "b.ts" + ] +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "builds after fixing config file errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "composite": true, "declaration": true + }, + "files": [ + "a.ts", + "b.ts" + ] +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_demo_updates_with_bad_reference_test.go b/internal/execute/tsctests/tests/tsbuildWatch_demo_updates_with_bad_reference_test.go new file mode 100644 index 00000000000..c633eac1591 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_demo_updates_with_bad_reference_test.go @@ -0,0 +1,120 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_demo_updates_with_bad_reference(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "demo", + SubScenario: "updates with bad reference", + CommandLineArgs: []string{"--b", "-w", "--verbose"}, + Cwd: "/user/username/projects/demo", + Files: tsctests.FileMap{ + "/user/username/projects/demo/animals/animal.ts": `export type Size = "small" | "medium" | "large"; +export default interface Animal { + size: Size; +}`, + "/user/username/projects/demo/animals/dog.ts": "import Animal from '.';\nimport { makeRandomName } from '../core/utilities';\n\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\n\nexport function createDog(): Dog {\n return ({\n size: \"medium\",\n woof: function(this: Dog) {\n console.log(`${ this.name } says \"Woof\"!`);\n },\n name: makeRandomName()\n });\n}", + "/user/username/projects/demo/animals/index.ts": `import Animal from './animal'; + +export default Animal; +import { createDog, Dog } from './dog'; +export { createDog, Dog };`, + "/user/username/projects/demo/animals/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/animals", + "rootDir": "." + }, + "references": [ + { "path": "../core" } + ] +}`, + "/user/username/projects/demo/core/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/core", + "rootDir": "." + }, +}`, + "/user/username/projects/demo/core/utilities.ts": `import * as A from '../animals' +export function makeRandomName() { + return "Bob!?! "; +} + +export function lastElementOf(arr: T[]): T | undefined { + if (arr.length === 0) return undefined; + return arr[arr.length - 1]; +}`, + "/user/username/projects/demo/tsconfig-base.json": `{ + "compilerOptions": { + "declaration": true, + "target": "es5", + "module": "commonjs", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "composite": true, + }, +}`, + "/user/username/projects/demo/tsconfig.json": `{ + "files": [], + "references": [ + { + "path": "./core" + }, + { + "path": "./animals", + }, + { + "path": "./zoo", + }, + ], +}`, + "/user/username/projects/demo/zoo/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/zoo", + "rootDir": "." + }, + "references": [ + { + "path": "../animals" + } + ] +}`, + "/user/username/projects/demo/zoo/zoo.ts": `import { Dog, createDog } from '../animals/index'; + +export function createZoo(): Array { + return [ + createDog() + ]; +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Prepend a line", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/demo/core/utilities.ts", ` +import * as A from '../animals' +export function makeRandomName() { + return "Bob!?! "; +} + +export function lastElementOf(arr: T[]): T | undefined { + if (arr.length === 0) return undefined; + return arr[arr.length - 1]; +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_demo_updates_with_circular_reference_test.go b/internal/execute/tsctests/tests/tsbuildWatch_demo_updates_with_circular_reference_test.go new file mode 100644 index 00000000000..cbd3d986f7a --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_demo_updates_with_circular_reference_test.go @@ -0,0 +1,121 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_demo_updates_with_circular_reference(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "demo", + SubScenario: "updates with circular reference", + CommandLineArgs: []string{"--b", "-w", "--verbose"}, + Cwd: "/user/username/projects/demo", + Files: tsctests.FileMap{ + "/user/username/projects/demo/animals/animal.ts": `export type Size = "small" | "medium" | "large"; +export default interface Animal { + size: Size; +}`, + "/user/username/projects/demo/animals/dog.ts": "import Animal from '.';\nimport { makeRandomName } from '../core/utilities';\n\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\n\nexport function createDog(): Dog {\n return ({\n size: \"medium\",\n woof: function(this: Dog) {\n console.log(`${ this.name } says \"Woof\"!`);\n },\n name: makeRandomName()\n });\n}", + "/user/username/projects/demo/animals/index.ts": `import Animal from './animal'; + +export default Animal; +import { createDog, Dog } from './dog'; +export { createDog, Dog };`, + "/user/username/projects/demo/animals/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/animals", + "rootDir": "." + }, + "references": [ + { "path": "../core" } + ] +}`, + "/user/username/projects/demo/core/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/core", + "rootDir": "." + }, + "references": [ + { + "path": "../zoo", + } + ] +}`, + "/user/username/projects/demo/core/utilities.ts": `export function makeRandomName() { + return "Bob!?! "; +} + +export function lastElementOf(arr: T[]): T | undefined { + if (arr.length === 0) return undefined; + return arr[arr.length - 1]; +}`, + "/user/username/projects/demo/tsconfig-base.json": `{ + "compilerOptions": { + "declaration": true, + "target": "es5", + "module": "commonjs", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "composite": true, + }, +}`, + "/user/username/projects/demo/tsconfig.json": `{ + "files": [], + "references": [ + { + "path": "./core" + }, + { + "path": "./animals", + }, + { + "path": "./zoo", + }, + ], +}`, + "/user/username/projects/demo/zoo/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/zoo", + "rootDir": "." + }, + "references": [ + { + "path": "../animals" + } + ] +}`, + "/user/username/projects/demo/zoo/zoo.ts": `import { Dog, createDog } from '../animals/index'; + +export function createZoo(): Array { + return [ + createDog() + ]; +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/demo/core/tsconfig.json", `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/core", + "rootDir": "." + }, +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_extends_configDir_template_test.go b/internal/execute/tsctests/tests/tsbuildWatch_extends_configDir_template_test.go new file mode 100644 index 00000000000..44838039044 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_extends_configDir_template_test.go @@ -0,0 +1,68 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_extends_configDir_template(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "extends", + SubScenario: "configDir template", + CommandLineArgs: []string{"--b", "-w", "--explainFiles", "--v"}, + Cwd: "/home/src/projects/myproject", + Files: tsctests.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/*"], + }, + }, + "watchOptions": { + "excludeFiles": ["${configDir}/main.ts"], + }, +}`, + "/home/src/projects/myproject/main.ts": `// some comment +export const y = 10; +import { x } from "@myscope/sometype";`, + "/home/src/projects/myproject/tsconfig.json": `{ + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true, + }, +}`, + "/home/src/projects/myproject/types/sometype.ts": "export const x = 10;", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "edit extended config file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/configs/first/tsconfig.json", `{ + "extends": "../second/tsconfig.json", + "include": ["${configDir}/src"], + "compilerOptions": { + "typeRoots": ["${configDir}/root2"], + "types": [], + }, +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_libraryResolution_with_config_test.go b/internal/execute/tsctests/tests/tsbuildWatch_libraryResolution_with_config_test.go new file mode 100644 index 00000000000..28f74054a77 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_libraryResolution_with_config_test.go @@ -0,0 +1,73 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_libraryResolution_with_config(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "libraryResolution", + SubScenario: "with config", + CommandLineArgs: []string{"-b", "-w", "project1", "project2", "project3", "project4", "--verbose", "--explainFiles"}, + Cwd: "/home/src/workspace/projects", + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.dom.d.ts": "interface DOMInterface { }", + "/home/src/tslibs/TS/Lib/lib.scripthost.d.ts": "interface ScriptHostInterface { }", + "/home/src/tslibs/TS/Lib/lib.webworker.d.ts": "interface WebWorkerInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/unlreated/index.d.ts": "export const unrelated = 10;", + "/home/src/workspace/projects/project1/core.d.ts": "export const core = 10;", + "/home/src/workspace/projects/project1/file.ts": "export const file = 10;", + "/home/src/workspace/projects/project1/file2.ts": `/// +/// +/// `, + "/home/src/workspace/projects/project1/index.ts": "export const x = \"type1\";", + "/home/src/workspace/projects/project1/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "typeRoots": ["./typeroot1"], + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": false + } +}`, + "/home/src/workspace/projects/project1/typeroot1/sometype/index.d.ts": "export type TheNum = \"type1\";", + "/home/src/workspace/projects/project1/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project2/index.ts": "export const y = 10", + "/home/src/workspace/projects/project2/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": false + } +}`, + "/home/src/workspace/projects/project2/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project3/index.ts": "export const z = 10", + "/home/src/workspace/projects/project3/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": false + } +}`, + "/home/src/workspace/projects/project3/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project4/index.ts": "export const z = 10", + "/home/src/workspace/projects/project4/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["esnext", "dom", "webworker"], + "traceResolution": true, + "libReplacement": false + } +}`, + "/home/src/workspace/projects/project4/utils.d.ts": "export const y = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_libraryResolution_with_config_with_libReplacement_test.go b/internal/execute/tsctests/tests/tsbuildWatch_libraryResolution_with_config_with_libReplacement_test.go new file mode 100644 index 00000000000..e5be64d4fa1 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_libraryResolution_with_config_with_libReplacement_test.go @@ -0,0 +1,120 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_libraryResolution_with_config_with_libReplacement(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "libraryResolution", + SubScenario: "with config with libReplacement", + CommandLineArgs: []string{"-b", "-w", "project1", "project2", "project3", "project4", "--verbose", "--explainFiles"}, + Cwd: "/home/src/workspace/projects", + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.dom.d.ts": "interface DOMInterface { }", + "/home/src/tslibs/TS/Lib/lib.scripthost.d.ts": "interface ScriptHostInterface { }", + "/home/src/tslibs/TS/Lib/lib.webworker.d.ts": "interface WebWorkerInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/lib-dom/index.d.ts": "interface DOMInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/lib-es5/index.d.ts": `/// +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/workspace/projects/node_modules/@typescript/lib-esnext/index.d.ts": `/// +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/workspace/projects/node_modules/@typescript/lib-scripthost/index.d.ts": "interface ScriptHostInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/lib-webworker/index.d.ts": "interface WebWorkerInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/unlreated/index.d.ts": "export const unrelated = 10;", + "/home/src/workspace/projects/project1/core.d.ts": "export const core = 10;", + "/home/src/workspace/projects/project1/file.ts": "export const file = 10;", + "/home/src/workspace/projects/project1/file2.ts": `/// +/// +/// `, + "/home/src/workspace/projects/project1/index.ts": "export const x = \"type1\";", + "/home/src/workspace/projects/project1/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "typeRoots": ["./typeroot1"], + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": true + } +}`, + "/home/src/workspace/projects/project1/typeroot1/sometype/index.d.ts": "export type TheNum = \"type1\";", + "/home/src/workspace/projects/project1/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project2/index.ts": "export const y = 10", + "/home/src/workspace/projects/project2/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": true + } +}`, + "/home/src/workspace/projects/project2/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project3/index.ts": "export const z = 10", + "/home/src/workspace/projects/project3/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": true + } +}`, + "/home/src/workspace/projects/project3/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project4/index.ts": "export const z = 10", + "/home/src/workspace/projects/project4/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["esnext", "dom", "webworker"], + "traceResolution": true, + "libReplacement": true + } +}`, + "/home/src/workspace/projects/project4/utils.d.ts": "export const y = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_moduleResolution_build_mode_watches_for_changes_to_package_json_main_fields_test.go b/internal/execute/tsctests/tests/tsbuildWatch_moduleResolution_build_mode_watches_for_changes_to_package_json_main_fields_test.go new file mode 100644 index 00000000000..1ec16f5bfdb --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_moduleResolution_build_mode_watches_for_changes_to_package_json_main_fields_test.go @@ -0,0 +1,74 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsbuildWatch_moduleResolution_build_mode_watches_for_changes_to_package_json_main_fields(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleResolution", + SubScenario: "build mode watches for changes to package-json main fields", + CommandLineArgs: []string{"-b", "packages/pkg1", "--verbose", "-w", "--traceResolution"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/node_modules/pkg2": vfstest.Symlink("/user/username/projects/myproject/packages/pkg2"), + "/user/username/projects/myproject/packages/pkg1/index.ts": `import type { TheNum } from 'pkg2' +export const theNum: TheNum = 42;`, + "/user/username/projects/myproject/packages/pkg1/package.json": `{ + "name": "pkg1", + "version": "1.0.0", + "main": "build/index.js" +}`, + "/user/username/projects/myproject/packages/pkg1/tsconfig.json": `{ + "compilerOptions": { + "outDir": "build", + }, + "references": [{ "path": "../pkg2" }], +}`, + "/user/username/projects/myproject/packages/pkg2/const.ts": "export type TheNum = 42;", + "/user/username/projects/myproject/packages/pkg2/index.ts": "export type { TheNum } from './const.js';", + "/user/username/projects/myproject/packages/pkg2/other.ts": "export type TheStr = string;", + "/user/username/projects/myproject/packages/pkg2/package.json": `{ + "name": "pkg2", + "version": "1.0.0", + "main": "build/index.js" +}`, + "/user/username/projects/myproject/packages/pkg2/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "build", + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "reports import errors after change to package file", + ExpectedDiff: "Package.json watch pending, so no change detected yet", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/packages/pkg2/package.json", `{ + "name": "pkg2", + "version": "1.0.0", + "main": "build/other.js" +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "removes those errors when a package file is changed back", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/packages/pkg2/package.json", `{ + "name": "pkg2", + "version": "1.0.0", + "main": "build/index.js" +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_moduleResolution_handles_the_cache_correctly_when_two_projects_use_different_module_resolution_settings_test.go b/internal/execute/tsctests/tests/tsbuildWatch_moduleResolution_handles_the_cache_correctly_when_two_projects_use_different_module_resolution_settings_test.go new file mode 100644 index 00000000000..1502509ecc2 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_moduleResolution_handles_the_cache_correctly_when_two_projects_use_different_module_resolution_settings_test.go @@ -0,0 +1,58 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_moduleResolution_handles_the_cache_correctly_when_two_projects_use_different_module_resolution_settings(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleResolution", + SubScenario: "handles the cache correctly when two projects use different module resolution settings", + CommandLineArgs: []string{"--b", "-w", "-v"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/node_modules/@types/bar/index.d.ts": "export const bar = 10;", + "/user/username/projects/myproject/node_modules/@types/foo/index.d.ts": "export const foo = 10;", + "/user/username/projects/myproject/project1/index.ts": "import { foo } from \"file\";", + "/user/username/projects/myproject/project1/node_modules/file/index.d.ts": "export const foo = 10;", + "/user/username/projects/myproject/project1/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "types": ["foo", "bar"] + }, + "files": ["index.ts"], +}`, + "/user/username/projects/myproject/project2/index.ts": "import { foo } from \"file\";", + "/user/username/projects/myproject/project2/node_modules/file/index.d.ts": "export const foo = 10;", + "/user/username/projects/myproject/project2/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "types": ["foo"], + "module": "nodenext", + "moduleResolution": "nodenext" + }, + "files": ["index.ts"], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "files": [], + "references": [ + { "path": "./project1" }, + { "path": "./project2" }, + ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Append text", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/project1/index.ts", "import { foo } from \"file\";const bar = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_moduleResolution_resolves_specifier_in_output_declaration_file_from_referenced_project_correctly_with_cts_and_mts_extensions_test.go b/internal/execute/tsctests/tests/tsbuildWatch_moduleResolution_resolves_specifier_in_output_declaration_file_from_referenced_project_correctly_with_cts_and_mts_extensions_test.go new file mode 100644 index 00000000000..e2fd2f3529f --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_moduleResolution_resolves_specifier_in_output_declaration_file_from_referenced_project_correctly_with_cts_and_mts_extensions_test.go @@ -0,0 +1,106 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsbuildWatch_moduleResolution_resolves_specifier_in_output_declaration_file_from_referenced_project_correctly_with_cts_and_mts_extensions(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleResolution", + SubScenario: "resolves specifier in output declaration file from referenced project correctly with cts and mts extensions", + CommandLineArgs: []string{"-b", "packages/pkg1", "-w", "--verbose", "--traceResolution"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/node_modules/pkg2": vfstest.Symlink("/user/username/projects/myproject/packages/pkg2"), + "/user/username/projects/myproject/packages/pkg1/index.ts": `import type { TheNum } from 'pkg2' +export const theNum: TheNum = 42;`, + "/user/username/projects/myproject/packages/pkg1/package.json": `{ + "name": "pkg1", + "version": "1.0.0", + "main": "build/index.js", + "type": "module" +}`, + "/user/username/projects/myproject/packages/pkg1/tsconfig.json": `{ + "compilerOptions": { + "outDir": "build", + "module": "node16", + }, + "references": [{ "path": "../pkg2" }], +}`, + "/user/username/projects/myproject/packages/pkg2/const.cts": "export type TheNum = 42;", + "/user/username/projects/myproject/packages/pkg2/index.ts": "export type { TheNum } from './const.cjs';", + "/user/username/projects/myproject/packages/pkg2/package.json": `{ + "name": "pkg2", + "version": "1.0.0", + "main": "build/index.js", + "type": "module" +}`, + "/user/username/projects/myproject/packages/pkg2/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "build", + "module": "node16", + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "reports import errors after change to package file", + ExpectedDiff: "Package.json watch pending, so no change detected yet", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/packages/pkg1/package.json", `{ + "name": "pkg1", + "version": "1.0.0", + "main": "build/index.js", + "type": "commonjs" +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "removes those errors when a package file is changed back", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/packages/pkg1/package.json", `{ + "name": "pkg1", + "version": "1.0.0", + "main": "build/index.js", + "type": "module" +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "reports import errors after change to package file", + ExpectedDiff: "Package.json watch pending, so no change detected yet", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/packages/pkg1/package.json", `{ + "name": "pkg1", + "version": "1.0.0", + "main": "build/index.js", + "type": "commonjs" +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "removes those errors when a package file is changed to cjs extensions", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/user/username/projects/myproject/packages/pkg2/index.ts") + sys.WriteFile("/user/username/projects/myproject/packages/pkg2/index.cts", "export type { TheNum } from './const.cjs';") + sys.WriteFile("/user/username/projects/myproject/packages/pkg2/package.json", `{ + "name": "pkg2", + "version": "1.0.0", + "main": "build/index.cjs", + "type": "module" +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmitOnError_noEmitOnError_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmitOnError_noEmitOnError_test.go new file mode 100644 index 00000000000..afd490b634f --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmitOnError_noEmitOnError_test.go @@ -0,0 +1,133 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmitOnError_noEmitOnError(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "noEmitOnError", + CommandLineArgs: []string{"-b", "-w", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix syntax errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "semantic errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix semantic errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix dts errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmitOnError_noEmitOnError_with_declaration_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmitOnError_noEmitOnError_with_declaration_test.go new file mode 100644 index 00000000000..63a1ae55ef4 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmitOnError_noEmitOnError_with_declaration_test.go @@ -0,0 +1,133 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmitOnError_noEmitOnError_with_declaration(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "noEmitOnError with declaration", + CommandLineArgs: []string{"-b", "-w", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix syntax errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "semantic errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix semantic errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix dts errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmitOnError_noEmitOnError_with_declaration_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmitOnError_noEmitOnError_with_declaration_with_incremental_test.go new file mode 100644 index 00000000000..5e6a9e78051 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmitOnError_noEmitOnError_with_declaration_with_incremental_test.go @@ -0,0 +1,133 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmitOnError_noEmitOnError_with_declaration_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "noEmitOnError with declaration with incremental", + CommandLineArgs: []string{"-b", "-w", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix syntax errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "semantic errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix semantic errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix dts errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmitOnError_noEmitOnError_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmitOnError_noEmitOnError_with_incremental_test.go new file mode 100644 index 00000000000..49fac3b4b8b --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmitOnError_noEmitOnError_with_incremental_test.go @@ -0,0 +1,133 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmitOnError_noEmitOnError_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "noEmitOnError with incremental", + CommandLineArgs: []string{"-b", "-w", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix syntax errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "semantic errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix semantic errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix dts errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_does_not_go_in_loop_when_watching_when_no_files_are_emitted_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_does_not_go_in_loop_when_watching_when_no_files_are_emitted_test.go new file mode 100644 index 00000000000..d328156b046 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_does_not_go_in_loop_when_watching_when_no_files_are_emitted_test.go @@ -0,0 +1,44 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_does_not_go_in_loop_when_watching_when_no_files_are_emitted(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "does not go in loop when watching when no files are emitted", + CommandLineArgs: []string{"-b", "-w", "-verbose"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/a.js": "", + "/user/username/projects/myproject/b.ts": "", + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { + "allowJs": true, + "noEmit": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/a.js", "") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/a.js", "const x = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_does_not_go_in_loop_when_watching_when_no_files_are_emitted_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_does_not_go_in_loop_when_watching_when_no_files_are_emitted_with_incremental_test.go new file mode 100644 index 00000000000..5aec18aa6de --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_does_not_go_in_loop_when_watching_when_no_files_are_emitted_with_incremental_test.go @@ -0,0 +1,44 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_does_not_go_in_loop_when_watching_when_no_files_are_emitted_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "does not go in loop when watching when no files are emitted with incremental", + CommandLineArgs: []string{"-b", "-w", "-verbose", "--incremental"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/a.js": "", + "/user/username/projects/myproject/b.ts": "", + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { + "allowJs": true, + "noEmit": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/a.js", "") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/a.js", "const x = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_test.go new file mode 100644 index 00000000000..92a65664403 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_test.go @@ -0,0 +1,91 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_dts_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors", + CommandLineArgs: []string{"-b", "-verbose", "-w"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": false, + "declaration": true + , "noEmit": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": true + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": true + , "noEmit": true } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": true + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": true + , "noEmit": true } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_with_incremental_as_modules_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_with_incremental_as_modules_test.go new file mode 100644 index 00000000000..280469f2339 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_with_incremental_as_modules_test.go @@ -0,0 +1,92 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_dts_errors_with_incremental_as_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors with incremental as modules", + CommandLineArgs: []string{"-b", "-verbose", "-w"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a = class { private p = 10; };", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": true + , "noEmit": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": true + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": true + , "noEmit": true } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": true + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": true + , "noEmit": true } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_with_incremental_test.go new file mode 100644 index 00000000000..0251e6b82a2 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_with_incremental_test.go @@ -0,0 +1,91 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_dts_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors with incremental", + CommandLineArgs: []string{"-b", "-verbose", "-w"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": true + , "noEmit": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": true + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": true + , "noEmit": true } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": true + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": true + , "noEmit": true } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_without_dts_enabled_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_without_dts_enabled_test.go new file mode 100644 index 00000000000..aac826c0468 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_without_dts_enabled_test.go @@ -0,0 +1,91 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_dts_errors_without_dts_enabled(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors without dts enabled", + CommandLineArgs: []string{"-b", "-verbose", "-w"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": true } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": true } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_without_dts_enabled_with_incremental_as_modules_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_without_dts_enabled_with_incremental_as_modules_test.go new file mode 100644 index 00000000000..c083dcdddb1 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_without_dts_enabled_with_incremental_as_modules_test.go @@ -0,0 +1,92 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_dts_errors_without_dts_enabled_with_incremental_as_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors without dts enabled with incremental as modules", + CommandLineArgs: []string{"-b", "-verbose", "-w"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a = class { private p = 10; };", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_without_dts_enabled_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_without_dts_enabled_with_incremental_test.go new file mode 100644 index 00000000000..fcef5c62d85 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_dts_errors_without_dts_enabled_with_incremental_test.go @@ -0,0 +1,91 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_dts_errors_without_dts_enabled_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors without dts enabled with incremental", + CommandLineArgs: []string{"-b", "-verbose", "-w"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_semantic_errors_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_semantic_errors_test.go new file mode 100644 index 00000000000..c024c33b1e2 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_semantic_errors_test.go @@ -0,0 +1,91 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_semantic_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "semantic errors", + CommandLineArgs: []string{"-b", "-verbose", "-w"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a: number = \"hello\"", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": true } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a: number = \"hello\"") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": true } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_semantic_errors_with_incremental_as_modules_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_semantic_errors_with_incremental_as_modules_test.go new file mode 100644 index 00000000000..1a1d74148cc --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_semantic_errors_with_incremental_as_modules_test.go @@ -0,0 +1,92 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_semantic_errors_with_incremental_as_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "semantic errors with incremental as modules", + CommandLineArgs: []string{"-b", "-verbose", "-w"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a: number = \"hello\"", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a: number = \"hello\"") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_semantic_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_semantic_errors_with_incremental_test.go new file mode 100644 index 00000000000..6c1c51118e5 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_semantic_errors_with_incremental_test.go @@ -0,0 +1,91 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_semantic_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "semantic errors with incremental", + CommandLineArgs: []string{"-b", "-verbose", "-w"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a: number = \"hello\"", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a: number = \"hello\"") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_syntax_errors_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_syntax_errors_test.go new file mode 100644 index 00000000000..19bc5ff527b --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_syntax_errors_test.go @@ -0,0 +1,91 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_syntax_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "syntax errors", + CommandLineArgs: []string{"-b", "-verbose", "-w"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = \"hello", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": true } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": false, + "declaration": false + , "noEmit": true } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_syntax_errors_with_incremental_as_modules_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_syntax_errors_with_incremental_as_modules_test.go new file mode 100644 index 00000000000..0f83de27ec7 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_syntax_errors_with_incremental_as_modules_test.go @@ -0,0 +1,92 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_syntax_errors_with_incremental_as_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "syntax errors with incremental as modules", + CommandLineArgs: []string{"-b", "-verbose", "-w"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a = \"hello", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_noEmit_syntax_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_syntax_errors_with_incremental_test.go new file mode 100644 index 00000000000..13aea1eceb1 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_noEmit_syntax_errors_with_incremental_test.go @@ -0,0 +1,91 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_noEmit_syntax_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "syntax errors with incremental", + CommandLineArgs: []string{"-b", "-verbose", "-w"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = \"hello", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no Emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "declaration": false + , "noEmit": true } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_declarationEmitErrors_introduceError_when_file_with_no_error_changes_test.go b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_declarationEmitErrors_introduceError_when_file_with_no_error_changes_test.go new file mode 100644 index 00000000000..0dd1dbbf92a --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_declarationEmitErrors_introduceError_when_file_with_no_error_changes_test.go @@ -0,0 +1,49 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_programUpdates_declarationEmitErrors_introduceError_when_file_with_no_error_changes(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "programUpdates", + SubScenario: "declarationEmitErrors introduceError when file with no error changes", + CommandLineArgs: []string{"-b", "-w", "app"}, + Cwd: "/user/username/projects/solution", + Files: tsctests.FileMap{ + "/user/username/projects/solution/app/fileWithError.ts": `export var myClassWithError = class { + tags() { } + +};`, + "/user/username/projects/solution/app/fileWithoutError.ts": "export class myClass { }", + "/user/username/projects/solution/app/tsconfig.json": `{ + "compilerOptions": { + "composite": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/solution/app/fileWithError.ts", `export var myClassWithError = class { + tags() { } + private p = 12 +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Change fileWithoutError", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/solution/app/fileWithoutError.ts", "export class myClass2 { }") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_declarationEmitErrors_introduceError_when_fixing_errors_only_changed_file_is_emitted_test.go b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_declarationEmitErrors_introduceError_when_fixing_errors_only_changed_file_is_emitted_test.go new file mode 100644 index 00000000000..f0f9936f809 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_declarationEmitErrors_introduceError_when_fixing_errors_only_changed_file_is_emitted_test.go @@ -0,0 +1,52 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_programUpdates_declarationEmitErrors_introduceError_when_fixing_errors_only_changed_file_is_emitted(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "programUpdates", + SubScenario: "declarationEmitErrors introduceError when fixing errors only changed file is emitted", + CommandLineArgs: []string{"-b", "-w", "app"}, + Cwd: "/user/username/projects/solution", + Files: tsctests.FileMap{ + "/user/username/projects/solution/app/fileWithError.ts": `export var myClassWithError = class { + tags() { } + +};`, + "/user/username/projects/solution/app/fileWithoutError.ts": "export class myClass { }", + "/user/username/projects/solution/app/tsconfig.json": `{ + "compilerOptions": { + "composite": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/solution/app/fileWithError.ts", `export var myClassWithError = class { + tags() { } + private p = 12 +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/solution/app/fileWithError.ts", `export var myClassWithError = class { + tags() { } + +};`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_declarationEmitErrors_when_file_with_no_error_changes_test.go b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_declarationEmitErrors_when_file_with_no_error_changes_test.go new file mode 100644 index 00000000000..93ecc59fcfb --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_declarationEmitErrors_when_file_with_no_error_changes_test.go @@ -0,0 +1,39 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_programUpdates_declarationEmitErrors_when_file_with_no_error_changes(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "programUpdates", + SubScenario: "declarationEmitErrors when file with no error changes", + CommandLineArgs: []string{"-b", "-w", "app"}, + Cwd: "/user/username/projects/solution", + Files: tsctests.FileMap{ + "/user/username/projects/solution/app/fileWithError.ts": `export var myClassWithError = class { + tags() { } + private p = 12 +};`, + "/user/username/projects/solution/app/fileWithoutError.ts": "export class myClass { }", + "/user/username/projects/solution/app/tsconfig.json": `{ + "compilerOptions": { + "composite": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Change fileWithoutError", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/solution/app/fileWithoutError.ts", "export class myClass2 { }") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_declarationEmitErrors_when_fixing_error_files_all_files_are_emitted_test.go b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_declarationEmitErrors_when_fixing_error_files_all_files_are_emitted_test.go new file mode 100644 index 00000000000..6c8afdc8948 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_declarationEmitErrors_when_fixing_error_files_all_files_are_emitted_test.go @@ -0,0 +1,42 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_programUpdates_declarationEmitErrors_when_fixing_error_files_all_files_are_emitted(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "programUpdates", + SubScenario: "declarationEmitErrors when fixing error files all files are emitted", + CommandLineArgs: []string{"-b", "-w", "app"}, + Cwd: "/user/username/projects/solution", + Files: tsctests.FileMap{ + "/user/username/projects/solution/app/fileWithError.ts": `export var myClassWithError = class { + tags() { } + private p = 12 +};`, + "/user/username/projects/solution/app/fileWithoutError.ts": "export class myClass { }", + "/user/username/projects/solution/app/tsconfig.json": `{ + "compilerOptions": { + "composite": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/solution/app/fileWithError.ts", `export var myClassWithError = class { + tags() { } + +};`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_tsbuildinfo_has_error_test.go b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_tsbuildinfo_has_error_test.go new file mode 100644 index 00000000000..a9828420133 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_tsbuildinfo_has_error_test.go @@ -0,0 +1,25 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_programUpdates_tsbuildinfo_has_error(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "programUpdates", + SubScenario: "tsbuildinfo has error", + CommandLineArgs: []string{"--b", "-i", "-w"}, + Cwd: "/user/username/projects/project", + Files: tsctests.FileMap{ + "/user/username/projects/project/main.ts": "export const x = 10;", + "/user/username/projects/project/tsconfig.json": "{}", + "/user/username/projects/project/tsconfig.tsbuildinfo": "Some random string", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_when_referenced_project_change_introduces_error_in_the_down_stream_project_and_then_fixes_it_test.go b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_when_referenced_project_change_introduces_error_in_the_down_stream_project_and_then_fixes_it_test.go new file mode 100644 index 00000000000..0047b568761 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_when_referenced_project_change_introduces_error_in_the_down_stream_project_and_then_fixes_it_test.go @@ -0,0 +1,77 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_programUpdates_when_referenced_project_change_introduces_error_in_the_down_stream_project_and_then_fixes_it(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "programUpdates", + SubScenario: "when referenced project change introduces error in the down stream project and then fixes it", + CommandLineArgs: []string{"-b", "-w", "App"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/App/app.ts": `import { createSomeObject } from "../Library/library"; +createSomeObject().message;`, + "/user/username/projects/sample1/App/tsconfig.json": `{ + "references": [{ "path": "../Library" }] +}`, + "/user/username/projects/sample1/Library/library.ts": `interface SomeObject +{ + message: string; +} + +export function createSomeObject(): SomeObject +{ + return { + message: "new Object" + }; +}`, + "/user/username/projects/sample1/Library/tsconfig.json": `{ + "compilerOptions": { + "composite": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/Library/library.ts", `interface SomeObject +{ + message2: string; +} + +export function createSomeObject(): SomeObject +{ + return { + message2: "new Object" + }; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/Library/library.ts", `interface SomeObject +{ + message: string; +} + +export function createSomeObject(): SomeObject +{ + return { + message: "new Object" + }; +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_works_correctly_when_project_with_extended_config_is_removed_test.go b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_works_correctly_when_project_with_extended_config_is_removed_test.go new file mode 100644 index 00000000000..61064a437d3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_works_correctly_when_project_with_extended_config_is_removed_test.go @@ -0,0 +1,74 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_programUpdates_works_correctly_when_project_with_extended_config_is_removed(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "programUpdates", + SubScenario: "works correctly when project with extended config is removed", + CommandLineArgs: []string{"-b", "-w", "-v"}, + Cwd: "/user/username/projects/project", + Files: tsctests.FileMap{ + "/user/username/projects/project/alpha.tsconfig.json": `{ + "compilerOptions": { + "strict": true, + }, +}`, + "/user/username/projects/project/bravo.tsconfig.json": `{ + "compilerOptions": { + "strict": true, + }, +}`, + "/user/username/projects/project/commonFile1.ts": "let x = 1", + "/user/username/projects/project/commonFile2.ts": "let y = 1", + "/user/username/projects/project/other.ts": "let z = 0;", + "/user/username/projects/project/project1.tsconfig.json": `{ + "extends": "./alpha.tsconfig.json", + "compilerOptions": { + "composite": true, + }, + "files": ["commonFile1.ts", "commonFile2.ts"], +}`, + "/user/username/projects/project/project2.tsconfig.json": `{ + "extends": "./bravo.tsconfig.json", + "compilerOptions": { + "composite": true, + }, + "files": ["other.ts"], +}`, + "/user/username/projects/project/tsconfig.json": `{ + "references": [ + { + "path": "./project1.tsconfig.json", + }, + { + "path": "./project2.tsconfig.json", + }, + ], + "files": [], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Remove project2 from base config", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/project/tsconfig.json", `{ + "references": [ + { + "path": "./project1.tsconfig.json", + }, + ], + "files": [], +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_works_when_noUnusedParameters_changes_to_false_test.go b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_works_when_noUnusedParameters_changes_to_false_test.go new file mode 100644 index 00000000000..bed7d3c119e --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_works_when_noUnusedParameters_changes_to_false_test.go @@ -0,0 +1,39 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_programUpdates_works_when_noUnusedParameters_changes_to_false(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "programUpdates", + SubScenario: "works when noUnusedParameters changes to false", + CommandLineArgs: []string{"-b", "-w"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/index.ts": "const fn = (a: string, b: string) => b;", + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { + "noUnusedParameters": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Change tsconfig to set noUnusedParameters to false", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/tsconfig.json", `{ + "compilerOptions": { + "noUnusedParameters": false, + }, +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_works_with_extended_source_files_test.go b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_works_with_extended_source_files_test.go new file mode 100644 index 00000000000..ffc536c97f5 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_programUpdates_works_with_extended_source_files_test.go @@ -0,0 +1,135 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_programUpdates_works_with_extended_source_files(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "programUpdates", + SubScenario: "works with extended source files", + CommandLineArgs: []string{"-b", "-w", "-v", "project1.tsconfig.json", "project2.tsconfig.json", "project3.tsconfig.json"}, + Cwd: "/user/username/projects/project", + Files: tsctests.FileMap{ + "/user/username/projects/project/alpha.tsconfig.json": "{}", + "/user/username/projects/project/bravo.tsconfig.json": `{ + "extends": "./alpha.tsconfig.json", +}`, + "/user/username/projects/project/commonFile1.ts": "let x = 1", + "/user/username/projects/project/commonFile2.ts": "let y = 1", + "/user/username/projects/project/extendsConfig1.tsconfig.json": `{ + "compilerOptions": { + "composite": true, + }, +}`, + "/user/username/projects/project/extendsConfig2.tsconfig.json": `{ + "compilerOptions": { + "strictNullChecks": false, + }, +}`, + "/user/username/projects/project/extendsConfig3.tsconfig.json": `{ + "compilerOptions": { + "noImplicitAny": true, + }, +}`, + "/user/username/projects/project/other.ts": "let z = 0;", + "/user/username/projects/project/other2.ts": "let k = 0;", + "/user/username/projects/project/project1.tsconfig.json": `{ + "extends": "./alpha.tsconfig.json", + "compilerOptions": { + "composite": true, + }, + "files": ["commonFile1.ts", "commonFile2.ts"], +}`, + "/user/username/projects/project/project2.tsconfig.json": `{ + "extends": "./bravo.tsconfig.json", + "compilerOptions": { + "composite": true, + }, + "files": ["other.ts"], +}`, + "/user/username/projects/project/project3.tsconfig.json": `{ + "extends": [ + "./extendsConfig1.tsconfig.json", + "./extendsConfig2.tsconfig.json", + "./extendsConfig3.tsconfig.json", + ], + "compilerOptions": { + "composite": false, + }, + "files": ["other2.ts"], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Modify alpha config", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/project/alpha.tsconfig.json", `{ + "compilerOptions": { + "strict": true + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "change bravo config", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/project/bravo.tsconfig.json", `{ + "extends": "./alpha.tsconfig.json", + "compilerOptions": { "strict": false } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "project 2 extends alpha", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/project/project2.tsconfig.json", `{ + "extends": "./alpha.tsconfig.json", + "files": ["other.ts"] +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "update aplha config", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/project/alpha.tsconfig.json", "{}") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Modify extendsConfigFile2", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/project/extendsConfig2.tsconfig.json", `{ + "compilerOptions": { "strictNullChecks": true } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Modify project 3", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/project/project3.tsconfig.json", `{ + "extends": ["./extendsConfig1.tsconfig.json", "./extendsConfig2.tsconfig.json"], + "compilerOptions": { "composite": false }, + "files": ["other2.ts"], +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Delete extendedConfigFile2 and report error", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/user/username/projects/project/extendsConfig2.tsconfig.json") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_23_projects_in_a_solution_test.go b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_23_projects_in_a_solution_test.go new file mode 100644 index 00000000000..16a9542960a --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_23_projects_in_a_solution_test.go @@ -0,0 +1,187 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_projectsBuilding_when_there_are_23_projects_in_a_solution(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 23 projects in a solution", + CommandLineArgs: []string{"-b", "-w", "-v"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg10/index.ts": "export const pkg10 = 10;", + "/user/username/projects/myproject/pkg10/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg11/index.ts": "export const pkg11 = 11;", + "/user/username/projects/myproject/pkg11/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg12/index.ts": "export const pkg12 = 12;", + "/user/username/projects/myproject/pkg12/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg13/index.ts": "export const pkg13 = 13;", + "/user/username/projects/myproject/pkg13/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg14/index.ts": "export const pkg14 = 14;", + "/user/username/projects/myproject/pkg14/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg15/index.ts": "export const pkg15 = 15;", + "/user/username/projects/myproject/pkg15/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg16/index.ts": "export const pkg16 = 16;", + "/user/username/projects/myproject/pkg16/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg17/index.ts": "export const pkg17 = 17;", + "/user/username/projects/myproject/pkg17/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg18/index.ts": "export const pkg18 = 18;", + "/user/username/projects/myproject/pkg18/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg19/index.ts": "export const pkg19 = 19;", + "/user/username/projects/myproject/pkg19/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg20/index.ts": "export const pkg20 = 20;", + "/user/username/projects/myproject/pkg20/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg21/index.ts": "export const pkg21 = 21;", + "/user/username/projects/myproject/pkg21/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg22/index.ts": "export const pkg22 = 22;", + "/user/username/projects/myproject/pkg22/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg3/index.ts": "export const pkg3 = 3;", + "/user/username/projects/myproject/pkg3/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg4/index.ts": "export const pkg4 = 4;", + "/user/username/projects/myproject/pkg4/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg5/index.ts": "export const pkg5 = 5;", + "/user/username/projects/myproject/pkg5/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg6/index.ts": "export const pkg6 = 6;", + "/user/username/projects/myproject/pkg6/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg7/index.ts": "export const pkg7 = 7;", + "/user/username/projects/myproject/pkg7/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg8/index.ts": "export const pkg8 = 8;", + "/user/username/projects/myproject/pkg8/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg9/index.ts": "export const pkg9 = 9;", + "/user/username/projects/myproject/pkg9/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" }, + { "path": "./pkg3" }, + { "path": "./pkg4" }, + { "path": "./pkg5" }, + { "path": "./pkg6" }, + { "path": "./pkg7" }, + { "path": "./pkg8" }, + { "path": "./pkg9" }, + { "path": "./pkg10" }, + { "path": "./pkg11" }, + { "path": "./pkg12" }, + { "path": "./pkg13" }, + { "path": "./pkg14" }, + { "path": "./pkg15" }, + { "path": "./pkg16" }, + { "path": "./pkg17" }, + { "path": "./pkg18" }, + { "path": "./pkg19" }, + { "path": "./pkg20" }, + { "path": "./pkg21" }, + { "path": "./pkg22" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_23_projects_in_a_solution_with_builders_3_test.go b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_23_projects_in_a_solution_with_builders_3_test.go new file mode 100644 index 00000000000..da8e03aff95 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_23_projects_in_a_solution_with_builders_3_test.go @@ -0,0 +1,187 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_projectsBuilding_when_there_are_23_projects_in_a_solution_with_builders_3(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 23 projects in a solution with --builders 3", + CommandLineArgs: []string{"-b", "-w", "-v", "--builders", "3"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg10/index.ts": "export const pkg10 = 10;", + "/user/username/projects/myproject/pkg10/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg11/index.ts": "export const pkg11 = 11;", + "/user/username/projects/myproject/pkg11/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg12/index.ts": "export const pkg12 = 12;", + "/user/username/projects/myproject/pkg12/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg13/index.ts": "export const pkg13 = 13;", + "/user/username/projects/myproject/pkg13/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg14/index.ts": "export const pkg14 = 14;", + "/user/username/projects/myproject/pkg14/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg15/index.ts": "export const pkg15 = 15;", + "/user/username/projects/myproject/pkg15/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg16/index.ts": "export const pkg16 = 16;", + "/user/username/projects/myproject/pkg16/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg17/index.ts": "export const pkg17 = 17;", + "/user/username/projects/myproject/pkg17/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg18/index.ts": "export const pkg18 = 18;", + "/user/username/projects/myproject/pkg18/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg19/index.ts": "export const pkg19 = 19;", + "/user/username/projects/myproject/pkg19/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg20/index.ts": "export const pkg20 = 20;", + "/user/username/projects/myproject/pkg20/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg21/index.ts": "export const pkg21 = 21;", + "/user/username/projects/myproject/pkg21/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg22/index.ts": "export const pkg22 = 22;", + "/user/username/projects/myproject/pkg22/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg3/index.ts": "export const pkg3 = 3;", + "/user/username/projects/myproject/pkg3/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg4/index.ts": "export const pkg4 = 4;", + "/user/username/projects/myproject/pkg4/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg5/index.ts": "export const pkg5 = 5;", + "/user/username/projects/myproject/pkg5/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg6/index.ts": "export const pkg6 = 6;", + "/user/username/projects/myproject/pkg6/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg7/index.ts": "export const pkg7 = 7;", + "/user/username/projects/myproject/pkg7/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg8/index.ts": "export const pkg8 = 8;", + "/user/username/projects/myproject/pkg8/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg9/index.ts": "export const pkg9 = 9;", + "/user/username/projects/myproject/pkg9/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" }, + { "path": "./pkg3" }, + { "path": "./pkg4" }, + { "path": "./pkg5" }, + { "path": "./pkg6" }, + { "path": "./pkg7" }, + { "path": "./pkg8" }, + { "path": "./pkg9" }, + { "path": "./pkg10" }, + { "path": "./pkg11" }, + { "path": "./pkg12" }, + { "path": "./pkg13" }, + { "path": "./pkg14" }, + { "path": "./pkg15" }, + { "path": "./pkg16" }, + { "path": "./pkg17" }, + { "path": "./pkg18" }, + { "path": "./pkg19" }, + { "path": "./pkg20" }, + { "path": "./pkg21" }, + { "path": "./pkg22" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_3_projects_in_a_solution_test.go b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_3_projects_in_a_solution_test.go new file mode 100644 index 00000000000..050c8dcf67e --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_3_projects_in_a_solution_test.go @@ -0,0 +1,67 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_projectsBuilding_when_there_are_3_projects_in_a_solution(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 3 projects in a solution", + CommandLineArgs: []string{"-b", "-w", "-v"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_3_projects_in_a_solution_with_builders_1_test.go b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_3_projects_in_a_solution_with_builders_1_test.go new file mode 100644 index 00000000000..ed480d0b4a7 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_3_projects_in_a_solution_with_builders_1_test.go @@ -0,0 +1,67 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_projectsBuilding_when_there_are_3_projects_in_a_solution_with_builders_1(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 3 projects in a solution with --builders 1", + CommandLineArgs: []string{"-b", "-w", "-v", "--builders", "1"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_5_projects_in_a_solution_test.go b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_5_projects_in_a_solution_test.go new file mode 100644 index 00000000000..2aa872d1eec --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_5_projects_in_a_solution_test.go @@ -0,0 +1,79 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_projectsBuilding_when_there_are_5_projects_in_a_solution(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 5 projects in a solution", + CommandLineArgs: []string{"-b", "-w", "-v"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg3/index.ts": "export const pkg3 = 3;", + "/user/username/projects/myproject/pkg3/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg4/index.ts": "export const pkg4 = 4;", + "/user/username/projects/myproject/pkg4/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" }, + { "path": "./pkg3" }, + { "path": "./pkg4" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_5_projects_in_a_solution_with_builders_2_test.go b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_5_projects_in_a_solution_with_builders_2_test.go new file mode 100644 index 00000000000..fee7cdc0c11 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_5_projects_in_a_solution_with_builders_2_test.go @@ -0,0 +1,79 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_projectsBuilding_when_there_are_5_projects_in_a_solution_with_builders_2(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 5 projects in a solution with --builders 2", + CommandLineArgs: []string{"-b", "-w", "-v", "--builders", "2"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg3/index.ts": "export const pkg3 = 3;", + "/user/username/projects/myproject/pkg3/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg4/index.ts": "export const pkg4 = 4;", + "/user/username/projects/myproject/pkg4/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" }, + { "path": "./pkg3" }, + { "path": "./pkg4" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_8_projects_in_a_solution_test.go b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_8_projects_in_a_solution_test.go new file mode 100644 index 00000000000..a80de8ec2b4 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_8_projects_in_a_solution_test.go @@ -0,0 +1,97 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_projectsBuilding_when_there_are_8_projects_in_a_solution(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 8 projects in a solution", + CommandLineArgs: []string{"-b", "-w", "-v"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg3/index.ts": "export const pkg3 = 3;", + "/user/username/projects/myproject/pkg3/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg4/index.ts": "export const pkg4 = 4;", + "/user/username/projects/myproject/pkg4/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg5/index.ts": "export const pkg5 = 5;", + "/user/username/projects/myproject/pkg5/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg6/index.ts": "export const pkg6 = 6;", + "/user/username/projects/myproject/pkg6/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg7/index.ts": "export const pkg7 = 7;", + "/user/username/projects/myproject/pkg7/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" }, + { "path": "./pkg3" }, + { "path": "./pkg4" }, + { "path": "./pkg5" }, + { "path": "./pkg6" }, + { "path": "./pkg7" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_8_projects_in_a_solution_with_builders_3_test.go b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_8_projects_in_a_solution_with_builders_3_test.go new file mode 100644 index 00000000000..7f0cb272c7f --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_projectsBuilding_when_there_are_8_projects_in_a_solution_with_builders_3_test.go @@ -0,0 +1,97 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_projectsBuilding_when_there_are_8_projects_in_a_solution_with_builders_3(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 8 projects in a solution with --builders 3", + CommandLineArgs: []string{"-b", "-w", "-v", "--builders", "3"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg3/index.ts": "export const pkg3 = 3;", + "/user/username/projects/myproject/pkg3/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg4/index.ts": "export const pkg4 = 4;", + "/user/username/projects/myproject/pkg4/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg5/index.ts": "export const pkg5 = 5;", + "/user/username/projects/myproject/pkg5/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg6/index.ts": "export const pkg6 = 6;", + "/user/username/projects/myproject/pkg6/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg7/index.ts": "export const pkg7 = 7;", + "/user/username/projects/myproject/pkg7/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" }, + { "path": "./pkg3" }, + { "path": "./pkg4" }, + { "path": "./pkg5" }, + { "path": "./pkg6" }, + { "path": "./pkg7" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_reexport_Reports_errors_correctly_test.go b/internal/execute/tsctests/tests/tsbuildWatch_reexport_Reports_errors_correctly_test.go new file mode 100644 index 00000000000..1f1581d05ec --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_reexport_Reports_errors_correctly_test.go @@ -0,0 +1,73 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_reexport_Reports_errors_correctly(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "reexport", + SubScenario: "Reports errors correctly", + CommandLineArgs: []string{"-b", "-w", "-verbose", "src"}, + Cwd: "/user/username/projects/reexport", + Files: tsctests.FileMap{ + "/user/username/projects/reexport/src/main/index.ts": `import { Session } from "../pure"; + +export const session: Session = { + foo: 1 +};`, + "/user/username/projects/reexport/src/main/tsconfig.json": `{ + "compilerOptions": { + "outDir": "../../out", + "rootDir": "../", + }, + "include": ["**/*.ts"], + "references": [{ "path": "../pure" }], +}`, + "/user/username/projects/reexport/src/pure/index.ts": "export * from \"./session\";", + "/user/username/projects/reexport/src/pure/session.ts": `export interface Session { + foo: number; + // bar: number; +}`, + "/user/username/projects/reexport/src/pure/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "../../out", + "rootDir": "../", + }, + "include": ["**/*.ts"], +}`, + "/user/username/projects/reexport/src/tsconfig.json": `{ + "files": [], + "include": [], + "references": [{ "path": "./pure" }, { "path": "./main" }], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/reexport/src/pure/session.ts", `export interface Session { + foo: number; + bar: number; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/reexport/src/pure/session.ts", `export interface Session { + foo: number; + // bar: number; +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_roots_when_root_file_is_from_referenced_project_and_shared_is_first_test.go b/internal/execute/tsctests/tests/tsbuildWatch_roots_when_root_file_is_from_referenced_project_and_shared_is_first_test.go new file mode 100644 index 00000000000..cb8f92618a4 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_roots_when_root_file_is_from_referenced_project_and_shared_is_first_test.go @@ -0,0 +1,89 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_roots_when_root_file_is_from_referenced_project_and_shared_is_first(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "roots", + SubScenario: "when root file is from referenced project and shared is first", + CommandLineArgs: []string{"--b", "-w", "projects/server", "-v", "--traceResolution", "--explainFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/projects/server/src/server.ts": `import { MyClass } from ':shared/myClass.js'; +console.log('Hello, world!');`, + "/home/src/workspaces/solution/projects/server/tsconfig.json": `{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "rootDir": "..", + "outDir": "./dist", + "paths": { + ":shared/*": ["./src/../../shared/src/*"], + }, + }, + "include": [ "../shared/src/**/*.ts", "src/**/*.ts" ], + "references": [ + { "path": "../shared" }, + ], +}`, + "/home/src/workspaces/solution/projects/shared/src/logging.ts": `export function log(str: string) { + console.log(str); +}`, + "/home/src/workspaces/solution/projects/shared/src/myClass.ts": "export class MyClass { }", + "/home/src/workspaces/solution/projects/shared/src/random.ts": `export function randomFn(str: string) { + console.log(str); +}`, + "/home/src/workspaces/solution/projects/shared/tsconfig.json": `{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist", + }, + "include": ["src/**/*.ts"], +}`, + "/home/src/workspaces/solution/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "projects/server" }, + { "path": "projects/shared" }, + ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "edit logging file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/projects/shared/src/logging.ts", `export function log(str: string) { + console.log(str); +}export const x = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete random file", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/solution/projects/shared/src/random.ts") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_roots_when_root_file_is_from_referenced_project_test.go b/internal/execute/tsctests/tests/tsbuildWatch_roots_when_root_file_is_from_referenced_project_test.go new file mode 100644 index 00000000000..22b535519d5 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_roots_when_root_file_is_from_referenced_project_test.go @@ -0,0 +1,89 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_roots_when_root_file_is_from_referenced_project(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "roots", + SubScenario: "when root file is from referenced project", + CommandLineArgs: []string{"--b", "-w", "projects/server", "-v", "--traceResolution", "--explainFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/projects/server/src/server.ts": `import { MyClass } from ':shared/myClass.js'; +console.log('Hello, world!');`, + "/home/src/workspaces/solution/projects/server/tsconfig.json": `{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "rootDir": "..", + "outDir": "./dist", + "paths": { + ":shared/*": ["./src/../../shared/src/*"], + }, + }, + "include": [ "src/**/*.ts", "../shared/src/**/*.ts" ], + "references": [ + { "path": "../shared" }, + ], +}`, + "/home/src/workspaces/solution/projects/shared/src/logging.ts": `export function log(str: string) { + console.log(str); +}`, + "/home/src/workspaces/solution/projects/shared/src/myClass.ts": "export class MyClass { }", + "/home/src/workspaces/solution/projects/shared/src/random.ts": `export function randomFn(str: string) { + console.log(str); +}`, + "/home/src/workspaces/solution/projects/shared/tsconfig.json": `{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist", + }, + "include": ["src/**/*.ts"], +}`, + "/home/src/workspaces/solution/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "projects/server" }, + { "path": "projects/shared" }, + ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "edit logging file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/projects/shared/src/logging.ts", `export function log(str: string) { + console.log(str); +}export const x = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete random file", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/solution/projects/shared/src/random.ts") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_builds_when_new_file_is_added_and_its_subsequent_updates_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_builds_when_new_file_is_added_and_its_subsequent_updates_test.go new file mode 100644 index 00000000000..5a3e21e3932 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_builds_when_new_file_is_added_and_its_subsequent_updates_test.go @@ -0,0 +1,87 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_builds_when_new_file_is_added_and_its_subsequent_updates(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "builds when new file is added, and its subsequent updates", + CommandLineArgs: []string{"--b", "-w", "tests"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Change to new File and build core", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/newfile.ts", "export const newFileConst = 30;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Change to new File and build core", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/newfile.ts", ` +export class someClass2 { }`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_builds_when_new_file_is_added_and_its_subsequent_updates_with_circular_references_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_builds_when_new_file_is_added_and_its_subsequent_updates_with_circular_references_test.go new file mode 100644 index 00000000000..27908a80f30 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_builds_when_new_file_is_added_and_its_subsequent_updates_with_circular_references_test.go @@ -0,0 +1,88 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_builds_when_new_file_is_added_and_its_subsequent_updates_with_circular_references(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "builds when new file is added, and its subsequent updates with circular references", + CommandLineArgs: []string{"--b", "-w", "tests"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true + }, + "references": [ + { "path": "../tests", "circular": true } + ], +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Change to new File and build core", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/newfile.ts", "export const newFileConst = 30;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Change to new File and build core", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/newfile.ts", ` +export class someClass2 { }`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_change_builds_changes_and_reports_found_errors_message_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_change_builds_changes_and_reports_found_errors_message_test.go new file mode 100644 index 00000000000..0149387d493 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_change_builds_changes_and_reports_found_errors_message_test.go @@ -0,0 +1,102 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_change_builds_changes_and_reports_found_errors_message(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "change builds changes and reports found errors message", + CommandLineArgs: []string{"--b", "-w", "tests"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Make change to core", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +export class someClass { }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Revert core file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Make two changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +export class someClass { } +export class someClass2 { }`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_change_builds_changes_and_reports_found_errors_message_with_circular_references_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_change_builds_changes_and_reports_found_errors_message_with_circular_references_test.go new file mode 100644 index 00000000000..5ab7221bb55 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_change_builds_changes_and_reports_found_errors_message_with_circular_references_test.go @@ -0,0 +1,103 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_change_builds_changes_and_reports_found_errors_message_with_circular_references(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "change builds changes and reports found errors message with circular references", + CommandLineArgs: []string{"--b", "-w", "tests"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true + }, + "references": [ + { "path": "../tests", "circular": true } + ], +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Make change to core", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +export class someClass { }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Revert core file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Make two changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +export class someClass { } +export class someClass2 { }`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_incremental_updates_in_verbose_mode_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_incremental_updates_in_verbose_mode_test.go new file mode 100644 index 00000000000..ecd0f01e7f0 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_incremental_updates_in_verbose_mode_test.go @@ -0,0 +1,98 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_incremental_updates_in_verbose_mode(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "incremental updates in verbose mode", + CommandLineArgs: []string{"--b", "-w", "tests", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Make non dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/logic/index.ts", `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod; +function someFn() { }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Make dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/logic/index.ts", `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod; +export function someFn() { }`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_non_local_change_does_not_start_build_of_referencing_projects_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_non_local_change_does_not_start_build_of_referencing_projects_test.go new file mode 100644 index 00000000000..90624d25c77 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_non_local_change_does_not_start_build_of_referencing_projects_test.go @@ -0,0 +1,82 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_non_local_change_does_not_start_build_of_referencing_projects(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "non local change does not start build of referencing projects", + CommandLineArgs: []string{"--b", "-w", "tests"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Make local change to core", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +function foo() { }`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_non_local_change_does_not_start_build_of_referencing_projects_with_circular_references_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_non_local_change_does_not_start_build_of_referencing_projects_with_circular_references_test.go new file mode 100644 index 00000000000..2b34cc7f684 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_non_local_change_does_not_start_build_of_referencing_projects_with_circular_references_test.go @@ -0,0 +1,83 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_non_local_change_does_not_start_build_of_referencing_projects_with_circular_references(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "non local change does not start build of referencing projects with circular references", + CommandLineArgs: []string{"--b", "-w", "tests"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true + }, + "references": [ + { "path": "../tests", "circular": true } + ], +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Make local change to core", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +function foo() { }`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_reportErrors_when_preserveWatchOutput_is_not_used_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_reportErrors_when_preserveWatchOutput_is_not_used_test.go new file mode 100644 index 00000000000..5e7f270258f --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_reportErrors_when_preserveWatchOutput_is_not_used_test.go @@ -0,0 +1,107 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_reportErrors_when_preserveWatchOutput_is_not_used(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "reportErrors when preserveWatchOutput is not used", + CommandLineArgs: []string{"-b", "-w", "tests"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "change logic", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/logic/index.ts", `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod; +let y: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "change core", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +let x: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "fix error in logic", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/logic/index.ts", `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_reportErrors_when_preserveWatchOutput_is_passed_on_command_line_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_reportErrors_when_preserveWatchOutput_is_passed_on_command_line_test.go new file mode 100644 index 00000000000..dcabc643f0b --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_reportErrors_when_preserveWatchOutput_is_passed_on_command_line_test.go @@ -0,0 +1,107 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_reportErrors_when_preserveWatchOutput_is_passed_on_command_line(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "reportErrors when preserveWatchOutput is passed on command line", + CommandLineArgs: []string{"-b", "-w", "tests", "--preserveWatchOutput"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "change logic", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/logic/index.ts", `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod; +let y: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "change core", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +let x: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "fix error in logic", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/logic/index.ts", `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_reportErrors_when_stopBuildOnErrors_is_passed_on_command_line_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_reportErrors_when_stopBuildOnErrors_is_passed_on_command_line_test.go new file mode 100644 index 00000000000..0097d642f25 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_reportErrors_when_stopBuildOnErrors_is_passed_on_command_line_test.go @@ -0,0 +1,108 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_reportErrors_when_stopBuildOnErrors_is_passed_on_command_line(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "reportErrors when stopBuildOnErrors is passed on command line", + CommandLineArgs: []string{"-b", "-w", "tests", "--stopBuildOnErrors"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "change logic", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/logic/index.ts", `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod; +let y: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "change core", + ExpectedDiff: "Clean build will stop on error in core and will not report error in logic\nWatch build will retain previous errors from logic and report it", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +let x: string = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "fix error in logic", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/logic/index.ts", `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_should_not_trigger_recompilation_because_of_program_emit_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_should_not_trigger_recompilation_because_of_program_emit_test.go new file mode 100644 index 00000000000..bee559a28f8 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_should_not_trigger_recompilation_because_of_program_emit_test.go @@ -0,0 +1,87 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_should_not_trigger_recompilation_because_of_program_emit(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "should not trigger recompilation because of program emit", + CommandLineArgs: []string{"--b", "-w", "core", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add new file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/file3.ts", "export const y = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_should_not_trigger_recompilation_because_of_program_emit_with_outDir_specified_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_should_not_trigger_recompilation_because_of_program_emit_with_outDir_specified_test.go new file mode 100644 index 00000000000..40edaa08c11 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_should_not_trigger_recompilation_because_of_program_emit_with_outDir_specified_test.go @@ -0,0 +1,85 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_should_not_trigger_recompilation_because_of_program_emit_with_outDir_specified(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "should not trigger recompilation because of program emit with outDir specified", + CommandLineArgs: []string{"--b", "-w", "core", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "outDir" + } +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add new file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/file3.ts", "export const y = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_test.go new file mode 100644 index 00000000000..86a14fb7a34 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_test.go @@ -0,0 +1,81 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "skips builds downstream projects if upstream projects have errors with stopBuildOnErrors", + CommandLineArgs: []string{"--b", "tests", "--verbose", "--stopBuildOnErrors", "--watch"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }multiply();`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_when_test_does_not_reference_core_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_when_test_does_not_reference_core_test.go new file mode 100644 index 00000000000..2ec1612f90e --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_when_test_does_not_reference_core_test.go @@ -0,0 +1,80 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_when_test_does_not_reference_core(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "skips builds downstream projects if upstream projects have errors with stopBuildOnErrors when test does not reference core", + CommandLineArgs: []string{"--b", "tests", "--verbose", "--stopBuildOnErrors", "--watch"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }multiply();`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuildWatch_sample_watches_config_files_that_are_not_present_test.go b/internal/execute/tsctests/tests/tsbuildWatch_sample_watches_config_files_that_are_not_present_test.go new file mode 100644 index 00000000000..d8e09f8c1e6 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuildWatch_sample_watches_config_files_that_are_not_present_test.go @@ -0,0 +1,78 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuildWatch_sample_watches_config_files_that_are_not_present(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "watches config files that are not present", + CommandLineArgs: []string{"--b", "-w", "tests"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Write logic", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/logic/tsconfig.json", `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_clean_file_name_and_output_name_clashing_test.go b/internal/execute/tsctests/tests/tsbuild_clean_file_name_and_output_name_clashing_test.go new file mode 100644 index 00000000000..2d7992ca77b --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_clean_file_name_and_output_name_clashing_test.go @@ -0,0 +1,27 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_clean_file_name_and_output_name_clashing(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "clean", + SubScenario: "file name and output name clashing", + CommandLineArgs: []string{"--b", "--clean"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/bar.ts": "", + "/home/src/workspaces/solution/index.js": "", + "/home/src/workspaces/solution/tsconfig.json": `{ + "compilerOptions": { "allowJs": true } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_clean_tsx_with_dts_emit_test.go b/internal/execute/tsctests/tests/tsbuild_clean_tsx_with_dts_emit_test.go new file mode 100644 index 00000000000..d3cd6b0edff --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_clean_tsx_with_dts_emit_test.go @@ -0,0 +1,36 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_clean_tsx_with_dts_emit(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "clean", + SubScenario: "tsx with dts emit", + CommandLineArgs: []string{"--b", "project", "-v", "--explainFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/main.tsx": "export const x = 10;", + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { "declaration": true }, + "include": ["src/**/*.tsx", "src/**/*.ts"] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "clean build", + CommandLineArgs: []string{"-b", "project", "--clean"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_commandLine_bad_locale_test.go b/internal/execute/tsctests/tests/tsbuild_commandLine_bad_locale_test.go new file mode 100644 index 00000000000..d99bda664f9 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_commandLine_bad_locale_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_commandLine_bad_locale(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "bad locale", + CommandLineArgs: []string{"--build", "--help", "--locale", "whoops"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_commandLine_different_options_test.go b/internal/execute/tsctests/tests/tsbuild_commandLine_different_options_test.go new file mode 100644 index 00000000000..8de820f15b8 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_commandLine_different_options_test.go @@ -0,0 +1,88 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_commandLine_different_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "different options", + CommandLineArgs: []string{"--build", "--verbose"}, + Files: tsctests.FileMap{ + "/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;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "with sourceMap", + CommandLineArgs: []string{"--build", "--verbose", "--sourceMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "should re-emit only js so they dont contain sourcemap", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration should not emit anything", + CommandLineArgs: []string{"--build", "--verbose", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration and declarationMap", + CommandLineArgs: []string{"--build", "--verbose", "--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "should re-emit only dts so they dont contain sourcemap", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with emitDeclarationOnly should not emit anything", + CommandLineArgs: []string{"--build", "--verbose", "--emitDeclarationOnly"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = 10;const aLocal = 100;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration should not emit anything", + CommandLineArgs: []string{"--build", "--verbose", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with inlineSourceMap", + CommandLineArgs: []string{"--build", "--verbose", "--inlineSourceMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with sourceMap", + CommandLineArgs: []string{"--build", "--verbose", "--sourceMap"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_commandLine_different_options_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_commandLine_different_options_with_incremental_test.go new file mode 100644 index 00000000000..9cbf3c1394e --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_commandLine_different_options_with_incremental_test.go @@ -0,0 +1,93 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_commandLine_different_options_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "different options with incremental", + CommandLineArgs: []string{"--build", "--verbose"}, + Files: tsctests.FileMap{ + "/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;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "with sourceMap", + CommandLineArgs: []string{"--build", "--verbose", "--sourceMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "should re-emit only js so they dont contain sourcemap", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration, emit Dts and should not emit js", + CommandLineArgs: []string{"--build", "--verbose", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration and declarationMap", + CommandLineArgs: []string{"--build", "--verbose", "--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = 10;const aLocal = 100;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration and declarationMap", + CommandLineArgs: []string{"--build", "--verbose", "--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with inlineSourceMap", + CommandLineArgs: []string{"--build", "--verbose", "--inlineSourceMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with sourceMap", + CommandLineArgs: []string{"--build", "--verbose", "--sourceMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit js files", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration and declarationMap", + CommandLineArgs: []string{"--build", "--verbose", "--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration and declarationMap, should not re-emit", + CommandLineArgs: []string{"--build", "--verbose", "--declaration", "--declarationMap"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_false_on_commandline_test.go b/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_false_on_commandline_test.go new file mode 100644 index 00000000000..ddf72eafedb --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_false_on_commandline_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_commandLine_emitDeclarationOnly_false_on_commandline(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "emitDeclarationOnly false on commandline", + CommandLineArgs: []string{"--b", "project2/src", "--verbose"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project1/src/a.ts": "export const a = 10;const aLocal = 10;", + "/home/src/workspaces/solution/project1/src/b.ts": "export const b = 10;const bLocal = 10;", + "/home/src/workspaces/solution/project1/src/c.ts": "import { a } from \"./a\";export const c = a;", + "/home/src/workspaces/solution/project1/src/d.ts": "import { b } from \"./b\";export const d = b;", + "/home/src/workspaces/solution/project1/src/tsconfig.json": `{ + "compilerOptions": { "composite": true, "emitDeclarationOnly": true } +}`, + "/home/src/workspaces/solution/project2/src/e.ts": "export const e = 10;", + "/home/src/workspaces/solution/project2/src/f.ts": "import { a } from \"../../project1/src/a\"; export const f = a;", + "/home/src/workspaces/solution/project2/src/g.ts": "import { b } from \"../../project1/src/b\"; export const g = b;", + "/home/src/workspaces/solution/project2/src/tsconfig.json": `{ + "compilerOptions": { "composite": true, "emitDeclarationOnly": true }, + "references": [{ "path": "../../project1/src" }] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/a.ts", "export const a = 10;const aLocal = 10;const aa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit js files", + CommandLineArgs: []string{"--b", "project2/src", "--verbose", "--emitDeclarationOnly", "false"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change run with js emit", + CommandLineArgs: []string{"--b", "project2/src", "--verbose", "--emitDeclarationOnly", "false"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "js emit with change", + CommandLineArgs: []string{"--b", "project2/src", "--verbose", "--emitDeclarationOnly", "false"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const blocal = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_false_on_commandline_with_declaration_and_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_false_on_commandline_with_declaration_and_incremental_test.go new file mode 100644 index 00000000000..05fd2b02118 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_false_on_commandline_with_declaration_and_incremental_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_commandLine_emitDeclarationOnly_false_on_commandline_with_declaration_and_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "emitDeclarationOnly false on commandline with declaration and incremental", + CommandLineArgs: []string{"--b", "project2/src", "--verbose"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project1/src/a.ts": "export const a = 10;const aLocal = 10;", + "/home/src/workspaces/solution/project1/src/b.ts": "export const b = 10;const bLocal = 10;", + "/home/src/workspaces/solution/project1/src/c.ts": "import { a } from \"./a\";export const c = a;", + "/home/src/workspaces/solution/project1/src/d.ts": "import { b } from \"./b\";export const d = b;", + "/home/src/workspaces/solution/project1/src/tsconfig.json": `{ + "compilerOptions": { "incremental": true, "declaration": true, "emitDeclarationOnly": true } +}`, + "/home/src/workspaces/solution/project2/src/e.ts": "export const e = 10;", + "/home/src/workspaces/solution/project2/src/f.ts": "import { a } from \"../../project1/src/a\"; export const f = a;", + "/home/src/workspaces/solution/project2/src/g.ts": "import { b } from \"../../project1/src/b\"; export const g = b;", + "/home/src/workspaces/solution/project2/src/tsconfig.json": `{ + "compilerOptions": { "incremental": true, "declaration": true, "emitDeclarationOnly": true }, + "references": [{ "path": "../../project1/src" }] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/a.ts", "export const a = 10;const aLocal = 10;const aa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit js files", + CommandLineArgs: []string{"--b", "project2/src", "--verbose", "--emitDeclarationOnly", "false"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change run with js emit", + CommandLineArgs: []string{"--b", "project2/src", "--verbose", "--emitDeclarationOnly", "false"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "js emit with change", + CommandLineArgs: []string{"--b", "project2/src", "--verbose", "--emitDeclarationOnly", "false"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const blocal = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_false_on_commandline_with_declaration_test.go b/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_false_on_commandline_with_declaration_test.go new file mode 100644 index 00000000000..a08bb4bf95a --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_false_on_commandline_with_declaration_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_commandLine_emitDeclarationOnly_false_on_commandline_with_declaration(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "emitDeclarationOnly false on commandline with declaration", + CommandLineArgs: []string{"--b", "project2/src", "--verbose"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project1/src/a.ts": "export const a = 10;const aLocal = 10;", + "/home/src/workspaces/solution/project1/src/b.ts": "export const b = 10;const bLocal = 10;", + "/home/src/workspaces/solution/project1/src/c.ts": "import { a } from \"./a\";export const c = a;", + "/home/src/workspaces/solution/project1/src/d.ts": "import { b } from \"./b\";export const d = b;", + "/home/src/workspaces/solution/project1/src/tsconfig.json": `{ + "compilerOptions": { "declaration": true, "emitDeclarationOnly": true } +}`, + "/home/src/workspaces/solution/project2/src/e.ts": "export const e = 10;", + "/home/src/workspaces/solution/project2/src/f.ts": "import { a } from \"../../project1/src/a\"; export const f = a;", + "/home/src/workspaces/solution/project2/src/g.ts": "import { b } from \"../../project1/src/b\"; export const g = b;", + "/home/src/workspaces/solution/project2/src/tsconfig.json": `{ + "compilerOptions": { "declaration": true, "emitDeclarationOnly": true }, + "references": [{ "path": "../../project1/src" }] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/a.ts", "export const a = 10;const aLocal = 10;const aa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit js files", + CommandLineArgs: []string{"--b", "project2/src", "--verbose", "--emitDeclarationOnly", "false"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change run with js emit", + CommandLineArgs: []string{"--b", "project2/src", "--verbose", "--emitDeclarationOnly", "false"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "js emit with change", + CommandLineArgs: []string{"--b", "project2/src", "--verbose", "--emitDeclarationOnly", "false"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const blocal = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_on_commandline_test.go b/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_on_commandline_test.go new file mode 100644 index 00000000000..07098f38f72 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_on_commandline_test.go @@ -0,0 +1,93 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_commandLine_emitDeclarationOnly_on_commandline(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "emitDeclarationOnly on commandline", + CommandLineArgs: []string{"--b", "project2/src", "--verbose", "--emitDeclarationOnly"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project1/src/a.ts": "export const a = 10;const aLocal = 10;", + "/home/src/workspaces/solution/project1/src/b.ts": "export const b = 10;const bLocal = 10;", + "/home/src/workspaces/solution/project1/src/c.ts": "import { a } from \"./a\";export const c = a;", + "/home/src/workspaces/solution/project1/src/d.ts": "import { b } from \"./b\";export const d = b;", + "/home/src/workspaces/solution/project1/src/tsconfig.json": `{ + "compilerOptions": { "composite": true } +}`, + "/home/src/workspaces/solution/project2/src/e.ts": "export const e = 10;", + "/home/src/workspaces/solution/project2/src/f.ts": "import { a } from \"../../project1/src/a\"; export const f = a;", + "/home/src/workspaces/solution/project2/src/g.ts": "import { b } from \"../../project1/src/b\"; export const g = b;", + "/home/src/workspaces/solution/project2/src/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../../project1/src" }] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/a.ts", "export const a = 10;const aLocal = 10;const aa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "non local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/a.ts", "export const a = 10;const aLocal = 10;const aa = 10;export const aaa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit js files", + CommandLineArgs: []string{"--b", "project2/src", "--verbose"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "js emit with change without emitDeclarationOnly", + CommandLineArgs: []string{"--b", "project2/src", "--verbose"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const alocal = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const alocal = 10;const aaaa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "non local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const alocal = 10;const aaaa = 10;export const aaaaa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "js emit with change without emitDeclarationOnly", + CommandLineArgs: []string{"--b", "project2/src", "--verbose"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const alocal = 10;const aaaa = 10;export const aaaaa = 10;export const a2 = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_on_commandline_with_declaration_and_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_on_commandline_with_declaration_and_incremental_test.go new file mode 100644 index 00000000000..5cdbb1a1b4a --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_on_commandline_with_declaration_and_incremental_test.go @@ -0,0 +1,93 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_commandLine_emitDeclarationOnly_on_commandline_with_declaration_and_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "emitDeclarationOnly on commandline with declaration and incremental", + CommandLineArgs: []string{"--b", "project2/src", "--verbose", "--emitDeclarationOnly"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project1/src/a.ts": "export const a = 10;const aLocal = 10;", + "/home/src/workspaces/solution/project1/src/b.ts": "export const b = 10;const bLocal = 10;", + "/home/src/workspaces/solution/project1/src/c.ts": "import { a } from \"./a\";export const c = a;", + "/home/src/workspaces/solution/project1/src/d.ts": "import { b } from \"./b\";export const d = b;", + "/home/src/workspaces/solution/project1/src/tsconfig.json": `{ + "compilerOptions": { "incremental": true, "declaration": true } +}`, + "/home/src/workspaces/solution/project2/src/e.ts": "export const e = 10;", + "/home/src/workspaces/solution/project2/src/f.ts": "import { a } from \"../../project1/src/a\"; export const f = a;", + "/home/src/workspaces/solution/project2/src/g.ts": "import { b } from \"../../project1/src/b\"; export const g = b;", + "/home/src/workspaces/solution/project2/src/tsconfig.json": `{ + "compilerOptions": { "incremental": true, "declaration": true }, + "references": [{ "path": "../../project1/src" }] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/a.ts", "export const a = 10;const aLocal = 10;const aa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "non local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/a.ts", "export const a = 10;const aLocal = 10;const aa = 10;export const aaa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit js files", + CommandLineArgs: []string{"--b", "project2/src", "--verbose"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "js emit with change without emitDeclarationOnly", + CommandLineArgs: []string{"--b", "project2/src", "--verbose"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const alocal = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const alocal = 10;const aaaa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "non local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const alocal = 10;const aaaa = 10;export const aaaaa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "js emit with change without emitDeclarationOnly", + CommandLineArgs: []string{"--b", "project2/src", "--verbose"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const alocal = 10;const aaaa = 10;export const aaaaa = 10;export const a2 = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_on_commandline_with_declaration_test.go b/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_on_commandline_with_declaration_test.go new file mode 100644 index 00000000000..66ab23e643d --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_commandLine_emitDeclarationOnly_on_commandline_with_declaration_test.go @@ -0,0 +1,93 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_commandLine_emitDeclarationOnly_on_commandline_with_declaration(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "emitDeclarationOnly on commandline with declaration", + CommandLineArgs: []string{"--b", "project2/src", "--verbose", "--emitDeclarationOnly"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project1/src/a.ts": "export const a = 10;const aLocal = 10;", + "/home/src/workspaces/solution/project1/src/b.ts": "export const b = 10;const bLocal = 10;", + "/home/src/workspaces/solution/project1/src/c.ts": "import { a } from \"./a\";export const c = a;", + "/home/src/workspaces/solution/project1/src/d.ts": "import { b } from \"./b\";export const d = b;", + "/home/src/workspaces/solution/project1/src/tsconfig.json": `{ + "compilerOptions": { "declaration": true } +}`, + "/home/src/workspaces/solution/project2/src/e.ts": "export const e = 10;", + "/home/src/workspaces/solution/project2/src/f.ts": "import { a } from \"../../project1/src/a\"; export const f = a;", + "/home/src/workspaces/solution/project2/src/g.ts": "import { b } from \"../../project1/src/b\"; export const g = b;", + "/home/src/workspaces/solution/project2/src/tsconfig.json": `{ + "compilerOptions": { "declaration": true }, + "references": [{ "path": "../../project1/src" }] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/a.ts", "export const a = 10;const aLocal = 10;const aa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "non local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/a.ts", "export const a = 10;const aLocal = 10;const aa = 10;export const aaa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit js files", + CommandLineArgs: []string{"--b", "project2/src", "--verbose"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "js emit with change without emitDeclarationOnly", + CommandLineArgs: []string{"--b", "project2/src", "--verbose"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const alocal = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const alocal = 10;const aaaa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "non local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const alocal = 10;const aaaa = 10;export const aaaaa = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "js emit with change without emitDeclarationOnly", + CommandLineArgs: []string{"--b", "project2/src", "--verbose"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project1/src/b.ts", "export const b = 10;const bLocal = 10;const alocal = 10;const aaaa = 10;export const aaaaa = 10;export const a2 = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_commandLine_help_test.go b/internal/execute/tsctests/tests/tsbuild_commandLine_help_test.go new file mode 100644 index 00000000000..29ef626dba3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_commandLine_help_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_commandLine_help(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "help", + CommandLineArgs: []string{"--build", "--help"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_commandLine_locale_test.go b/internal/execute/tsctests/tests/tsbuild_commandLine_locale_test.go new file mode 100644 index 00000000000..a0b00c358e5 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_commandLine_locale_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_commandLine_locale(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "locale", + CommandLineArgs: []string{"--build", "--help", "--locale", "en"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_commandLine_when_build_not_first_argument_test.go b/internal/execute/tsctests/tests/tsbuild_commandLine_when_build_not_first_argument_test.go new file mode 100644 index 00000000000..98f536abe50 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_commandLine_when_build_not_first_argument_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_commandLine_when_build_not_first_argument(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "when build not first argument", + CommandLineArgs: []string{"--verbose", "--build"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_configFileErrors_missing_config_file_test.go b/internal/execute/tsctests/tests/tsbuild_configFileErrors_missing_config_file_test.go new file mode 100644 index 00000000000..ce94ddd8047 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_configFileErrors_missing_config_file_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_configFileErrors_missing_config_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "configFileErrors", + SubScenario: "missing config file", + CommandLineArgs: []string{"--b", "bogus.json"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_configFileErrors_reports_syntax_errors_in_config_file_test.go b/internal/execute/tsctests/tests/tsbuild_configFileErrors_reports_syntax_errors_in_config_file_test.go new file mode 100644 index 00000000000..3d9aee0ba2e --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_configFileErrors_reports_syntax_errors_in_config_file_test.go @@ -0,0 +1,73 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_configFileErrors_reports_syntax_errors_in_config_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "configFileErrors", + SubScenario: "reports syntax errors in config file", + CommandLineArgs: []string{"--b"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export function foo() { }", + "/home/src/workspaces/project/b.ts": "export function bar() { }", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + }, + "files": [ + "a.ts" + "b.ts" + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "reports syntax errors after change to config file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "composite": true, "declaration": true + }, + "files": [ + "a.ts" + "b.ts" + ] +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "reports syntax errors after change to ts file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export function foo() { }export function fooBar() { }") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "builds after fixing config file errors", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "composite": true, "declaration": true + }, + "files": [ + "a.ts", + "b.ts" + ] +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_configFileErrors_when_tsconfig_extends_the_missing_file_test.go b/internal/execute/tsctests/tests/tsbuild_configFileErrors_when_tsconfig_extends_the_missing_file_test.go new file mode 100644 index 00000000000..bc9b670c669 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_configFileErrors_when_tsconfig_extends_the_missing_file_test.go @@ -0,0 +1,42 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_configFileErrors_when_tsconfig_extends_the_missing_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "configFileErrors", + SubScenario: "when tsconfig extends the missing file", + CommandLineArgs: []string{"--b"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/tsconfig.first.json": `{ + "extends": "./foobar.json", + "compilerOptions": { + "composite": true + } +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "./tsconfig.first.json" }, + { "path": "./tsconfig.second.json" } + ] +}`, + "/home/src/workspaces/project/tsconfig.second.json": `{ + "extends": "./foobar.json", + "compilerOptions": { + "composite": true + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_declarationEmit_reports_dts_generation_errors_test.go b/internal/execute/tsctests/tests/tsbuild_declarationEmit_reports_dts_generation_errors_test.go new file mode 100644 index 00000000000..79d6538d3e3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_declarationEmit_reports_dts_generation_errors_test.go @@ -0,0 +1,51 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_declarationEmit_reports_dts_generation_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "declarationEmit", + SubScenario: "reports dts generation errors", + CommandLineArgs: []string{"-b", "--explainFiles", "--listEmittedFiles", "--v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": `import ky from 'ky'; +export const api = ky.extend({});`, + "/home/src/workspaces/project/node_modules/ky/distribution/index.d.ts": `type KyInstance = { + extend(options: Record): KyInstance; +} +declare const ky: KyInstance; +export default ky;`, + "/home/src/workspaces/project/node_modules/ky/package.json": `{ + "name": "ky", + "type": "module", + "main": "./distribution/index.js" +}`, + "/home/src/workspaces/project/package.json": `{ + "type": "module" +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "module": "NodeNext", + "moduleResolution": "NodeNext", + "composite": false, + "incremental": false, + "declaration": true, + "skipLibCheck": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_declarationEmit_reports_dts_generation_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_declarationEmit_reports_dts_generation_errors_with_incremental_test.go new file mode 100644 index 00000000000..c70b4c1ee7b --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_declarationEmit_reports_dts_generation_errors_with_incremental_test.go @@ -0,0 +1,51 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_declarationEmit_reports_dts_generation_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "declarationEmit", + SubScenario: "reports dts generation errors with incremental", + CommandLineArgs: []string{"-b", "--explainFiles", "--listEmittedFiles", "--v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": `import ky from 'ky'; +export const api = ky.extend({});`, + "/home/src/workspaces/project/node_modules/ky/distribution/index.d.ts": `type KyInstance = { + extend(options: Record): KyInstance; +} +declare const ky: KyInstance; +export default ky;`, + "/home/src/workspaces/project/node_modules/ky/package.json": `{ + "name": "ky", + "type": "module", + "main": "./distribution/index.js" +}`, + "/home/src/workspaces/project/package.json": `{ + "type": "module" +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "module": "NodeNext", + "moduleResolution": "NodeNext", + "composite": false, + "incremental": true, + "declaration": true, + "skipLibCheck": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_declarationEmit_when_declaration_file_is_referenced_through_triple_slash_but_uses_no_references_test.go b/internal/execute/tsctests/tests/tsbuild_declarationEmit_when_declaration_file_is_referenced_through_triple_slash_but_uses_no_references_test.go new file mode 100644 index 00000000000..0d76389586d --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_declarationEmit_when_declaration_file_is_referenced_through_triple_slash_but_uses_no_references_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_declarationEmit_when_declaration_file_is_referenced_through_triple_slash_but_uses_no_references(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "declarationEmit", + SubScenario: "when declaration file is referenced through triple slash but uses no references", + CommandLineArgs: []string{"--b", "--verbose"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/src/common/nominal.ts": `/// +export declare type Nominal = MyNominal;`, + "/home/src/workspaces/solution/src/common/tsconfig.json": `{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { "composite": true }, + "include": ["./nominal.ts"], +}`, + "/home/src/workspaces/solution/src/common/types.d.ts": `declare type MyNominal = T & { + specialKey: Name; +};`, + "/home/src/workspaces/solution/src/subProject/index.ts": `import { Nominal } from '../common/nominal'; +export type MyNominal = Nominal;`, + "/home/src/workspaces/solution/src/subProject/tsconfig.json": `{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { "composite": true }, + "references": [{ "path": "../common" }], + "include": ["./index.ts"], +}`, + "/home/src/workspaces/solution/src/subProject2/index.ts": `import { MyNominal } from '../subProject/index'; +const variable = { + key: 'value' as MyNominal, +}; +export function getVar(): keyof typeof variable { + return 'key'; +}`, + "/home/src/workspaces/solution/src/subProject2/tsconfig.json": `{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { "composite": true }, + "references": [{ "path": "../subProject" }], + "include": ["./index.ts"], +}`, + "/home/src/workspaces/solution/src/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "./subProject" }, { "path": "./subProject2" }], + "include": [], +}`, + "/home/src/workspaces/solution/tsconfig.base.json": `{ + "compilerOptions": { + "rootDir": "./", + "outDir": "lib", + }, +}`, + "/home/src/workspaces/solution/tsconfig.json": `{ + "extends": "./tsconfig.base.json", + "compilerOptions": { "composite": true }, + "include": ["./src/**/*.ts"], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_declarationEmit_when_declaration_file_is_referenced_through_triple_slash_test.go b/internal/execute/tsctests/tests/tsbuild_declarationEmit_when_declaration_file_is_referenced_through_triple_slash_test.go new file mode 100644 index 00000000000..6989ca745ad --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_declarationEmit_when_declaration_file_is_referenced_through_triple_slash_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_declarationEmit_when_declaration_file_is_referenced_through_triple_slash(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "declarationEmit", + SubScenario: "when declaration file is referenced through triple slash", + CommandLineArgs: []string{"--b", "--verbose"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/src/common/nominal.ts": `/// +export declare type Nominal = MyNominal;`, + "/home/src/workspaces/solution/src/common/tsconfig.json": `{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { "composite": true }, + "include": ["./nominal.ts"], +}`, + "/home/src/workspaces/solution/src/common/types.d.ts": `declare type MyNominal = T & { + specialKey: Name; +};`, + "/home/src/workspaces/solution/src/subProject/index.ts": `import { Nominal } from '../common/nominal'; +export type MyNominal = Nominal;`, + "/home/src/workspaces/solution/src/subProject/tsconfig.json": `{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { "composite": true }, + "references": [{ "path": "../common" }], + "include": ["./index.ts"], +}`, + "/home/src/workspaces/solution/src/subProject2/index.ts": `import { MyNominal } from '../subProject/index'; +const variable = { + key: 'value' as MyNominal, +}; +export function getVar(): keyof typeof variable { + return 'key'; +}`, + "/home/src/workspaces/solution/src/subProject2/tsconfig.json": `{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { "composite": true }, + "references": [{ "path": "../subProject" }], + "include": ["./index.ts"], +}`, + "/home/src/workspaces/solution/src/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "./subProject" }, { "path": "./subProject2" }], + "include": [], +}`, + "/home/src/workspaces/solution/tsconfig.base.json": `{ + "compilerOptions": { + "rootDir": "./", + "outDir": "lib", + }, +}`, + "/home/src/workspaces/solution/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "./src" }], + "include": [], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_declarationEmit_when_declaration_file_used_inferred_type_from_referenced_project_test.go b/internal/execute/tsctests/tests/tsbuild_declarationEmit_when_declaration_file_used_inferred_type_from_referenced_project_test.go new file mode 100644 index 00000000000..85a6c2fa28e --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_declarationEmit_when_declaration_file_used_inferred_type_from_referenced_project_test.go @@ -0,0 +1,49 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_declarationEmit_when_declaration_file_used_inferred_type_from_referenced_project(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "declarationEmit", + SubScenario: "when declaration file used inferred type from referenced project", + CommandLineArgs: []string{"--b", "packages/pkg2/tsconfig.json", "--verbose"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/packages/pkg1/src/index.ts": `export interface IThing { + a: string; +} +export interface IThings { + thing1: IThing; +}`, + "/home/src/workspaces/project/packages/pkg1/tsconfig.json": `{ + "extends": "../../tsconfig", + "compilerOptions": { "outDir": "lib" }, + "include": ["src"], +}`, + "/home/src/workspaces/project/packages/pkg2/src/index.ts": `import { IThings } from '@fluentui/pkg1'; +export function fn4() { + const a: IThings = { thing1: { a: 'b' } }; + return a.thing1; +}`, + "/home/src/workspaces/project/packages/pkg2/tsconfig.json": `{ + "extends": "../../tsconfig", + "compilerOptions": { "outDir": "lib" }, + "include": ["src"], + "references": [{ "path": "../pkg1" }], +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "paths": { "@fluentui/*": ["./packages/*/src"] }, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_demo_in_bad_ref_branch_reports_the_error_about_files_not_in_rootDir_at_the_import_location_test.go b/internal/execute/tsctests/tests/tsbuild_demo_in_bad_ref_branch_reports_the_error_about_files_not_in_rootDir_at_the_import_location_test.go new file mode 100644 index 00000000000..b79c0294aa0 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_demo_in_bad_ref_branch_reports_the_error_about_files_not_in_rootDir_at_the_import_location_test.go @@ -0,0 +1,104 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_demo_in_bad_ref_branch_reports_the_error_about_files_not_in_rootDir_at_the_import_location(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "demo", + SubScenario: "in bad-ref branch reports the error about files not in rootDir at the import location", + CommandLineArgs: []string{"--b", "--verbose"}, + Cwd: "/user/username/projects/demo", + Files: tsctests.FileMap{ + "/user/username/projects/demo/animals/animal.ts": `export type Size = "small" | "medium" | "large"; +export default interface Animal { + size: Size; +}`, + "/user/username/projects/demo/animals/dog.ts": "import Animal from '.';\nimport { makeRandomName } from '../core/utilities';\n\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\n\nexport function createDog(): Dog {\n return ({\n size: \"medium\",\n woof: function(this: Dog) {\n console.log(`${ this.name } says \"Woof\"!`);\n },\n name: makeRandomName()\n });\n}", + "/user/username/projects/demo/animals/index.ts": `import Animal from './animal'; + +export default Animal; +import { createDog, Dog } from './dog'; +export { createDog, Dog };`, + "/user/username/projects/demo/animals/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/animals", + "rootDir": "." + }, + "references": [ + { "path": "../core" } + ] +}`, + "/user/username/projects/demo/core/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/core", + "rootDir": "." + }, +}`, + "/user/username/projects/demo/core/utilities.ts": `import * as A from '../animals' +export function makeRandomName() { + return "Bob!?! "; +} + +export function lastElementOf(arr: T[]): T | undefined { + if (arr.length === 0) return undefined; + return arr[arr.length - 1]; +}`, + "/user/username/projects/demo/tsconfig-base.json": `{ + "compilerOptions": { + "declaration": true, + "target": "es5", + "module": "commonjs", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "composite": true, + }, +}`, + "/user/username/projects/demo/tsconfig.json": `{ + "files": [], + "references": [ + { + "path": "./core" + }, + { + "path": "./animals", + }, + { + "path": "./zoo", + }, + ], +}`, + "/user/username/projects/demo/zoo/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/zoo", + "rootDir": "." + }, + "references": [ + { + "path": "../animals" + } + ] +}`, + "/user/username/projects/demo/zoo/zoo.ts": `import { Dog, createDog } from '../animals/index'; + +export function createZoo(): Array { + return [ + createDog() + ]; +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_demo_in_circular_branch_reports_the_error_about_it_by_stopping_build_test.go b/internal/execute/tsctests/tests/tsbuild_demo_in_circular_branch_reports_the_error_about_it_by_stopping_build_test.go new file mode 100644 index 00000000000..b6a89722fff --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_demo_in_circular_branch_reports_the_error_about_it_by_stopping_build_test.go @@ -0,0 +1,108 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_demo_in_circular_branch_reports_the_error_about_it_by_stopping_build(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "demo", + SubScenario: "in circular branch reports the error about it by stopping build", + CommandLineArgs: []string{"--b", "--verbose"}, + Cwd: "/user/username/projects/demo", + Files: tsctests.FileMap{ + "/user/username/projects/demo/animals/animal.ts": `export type Size = "small" | "medium" | "large"; +export default interface Animal { + size: Size; +}`, + "/user/username/projects/demo/animals/dog.ts": "import Animal from '.';\nimport { makeRandomName } from '../core/utilities';\n\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\n\nexport function createDog(): Dog {\n return ({\n size: \"medium\",\n woof: function(this: Dog) {\n console.log(`${ this.name } says \"Woof\"!`);\n },\n name: makeRandomName()\n });\n}", + "/user/username/projects/demo/animals/index.ts": `import Animal from './animal'; + +export default Animal; +import { createDog, Dog } from './dog'; +export { createDog, Dog };`, + "/user/username/projects/demo/animals/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/animals", + "rootDir": "." + }, + "references": [ + { "path": "../core" } + ] +}`, + "/user/username/projects/demo/core/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/core", + "rootDir": "." + }, + "references": [ + { + "path": "../zoo", + } + ] +}`, + "/user/username/projects/demo/core/utilities.ts": `export function makeRandomName() { + return "Bob!?! "; +} + +export function lastElementOf(arr: T[]): T | undefined { + if (arr.length === 0) return undefined; + return arr[arr.length - 1]; +}`, + "/user/username/projects/demo/tsconfig-base.json": `{ + "compilerOptions": { + "declaration": true, + "target": "es5", + "module": "commonjs", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "composite": true, + }, +}`, + "/user/username/projects/demo/tsconfig.json": `{ + "files": [], + "references": [ + { + "path": "./core" + }, + { + "path": "./animals", + }, + { + "path": "./zoo", + }, + ], +}`, + "/user/username/projects/demo/zoo/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/zoo", + "rootDir": "." + }, + "references": [ + { + "path": "../animals" + } + ] +}`, + "/user/username/projects/demo/zoo/zoo.ts": `import { Dog, createDog } from '../animals/index'; + +export function createZoo(): Array { + return [ + createDog() + ]; +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_demo_in_circular_is_set_in_the_reference_test.go b/internal/execute/tsctests/tests/tsbuild_demo_in_circular_is_set_in_the_reference_test.go new file mode 100644 index 00000000000..ab5102fea31 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_demo_in_circular_is_set_in_the_reference_test.go @@ -0,0 +1,136 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_demo_in_circular_is_set_in_the_reference(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "demo", + SubScenario: "in circular is set in the reference", + CommandLineArgs: []string{"--b", "--verbose"}, + Cwd: "/user/username/projects/demo", + Files: tsctests.FileMap{ + "/user/username/projects/demo/a/index.ts": "export const a = 10;", + "/user/username/projects/demo/a/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/a", + "rootDir": "." + }, + "references": [ + { + "path": "../b", + "circular": true + } + ] +}`, + "/user/username/projects/demo/animals/animal.ts": `export type Size = "small" | "medium" | "large"; +export default interface Animal { + size: Size; +}`, + "/user/username/projects/demo/animals/dog.ts": "import Animal from '.';\nimport { makeRandomName } from '../core/utilities';\n\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\n\nexport function createDog(): Dog {\n return ({\n size: \"medium\",\n woof: function(this: Dog) {\n console.log(`${ this.name } says \"Woof\"!`);\n },\n name: makeRandomName()\n });\n}", + "/user/username/projects/demo/animals/index.ts": `import Animal from './animal'; + +export default Animal; +import { createDog, Dog } from './dog'; +export { createDog, Dog };`, + "/user/username/projects/demo/animals/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/animals", + "rootDir": "." + }, + "references": [ + { "path": "../core" } + ] +}`, + "/user/username/projects/demo/b/index.ts": "export const b = 10;", + "/user/username/projects/demo/b/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/b", + "rootDir": "." + }, + "references": [ + { + "path": "../a", + } + ] +}`, + "/user/username/projects/demo/core/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/core", + "rootDir": "." + }, +}`, + "/user/username/projects/demo/core/utilities.ts": `export function makeRandomName() { + return "Bob!?! "; +} + +export function lastElementOf(arr: T[]): T | undefined { + if (arr.length === 0) return undefined; + return arr[arr.length - 1]; +}`, + "/user/username/projects/demo/tsconfig-base.json": `{ + "compilerOptions": { + "declaration": true, + "target": "es5", + "module": "commonjs", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "composite": true, + }, +}`, + "/user/username/projects/demo/tsconfig.json": `{ + "files": [], + "references": [ + { + "path": "./core" + }, + { + "path": "./animals", + }, + { + "path": "./zoo", + }, + { + "path": "./a", + }, + { + "path": "./b", + }, + ], +}`, + "/user/username/projects/demo/zoo/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/zoo", + "rootDir": "." + }, + "references": [ + { + "path": "../animals" + } + ] +}`, + "/user/username/projects/demo/zoo/zoo.ts": `import { Dog, createDog } from '../animals/index'; + +export function createZoo(): Array { + return [ + createDog() + ]; +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_demo_in_master_branch_with_everything_setup_correctly_and_reports_no_error_test.go b/internal/execute/tsctests/tests/tsbuild_demo_in_master_branch_with_everything_setup_correctly_and_reports_no_error_test.go new file mode 100644 index 00000000000..ae8b7bfa965 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_demo_in_master_branch_with_everything_setup_correctly_and_reports_no_error_test.go @@ -0,0 +1,107 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_demo_in_master_branch_with_everything_setup_correctly_and_reports_no_error(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "demo", + SubScenario: "in master branch with everything setup correctly and reports no error", + CommandLineArgs: []string{"--b", "--verbose"}, + Cwd: "/user/username/projects/demo", + Files: tsctests.FileMap{ + "/user/username/projects/demo/animals/animal.ts": `export type Size = "small" | "medium" | "large"; +export default interface Animal { + size: Size; +}`, + "/user/username/projects/demo/animals/dog.ts": "import Animal from '.';\nimport { makeRandomName } from '../core/utilities';\n\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\n\nexport function createDog(): Dog {\n return ({\n size: \"medium\",\n woof: function(this: Dog) {\n console.log(`${ this.name } says \"Woof\"!`);\n },\n name: makeRandomName()\n });\n}", + "/user/username/projects/demo/animals/index.ts": `import Animal from './animal'; + +export default Animal; +import { createDog, Dog } from './dog'; +export { createDog, Dog };`, + "/user/username/projects/demo/animals/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/animals", + "rootDir": "." + }, + "references": [ + { "path": "../core" } + ] +}`, + "/user/username/projects/demo/core/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/core", + "rootDir": "." + }, +}`, + "/user/username/projects/demo/core/utilities.ts": `export function makeRandomName() { + return "Bob!?! "; +} + +export function lastElementOf(arr: T[]): T | undefined { + if (arr.length === 0) return undefined; + return arr[arr.length - 1]; +}`, + "/user/username/projects/demo/tsconfig-base.json": `{ + "compilerOptions": { + "declaration": true, + "target": "es5", + "module": "commonjs", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "composite": true, + }, +}`, + "/user/username/projects/demo/tsconfig.json": `{ + "files": [], + "references": [ + { + "path": "./core" + }, + { + "path": "./animals", + }, + { + "path": "./zoo", + }, + ], +}`, + "/user/username/projects/demo/zoo/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "outDir": "../lib/zoo", + "rootDir": "." + }, + "references": [ + { + "path": "../animals" + } + ] +}`, + "/user/username/projects/demo/zoo/zoo.ts": `import { Dog, createDog } from '../animals/index'; + +export function createZoo(): Array { + return [ + createDog() + ]; +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_emitDeclarationOnly_only_dts_output_in_circular_import_project_with_emitDeclarationOnly_and_declarationMap_test.go b/internal/execute/tsctests/tests/tsbuild_emitDeclarationOnly_only_dts_output_in_circular_import_project_with_emitDeclarationOnly_and_declarationMap_test.go new file mode 100644 index 00000000000..237c190317b --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_emitDeclarationOnly_only_dts_output_in_circular_import_project_with_emitDeclarationOnly_and_declarationMap_test.go @@ -0,0 +1,67 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_emitDeclarationOnly_only_dts_output_in_circular_import_project_with_emitDeclarationOnly_and_declarationMap(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "emitDeclarationOnly", + SubScenario: "only dts output in circular import project with emitDeclarationOnly and declarationMap", + CommandLineArgs: []string{"--b", "--verbose"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/a.ts": `import { B } from "./b"; + +export interface A { + b: B; +}`, + "/home/src/workspaces/project/src/b.ts": `import { C } from "./c"; + +export interface B { + b: C; +}`, + "/home/src/workspaces/project/src/c.ts": `import { A } from "./a"; + +export interface C { + a: A; +}`, + "/home/src/workspaces/project/src/index.ts": `export { A } from "./a"; +export { B } from "./b"; +export { C } from "./c";`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "target": "es5", + "module": "commonjs", + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "outDir": "./lib", + "composite": true, + "strict": true, + "esModuleInterop": true, + "alwaysStrict": true, + "rootDir": "src", + "emitDeclarationOnly": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/a.ts", `import { B } from "./b"; + +export interface A { + b: B; foo: any; +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_emitDeclarationOnly_only_dts_output_in_circular_import_project_with_emitDeclarationOnly_test.go b/internal/execute/tsctests/tests/tsbuild_emitDeclarationOnly_only_dts_output_in_circular_import_project_with_emitDeclarationOnly_test.go new file mode 100644 index 00000000000..3dad9c4f8cb --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_emitDeclarationOnly_only_dts_output_in_circular_import_project_with_emitDeclarationOnly_test.go @@ -0,0 +1,67 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_emitDeclarationOnly_only_dts_output_in_circular_import_project_with_emitDeclarationOnly(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "emitDeclarationOnly", + SubScenario: "only dts output in circular import project with emitDeclarationOnly", + CommandLineArgs: []string{"--b", "--verbose"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/a.ts": `import { B } from "./b"; + +export interface A { + b: B; +}`, + "/home/src/workspaces/project/src/b.ts": `import { C } from "./c"; + +export interface B { + b: C; +}`, + "/home/src/workspaces/project/src/c.ts": `import { A } from "./a"; + +export interface C { + a: A; +}`, + "/home/src/workspaces/project/src/index.ts": `export { A } from "./a"; +export { B } from "./b"; +export { C } from "./c";`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "target": "es5", + "module": "commonjs", + "declaration": true, + "declarationMap": false, + "sourceMap": true, + "outDir": "./lib", + "composite": true, + "strict": true, + "esModuleInterop": true, + "alwaysStrict": true, + "rootDir": "src", + "emitDeclarationOnly": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/a.ts", `import { B } from "./b"; + +export interface A { + b: B; foo: any; +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_emitDeclarationOnly_only_dts_output_in_non_circular_imports_project_with_emitDeclarationOnly_test.go b/internal/execute/tsctests/tests/tsbuild_emitDeclarationOnly_only_dts_output_in_non_circular_imports_project_with_emitDeclarationOnly_test.go new file mode 100644 index 00000000000..5d5cac27cbe --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_emitDeclarationOnly_only_dts_output_in_non_circular_imports_project_with_emitDeclarationOnly_test.go @@ -0,0 +1,77 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_emitDeclarationOnly_only_dts_output_in_non_circular_imports_project_with_emitDeclarationOnly(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "emitDeclarationOnly", + SubScenario: "only dts output in non circular imports project with emitDeclarationOnly", + CommandLineArgs: []string{"--b", "--verbose"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/a.ts": `export class B { prop = "hello"; } + +export interface A { + b: B; +}`, + "/home/src/workspaces/project/src/b.ts": `import { C } from "./c"; + +export interface B { + b: C; +}`, + "/home/src/workspaces/project/src/c.ts": `import { A } from "./a"; + +export interface C { + a: A; +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "target": "es5", + "module": "commonjs", + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "outDir": "./lib", + "composite": true, + "strict": true, + "esModuleInterop": true, + "alwaysStrict": true, + "rootDir": "src", + "emitDeclarationOnly": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-doesnt-change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/a.ts", `export class B { prop = "hello"; } + +class C { } +export interface A { + b: B; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/a.ts", `export class B { prop = "hello"; } + +class C { } +export interface A { + b: B; foo: any; +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_extends_configDir_template_test.go b/internal/execute/tsctests/tests/tsbuild_extends_configDir_template_test.go new file mode 100644 index 00000000000..b4de0d49896 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_extends_configDir_template_test.go @@ -0,0 +1,54 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_extends_configDir_template(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "extends", + SubScenario: "configDir template", + CommandLineArgs: []string{"--b", "--explainFiles", "--v"}, + Cwd: "/home/src/projects/myproject", + Files: tsctests.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/*"], + }, + }, + "watchOptions": { + "excludeFiles": ["${configDir}/main.ts"], + }, +}`, + "/home/src/projects/myproject/main.ts": `// some comment +export const y = 10; +import { x } from "@myscope/sometype";`, + "/home/src/projects/myproject/tsconfig.json": `{ + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true, + }, +}`, + "/home/src/projects/myproject/types/sometype.ts": "export const x = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_extends_resolves_the_symlink_path_test.go b/internal/execute/tsctests/tests/tsbuild_extends_resolves_the_symlink_path_test.go new file mode 100644 index 00000000000..a19a943bf8a --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_extends_resolves_the_symlink_path_test.go @@ -0,0 +1,38 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsbuild_extends_resolves_the_symlink_path(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "extends", + SubScenario: "resolves the symlink path", + CommandLineArgs: []string{"-b", "src", "--extendedDiagnostics"}, + Cwd: "/users/user/projects/myproject", + Files: tsctests.FileMap{ + "/users/user/projects/myconfigs/node_modules/@something/tsconfig-base/tsconfig.json": `{ + "compilerOptions": { "composite": true } +}`, + "/users/user/projects/myconfigs/node_modules/@something/tsconfig-node/tsconfig.json": `{ + "extends": "@something/tsconfig-base/tsconfig.json", + "compilerOptions": { + "removeComments": true + } +}`, + "/users/user/projects/myproject/node_modules/@something/tsconfig-node": vfstest.Symlink("/users/user/projects/myconfigs/node_modules/@something/tsconfig-node"), + "/users/user/projects/myproject/src/index.ts": `// some comment +export const x = 10;`, + "/users/user/projects/myproject/src/tsconfig.json": `{ + "extends": "@something/tsconfig-node/tsconfig.json" +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_extends_when_building_project_uses_reference_and_both_extend_config_with_include_test.go b/internal/execute/tsctests/tests/tsbuild_extends_when_building_project_uses_reference_and_both_extend_config_with_include_test.go new file mode 100644 index 00000000000..f52a222a706 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_extends_when_building_project_uses_reference_and_both_extend_config_with_include_test.go @@ -0,0 +1,54 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_extends_when_building_project_uses_reference_and_both_extend_config_with_include(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "extends", + SubScenario: "when building project uses reference and both extend config with include", + CommandLineArgs: []string{"--b", "webpack/tsconfig.json", "--v", "--listFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/shared/index.ts": "export const a: Unrestricted = 1;", + "/home/src/workspaces/solution/shared/tsconfig-base.json": `{ + "include": ["./typings-base/"], +}`, + "/home/src/workspaces/solution/shared/tsconfig.json": `{ + "extends": "./tsconfig-base.json", + "compilerOptions": { + "composite": true, + "outDir": "../target-tsc-build/", + "rootDir": "..", + }, + "files": ["./index.ts"], +}`, + "/home/src/workspaces/solution/shared/typings-base/globals.d.ts": "type Unrestricted = any;", + "/home/src/workspaces/solution/tsconfig.json": `{ + "references": [ + { "path": "./shared/tsconfig.json" }, + { "path": "./webpack/tsconfig.json" }, + ], + "files": [], +}`, + "/home/src/workspaces/solution/webpack/index.ts": "export const b: Unrestricted = 1;", + "/home/src/workspaces/solution/webpack/tsconfig.json": `{ + "extends": "../shared/tsconfig-base.json", + "compilerOptions": { + "composite": true, + "outDir": "../target-tsc-build/", + "rootDir": "..", + }, + "files": ["./index.ts"], + "references": [{ "path": "../shared/tsconfig.json" }], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_extends_when_building_solution_with_projects_extends_config_with_include_test.go b/internal/execute/tsctests/tests/tsbuild_extends_when_building_solution_with_projects_extends_config_with_include_test.go new file mode 100644 index 00000000000..cff50036031 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_extends_when_building_solution_with_projects_extends_config_with_include_test.go @@ -0,0 +1,54 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_extends_when_building_solution_with_projects_extends_config_with_include(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "extends", + SubScenario: "when building solution with projects extends config with include", + CommandLineArgs: []string{"--b", "--v", "--listFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/shared/index.ts": "export const a: Unrestricted = 1;", + "/home/src/workspaces/solution/shared/tsconfig-base.json": `{ + "include": ["./typings-base/"], +}`, + "/home/src/workspaces/solution/shared/tsconfig.json": `{ + "extends": "./tsconfig-base.json", + "compilerOptions": { + "composite": true, + "outDir": "../target-tsc-build/", + "rootDir": "..", + }, + "files": ["./index.ts"], +}`, + "/home/src/workspaces/solution/shared/typings-base/globals.d.ts": "type Unrestricted = any;", + "/home/src/workspaces/solution/tsconfig.json": `{ + "references": [ + { "path": "./shared/tsconfig.json" }, + { "path": "./webpack/tsconfig.json" }, + ], + "files": [], +}`, + "/home/src/workspaces/solution/webpack/index.ts": "export const b: Unrestricted = 1;", + "/home/src/workspaces/solution/webpack/tsconfig.json": `{ + "extends": "../shared/tsconfig-base.json", + "compilerOptions": { + "composite": true, + "outDir": "../target-tsc-build/", + "rootDir": "..", + }, + "files": ["./index.ts"], + "references": [{ "path": "../shared/tsconfig.json" }], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_fileDelete_deleted_file_without_composite_test.go b/internal/execute/tsctests/tests/tsbuild_fileDelete_deleted_file_without_composite_test.go new file mode 100644 index 00000000000..fcf2d3368a3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_fileDelete_deleted_file_without_composite_test.go @@ -0,0 +1,39 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_fileDelete_deleted_file_without_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "fileDelete", + SubScenario: "deleted file without composite", + CommandLineArgs: []string{"--b", "child/tsconfig.json", "-v", "--traceResolution", "--explainFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/child/child.ts": `import { child2 } from "../child/child2"; +export function child() { + child2(); +}`, + "/home/src/workspaces/solution/child/child2.ts": `export function child2() { +}`, + "/home/src/workspaces/solution/child/tsconfig.json": `{ + "compilerOptions": { } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete child2 file", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/solution/child/child2.js") + sys.Remove("/home/src/workspaces/solution/child/child2.ts") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_fileDelete_detects_deleted_file_test.go b/internal/execute/tsctests/tests/tsbuild_fileDelete_detects_deleted_file_test.go new file mode 100644 index 00000000000..4b46471b771 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_fileDelete_detects_deleted_file_test.go @@ -0,0 +1,48 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_fileDelete_detects_deleted_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "fileDelete", + SubScenario: "detects deleted file", + CommandLineArgs: []string{"--b", "main/tsconfig.json", "-v", "--traceResolution", "--explainFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/child/child.ts": `import { child2 } from "../child/child2"; +export function child() { + child2(); +}`, + "/home/src/workspaces/solution/child/child2.ts": `export function child2() { +}`, + "/home/src/workspaces/solution/child/tsconfig.json": `{ + "compilerOptions": { "composite": true } +}`, + "/home/src/workspaces/solution/main/main.ts": `import { child } from "../child/child"; +export function main() { + child(); +}`, + "/home/src/workspaces/solution/main/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../child" }], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete child2 file", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/solution/child/child2.d.ts") + sys.Remove("/home/src/workspaces/solution/child/child2.js") + sys.Remove("/home/src/workspaces/solution/child/child2.ts") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_inferredTypeFromMonorepoReference_inferred_type_from_referenced_project_that_references_another_project_in_monorepo_test.go b/internal/execute/tsctests/tests/tsbuild_inferredTypeFromMonorepoReference_inferred_type_from_referenced_project_that_references_another_project_in_monorepo_test.go new file mode 100644 index 00000000000..3133c8d45ff --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_inferredTypeFromMonorepoReference_inferred_type_from_referenced_project_that_references_another_project_in_monorepo_test.go @@ -0,0 +1,137 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsbuild_inferredTypeFromMonorepoReference_inferred_type_from_referenced_project_that_references_another_project_in_monorepo(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "inferredTypeFromMonorepoReference", + SubScenario: "inferred type from referenced project that references another project in monorepo", + CommandLineArgs: []string{"--b", "--verbose"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/node_modules/package-a": vfstest.Symlink("/home/src/workspaces/solution/packages/package-a"), + "/home/src/workspaces/solution/node_modules/package-b": vfstest.Symlink("/home/src/workspaces/solution/packages/package-b"), + "/home/src/workspaces/solution/node_modules/package-c": vfstest.Symlink("/home/src/workspaces/solution/packages/package-c"), + "/home/src/workspaces/solution/package.json": `{ + "name": "tsgo-monorepo-issue", + "private": true, + "workspaces": ["packages/*"] +}`, + "/home/src/workspaces/solution/packages/package-a/package.json": `{ + "name": "package-a", + "version": "1.0.0", + "private": true, + "type": "module", + "main": "./src/index.ts", + "types": "./src/index.ts", + "exports": { + ".": "./src/index.ts" + }, + "dependencies": { + "package-b": "workspace:*" + } +}`, + "/home/src/workspaces/solution/packages/package-a/src/index.ts": `import { createThing } from "package-b"; + +class MyClass { + public thing = createThing({ id: "1", name: "test", enabled: true }); +} + +export { MyClass };`, + "/home/src/workspaces/solution/packages/package-a/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "emitDeclarationOnly": true, + "module": "ESNext", + "moduleResolution": "Bundler", + "target": "ES2022", + "outDir": "./out", + "rootDir": "./src" + }, + "include": ["src/**/*"], + "references": [{ "path": "../package-b" }] +}`, + "/home/src/workspaces/solution/packages/package-b/package.json": `{ + "name": "package-b", + "version": "1.0.0", + "private": true, + "type": "module", + "main": "./src/index.ts", + "types": "./src/index.ts", + "exports": { + ".": "./src/index.ts" + }, + "dependencies": { + "package-c": "workspace:*" + } +}`, + "/home/src/workspaces/solution/packages/package-b/src/index.ts": `import type { MyType } from "package-c"; + +export function createThing(input: MyType): MyType { + return { ...input }; +}`, + "/home/src/workspaces/solution/packages/package-b/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "emitDeclarationOnly": true, + "module": "ESNext", + "moduleResolution": "Bundler", + "target": "ES2022", + "outDir": "./out", + "rootDir": "./src" + }, + "include": ["src/**/*"], + "references": [{ "path": "../package-c" }] +}`, + "/home/src/workspaces/solution/packages/package-c/package.json": `{ + "name": "package-c", + "version": "1.0.0", + "private": true, + "type": "module", + "main": "./src/index.ts", + "types": "./src/index.ts", + "exports": { + ".": "./src/index.ts" + } +}`, + "/home/src/workspaces/solution/packages/package-c/src/index.ts": `export interface MyType { + id: string; + name: string; + enabled: boolean; +}`, + "/home/src/workspaces/solution/packages/package-c/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "emitDeclarationOnly": true, + "module": "ESNext", + "moduleResolution": "Bundler", + "target": "ES2022", + "outDir": "./out", + "rootDir": "./src" + }, + "include": ["src/**/*"] +}`, + "/home/src/workspaces/solution/tsconfig.json": `{ + "files": [], + "include": [], + "references": [ + { "path": "packages/package-a" }, + { "path": "packages/package-b" }, + { "path": "packages/package-c" } + ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_inferredTypeFromTransitiveModule_inferred_type_from_transitive_module_test.go b/internal/execute/tsctests/tests/tsbuild_inferredTypeFromTransitiveModule_inferred_type_from_transitive_module_test.go new file mode 100644 index 00000000000..e168c9fe503 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_inferredTypeFromTransitiveModule_inferred_type_from_transitive_module_test.go @@ -0,0 +1,92 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_inferredTypeFromTransitiveModule_inferred_type_from_transitive_module(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "inferredTypeFromTransitiveModule", + SubScenario: "inferred type from transitive module", + CommandLineArgs: []string{"--b", "--verbose"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/bar.ts": `interface RawAction { + (...args: any[]): Promise | void; +} +interface ActionFactory { + (target: T): T; +} +declare function foo(): ActionFactory; +export default foo()(function foobar(param: string): void { +});`, + "/home/src/workspaces/project/bundling.ts": `export class LazyModule { + constructor(private importCallback: () => Promise) {} +} + +export class LazyAction< + TAction extends (...args: any[]) => any, + TModule +> { + constructor(_lazyModule: LazyModule, _getter: (module: TModule) => TAction) { + } +}`, + "/home/src/workspaces/project/global.d.ts": `interface PromiseConstructor { + new (): Promise; +} +declare var Promise: PromiseConstructor; +interface Promise { +}`, + "/home/src/workspaces/project/index.ts": `import { LazyAction, LazyModule } from './bundling'; +const lazyModule = new LazyModule(() => + import('./lazyIndex') +); +export const lazyBar = new LazyAction(lazyModule, m => m.bar);`, + "/home/src/workspaces/project/lazyIndex.ts": "export { default as bar } from './bar';", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "target": "es5", + "declaration": true, + "outDir": "obj", + "incremental": true, + "isolatedModules": false, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/bar.ts", `interface RawAction { + (...args: any[]): Promise | void; +} +interface ActionFactory { + (target: T): T; +} +declare function foo(): ActionFactory; +export default foo()(function foobar(): void { +});`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/bar.ts", `interface RawAction { + (...args: any[]): Promise | void; +} +interface ActionFactory { + (target: T): T; +} +declare function foo(): ActionFactory; +export default foo()(function foobar(param: string): void { +});`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_inferredTypeFromTransitiveModule_inferred_type_from_transitive_module_with_isolatedModules_test.go b/internal/execute/tsctests/tests/tsbuild_inferredTypeFromTransitiveModule_inferred_type_from_transitive_module_with_isolatedModules_test.go new file mode 100644 index 00000000000..700d40c158c --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_inferredTypeFromTransitiveModule_inferred_type_from_transitive_module_with_isolatedModules_test.go @@ -0,0 +1,92 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_inferredTypeFromTransitiveModule_inferred_type_from_transitive_module_with_isolatedModules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "inferredTypeFromTransitiveModule", + SubScenario: "inferred type from transitive module with isolatedModules", + CommandLineArgs: []string{"--b", "--verbose"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/bar.ts": `interface RawAction { + (...args: any[]): Promise | void; +} +interface ActionFactory { + (target: T): T; +} +declare function foo(): ActionFactory; +export default foo()(function foobar(param: string): void { +});`, + "/home/src/workspaces/project/bundling.ts": `export class LazyModule { + constructor(private importCallback: () => Promise) {} +} + +export class LazyAction< + TAction extends (...args: any[]) => any, + TModule +> { + constructor(_lazyModule: LazyModule, _getter: (module: TModule) => TAction) { + } +}`, + "/home/src/workspaces/project/global.d.ts": `interface PromiseConstructor { + new (): Promise; +} +declare var Promise: PromiseConstructor; +interface Promise { +}`, + "/home/src/workspaces/project/index.ts": `import { LazyAction, LazyModule } from './bundling'; +const lazyModule = new LazyModule(() => + import('./lazyIndex') +); +export const lazyBar = new LazyAction(lazyModule, m => m.bar);`, + "/home/src/workspaces/project/lazyIndex.ts": "export { default as bar } from './bar';", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "target": "es5", + "declaration": true, + "outDir": "obj", + "incremental": true, + "isolatedModules": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/bar.ts", `interface RawAction { + (...args: any[]): Promise | void; +} +interface ActionFactory { + (target: T): T; +} +declare function foo(): ActionFactory; +export default foo()(function foobar(): void { +});`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/bar.ts", `interface RawAction { + (...args: any[]): Promise | void; +} +interface ActionFactory { + (target: T): T; +} +declare function foo(): ActionFactory; +export default foo()(function foobar(param: string): void { +});`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_inferredTypeFromTransitiveModule_reports_errors_in_files_affected_by_change_in_signature_with_isolatedModules_test.go b/internal/execute/tsctests/tests/tsbuild_inferredTypeFromTransitiveModule_reports_errors_in_files_affected_by_change_in_signature_with_isolatedModules_test.go new file mode 100644 index 00000000000..fdfd12f3be7 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_inferredTypeFromTransitiveModule_reports_errors_in_files_affected_by_change_in_signature_with_isolatedModules_test.go @@ -0,0 +1,116 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_inferredTypeFromTransitiveModule_reports_errors_in_files_affected_by_change_in_signature_with_isolatedModules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "inferredTypeFromTransitiveModule", + SubScenario: "reports errors in files affected by change in signature with isolatedModules", + CommandLineArgs: []string{"--b", "--verbose"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/bar.ts": `interface RawAction { + (...args: any[]): Promise | void; +} +interface ActionFactory { + (target: T): T; +} +declare function foo(): ActionFactory; +export default foo()(function foobar(param: string): void { +});`, + "/home/src/workspaces/project/bundling.ts": `export class LazyModule { + constructor(private importCallback: () => Promise) {} +} + +export class LazyAction< + TAction extends (...args: any[]) => any, + TModule +> { + constructor(_lazyModule: LazyModule, _getter: (module: TModule) => TAction) { + } +}`, + "/home/src/workspaces/project/global.d.ts": `interface PromiseConstructor { + new (): Promise; +} +declare var Promise: PromiseConstructor; +interface Promise { +}`, + "/home/src/workspaces/project/index.ts": `import { LazyAction, LazyModule } from './bundling'; +const lazyModule = new LazyModule(() => + import('./lazyIndex') +); +export const lazyBar = new LazyAction(lazyModule, m => m.bar);`, + "/home/src/workspaces/project/lazyIndex.ts": `export { default as bar } from './bar';import { default as bar } from './bar'; +bar("hello");`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "target": "es5", + "declaration": true, + "outDir": "obj", + "incremental": true, + "isolatedModules": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/bar.ts", `interface RawAction { + (...args: any[]): Promise | void; +} +interface ActionFactory { + (target: T): T; +} +declare function foo(): ActionFactory; +export default foo()(function foobar(): void { +});`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/bar.ts", `interface RawAction { + (...args: any[]): Promise | void; +} +interface ActionFactory { + (target: T): T; +} +declare function foo(): ActionFactory; +export default foo()(function foobar(param: string): void { +});`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/bar.ts", `interface RawAction { + (...args: any[]): Promise | void; +} +interface ActionFactory { + (target: T): T; +} +declare function foo(): ActionFactory; +export default foo()(function foobar(): void { +});`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix Error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/lazyIndex.ts", `export { default as bar } from './bar';import { default as bar } from './bar'; +bar();`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_javascriptProjectEmit_loads_js_based_projects_and_emits_them_correctly_test.go b/internal/execute/tsctests/tests/tsbuild_javascriptProjectEmit_loads_js_based_projects_and_emits_them_correctly_test.go new file mode 100644 index 00000000000..4469b1fc3a3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_javascriptProjectEmit_loads_js_based_projects_and_emits_them_correctly_test.go @@ -0,0 +1,114 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_javascriptProjectEmit_loads_js_based_projects_and_emits_them_correctly(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "javascriptProjectEmit", + SubScenario: "loads js-based projects and emits them correctly", + CommandLineArgs: []string{"--b"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.d.ts": `/// +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 { + readonly species: symbol; + (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/common/nominal.js": `/** + * @template T, Name + * @typedef {T & {[Symbol.species]: Name}} Nominal + */ +module.exports = {};`, + "/home/src/workspaces/solution/common/tsconfig.json": `{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "composite": true, + }, + "include": ["nominal.js"], +}`, + "/home/src/workspaces/solution/sub-project-2/index.js": `import { MyNominal } from '../sub-project/index'; + +const variable = { + key: /** @type {MyNominal} */('value'), +}; + +/** + * @return {keyof typeof variable} + */ +export function getVar() { + return 'key'; +}`, + "/home/src/workspaces/solution/sub-project-2/tsconfig.json": `{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../sub-project" }, + ], + "include": ["./index.js"], +}`, + "/home/src/workspaces/solution/sub-project/index.js": `import { Nominal } from '../common/nominal'; + +/** + * @typedef {Nominal} MyNominal + */`, + "/home/src/workspaces/solution/sub-project/tsconfig.json": `{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../common" }, + ], + "include": ["./index.js"], +}`, + "/home/src/workspaces/solution/tsconfig.base.json": `{ + "compilerOptions": { + "skipLibCheck": true, + "rootDir": "./", + "outDir": "../lib", + "allowJs": true, + "checkJs": true, + "declaration": true, + }, +}`, + "/home/src/workspaces/solution/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "./sub-project" }, + { "path": "./sub-project-2" }, + ], + "include": [], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_javascriptProjectEmit_loads_js_based_projects_with_non_moved_json_files_and_emits_them_correctly_test.go b/internal/execute/tsctests/tests/tsbuild_javascriptProjectEmit_loads_js_based_projects_with_non_moved_json_files_and_emits_them_correctly_test.go new file mode 100644 index 00000000000..ed6464900ed --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_javascriptProjectEmit_loads_js_based_projects_with_non_moved_json_files_and_emits_them_correctly_test.go @@ -0,0 +1,89 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_javascriptProjectEmit_loads_js_based_projects_with_non_moved_json_files_and_emits_them_correctly(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "javascriptProjectEmit", + SubScenario: "loads js-based projects with non-moved json files and emits them correctly", + CommandLineArgs: []string{"-b"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/common/index.ts": `import x = require("./obj.json"); +export = x;`, + "/home/src/workspaces/solution/common/obj.json": `{ + "val": 42, +}`, + "/home/src/workspaces/solution/common/tsconfig.json": `{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "outDir": null, + "composite": true, + }, + "include": ["index.ts", "obj.json"], +}`, + "/home/src/workspaces/solution/sub-project-2/index.js": `import { m } from '../sub-project/index'; + +const variable = { + key: m, +}; + +export function getVar() { + return variable; +}`, + "/home/src/workspaces/solution/sub-project-2/tsconfig.json": `{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../sub-project" }, + ], + "include": ["./index.js"], +}`, + "/home/src/workspaces/solution/sub-project/index.js": `import mod from '../common'; + +export const m = mod;`, + "/home/src/workspaces/solution/sub-project/tsconfig.json": `{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../common" }, + ], + "include": ["./index.js"], +}`, + "/home/src/workspaces/solution/tsconfig.base.json": `{ + "compilerOptions": { + "skipLibCheck": true, + "rootDir": "./", + "outDir": "../out", + "allowJs": true, + "checkJs": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "declaration": true, + }, +}`, + "/home/src/workspaces/solution/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "./sub-project" }, + { "path": "./sub-project-2" }, + ], + "include": [], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_lateBoundSymbol_interface_is_merged_and_contains_late_bound_member_test.go b/internal/execute/tsctests/tests/tsbuild_lateBoundSymbol_interface_is_merged_and_contains_late_bound_member_test.go new file mode 100644 index 00000000000..d874a2cff20 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_lateBoundSymbol_interface_is_merged_and_contains_late_bound_member_test.go @@ -0,0 +1,77 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_lateBoundSymbol_interface_is_merged_and_contains_late_bound_member(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "lateBoundSymbol", + SubScenario: "interface is merged and contains late bound member", + CommandLineArgs: []string{"--b", "--verbose"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/globals.d.ts": `interface SymbolConstructor { + (description?: string | number): symbol; +} +declare var Symbol: SymbolConstructor;`, + "/home/src/workspaces/project/src/hkt.ts": "export interface HKT { }", + "/home/src/workspaces/project/src/main.ts": `import { HKT } from "./hkt"; + +const sym = Symbol(); + +declare module "./hkt" { + interface HKT { + [sym]: { a: T } + } +} +const x = 10; +type A = HKT[typeof sym];`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "rootDir": "src", + "incremental": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-doesnt-change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/main.ts", `import { HKT } from "./hkt"; + +const sym = Symbol(); + +declare module "./hkt" { + interface HKT { + [sym]: { a: T } + } +} + +type A = HKT[typeof sym];`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-doesnt-change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/main.ts", `import { HKT } from "./hkt"; + +const sym = Symbol(); + +declare module "./hkt" { + interface HKT { + [sym]: { a: T } + } +} + +type A = HKT[typeof sym];const x = 10;`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_libraryResolution_with_config_test.go b/internal/execute/tsctests/tests/tsbuild_libraryResolution_with_config_test.go new file mode 100644 index 00000000000..1be6da33214 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_libraryResolution_with_config_test.go @@ -0,0 +1,73 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_libraryResolution_with_config(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "libraryResolution", + SubScenario: "with config", + CommandLineArgs: []string{"-b", "project1", "project2", "project3", "project4", "--verbose", "--explainFiles"}, + Cwd: "/home/src/workspace/projects", + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.dom.d.ts": "interface DOMInterface { }", + "/home/src/tslibs/TS/Lib/lib.scripthost.d.ts": "interface ScriptHostInterface { }", + "/home/src/tslibs/TS/Lib/lib.webworker.d.ts": "interface WebWorkerInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/unlreated/index.d.ts": "export const unrelated = 10;", + "/home/src/workspace/projects/project1/core.d.ts": "export const core = 10;", + "/home/src/workspace/projects/project1/file.ts": "export const file = 10;", + "/home/src/workspace/projects/project1/file2.ts": `/// +/// +/// `, + "/home/src/workspace/projects/project1/index.ts": "export const x = \"type1\";", + "/home/src/workspace/projects/project1/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "typeRoots": ["./typeroot1"], + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": false + } +}`, + "/home/src/workspace/projects/project1/typeroot1/sometype/index.d.ts": "export type TheNum = \"type1\";", + "/home/src/workspace/projects/project1/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project2/index.ts": "export const y = 10", + "/home/src/workspace/projects/project2/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": false + } +}`, + "/home/src/workspace/projects/project2/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project3/index.ts": "export const z = 10", + "/home/src/workspace/projects/project3/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": false + } +}`, + "/home/src/workspace/projects/project3/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project4/index.ts": "export const z = 10", + "/home/src/workspace/projects/project4/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["esnext", "dom", "webworker"], + "traceResolution": true, + "libReplacement": false + } +}`, + "/home/src/workspace/projects/project4/utils.d.ts": "export const y = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_libraryResolution_with_config_with_libReplacement_test.go b/internal/execute/tsctests/tests/tsbuild_libraryResolution_with_config_with_libReplacement_test.go new file mode 100644 index 00000000000..b2ad2645d45 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_libraryResolution_with_config_with_libReplacement_test.go @@ -0,0 +1,120 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_libraryResolution_with_config_with_libReplacement(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "libraryResolution", + SubScenario: "with config with libReplacement", + CommandLineArgs: []string{"-b", "project1", "project2", "project3", "project4", "--verbose", "--explainFiles"}, + Cwd: "/home/src/workspace/projects", + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.dom.d.ts": "interface DOMInterface { }", + "/home/src/tslibs/TS/Lib/lib.scripthost.d.ts": "interface ScriptHostInterface { }", + "/home/src/tslibs/TS/Lib/lib.webworker.d.ts": "interface WebWorkerInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/lib-dom/index.d.ts": "interface DOMInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/lib-es5/index.d.ts": `/// +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/workspace/projects/node_modules/@typescript/lib-esnext/index.d.ts": `/// +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/workspace/projects/node_modules/@typescript/lib-scripthost/index.d.ts": "interface ScriptHostInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/lib-webworker/index.d.ts": "interface WebWorkerInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/unlreated/index.d.ts": "export const unrelated = 10;", + "/home/src/workspace/projects/project1/core.d.ts": "export const core = 10;", + "/home/src/workspace/projects/project1/file.ts": "export const file = 10;", + "/home/src/workspace/projects/project1/file2.ts": `/// +/// +/// `, + "/home/src/workspace/projects/project1/index.ts": "export const x = \"type1\";", + "/home/src/workspace/projects/project1/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "typeRoots": ["./typeroot1"], + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": true + } +}`, + "/home/src/workspace/projects/project1/typeroot1/sometype/index.d.ts": "export type TheNum = \"type1\";", + "/home/src/workspace/projects/project1/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project2/index.ts": "export const y = 10", + "/home/src/workspace/projects/project2/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": true + } +}`, + "/home/src/workspace/projects/project2/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project3/index.ts": "export const z = 10", + "/home/src/workspace/projects/project3/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": true + } +}`, + "/home/src/workspace/projects/project3/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project4/index.ts": "export const z = 10", + "/home/src/workspace/projects/project4/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["esnext", "dom", "webworker"], + "traceResolution": true, + "libReplacement": true + } +}`, + "/home/src/workspace/projects/project4/utils.d.ts": "export const y = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_moduleResolution_impliedNodeFormat_differs_between_projects_for_shared_file_test.go b/internal/execute/tsctests/tests/tsbuild_moduleResolution_impliedNodeFormat_differs_between_projects_for_shared_file_test.go new file mode 100644 index 00000000000..3294630fd7d --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_moduleResolution_impliedNodeFormat_differs_between_projects_for_shared_file_test.go @@ -0,0 +1,48 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_moduleResolution_impliedNodeFormat_differs_between_projects_for_shared_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleResolution", + SubScenario: "impliedNodeFormat differs between projects for shared file", + CommandLineArgs: []string{"-b", "a", "b", "--verbose", "--traceResolution", "--explainFiles"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a/src/index.ts": "", + "/home/src/workspaces/project/a/tsconfig.json": `{ + "compilerOptions": { + "strict": true + } +}`, + "/home/src/workspaces/project/b/package.json": `{ + "name": "b", + "type": "module" +}`, + "/home/src/workspaces/project/b/src/index.ts": `import pg from "pg"; +pg.foo();`, + "/home/src/workspaces/project/b/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "module": "node16" + }, +}`, + "/home/src/workspaces/project/node_modules/@types/pg/index.d.ts": "export function foo(): void;", + "/home/src/workspaces/project/node_modules/@types/pg/package.json": `{ + "name": "@types/pg", + "types": "index.d.ts" +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_moduleResolution_resolution_from_d_ts_of_referenced_project_test.go b/internal/execute/tsctests/tests/tsbuild_moduleResolution_resolution_from_d_ts_of_referenced_project_test.go new file mode 100644 index 00000000000..0308b10ed5e --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_moduleResolution_resolution_from_d_ts_of_referenced_project_test.go @@ -0,0 +1,64 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_moduleResolution_resolution_from_d_ts_of_referenced_project(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleResolution", + SubScenario: "resolution from d.ts of referenced project", + CommandLineArgs: []string{"--b", "consumer", "--traceResolution", "-v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/common.d.ts": "export type OnValue = (value: number) => void", + "/home/src/workspaces/project/consumer/index.ts": `import { ValueProducerDeclaration, ValueProducerFromTs } from "@producer" +declare let v: ValueProducerDeclaration; +// n is implicitly any because onValue is actually any (despite what the tooltip says) +v.onValue = (n) => { +} +// n is implicitly number as expected +declare let v2: ValueProducerFromTs; +v2.onValue = (n) => { +}`, + "/home/src/workspaces/project/consumer/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "module": "nodenext", + "moduleResolution": "nodenext", + "paths": { + "@producer": ["../producer/index"], + }, + }, + "references": [ + { "path": "../producer" }, + ], +}`, + "/home/src/workspaces/project/producer/in-js.d.ts": `import { OnValue } from "@common" +export interface ValueProducerDeclaration { + onValue: OnValue; +}`, + "/home/src/workspaces/project/producer/index.ts": `export { ValueProducerDeclaration } from "./in-js" +import { OnValue } from "@common" +export interface ValueProducerFromTs { + onValue: OnValue; +}`, + "/home/src/workspaces/project/producer/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "composite": true, + "module": "nodenext", + "moduleResolution": "nodenext", + "paths": { + "@common": ["../common.d.ts"], + }, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_moduleResolution_resolves_specifier_in_output_declaration_file_from_referenced_project_correctly_test.go b/internal/execute/tsctests/tests/tsbuild_moduleResolution_resolves_specifier_in_output_declaration_file_from_referenced_project_correctly_test.go new file mode 100644 index 00000000000..a789e9de63d --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_moduleResolution_resolves_specifier_in_output_declaration_file_from_referenced_project_correctly_test.go @@ -0,0 +1,50 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsbuild_moduleResolution_resolves_specifier_in_output_declaration_file_from_referenced_project_correctly(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleResolution", + SubScenario: "resolves specifier in output declaration file from referenced project correctly", + CommandLineArgs: []string{"-b", "packages/pkg1", "--verbose", "--traceResolution"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/node_modules/pkg2": vfstest.Symlink("/user/username/projects/myproject/packages/pkg2"), + "/user/username/projects/myproject/packages/pkg1/index.ts": `import type { TheNum } from 'pkg2' +export const theNum: TheNum = 42;`, + "/user/username/projects/myproject/packages/pkg1/tsconfig.json": `{ + "compilerOptions": { + "outDir": "build", + "preserveSymlinks": false + }, + "references": [{ "path": "../pkg2" }] +}`, + "/user/username/projects/myproject/packages/pkg2/const.ts": "export type TheNum = 42;", + "/user/username/projects/myproject/packages/pkg2/index.ts": "export type { TheNum } from 'const';", + "/user/username/projects/myproject/packages/pkg2/package.json": `{ + "name": "pkg2", + "version": "1.0.0", + "main": "build/index.js" +}`, + "/user/username/projects/myproject/packages/pkg2/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "build", + "paths": { + "const": ["./const"] + }, + "preserveSymlinks": false, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_moduleResolution_resolves_specifier_in_output_declaration_file_from_referenced_project_correctly_with_preserveSymlinks_test.go b/internal/execute/tsctests/tests/tsbuild_moduleResolution_resolves_specifier_in_output_declaration_file_from_referenced_project_correctly_with_preserveSymlinks_test.go new file mode 100644 index 00000000000..eadf705880e --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_moduleResolution_resolves_specifier_in_output_declaration_file_from_referenced_project_correctly_with_preserveSymlinks_test.go @@ -0,0 +1,50 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsbuild_moduleResolution_resolves_specifier_in_output_declaration_file_from_referenced_project_correctly_with_preserveSymlinks(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleResolution", + SubScenario: "resolves specifier in output declaration file from referenced project correctly with preserveSymlinks", + CommandLineArgs: []string{"-b", "packages/pkg1", "--verbose", "--traceResolution"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/node_modules/pkg2": vfstest.Symlink("/user/username/projects/myproject/packages/pkg2"), + "/user/username/projects/myproject/packages/pkg1/index.ts": `import type { TheNum } from 'pkg2' +export const theNum: TheNum = 42;`, + "/user/username/projects/myproject/packages/pkg1/tsconfig.json": `{ + "compilerOptions": { + "outDir": "build", + "preserveSymlinks": true + }, + "references": [{ "path": "../pkg2" }] +}`, + "/user/username/projects/myproject/packages/pkg2/const.ts": "export type TheNum = 42;", + "/user/username/projects/myproject/packages/pkg2/index.ts": "export type { TheNum } from 'const';", + "/user/username/projects/myproject/packages/pkg2/package.json": `{ + "name": "pkg2", + "version": "1.0.0", + "main": "build/index.js" +}`, + "/user/username/projects/myproject/packages/pkg2/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "build", + "paths": { + "const": ["./const"] + }, + "preserveSymlinks": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_moduleResolution_shared_resolution_should_not_report_error_test.go b/internal/execute/tsctests/tests/tsbuild_moduleResolution_shared_resolution_should_not_report_error_test.go new file mode 100644 index 00000000000..d69d658af88 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_moduleResolution_shared_resolution_should_not_report_error_test.go @@ -0,0 +1,61 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsbuild_moduleResolution_shared_resolution_should_not_report_error(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleResolution", + SubScenario: "shared resolution should not report error", + CommandLineArgs: []string{"-b", "packages/b", "--verbose", "--traceResolution", "--explainFiles"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/node_modules/a": vfstest.Symlink("/home/src/workspaces/project/packages/a"), + "/home/src/workspaces/project/packages/a/index.js": "export const a = 'a';", + "/home/src/workspaces/project/packages/a/package.json": `{ + "name": "a", + "version": "0.0.0", + "type": "module", + "exports": { + ".": { + "types": "./types/index.d.ts", + "default": "./index.js" + } + } +}`, + "/home/src/workspaces/project/packages/a/test/index.js": "import 'a';", + "/home/src/workspaces/project/packages/a/tsconfig.json": `{ + "compilerOptions": { + "checkJs": true, + "composite": true, + "declaration": true, + "emitDeclarationOnly": true, + "module": "nodenext", + "outDir": "types", + }, +}`, + "/home/src/workspaces/project/packages/b/index.js": "export { a } from 'a';", + "/home/src/workspaces/project/packages/b/package.json": `{ + "name": "b", + "version": "0.0.0", + "type": "module" +}`, + "/home/src/workspaces/project/packages/b/tsconfig.json": `{ +"references": [{ "path": "../a" }], + "compilerOptions": { + "checkJs": true, + "module": "nodenext", + "noEmit": true, + "noImplicitAny": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_moduleResolution_type_reference_resolution_uses_correct_options_for_different_resolution_options_referenced_project_test.go b/internal/execute/tsctests/tests/tsbuild_moduleResolution_type_reference_resolution_uses_correct_options_for_different_resolution_options_referenced_project_test.go new file mode 100644 index 00000000000..e33c6f9a8c5 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_moduleResolution_type_reference_resolution_uses_correct_options_for_different_resolution_options_referenced_project_test.go @@ -0,0 +1,39 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_moduleResolution_type_reference_resolution_uses_correct_options_for_different_resolution_options_referenced_project(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleResolution", + SubScenario: "type reference resolution uses correct options for different resolution options referenced project", + CommandLineArgs: []string{"-b", "packages/pkg1.tsconfig.json", "packages/pkg2.tsconfig.json", "--verbose", "--traceResolution"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/packages/pkg1.tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "typeRoots": ["./typeroot1"] + }, + "files": ["./pkg1_index.ts"], +}`, + "/home/src/workspaces/project/packages/pkg1_index.ts": "export const theNum: TheNum = \"type1\";", + "/home/src/workspaces/project/packages/pkg2.tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "typeRoots": ["./typeroot2"] + }, + "files": ["./pkg2_index.ts"], +}`, + "/home/src/workspaces/project/packages/pkg2_index.ts": "export const theNum: TheNum2 = \"type2\";", + "/home/src/workspaces/project/packages/typeroot1/sometype/index.d.ts": "declare type TheNum = \"type1\";", + "/home/src/workspaces/project/packages/typeroot2/sometype/index.d.ts": "declare type TheNum2 = \"type2\";", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_moduleResolution_when_resolution_is_not_shared_test.go b/internal/execute/tsctests/tests/tsbuild_moduleResolution_when_resolution_is_not_shared_test.go new file mode 100644 index 00000000000..2ad86a11fc5 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_moduleResolution_when_resolution_is_not_shared_test.go @@ -0,0 +1,66 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsbuild_moduleResolution_when_resolution_is_not_shared(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleResolution", + SubScenario: "when resolution is not shared", + CommandLineArgs: []string{"-b", "packages/a", "--verbose", "--traceResolution", "--explainFiles"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/node_modules/a": vfstest.Symlink("/home/src/workspaces/project/packages/a"), + "/home/src/workspaces/project/packages/a/index.js": "export const a = 'a';", + "/home/src/workspaces/project/packages/a/package.json": `{ + "name": "a", + "version": "0.0.0", + "type": "module", + "exports": { + ".": { + "types": "./types/index.d.ts", + "default": "./index.js" + } + } +}`, + "/home/src/workspaces/project/packages/a/test/index.js": "import 'a';", + "/home/src/workspaces/project/packages/a/tsconfig.json": `{ + "compilerOptions": { + "checkJs": true, + "composite": true, + "declaration": true, + "emitDeclarationOnly": true, + "module": "nodenext", + "outDir": "types", + }, +}`, + "/home/src/workspaces/project/packages/b/index.js": "export { a } from 'a';", + "/home/src/workspaces/project/packages/b/package.json": `{ + "name": "b", + "version": "0.0.0", + "type": "module" +}`, + "/home/src/workspaces/project/packages/b/tsconfig.json": `{ +"references": [{ "path": "../a" }], + "compilerOptions": { + "checkJs": true, + "module": "nodenext", + "noEmit": true, + "noImplicitAny": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "build b", + CommandLineArgs: []string{"-b", "packages/b", "--verbose", "--traceResolution", "--explainFiles"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_moduleSpecifiers_synthesized_module_specifiers_across_projects_resolve_correctly_test.go b/internal/execute/tsctests/tests/tsbuild_moduleSpecifiers_synthesized_module_specifiers_across_projects_resolve_correctly_test.go new file mode 100644 index 00000000000..00121b0b0a5 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_moduleSpecifiers_synthesized_module_specifiers_across_projects_resolve_correctly_test.go @@ -0,0 +1,89 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsbuild_moduleSpecifiers_synthesized_module_specifiers_across_projects_resolve_correctly(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleSpecifiers", + SubScenario: "synthesized module specifiers across projects resolve correctly", + CommandLineArgs: []string{"-b", "src-types", "src-dogs", "--verbose"}, + Cwd: "/home/src/workspaces/packages", + Files: tsctests.FileMap{ + "/home/src/workspaces/packages/src-dogs/dog.ts": `import { DogConfig } from 'src-types'; +import { DOG_CONFIG } from './dogconfig.js'; + +export abstract class Dog { + + public static getCapabilities(): DogConfig { + return DOG_CONFIG; + } +}`, + "/home/src/workspaces/packages/src-dogs/dogconfig.ts": `import { DogConfig } from 'src-types'; + +export const DOG_CONFIG: DogConfig = { + name: 'Default dog', +};`, + "/home/src/workspaces/packages/src-dogs/index.ts": `export * from 'src-types'; +export * from './lassie/lassiedog.js';`, + "/home/src/workspaces/packages/src-dogs/lassie/lassieconfig.ts": `import { DogConfig } from 'src-types'; + +export const LASSIE_CONFIG: DogConfig = { name: 'Lassie' };`, + "/home/src/workspaces/packages/src-dogs/lassie/lassiedog.ts": `import { Dog } from '../dog.js'; +import { LASSIE_CONFIG } from './lassieconfig.js'; + +export class LassieDog extends Dog { + protected static getDogConfig = () => LASSIE_CONFIG; +}`, + "/home/src/workspaces/packages/src-dogs/node_modules": vfstest.Symlink("/home/src/workspaces/packages"), + "/home/src/workspaces/packages/src-dogs/package.json": `{ + "type": "module", + "exports": "./index.js" +}`, + "/home/src/workspaces/packages/src-dogs/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../src-types" }, + ], + "include": [ + "**/*", + ], +}`, + "/home/src/workspaces/packages/src-types/dogconfig.ts": `export interface DogConfig { + name: string; +}`, + "/home/src/workspaces/packages/src-types/index.ts": "export * from './dogconfig.js';", + "/home/src/workspaces/packages/src-types/node_modules": vfstest.Symlink("/home/src/workspaces/packages"), + "/home/src/workspaces/packages/src-types/package.json": `{ + "type": "module", + "exports": "./index.js" +}`, + "/home/src/workspaces/packages/src-types/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "composite": true, + }, + "include": [ + "**/*", + ], +}`, + "/home/src/workspaces/packages/tsconfig-base.json": `{ + "compilerOptions": { + "declaration": true, + "module": "node16", + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_moduleSpecifiers_synthesized_module_specifiers_resolve_correctly_test.go b/internal/execute/tsctests/tests/tsbuild_moduleSpecifiers_synthesized_module_specifiers_resolve_correctly_test.go new file mode 100644 index 00000000000..0c681fc8e6d --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_moduleSpecifiers_synthesized_module_specifiers_resolve_correctly_test.go @@ -0,0 +1,113 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_moduleSpecifiers_synthesized_module_specifiers_resolve_correctly(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleSpecifiers", + SubScenario: "synthesized module specifiers resolve correctly", + CommandLineArgs: []string{"-b", "--verbose"}, + Cwd: "/home/src/workspaces/packages", + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.d.ts": `/// +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 { + readonly species: symbol; + (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/solution/common/nominal.ts": `export declare type Nominal = T & { + [Symbol.species]: Name; +};`, + "/home/src/workspaces/packages/solution/common/tsconfig.json": `{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true + }, + "include": ["nominal.ts"] +}`, + "/home/src/workspaces/packages/solution/sub-project-2/index.ts": `import { MyNominal } from '../sub-project/index'; + +const variable = { + key: 'value' as MyNominal, +}; + +export function getVar(): keyof typeof variable { + return 'key'; +}`, + "/home/src/workspaces/packages/solution/sub-project-2/tsconfig.json": `{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "../sub-project" } + ], + "include": ["./index.ts"] +}`, + "/home/src/workspaces/packages/solution/sub-project/index.ts": `import { Nominal } from '../common/nominal'; + +export type MyNominal = Nominal;`, + "/home/src/workspaces/packages/solution/sub-project/tsconfig.json": `{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "../common" } + ], + "include": ["./index.ts"] +}`, + "/home/src/workspaces/packages/solution/tsconfig.json": `{ + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "./sub-project" }, + { "path": "./sub-project-2" } + ], + "include": [] +}`, + "/home/src/workspaces/packages/tsconfig.base.json": `{ + "compilerOptions": { + "skipLibCheck": true, + "rootDir": "./", + "outDir": "lib" + } +}`, + "/home/src/workspaces/packages/tsconfig.json": `{ + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "./solution" }, + ], + "include": [], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noCheck_dts_errors_test.go b/internal/execute/tsctests/tests/tsbuild_noCheck_dts_errors_test.go new file mode 100644 index 00000000000..61af4cab9ee --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noCheck_dts_errors_test.go @@ -0,0 +1,122 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noCheck_dts_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noCheck", + SubScenario: "dts errors", + CommandLineArgs: []string{"-b", "-v", "--noCheck"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a = class { private p = 10; };", + "/home/src/workspaces/project/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "incremental": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add file with error", + CommandLineArgs: []string{"-b", "-v"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/c.ts", "export const c: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noCheck_dts_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noCheck_dts_errors_with_incremental_test.go new file mode 100644 index 00000000000..87d4d95f3ee --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noCheck_dts_errors_with_incremental_test.go @@ -0,0 +1,122 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noCheck_dts_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noCheck", + SubScenario: "dts errors with incremental", + CommandLineArgs: []string{"-b", "-v", "--noCheck"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a = class { private p = 10; };", + "/home/src/workspaces/project/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "incremental": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add file with error", + CommandLineArgs: []string{"-b", "-v"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/c.ts", "export const c: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noCheck_semantic_errors_test.go b/internal/execute/tsctests/tests/tsbuild_noCheck_semantic_errors_test.go new file mode 100644 index 00000000000..3f0f5d4a331 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noCheck_semantic_errors_test.go @@ -0,0 +1,122 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noCheck_semantic_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noCheck", + SubScenario: "semantic errors", + CommandLineArgs: []string{"-b", "-v", "--noCheck"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a: number = \"hello\";", + "/home/src/workspaces/project/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "incremental": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add file with error", + CommandLineArgs: []string{"-b", "-v"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/c.ts", "export const c: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noCheck_semantic_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noCheck_semantic_errors_with_incremental_test.go new file mode 100644 index 00000000000..c48f9bf87bc --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noCheck_semantic_errors_with_incremental_test.go @@ -0,0 +1,122 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noCheck_semantic_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noCheck", + SubScenario: "semantic errors with incremental", + CommandLineArgs: []string{"-b", "-v", "--noCheck"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a: number = \"hello\";", + "/home/src/workspaces/project/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "incremental": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add file with error", + CommandLineArgs: []string{"-b", "-v"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/c.ts", "export const c: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noCheck_syntax_errors_test.go b/internal/execute/tsctests/tests/tsbuild_noCheck_syntax_errors_test.go new file mode 100644 index 00000000000..c7bd57566ea --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noCheck_syntax_errors_test.go @@ -0,0 +1,122 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noCheck_syntax_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noCheck", + SubScenario: "syntax errors", + CommandLineArgs: []string{"-b", "-v", "--noCheck"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a = \"hello", + "/home/src/workspaces/project/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "incremental": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add file with error", + CommandLineArgs: []string{"-b", "-v"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/c.ts", "export const c: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noCheck_syntax_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noCheck_syntax_errors_with_incremental_test.go new file mode 100644 index 00000000000..0ca24e273cb --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noCheck_syntax_errors_with_incremental_test.go @@ -0,0 +1,122 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noCheck_syntax_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noCheck", + SubScenario: "syntax errors with incremental", + CommandLineArgs: []string{"-b", "-v", "--noCheck"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a = \"hello", + "/home/src/workspaces/project/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "incremental": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add file with error", + CommandLineArgs: []string{"-b", "-v"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/c.ts", "export const c: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{"-b", "-v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmitOnError_dts_errors_test.go b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_dts_errors_test.go new file mode 100644 index 00000000000..6977dbb2ff2 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_dts_errors_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmitOnError_dts_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "dts errors", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmitOnError_dts_errors_with_declaration_test.go b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_dts_errors_with_declaration_test.go new file mode 100644 index 00000000000..0032e62c499 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_dts_errors_with_declaration_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmitOnError_dts_errors_with_declaration(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "dts errors with declaration", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmitOnError_dts_errors_with_declaration_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_dts_errors_with_declaration_with_incremental_test.go new file mode 100644 index 00000000000..774c5d04a51 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_dts_errors_with_declaration_with_incremental_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmitOnError_dts_errors_with_declaration_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "dts errors with declaration with incremental", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmitOnError_dts_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_dts_errors_with_incremental_test.go new file mode 100644 index 00000000000..87dc83f85ce --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_dts_errors_with_incremental_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmitOnError_dts_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "dts errors with incremental", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmitOnError_semantic_errors_test.go b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_semantic_errors_test.go new file mode 100644 index 00000000000..09b2f0b3693 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_semantic_errors_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmitOnError_semantic_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "semantic errors", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a: string = 10;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmitOnError_semantic_errors_with_declaration_test.go b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_semantic_errors_with_declaration_test.go new file mode 100644 index 00000000000..6b82ddd6cce --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_semantic_errors_with_declaration_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmitOnError_semantic_errors_with_declaration(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "semantic errors with declaration", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a: string = 10;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmitOnError_semantic_errors_with_declaration_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_semantic_errors_with_declaration_with_incremental_test.go new file mode 100644 index 00000000000..aa465756eda --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_semantic_errors_with_declaration_with_incremental_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmitOnError_semantic_errors_with_declaration_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "semantic errors with declaration with incremental", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a: string = 10;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmitOnError_semantic_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_semantic_errors_with_incremental_test.go new file mode 100644 index 00000000000..403ba2e944f --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_semantic_errors_with_incremental_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmitOnError_semantic_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "semantic errors with incremental", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a: string = 10;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmitOnError_syntax_errors_test.go b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_syntax_errors_test.go new file mode 100644 index 00000000000..c35d7ec30c4 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_syntax_errors_test.go @@ -0,0 +1,57 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmitOnError_syntax_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "syntax errors", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmitOnError_syntax_errors_with_declaration_test.go b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_syntax_errors_with_declaration_test.go new file mode 100644 index 00000000000..e5a60c4ee0e --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_syntax_errors_with_declaration_test.go @@ -0,0 +1,57 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmitOnError_syntax_errors_with_declaration(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "syntax errors with declaration", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmitOnError_syntax_errors_with_declaration_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_syntax_errors_with_declaration_with_incremental_test.go new file mode 100644 index 00000000000..2765c6f5438 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_syntax_errors_with_declaration_with_incremental_test.go @@ -0,0 +1,57 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmitOnError_syntax_errors_with_declaration_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "syntax errors with declaration with incremental", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmitOnError_syntax_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_syntax_errors_with_incremental_test.go new file mode 100644 index 00000000000..f5867f1b27a --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmitOnError_syntax_errors_with_incremental_test.go @@ -0,0 +1,57 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmitOnError_syntax_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "syntax errors with incremental", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_changes_composite_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_changes_composite_test.go new file mode 100644 index 00000000000..7e0fd3a5f14 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_changes_composite_test.go @@ -0,0 +1,147 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_changes_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "changes composite", + CommandLineArgs: []string{"-b", "-v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/class.ts": `export class classC { + prop = 1; +}`, + "/home/src/workspaces/project/src/directUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/indirectClass.ts": `import { classC } from './class'; +export class indirectClass { + classC = new classC(); +}`, + "/home/src/workspaces/project/src/indirectUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/noChangeFile.ts": `export function writeLog(s: string) { +}`, + "/home/src/workspaces/project/src/noChangeFileWithEmitSpecificError.ts": `function someFunc(arguments: boolean, ...rest: any[]) { +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "composite": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error but still noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error and emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and no emit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_changes_incremental_declaration_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_changes_incremental_declaration_test.go new file mode 100644 index 00000000000..886bffbc33b --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_changes_incremental_declaration_test.go @@ -0,0 +1,147 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_changes_incremental_declaration(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "changes incremental declaration", + CommandLineArgs: []string{"-b", "-v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/class.ts": `export class classC { + prop = 1; +}`, + "/home/src/workspaces/project/src/directUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/indirectClass.ts": `import { classC } from './class'; +export class indirectClass { + classC = new classC(); +}`, + "/home/src/workspaces/project/src/indirectUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/noChangeFile.ts": `export function writeLog(s: string) { +}`, + "/home/src/workspaces/project/src/noChangeFileWithEmitSpecificError.ts": `function someFunc(arguments: boolean, ...rest: any[]) { +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "incremental": true, "declaration": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error but still noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error and emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and no emit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_changes_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_changes_incremental_test.go new file mode 100644 index 00000000000..d7dd3398095 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_changes_incremental_test.go @@ -0,0 +1,147 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_changes_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "changes incremental", + CommandLineArgs: []string{"-b", "-v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/class.ts": `export class classC { + prop = 1; +}`, + "/home/src/workspaces/project/src/directUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/indirectClass.ts": `import { classC } from './class'; +export class indirectClass { + classC = new classC(); +}`, + "/home/src/workspaces/project/src/indirectUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/noChangeFile.ts": `export function writeLog(s: string) { +}`, + "/home/src/workspaces/project/src/noChangeFileWithEmitSpecificError.ts": `function someFunc(arguments: boolean, ...rest: any[]) { +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "incremental": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error but still noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error and emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and no emit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_changes_with_initial_noEmit_composite_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_changes_with_initial_noEmit_composite_test.go new file mode 100644 index 00000000000..efd0336ac9a --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_changes_with_initial_noEmit_composite_test.go @@ -0,0 +1,68 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_changes_with_initial_noEmit_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "changes with initial noEmit composite", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/class.ts": `export class classC { + prop = 1; +}`, + "/home/src/workspaces/project/src/directUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/indirectClass.ts": `import { classC } from './class'; +export class indirectClass { + classC = new classC(); +}`, + "/home/src/workspaces/project/src/indirectUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/noChangeFile.ts": `export function writeLog(s: string) { +}`, + "/home/src/workspaces/project/src/noChangeFileWithEmitSpecificError.ts": `function someFunc(arguments: boolean, ...rest: any[]) { +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "composite": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with emit", + CommandLineArgs: []string{"-b", "-v"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and no emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_changes_with_initial_noEmit_incremental_declaration_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_changes_with_initial_noEmit_incremental_declaration_test.go new file mode 100644 index 00000000000..14f8ebbec53 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_changes_with_initial_noEmit_incremental_declaration_test.go @@ -0,0 +1,68 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_changes_with_initial_noEmit_incremental_declaration(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "changes with initial noEmit incremental declaration", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/class.ts": `export class classC { + prop = 1; +}`, + "/home/src/workspaces/project/src/directUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/indirectClass.ts": `import { classC } from './class'; +export class indirectClass { + classC = new classC(); +}`, + "/home/src/workspaces/project/src/indirectUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/noChangeFile.ts": `export function writeLog(s: string) { +}`, + "/home/src/workspaces/project/src/noChangeFileWithEmitSpecificError.ts": `function someFunc(arguments: boolean, ...rest: any[]) { +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "incremental": true, "declaration": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with emit", + CommandLineArgs: []string{"-b", "-v"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and no emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_changes_with_initial_noEmit_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_changes_with_initial_noEmit_incremental_test.go new file mode 100644 index 00000000000..287a779402c --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_changes_with_initial_noEmit_incremental_test.go @@ -0,0 +1,68 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_changes_with_initial_noEmit_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "changes with initial noEmit incremental", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/class.ts": `export class classC { + prop = 1; +}`, + "/home/src/workspaces/project/src/directUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/indirectClass.ts": `import { classC } from './class'; +export class indirectClass { + classC = new classC(); +}`, + "/home/src/workspaces/project/src/indirectUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/noChangeFile.ts": `export function writeLog(s: string) { +}`, + "/home/src/workspaces/project/src/noChangeFileWithEmitSpecificError.ts": `function someFunc(arguments: boolean, ...rest: any[]) { +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "incremental": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with emit", + CommandLineArgs: []string{"-b", "-v"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and no emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{"-b", "-v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_test.go new file mode 100644 index 00000000000..8b03b580594 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_dts_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": false, + "declaration": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_declaration_enable_changes_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_declaration_enable_changes_test.go new file mode 100644 index 00000000000..855ea8de037 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_declaration_enable_changes_test.go @@ -0,0 +1,68 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_dts_errors_with_declaration_enable_changes(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors with declaration enable changes", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": false, + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration enabled noEmit - Should report errors", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration and declarationMap noEmit - Should report errors", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Dts Emit with error", + CommandLineArgs: []string{"-b", "-v", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix the error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { public p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration enabled noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration and declarationMap noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration", "--declarationMap"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_declaration_enable_changes_with_incremental_as_modules_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_declaration_enable_changes_with_incremental_as_modules_test.go new file mode 100644 index 00000000000..19f7f0edb0d --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_declaration_enable_changes_with_incremental_as_modules_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_dts_errors_with_declaration_enable_changes_with_incremental_as_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors with declaration enable changes with incremental as modules", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a = class { private p = 10; };", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration enabled noEmit - Should report errors", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration and declarationMap noEmit - Should report errors", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Dts Emit with error", + CommandLineArgs: []string{"-b", "-v", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix the error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = class { public p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration enabled noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration and declarationMap noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration", "--declarationMap"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_declaration_enable_changes_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_declaration_enable_changes_with_incremental_test.go new file mode 100644 index 00000000000..6eb8bc6110c --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_declaration_enable_changes_with_incremental_test.go @@ -0,0 +1,68 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_dts_errors_with_declaration_enable_changes_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors with declaration enable changes with incremental", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration enabled noEmit - Should report errors", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration and declarationMap noEmit - Should report errors", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Dts Emit with error", + CommandLineArgs: []string{"-b", "-v", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix the error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { public p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration enabled noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration and declarationMap noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration", "--declarationMap"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_declaration_enable_changes_with_multiple_files_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_declaration_enable_changes_with_multiple_files_test.go new file mode 100644 index 00000000000..840670924e9 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_declaration_enable_changes_with_multiple_files_test.go @@ -0,0 +1,79 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_dts_errors_with_declaration_enable_changes_with_multiple_files(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors with declaration enable changes with multiple files", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a = class { private p = 10; };", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/c.ts": "export const c = class { private p = 10; };", + "/home/src/projects/project/d.ts": "export const d = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration enabled noEmit - Should report errors", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration and declarationMap noEmit - Should report errors", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Dts Emit with error", + CommandLineArgs: []string{"-b", "-v", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix the error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = class { public p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration enabled noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration and declarationMap noEmit", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix the another ", + CommandLineArgs: []string{"-b", "-v", "--noEmit", "--declaration", "--declarationMap"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/c.ts", "export const c = class { public p = 10; };") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_incremental_as_modules_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_incremental_as_modules_test.go new file mode 100644 index 00000000000..c01824dd2be --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_incremental_as_modules_test.go @@ -0,0 +1,70 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_dts_errors_with_incremental_as_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors with incremental as modules", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a = class { private p = 10; };", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_incremental_test.go new file mode 100644 index 00000000000..e66ec73dddf --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_with_incremental_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_dts_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors with incremental", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_without_dts_enabled_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_without_dts_enabled_test.go new file mode 100644 index 00000000000..ebf45cbfb8f --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_without_dts_enabled_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_dts_errors_without_dts_enabled(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors without dts enabled", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": false, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_without_dts_enabled_with_incremental_as_modules_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_without_dts_enabled_with_incremental_as_modules_test.go new file mode 100644 index 00000000000..f861b15e924 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_without_dts_enabled_with_incremental_as_modules_test.go @@ -0,0 +1,70 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_dts_errors_without_dts_enabled_with_incremental_as_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors without dts enabled with incremental as modules", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a = class { private p = 10; };", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_without_dts_enabled_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_without_dts_enabled_with_incremental_test.go new file mode 100644 index 00000000000..398909f533a --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_dts_errors_without_dts_enabled_with_incremental_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_dts_errors_without_dts_enabled_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors without dts enabled with incremental", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_semantic_errors_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_semantic_errors_test.go new file mode 100644 index 00000000000..73b80339127 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_semantic_errors_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_semantic_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "semantic errors", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a: number = \"hello\"", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": false, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a: number = \"hello\"") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_semantic_errors_with_incremental_as_modules_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_semantic_errors_with_incremental_as_modules_test.go new file mode 100644 index 00000000000..3fd85369320 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_semantic_errors_with_incremental_as_modules_test.go @@ -0,0 +1,70 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_semantic_errors_with_incremental_as_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "semantic errors with incremental as modules", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a: number = \"hello\"", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a: number = \"hello\"") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_semantic_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_semantic_errors_with_incremental_test.go new file mode 100644 index 00000000000..55e7d4fcdbd --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_semantic_errors_with_incremental_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_semantic_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "semantic errors with incremental", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a: number = \"hello\"", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a: number = \"hello\"") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_syntax_errors_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_syntax_errors_test.go new file mode 100644 index 00000000000..09a520dad42 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_syntax_errors_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_syntax_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "syntax errors", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = \"hello", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": false, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_syntax_errors_with_incremental_as_modules_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_syntax_errors_with_incremental_as_modules_test.go new file mode 100644 index 00000000000..56d87e81b83 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_syntax_errors_with_incremental_as_modules_test.go @@ -0,0 +1,70 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_syntax_errors_with_incremental_as_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "syntax errors with incremental as modules", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a = \"hello", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_noEmit_syntax_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_noEmit_syntax_errors_with_incremental_test.go new file mode 100644 index 00000000000..467ea79d442 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_noEmit_syntax_errors_with_incremental_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_noEmit_syntax_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "syntax errors with incremental", + CommandLineArgs: []string{"-b", "-v", "--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = \"hello", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{"-b", "-v"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_not_specified_and_is_composite_test.go b/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_not_specified_and_is_composite_test.go new file mode 100644 index 00000000000..77553078a32 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_not_specified_and_is_composite_test.go @@ -0,0 +1,37 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_outputPaths_when_rootDir_is_not_specified_and_is_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "outputPaths", + SubScenario: "when rootDir is not specified and is composite", + CommandLineArgs: []string{"-b", "-v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/index.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "outDir": "dist", + "composite": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Normal build without change, that does not block emit on error to show files that get emitted", + CommandLineArgs: []string{"-p", "/home/src/workspaces/project/tsconfig.json"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_not_specified_test.go b/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_not_specified_test.go new file mode 100644 index 00000000000..6e4b69fc305 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_not_specified_test.go @@ -0,0 +1,36 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_outputPaths_when_rootDir_is_not_specified(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "outputPaths", + SubScenario: "when rootDir is not specified", + CommandLineArgs: []string{"-b", "-v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/index.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "outDir": "dist", + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Normal build without change, that does not block emit on error to show files that get emitted", + CommandLineArgs: []string{"-p", "/home/src/workspaces/project/tsconfig.json"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_specified_but_not_all_files_belong_to_rootDir_and_is_composite_test.go b/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_specified_but_not_all_files_belong_to_rootDir_and_is_composite_test.go new file mode 100644 index 00000000000..b6185fee091 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_specified_but_not_all_files_belong_to_rootDir_and_is_composite_test.go @@ -0,0 +1,39 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_outputPaths_when_rootDir_is_specified_but_not_all_files_belong_to_rootDir_and_is_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "outputPaths", + SubScenario: "when rootDir is specified but not all files belong to rootDir and is composite", + CommandLineArgs: []string{"-b", "-v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/index.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "outDir": "dist", + "rootDir": "src", + "composite": true + }, +}`, + "/home/src/workspaces/project/types/type.ts": "export type t = string;", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Normal build without change, that does not block emit on error to show files that get emitted", + CommandLineArgs: []string{"-p", "/home/src/workspaces/project/tsconfig.json"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_specified_but_not_all_files_belong_to_rootDir_test.go b/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_specified_but_not_all_files_belong_to_rootDir_test.go new file mode 100644 index 00000000000..0168f781b1d --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_specified_but_not_all_files_belong_to_rootDir_test.go @@ -0,0 +1,38 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_outputPaths_when_rootDir_is_specified_but_not_all_files_belong_to_rootDir(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "outputPaths", + SubScenario: "when rootDir is specified but not all files belong to rootDir", + CommandLineArgs: []string{"-b", "-v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/index.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "outDir": "dist", + "rootDir": "src", + }, +}`, + "/home/src/workspaces/project/types/type.ts": "export type t = string;", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Normal build without change, that does not block emit on error to show files that get emitted", + CommandLineArgs: []string{"-p", "/home/src/workspaces/project/tsconfig.json"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_specified_test.go b/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_specified_test.go new file mode 100644 index 00000000000..a2648bb8585 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_outputPaths_when_rootDir_is_specified_test.go @@ -0,0 +1,37 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_outputPaths_when_rootDir_is_specified(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "outputPaths", + SubScenario: "when rootDir is specified", + CommandLineArgs: []string{"-b", "-v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/index.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "outDir": "dist", + "rootDir": "src", + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Normal build without change, that does not block emit on error to show files that get emitted", + CommandLineArgs: []string{"-p", "/home/src/workspaces/project/tsconfig.json"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_programUpdates_when_root_is_source_from_project_reference_test.go b/internal/execute/tsctests/tests/tsbuild_programUpdates_when_root_is_source_from_project_reference_test.go new file mode 100644 index 00000000000..1b195e683e3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_programUpdates_when_root_is_source_from_project_reference_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_programUpdates_when_root_is_source_from_project_reference(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "programUpdates", + SubScenario: "when root is source from project reference", + CommandLineArgs: []string{"--b"}, + Cwd: "/home/src/workspaces/project", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "import { FOO } from \"./lib/foo\";", + "/home/src/workspaces/project/lib/foo.ts": "export const FOO: string = 'THEFOOEXPORT';", + "/home/src/workspaces/project/lib/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "./dist" + } +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "references": [ { "path": "./lib" } ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesnt change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/lib/foo.ts", "export const FOO: string = 'THEFOOEXPORT';const Bar = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_programUpdates_when_root_is_source_from_project_reference_with_composite_test.go b/internal/execute/tsctests/tests/tsbuild_programUpdates_when_root_is_source_from_project_reference_with_composite_test.go new file mode 100644 index 00000000000..4ca8623b02c --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_programUpdates_when_root_is_source_from_project_reference_with_composite_test.go @@ -0,0 +1,43 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_programUpdates_when_root_is_source_from_project_reference_with_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "programUpdates", + SubScenario: "when root is source from project reference with composite", + CommandLineArgs: []string{"--b"}, + Cwd: "/home/src/workspaces/project", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "import { FOO } from \"./lib/foo\";", + "/home/src/workspaces/project/lib/foo.ts": "export const FOO: string = 'THEFOOEXPORT';", + "/home/src/workspaces/project/lib/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "./dist" + } +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + }, + "references": [ { "path": "./lib" } ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesnt change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/lib/foo.ts", "export const FOO: string = 'THEFOOEXPORT';const Bar = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectReferenceRedirect_uses_correct_project_reference_redirect_when_file_belongs_to_multiple_sub_projects_test.go b/internal/execute/tsctests/tests/tsbuild_projectReferenceRedirect_uses_correct_project_reference_redirect_when_file_belongs_to_multiple_sub_projects_test.go new file mode 100644 index 00000000000..1cd6ccee9c3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectReferenceRedirect_uses_correct_project_reference_redirect_when_file_belongs_to_multiple_sub_projects_test.go @@ -0,0 +1,85 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsbuild_projectReferenceRedirect_uses_correct_project_reference_redirect_when_file_belongs_to_multiple_sub_projects(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferenceRedirect", + SubScenario: "uses correct project reference redirect when file belongs to multiple sub-projects", + CommandLineArgs: []string{"--b", "--verbose"}, + Cwd: "/home/src/workspaces/project", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/app.ts": `import { platform } from "pkg"; +const check: "native" = platform;`, + "/home/src/workspaces/project/node_modules/pkg": vfstest.Symlink("/home/src/workspaces/project/pkg"), + "/home/src/workspaces/project/pkg/index.native.ts": "export { platform } from \"./src/util\";", + "/home/src/workspaces/project/pkg/index.ts": "export { platform } from \"./src/util\";", + "/home/src/workspaces/project/pkg/package.json": `{ + "name": "pkg", + "exports": { + ".": { + "react-native": "./index.native.ts", + "types": "./index.ts", + "default": "./index.ts" + } + } +}`, + "/home/src/workspaces/project/pkg/src/util.native.ts": "export const platform = \"native\" as const;", + "/home/src/workspaces/project/pkg/src/util.ts": "export const platform = \"web\" as const;", + "/home/src/workspaces/project/pkg/tsconfig.json": `{ + "compilerOptions": { + "module": "esnext", + "moduleResolution": "bundler", + "composite": true, + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "./dist", + "strict": true + }, + "include": ["**/*"], + "exclude": ["dist"], + "references": [ + { "path": "./tsconfig.native.json" } + ] +}`, + "/home/src/workspaces/project/pkg/tsconfig.native.json": `{ + "compilerOptions": { + "module": "esnext", + "moduleResolution": "bundler", + "composite": true, + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "./dist", + "strict": true, + "customConditions": ["react-native"], + "moduleSuffixes": [".native", ""] + }, + "include": ["index.native.ts", "src/util.native.ts", "src/util.ts"], + "exclude": ["dist"] +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "module": "esnext", + "moduleResolution": "bundler", + "customConditions": ["react-native"], + "moduleSuffixes": [".native", ""], + "strict": true, + "noEmit": true + }, + "include": ["app.ts"], + "references": [ + { "path": "./pkg" } + ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_builds_correctly_test.go b/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_builds_correctly_test.go new file mode 100644 index 00000000000..1f6816980b0 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_builds_correctly_test.go @@ -0,0 +1,47 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectReferenceWithRootDirInParent_builds_correctly(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferenceWithRootDirInParent", + SubScenario: "builds correctly", + CommandLineArgs: []string{"--b", "src/main", "/home/src/workspaces/solution/src/other"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/src/main/a.ts": `import { b } from './b'; +const a = b;`, + "/home/src/workspaces/solution/src/main/b.ts": "export const b = 0;", + "/home/src/workspaces/solution/src/main/tsconfig.json": `{ + "extends": "../../tsconfig.base.json", + "references": [ + { "path": "../other" }, + ], +}`, + "/home/src/workspaces/solution/src/other/other.ts": "export const Other = 0;", + "/home/src/workspaces/solution/src/other/tsconfig.json": `{ + "extends": "../../tsconfig.base.json", +}`, + "/home/src/workspaces/solution/tsconfig.base.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "rootDir": "./src/", + "outDir": "./dist/", + "skipDefaultLibCheck": true, + }, + "exclude": [ + "node_modules", + ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_because_no_rootDir_in_the_base_test.go b/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_because_no_rootDir_in_the_base_test.go new file mode 100644 index 00000000000..909bf24c8d1 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_because_no_rootDir_in_the_base_test.go @@ -0,0 +1,47 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_because_no_rootDir_in_the_base(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferenceWithRootDirInParent", + SubScenario: "reports error for same tsbuildinfo file because no rootDir in the base", + CommandLineArgs: []string{"--b", "src/main", "--verbose"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/src/main/a.ts": `import { b } from './b'; +const a = b;`, + "/home/src/workspaces/solution/src/main/b.ts": "export const b = 0;", + "/home/src/workspaces/solution/src/main/tsconfig.json": `{ + "extends": "../../tsconfig.base.json", + "references": [ + { "path": "../other" }, + ], +}`, + "/home/src/workspaces/solution/src/other/other.ts": "export const Other = 0;", + "/home/src/workspaces/solution/src/other/tsconfig.json": `{ + "extends": "../../tsconfig.base.json", +}`, + "/home/src/workspaces/solution/tsconfig.base.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + + "outDir": "./dist/", + "skipDefaultLibCheck": true, + }, + "exclude": [ + "node_modules", + ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_test.go b/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_test.go new file mode 100644 index 00000000000..3610dbfb004 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_test.go @@ -0,0 +1,49 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferenceWithRootDirInParent", + SubScenario: "reports error for same tsbuildinfo file", + CommandLineArgs: []string{"--b", "src/main", "--verbose"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/src/main/a.ts": `import { b } from './b'; +const a = b;`, + "/home/src/workspaces/solution/src/main/b.ts": "export const b = 0;", + "/home/src/workspaces/solution/src/main/tsconfig.json": `{ + "compilerOptions": { "composite": true, "outDir": "../../dist/" }, + "references": [{ "path": "../other" }] +}`, + "/home/src/workspaces/solution/src/other/other.ts": "export const Other = 0;", + "/home/src/workspaces/solution/src/other/tsconfig.json": `{ + "compilerOptions": { "composite": true, "outDir": "../../dist/" }, +}`, + "/home/src/workspaces/solution/tsconfig.base.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "rootDir": "./src/", + "outDir": "./dist/", + "skipDefaultLibCheck": true, + }, + "exclude": [ + "node_modules", + ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_without_incremental_test.go b/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_without_incremental_test.go new file mode 100644 index 00000000000..e52798db19c --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_without_incremental_test.go @@ -0,0 +1,45 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_without_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferenceWithRootDirInParent", + SubScenario: "reports error for same tsbuildinfo file without incremental", + CommandLineArgs: []string{"--b", "src/main", "--verbose"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/src/main/a.ts": `import { b } from './b'; +const a = b;`, + "/home/src/workspaces/solution/src/main/b.ts": "export const b = 0;", + "/home/src/workspaces/solution/src/main/tsconfig.json": `{ + "compilerOptions": { "outDir": "../../dist/" }, + "references": [{ "path": "../other" }] +}`, + "/home/src/workspaces/solution/src/other/other.ts": "export const Other = 0;", + "/home/src/workspaces/solution/src/other/tsconfig.json": `{ + "compilerOptions": { "composite": true, "outDir": "../../dist/" }, +}`, + "/home/src/workspaces/solution/tsconfig.base.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "rootDir": "./src/", + "outDir": "./dist/", + "skipDefaultLibCheck": true, + }, + "exclude": [ + "node_modules", + ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_without_incremental_with_tsc_test.go b/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_without_incremental_with_tsc_test.go new file mode 100644 index 00000000000..72d4bced0a4 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_without_incremental_with_tsc_test.go @@ -0,0 +1,50 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectReferenceWithRootDirInParent_reports_error_for_same_tsbuildinfo_file_without_incremental_with_tsc(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferenceWithRootDirInParent", + SubScenario: "reports error for same tsbuildinfo file without incremental with tsc", + CommandLineArgs: []string{"--b", "src/other", "--verbose"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/src/main/a.ts": `import { b } from './b'; +const a = b;`, + "/home/src/workspaces/solution/src/main/b.ts": "export const b = 0;", + "/home/src/workspaces/solution/src/main/tsconfig.json": `{ + "compilerOptions": { "outDir": "../../dist/" }, + "references": [{ "path": "../other" }] +}`, + "/home/src/workspaces/solution/src/other/other.ts": "export const Other = 0;", + "/home/src/workspaces/solution/src/other/tsconfig.json": `{ + "compilerOptions": { "composite": true, "outDir": "../../dist/" }, +}`, + "/home/src/workspaces/solution/tsconfig.base.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "rootDir": "./src/", + "outDir": "./dist/", + "skipDefaultLibCheck": true, + }, + "exclude": [ + "node_modules", + ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Running tsc on main", + CommandLineArgs: []string{"-p", "src/main"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_no_error_when_tsbuildinfo_differ_test.go b/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_no_error_when_tsbuildinfo_differ_test.go new file mode 100644 index 00000000000..ed22ce10fc3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectReferenceWithRootDirInParent_reports_no_error_when_tsbuildinfo_differ_test.go @@ -0,0 +1,49 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectReferenceWithRootDirInParent_reports_no_error_when_tsbuildinfo_differ(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferenceWithRootDirInParent", + SubScenario: "reports no error when tsbuildinfo differ", + CommandLineArgs: []string{"--b", "src/main/tsconfig.main.json", "--verbose"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/src/main/a.ts": `import { b } from './b'; +const a = b;`, + "/home/src/workspaces/solution/src/main/b.ts": "export const b = 0;", + "/home/src/workspaces/solution/src/main/tsconfig.main.json": `{ + "compilerOptions": { "composite": true, "outDir": "../../dist/" }, + "references": [{ "path": "../other/tsconfig.other.json" }] +}`, + "/home/src/workspaces/solution/src/other/other.ts": "export const Other = 0;", + "/home/src/workspaces/solution/src/other/tsconfig.other.json": `{ + "compilerOptions": { "composite": true, "outDir": "../../dist/" }, +}`, + "/home/src/workspaces/solution/tsconfig.base.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "rootDir": "./src/", + "outDir": "./dist/", + "skipDefaultLibCheck": true, + }, + "exclude": [ + "node_modules", + ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_23_projects_in_a_solution_test.go b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_23_projects_in_a_solution_test.go new file mode 100644 index 00000000000..b8dfe4896e3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_23_projects_in_a_solution_test.go @@ -0,0 +1,187 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectsBuilding_when_there_are_23_projects_in_a_solution(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 23 projects in a solution", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg10/index.ts": "export const pkg10 = 10;", + "/user/username/projects/myproject/pkg10/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg11/index.ts": "export const pkg11 = 11;", + "/user/username/projects/myproject/pkg11/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg12/index.ts": "export const pkg12 = 12;", + "/user/username/projects/myproject/pkg12/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg13/index.ts": "export const pkg13 = 13;", + "/user/username/projects/myproject/pkg13/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg14/index.ts": "export const pkg14 = 14;", + "/user/username/projects/myproject/pkg14/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg15/index.ts": "export const pkg15 = 15;", + "/user/username/projects/myproject/pkg15/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg16/index.ts": "export const pkg16 = 16;", + "/user/username/projects/myproject/pkg16/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg17/index.ts": "export const pkg17 = 17;", + "/user/username/projects/myproject/pkg17/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg18/index.ts": "export const pkg18 = 18;", + "/user/username/projects/myproject/pkg18/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg19/index.ts": "export const pkg19 = 19;", + "/user/username/projects/myproject/pkg19/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg20/index.ts": "export const pkg20 = 20;", + "/user/username/projects/myproject/pkg20/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg21/index.ts": "export const pkg21 = 21;", + "/user/username/projects/myproject/pkg21/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg22/index.ts": "export const pkg22 = 22;", + "/user/username/projects/myproject/pkg22/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg3/index.ts": "export const pkg3 = 3;", + "/user/username/projects/myproject/pkg3/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg4/index.ts": "export const pkg4 = 4;", + "/user/username/projects/myproject/pkg4/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg5/index.ts": "export const pkg5 = 5;", + "/user/username/projects/myproject/pkg5/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg6/index.ts": "export const pkg6 = 6;", + "/user/username/projects/myproject/pkg6/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg7/index.ts": "export const pkg7 = 7;", + "/user/username/projects/myproject/pkg7/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg8/index.ts": "export const pkg8 = 8;", + "/user/username/projects/myproject/pkg8/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg9/index.ts": "export const pkg9 = 9;", + "/user/username/projects/myproject/pkg9/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" }, + { "path": "./pkg3" }, + { "path": "./pkg4" }, + { "path": "./pkg5" }, + { "path": "./pkg6" }, + { "path": "./pkg7" }, + { "path": "./pkg8" }, + { "path": "./pkg9" }, + { "path": "./pkg10" }, + { "path": "./pkg11" }, + { "path": "./pkg12" }, + { "path": "./pkg13" }, + { "path": "./pkg14" }, + { "path": "./pkg15" }, + { "path": "./pkg16" }, + { "path": "./pkg17" }, + { "path": "./pkg18" }, + { "path": "./pkg19" }, + { "path": "./pkg20" }, + { "path": "./pkg21" }, + { "path": "./pkg22" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_23_projects_in_a_solution_with_builders_3_test.go b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_23_projects_in_a_solution_with_builders_3_test.go new file mode 100644 index 00000000000..1e7a8a5f2cd --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_23_projects_in_a_solution_with_builders_3_test.go @@ -0,0 +1,187 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectsBuilding_when_there_are_23_projects_in_a_solution_with_builders_3(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 23 projects in a solution with --builders 3", + CommandLineArgs: []string{"-b", "-v", "--builders", "3"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg10/index.ts": "export const pkg10 = 10;", + "/user/username/projects/myproject/pkg10/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg11/index.ts": "export const pkg11 = 11;", + "/user/username/projects/myproject/pkg11/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg12/index.ts": "export const pkg12 = 12;", + "/user/username/projects/myproject/pkg12/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg13/index.ts": "export const pkg13 = 13;", + "/user/username/projects/myproject/pkg13/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg14/index.ts": "export const pkg14 = 14;", + "/user/username/projects/myproject/pkg14/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg15/index.ts": "export const pkg15 = 15;", + "/user/username/projects/myproject/pkg15/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg16/index.ts": "export const pkg16 = 16;", + "/user/username/projects/myproject/pkg16/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg17/index.ts": "export const pkg17 = 17;", + "/user/username/projects/myproject/pkg17/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg18/index.ts": "export const pkg18 = 18;", + "/user/username/projects/myproject/pkg18/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg19/index.ts": "export const pkg19 = 19;", + "/user/username/projects/myproject/pkg19/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg20/index.ts": "export const pkg20 = 20;", + "/user/username/projects/myproject/pkg20/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg21/index.ts": "export const pkg21 = 21;", + "/user/username/projects/myproject/pkg21/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg22/index.ts": "export const pkg22 = 22;", + "/user/username/projects/myproject/pkg22/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg3/index.ts": "export const pkg3 = 3;", + "/user/username/projects/myproject/pkg3/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg4/index.ts": "export const pkg4 = 4;", + "/user/username/projects/myproject/pkg4/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg5/index.ts": "export const pkg5 = 5;", + "/user/username/projects/myproject/pkg5/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg6/index.ts": "export const pkg6 = 6;", + "/user/username/projects/myproject/pkg6/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg7/index.ts": "export const pkg7 = 7;", + "/user/username/projects/myproject/pkg7/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg8/index.ts": "export const pkg8 = 8;", + "/user/username/projects/myproject/pkg8/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg9/index.ts": "export const pkg9 = 9;", + "/user/username/projects/myproject/pkg9/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" }, + { "path": "./pkg3" }, + { "path": "./pkg4" }, + { "path": "./pkg5" }, + { "path": "./pkg6" }, + { "path": "./pkg7" }, + { "path": "./pkg8" }, + { "path": "./pkg9" }, + { "path": "./pkg10" }, + { "path": "./pkg11" }, + { "path": "./pkg12" }, + { "path": "./pkg13" }, + { "path": "./pkg14" }, + { "path": "./pkg15" }, + { "path": "./pkg16" }, + { "path": "./pkg17" }, + { "path": "./pkg18" }, + { "path": "./pkg19" }, + { "path": "./pkg20" }, + { "path": "./pkg21" }, + { "path": "./pkg22" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_3_projects_in_a_solution_test.go b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_3_projects_in_a_solution_test.go new file mode 100644 index 00000000000..5e9ef897469 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_3_projects_in_a_solution_test.go @@ -0,0 +1,67 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectsBuilding_when_there_are_3_projects_in_a_solution(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 3 projects in a solution", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_3_projects_in_a_solution_with_builders_1_test.go b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_3_projects_in_a_solution_with_builders_1_test.go new file mode 100644 index 00000000000..a6765bf6287 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_3_projects_in_a_solution_with_builders_1_test.go @@ -0,0 +1,67 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectsBuilding_when_there_are_3_projects_in_a_solution_with_builders_1(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 3 projects in a solution with --builders 1", + CommandLineArgs: []string{"-b", "-v", "--builders", "1"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_5_projects_in_a_solution_test.go b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_5_projects_in_a_solution_test.go new file mode 100644 index 00000000000..383796a2382 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_5_projects_in_a_solution_test.go @@ -0,0 +1,79 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectsBuilding_when_there_are_5_projects_in_a_solution(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 5 projects in a solution", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg3/index.ts": "export const pkg3 = 3;", + "/user/username/projects/myproject/pkg3/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg4/index.ts": "export const pkg4 = 4;", + "/user/username/projects/myproject/pkg4/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" }, + { "path": "./pkg3" }, + { "path": "./pkg4" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_5_projects_in_a_solution_with_builders_2_test.go b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_5_projects_in_a_solution_with_builders_2_test.go new file mode 100644 index 00000000000..88692e19290 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_5_projects_in_a_solution_with_builders_2_test.go @@ -0,0 +1,79 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectsBuilding_when_there_are_5_projects_in_a_solution_with_builders_2(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 5 projects in a solution with --builders 2", + CommandLineArgs: []string{"-b", "-v", "--builders", "2"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg3/index.ts": "export const pkg3 = 3;", + "/user/username/projects/myproject/pkg3/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg4/index.ts": "export const pkg4 = 4;", + "/user/username/projects/myproject/pkg4/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" }, + { "path": "./pkg3" }, + { "path": "./pkg4" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_8_projects_in_a_solution_test.go b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_8_projects_in_a_solution_test.go new file mode 100644 index 00000000000..cc4a8500d1d --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_8_projects_in_a_solution_test.go @@ -0,0 +1,97 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectsBuilding_when_there_are_8_projects_in_a_solution(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 8 projects in a solution", + CommandLineArgs: []string{"-b", "-v"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg3/index.ts": "export const pkg3 = 3;", + "/user/username/projects/myproject/pkg3/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg4/index.ts": "export const pkg4 = 4;", + "/user/username/projects/myproject/pkg4/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg5/index.ts": "export const pkg5 = 5;", + "/user/username/projects/myproject/pkg5/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg6/index.ts": "export const pkg6 = 6;", + "/user/username/projects/myproject/pkg6/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg7/index.ts": "export const pkg7 = 7;", + "/user/username/projects/myproject/pkg7/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" }, + { "path": "./pkg3" }, + { "path": "./pkg4" }, + { "path": "./pkg5" }, + { "path": "./pkg6" }, + { "path": "./pkg7" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_8_projects_in_a_solution_with_builders_3_test.go b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_8_projects_in_a_solution_with_builders_3_test.go new file mode 100644 index 00000000000..f4589c2a2fc --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_projectsBuilding_when_there_are_8_projects_in_a_solution_with_builders_3_test.go @@ -0,0 +1,97 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_projectsBuilding_when_there_are_8_projects_in_a_solution_with_builders_3(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectsBuilding", + SubScenario: "when there are 8 projects in a solution with --builders 3", + CommandLineArgs: []string{"-b", "-v", "--builders", "3"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg0/index.ts": "export const pkg0 = 0;", + "/user/username/projects/myproject/pkg0/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + +}`, + "/user/username/projects/myproject/pkg1/index.ts": "export const pkg1 = 1;", + "/user/username/projects/myproject/pkg1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg2/index.ts": "export const pkg2 = 2;", + "/user/username/projects/myproject/pkg2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg3/index.ts": "export const pkg3 = 3;", + "/user/username/projects/myproject/pkg3/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg4/index.ts": "export const pkg4 = 4;", + "/user/username/projects/myproject/pkg4/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg5/index.ts": "export const pkg5 = 5;", + "/user/username/projects/myproject/pkg5/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg6/index.ts": "export const pkg6 = 6;", + "/user/username/projects/myproject/pkg6/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/pkg7/index.ts": "export const pkg7 = 7;", + "/user/username/projects/myproject/pkg7/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../pkg0" }], +}`, + "/user/username/projects/myproject/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "./pkg0" }, + { "path": "./pkg1" }, + { "path": "./pkg2" }, + { "path": "./pkg3" }, + { "path": "./pkg4" }, + { "path": "./pkg5" }, + { "path": "./pkg6" }, + { "path": "./pkg7" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts doesn't change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "dts change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/myproject/pkg0/index.ts", "export const pkg0 = 0;const someConst2 = 10;export const someConst = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_files_containing_json_file_non_composite_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_files_containing_json_file_non_composite_test.go new file mode 100644 index 00000000000..d6ee41e8b57 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_files_containing_json_file_non_composite_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_files_containing_json_file_non_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "files containing json file non-composite", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": false, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + + }, + "files": [ "src/index.ts", "src/hello.json", ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_files_containing_json_file_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_files_containing_json_file_test.go new file mode 100644 index 00000000000..8ebe0818661 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_files_containing_json_file_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_files_containing_json_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "files containing json file", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + + }, + "files": [ "src/index.ts", "src/hello.json", ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_importing_json_module_from_project_reference_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_importing_json_module_from_project_reference_test.go new file mode 100644 index 00000000000..75ab1bc1368 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_importing_json_module_from_project_reference_test.go @@ -0,0 +1,61 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_importing_json_module_from_project_reference(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "importing json module from project reference", + CommandLineArgs: []string{"--b", "project", "--verbose", "--explainFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/main/index.ts": `import { foo } from '../strings/foo.json'; +console.log(foo);`, + "/home/src/workspaces/solution/project/main/tsconfig.json": `{ + "extends": "../tsconfig.json", + "include": [ + "./**/*.ts", + ], + "references": [{ + "path": "../strings/tsconfig.json", + }], +}`, + "/home/src/workspaces/solution/project/strings/foo.json": `{ + "foo": "bar baz" +}`, + "/home/src/workspaces/solution/project/strings/tsconfig.json": `{ + "extends": "../tsconfig.json", + "include": ["foo.json"], + "references": [], +}`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "rootDir": "./", + "composite": true, + "resolveJsonModule": true, + "strict": true, + "esModuleInterop": true, + }, + "references": [ + { "path": "./strings/tsconfig.json" }, + { "path": "./main/tsconfig.json" }, + ], + "files": [], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_and_files_non_composite_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_and_files_non_composite_test.go new file mode 100644 index 00000000000..19c1daeed5c --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_and_files_non_composite_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_and_files_non_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include and files non-composite", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": false, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + + }, + "files": [ "src/hello.json" ], "include": [ "src/**/*" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_and_files_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_and_files_test.go new file mode 100644 index 00000000000..b6efb34abc2 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_and_files_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_and_files(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include and files", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + + }, + "files": [ "src/hello.json" ], "include": [ "src/**/*" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_of_json_along_with_other_include_and_file_name_matches_ts_file_non_composite_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_of_json_along_with_other_include_and_file_name_matches_ts_file_non_composite_test.go new file mode 100644 index 00000000000..fa0688fb572 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_of_json_along_with_other_include_and_file_name_matches_ts_file_non_composite_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_of_json_along_with_other_include_and_file_name_matches_ts_file_non_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include of json along with other include and file name matches ts file non-composite", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/index.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./index.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": false, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + + }, + "include": [ "src/**/*", "src/**/*.json" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_of_json_along_with_other_include_and_file_name_matches_ts_file_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_of_json_along_with_other_include_and_file_name_matches_ts_file_test.go new file mode 100644 index 00000000000..0e61dd449bd --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_of_json_along_with_other_include_and_file_name_matches_ts_file_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_of_json_along_with_other_include_and_file_name_matches_ts_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include of json along with other include and file name matches ts file", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/index.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./index.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + + }, + "include": [ "src/**/*", "src/**/*.json" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_of_json_along_with_other_include_non_composite_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_of_json_along_with_other_include_non_composite_test.go new file mode 100644 index 00000000000..ce678d81d1d --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_of_json_along_with_other_include_non_composite_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_of_json_along_with_other_include_non_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include of json along with other include non-composite", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": false, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + + }, + "include": [ "src/**/*", "src/**/*.json" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_of_json_along_with_other_include_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_of_json_along_with_other_include_test.go new file mode 100644 index 00000000000..6dff700c4c8 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_of_json_along_with_other_include_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_of_json_along_with_other_include(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include of json along with other include", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + + }, + "include": [ "src/**/*", "src/**/*.json" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_non_composite_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_non_composite_test.go new file mode 100644 index 00000000000..bd7eb7b2213 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_non_composite_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_only_non_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include only non-composite", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": false, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + + }, + "include": [ "src/**/*" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_test.go new file mode 100644 index 00000000000..d518300956a --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_only(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include only", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + + }, + "include": [ "src/**/*" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_with_json_not_in_rootDir_non_composite_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_with_json_not_in_rootDir_non_composite_test.go new file mode 100644 index 00000000000..bbb46b0f933 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_with_json_not_in_rootDir_non_composite_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_only_with_json_not_in_rootDir_non_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include only with json not in rootDir non-composite", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "../hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": false, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + "rootDir": "src", + }, + "include": [ "src/**/*" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_with_json_not_in_rootDir_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_with_json_not_in_rootDir_test.go new file mode 100644 index 00000000000..d3ca0543cd4 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_with_json_not_in_rootDir_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_only_with_json_not_in_rootDir(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include only with json not in rootDir", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "../hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + "rootDir": "src", + }, + "include": [ "src/**/*" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_with_json_without_rootDir_but_outside_configDirectory_non_composite_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_with_json_without_rootDir_but_outside_configDirectory_non_composite_test.go new file mode 100644 index 00000000000..7a0dc295625 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_with_json_without_rootDir_but_outside_configDirectory_non_composite_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_only_with_json_without_rootDir_but_outside_configDirectory_non_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include only with json without rootDir but outside configDirectory non-composite", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "../../hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": false, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + + }, + "include": [ "src/**/*" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_with_json_without_rootDir_but_outside_configDirectory_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_with_json_without_rootDir_but_outside_configDirectory_test.go new file mode 100644 index 00000000000..5334bfc1c05 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_with_json_without_rootDir_but_outside_configDirectory_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_only_with_json_without_rootDir_but_outside_configDirectory(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include only with json without rootDir but outside configDirectory", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "../../hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + + }, + "include": [ "src/**/*" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_without_outDir_non_composite_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_without_outDir_non_composite_test.go new file mode 100644 index 00000000000..779db43486d --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_without_outDir_non_composite_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_only_without_outDir_non_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include only without outDir non-composite", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": false, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + + "skipDefaultLibCheck": true, + + }, + "include": [ "src/**/*" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_without_outDir_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_without_outDir_test.go new file mode 100644 index 00000000000..3f478dd944f --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_include_only_without_outDir_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_include_only_without_outDir(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "include only without outDir", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + + "skipDefaultLibCheck": true, + + }, + "include": [ "src/**/*" ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_sourcemap_non_composite_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_sourcemap_non_composite_test.go new file mode 100644 index 00000000000..2ed1a9ba2fd --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_sourcemap_non_composite_test.go @@ -0,0 +1,44 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_sourcemap_non_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "sourcemap non-composite", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": false, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + "sourceMap": true, + }, + "files": [ "src/index.ts", "src/hello.json", ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_sourcemap_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_sourcemap_test.go new file mode 100644 index 00000000000..bbeca60fc6c --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_sourcemap_test.go @@ -0,0 +1,44 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_sourcemap(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "sourcemap", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + "sourceMap": true, + }, + "files": [ "src/index.ts", "src/hello.json", ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_without_outDir_non_composite_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_without_outDir_non_composite_test.go new file mode 100644 index 00000000000..6bb11ba1780 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_without_outDir_non_composite_test.go @@ -0,0 +1,44 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_without_outDir_non_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "without outDir non-composite", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": false, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + + "skipDefaultLibCheck": true, + + }, + "files": [ "src/index.ts", "src/hello.json", ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_without_outDir_test.go b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_without_outDir_test.go new file mode 100644 index 00000000000..3c7a4734164 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_resolveJsonModule_without_outDir_test.go @@ -0,0 +1,44 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_resolveJsonModule_without_outDir(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "resolveJsonModule", + SubScenario: "without outDir", + CommandLineArgs: []string{"--b", "project", "--v", "--explainFiles", "--listEmittedFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/src/hello.json": `{ + "hello": "world" +}`, + "/home/src/workspaces/solution/project/src/index.ts": `import hello from "./hello.json" +export default hello.hello`, + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + + "skipDefaultLibCheck": true, + + }, + "files": [ "src/index.ts", "src/hello.json", ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_roots_when_consecutive_and_non_consecutive_are_mixed_test.go b/internal/execute/tsctests/tests/tsbuild_roots_when_consecutive_and_non_consecutive_are_mixed_test.go new file mode 100644 index 00000000000..154afad879f --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_roots_when_consecutive_and_non_consecutive_are_mixed_test.go @@ -0,0 +1,47 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_roots_when_consecutive_and_non_consecutive_are_mixed(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "roots", + SubScenario: "when consecutive and non consecutive are mixed", + CommandLineArgs: []string{"--b", "-v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/anotherNonConsecutive.ts": `import { random } from "./random2"; +export const nonConsecutive = "hello";`, + "/home/src/workspaces/project/asArray1.ts": `import { random } from "./random1"; +export const x = "hello";`, + "/home/src/workspaces/project/asArray2.ts": "export const x = \"hello\";", + "/home/src/workspaces/project/asArray3.ts": "export const x = \"hello\";", + "/home/src/workspaces/project/file1.ts": "export const x = \"hello\";", + "/home/src/workspaces/project/file2.ts": "export const y = \"world\";", + "/home/src/workspaces/project/nonconsecutive.ts": `import { random } from "./random"; + export const nonConsecutive = "hello";`, + "/home/src/workspaces/project/random.d.ts": "export const random = \"hello\";", + "/home/src/workspaces/project/random1.d.ts": "export const random = \"hello\";", + "/home/src/workspaces/project/random2.d.ts": "export const random = \"hello\";", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "include": ["file*.ts", "nonconsecutive*.ts", "asArray*.ts", "anotherNonConsecutive.ts"], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete file1", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/file1.d.ts") + sys.Remove("/home/src/workspaces/project/file1.js") + sys.Remove("/home/src/workspaces/project/file1.ts") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_roots_when_files_are_not_consecutive_test.go b/internal/execute/tsctests/tests/tsbuild_roots_when_files_are_not_consecutive_test.go new file mode 100644 index 00000000000..89dc86a4d9b --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_roots_when_files_are_not_consecutive_test.go @@ -0,0 +1,38 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_roots_when_files_are_not_consecutive(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "roots", + SubScenario: "when files are not consecutive", + CommandLineArgs: []string{"--b", "-v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/file1.ts": "export const x = \"hello\";", + "/home/src/workspaces/project/file2.ts": `import { random } from "./random"; +export const y = "world";`, + "/home/src/workspaces/project/random.d.ts": "export const random = \"world\";", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "include": ["file*.ts"], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete file1", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/file1.d.ts") + sys.Remove("/home/src/workspaces/project/file1.js") + sys.Remove("/home/src/workspaces/project/file1.ts") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_roots_when_multiple_root_files_are_consecutive_test.go b/internal/execute/tsctests/tests/tsbuild_roots_when_multiple_root_files_are_consecutive_test.go new file mode 100644 index 00000000000..cc3fd710612 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_roots_when_multiple_root_files_are_consecutive_test.go @@ -0,0 +1,38 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_roots_when_multiple_root_files_are_consecutive(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "roots", + SubScenario: "when multiple root files are consecutive", + CommandLineArgs: []string{"--b", "-v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/file1.ts": "export const x = \"hello\";", + "/home/src/workspaces/project/file2.ts": "export const y = \"world\";", + "/home/src/workspaces/project/file3.ts": "export const y = \"world\";", + "/home/src/workspaces/project/file4.ts": "export const y = \"world\";", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "include": ["*.ts"], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete file1", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/file1.d.ts") + sys.Remove("/home/src/workspaces/project/file1.js") + sys.Remove("/home/src/workspaces/project/file1.ts") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_roots_when_root_file_is_from_referenced_project_and_shared_is_first_test.go b/internal/execute/tsctests/tests/tsbuild_roots_when_root_file_is_from_referenced_project_and_shared_is_first_test.go new file mode 100644 index 00000000000..97676573df6 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_roots_when_root_file_is_from_referenced_project_and_shared_is_first_test.go @@ -0,0 +1,89 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_roots_when_root_file_is_from_referenced_project_and_shared_is_first(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "roots", + SubScenario: "when root file is from referenced project and shared is first", + CommandLineArgs: []string{"--b", "projects/server", "-v", "--traceResolution", "--explainFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/projects/server/src/server.ts": `import { MyClass } from ':shared/myClass.js'; +console.log('Hello, world!');`, + "/home/src/workspaces/solution/projects/server/tsconfig.json": `{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "rootDir": "..", + "outDir": "./dist", + "paths": { + ":shared/*": ["./src/../../shared/src/*"], + }, + }, + "include": [ "../shared/src/**/*.ts", "src/**/*.ts" ], + "references": [ + { "path": "../shared" }, + ], +}`, + "/home/src/workspaces/solution/projects/shared/src/logging.ts": `export function log(str: string) { + console.log(str); +}`, + "/home/src/workspaces/solution/projects/shared/src/myClass.ts": "export class MyClass { }", + "/home/src/workspaces/solution/projects/shared/src/random.ts": `export function randomFn(str: string) { + console.log(str); +}`, + "/home/src/workspaces/solution/projects/shared/tsconfig.json": `{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist", + }, + "include": ["src/**/*.ts"], +}`, + "/home/src/workspaces/solution/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "projects/server" }, + { "path": "projects/shared" }, + ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "edit logging file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/projects/shared/src/logging.ts", `export function log(str: string) { + console.log(str); +}export const x = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete random file", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/solution/projects/shared/src/random.ts") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_roots_when_root_file_is_from_referenced_project_test.go b/internal/execute/tsctests/tests/tsbuild_roots_when_root_file_is_from_referenced_project_test.go new file mode 100644 index 00000000000..775145529af --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_roots_when_root_file_is_from_referenced_project_test.go @@ -0,0 +1,89 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_roots_when_root_file_is_from_referenced_project(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "roots", + SubScenario: "when root file is from referenced project", + CommandLineArgs: []string{"--b", "projects/server", "-v", "--traceResolution", "--explainFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/projects/server/src/server.ts": `import { MyClass } from ':shared/myClass.js'; +console.log('Hello, world!');`, + "/home/src/workspaces/solution/projects/server/tsconfig.json": `{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "rootDir": "..", + "outDir": "./dist", + "paths": { + ":shared/*": ["./src/../../shared/src/*"], + }, + }, + "include": [ "src/**/*.ts", "../shared/src/**/*.ts" ], + "references": [ + { "path": "../shared" }, + ], +}`, + "/home/src/workspaces/solution/projects/shared/src/logging.ts": `export function log(str: string) { + console.log(str); +}`, + "/home/src/workspaces/solution/projects/shared/src/myClass.ts": "export class MyClass { }", + "/home/src/workspaces/solution/projects/shared/src/random.ts": `export function randomFn(str: string) { + console.log(str); +}`, + "/home/src/workspaces/solution/projects/shared/tsconfig.json": `{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist", + }, + "include": ["src/**/*.ts"], +}`, + "/home/src/workspaces/solution/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "projects/server" }, + { "path": "projects/shared" }, + ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "edit logging file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/projects/shared/src/logging.ts", `export function log(str: string) { + console.log(str); +}export const x = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete random file", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/solution/projects/shared/src/random.ts") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_roots_when_two_root_files_are_consecutive_test.go b/internal/execute/tsctests/tests/tsbuild_roots_when_two_root_files_are_consecutive_test.go new file mode 100644 index 00000000000..1e2bc422093 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_roots_when_two_root_files_are_consecutive_test.go @@ -0,0 +1,36 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_roots_when_two_root_files_are_consecutive(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "roots", + SubScenario: "when two root files are consecutive", + CommandLineArgs: []string{"--b", "-v"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/file1.ts": "export const x = \"hello\";", + "/home/src/workspaces/project/file2.ts": "export const y = \"world\";", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "include": ["*.ts"], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete file1", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/file1.d.ts") + sys.Remove("/home/src/workspaces/project/file1.js") + sys.Remove("/home/src/workspaces/project/file1.ts") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_always_builds_under_with_force_option_test.go b/internal/execute/tsctests/tests/tsbuild_sample_always_builds_under_with_force_option_test.go new file mode 100644 index 00000000000..546ef3a1fc5 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_always_builds_under_with_force_option_test.go @@ -0,0 +1,76 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_always_builds_under_with_force_option(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "always builds under with force option", + CommandLineArgs: []string{"--b", "tests", "--force"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_building_project_in_not_build_order_doesnt_throw_error_test.go b/internal/execute/tsctests/tests/tsbuild_sample_building_project_in_not_build_order_doesnt_throw_error_test.go new file mode 100644 index 00000000000..73d5fe2cf2b --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_building_project_in_not_build_order_doesnt_throw_error_test.go @@ -0,0 +1,72 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_building_project_in_not_build_order_doesnt_throw_error(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "building project in not build order doesnt throw error", + CommandLineArgs: []string{"--b", "logic2/tsconfig.json", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_builds_correctly_when_declarationDir_is_specified_test.go b/internal/execute/tsctests/tests/tsbuild_sample_builds_correctly_when_declarationDir_is_specified_test.go new file mode 100644 index 00000000000..163a840a0fb --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_builds_correctly_when_declarationDir_is_specified_test.go @@ -0,0 +1,72 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_builds_correctly_when_declarationDir_is_specified(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "builds correctly when declarationDir is specified", + CommandLineArgs: []string{"--b", "tests"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "declarationDir": "out/decls", + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_builds_correctly_when_outDir_is_specified_test.go b/internal/execute/tsctests/tests/tsbuild_sample_builds_correctly_when_outDir_is_specified_test.go new file mode 100644 index 00000000000..b3db5254e29 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_builds_correctly_when_outDir_is_specified_test.go @@ -0,0 +1,72 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_builds_correctly_when_outDir_is_specified(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "builds correctly when outDir is specified", + CommandLineArgs: []string{"--b", "tests"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "outDir": "outDir", + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_builds_correctly_when_project_is_not_composite_or_doesnt_have_any_references_test.go b/internal/execute/tsctests/tests/tsbuild_sample_builds_correctly_when_project_is_not_composite_or_doesnt_have_any_references_test.go new file mode 100644 index 00000000000..5039b7c2643 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_builds_correctly_when_project_is_not_composite_or_doesnt_have_any_references_test.go @@ -0,0 +1,72 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_builds_correctly_when_project_is_not_composite_or_doesnt_have_any_references(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "builds correctly when project is not composite or doesnt have any references", + CommandLineArgs: []string{"--b", "core", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_builds_downstream_projects_even_if_upstream_projects_have_errors_test.go b/internal/execute/tsctests/tests/tsbuild_sample_builds_downstream_projects_even_if_upstream_projects_have_errors_test.go new file mode 100644 index 00000000000..cbbf478a596 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_builds_downstream_projects_even_if_upstream_projects_have_errors_test.go @@ -0,0 +1,76 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_builds_downstream_projects_even_if_upstream_projects_have_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "builds downstream projects even if upstream projects have errors", + CommandLineArgs: []string{"--b", "tests", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.muitply(); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_can_detect_when_and_what_to_rebuild_test.go b/internal/execute/tsctests/tests/tsbuild_sample_can_detect_when_and_what_to_rebuild_test.go new file mode 100644 index 00000000000..ada52b4ed9f --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_can_detect_when_and_what_to_rebuild_test.go @@ -0,0 +1,110 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_can_detect_when_and_what_to_rebuild(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "can detect when and what to rebuild", + CommandLineArgs: []string{"--b", "tests", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Only builds the leaf node project", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/tests/index.ts", "const m = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Detects type-only changes in upstream projects", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "WELCOME PLANET"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "rebuilds when tsconfig changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/tests/tsconfig.json", `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, "target": "es2020", + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_cleaning_project_in_not_build_order_doesnt_throw_error_test.go b/internal/execute/tsctests/tests/tsbuild_sample_cleaning_project_in_not_build_order_doesnt_throw_error_test.go new file mode 100644 index 00000000000..e646bee830d --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_cleaning_project_in_not_build_order_doesnt_throw_error_test.go @@ -0,0 +1,72 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_cleaning_project_in_not_build_order_doesnt_throw_error(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "cleaning project in not build order doesnt throw error", + CommandLineArgs: []string{"--b", "logic2", "--clean"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_does_not_write_any_files_in_a_dry_build_test.go b/internal/execute/tsctests/tests/tsbuild_sample_does_not_write_any_files_in_a_dry_build_test.go new file mode 100644 index 00000000000..667549437aa --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_does_not_write_any_files_in_a_dry_build_test.go @@ -0,0 +1,72 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_does_not_write_any_files_in_a_dry_build(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "does not write any files in a dry build", + CommandLineArgs: []string{"--b", "tests", "--dry"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_explainFiles_test.go b/internal/execute/tsctests/tests/tsbuild_sample_explainFiles_test.go new file mode 100644 index 00000000000..436b9bad66f --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_explainFiles_test.go @@ -0,0 +1,97 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_explainFiles(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "explainFiles", + CommandLineArgs: []string{"--b", "tests", "--explainFiles", "--v"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +export class someClass { }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-doesnt-change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +export class someClass { } +class someClass2 { }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_indicates_that_it_would_skip_builds_during_a_dry_build_test.go b/internal/execute/tsctests/tests/tsbuild_sample_indicates_that_it_would_skip_builds_during_a_dry_build_test.go new file mode 100644 index 00000000000..5256a9cc57b --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_indicates_that_it_would_skip_builds_during_a_dry_build_test.go @@ -0,0 +1,77 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_indicates_that_it_would_skip_builds_during_a_dry_build(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "indicates that it would skip builds during a dry build", + CommandLineArgs: []string{"--b", "tests"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "--dry", + CommandLineArgs: []string{"--b", "tests", "--dry"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_listEmittedFiles_test.go b/internal/execute/tsctests/tests/tsbuild_sample_listEmittedFiles_test.go new file mode 100644 index 00000000000..114c44ce59d --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_listEmittedFiles_test.go @@ -0,0 +1,97 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_listEmittedFiles(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "listEmittedFiles", + CommandLineArgs: []string{"--b", "tests", "--listEmittedFiles"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +export class someClass { }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-doesnt-change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +export class someClass { } +class someClass2 { }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_listFiles_test.go b/internal/execute/tsctests/tests/tsbuild_sample_listFiles_test.go new file mode 100644 index 00000000000..a6d85a0a40b --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_listFiles_test.go @@ -0,0 +1,97 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_listFiles(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "listFiles", + CommandLineArgs: []string{"--b", "tests", "--listFiles"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +export class someClass { }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-doesnt-change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +export class someClass { } +class someClass2 { }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_rebuilds_completely_when_version_in_tsbuildinfo_doesnt_match_ts_version_test.go b/internal/execute/tsctests/tests/tsbuild_sample_rebuilds_completely_when_version_in_tsbuildinfo_doesnt_match_ts_version_test.go new file mode 100644 index 00000000000..68bae73bcc1 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_rebuilds_completely_when_version_in_tsbuildinfo_doesnt_match_ts_version_test.go @@ -0,0 +1,81 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_rebuilds_completely_when_version_in_tsbuildinfo_doesnt_match_ts_version(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "rebuilds completely when version in tsbuildinfo doesnt match ts version", + CommandLineArgs: []string{"--b", "tests", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "convert tsbuildInfo version to something that is say to previous version", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/tsconfig.tsbuildinfo", "{\"version\":\"FakeTsPreviousVersion\",\"root\":[[2,4]],\"fileNames\":[\"lib.es2025.full.d.ts\",\"./anotherModule.ts\",\"./index.ts\",\"./some_decl.d.ts\"],\"fileInfos\":[{\"version\":\"8859c12c614ce56ba9a18e58384a198f-/// \\ninterface Boolean {}\\ninterface Function {}\\ninterface CallableFunction {}\\ninterface NewableFunction {}\\ninterface IArguments {}\\ninterface Number { toExponential: any; }\\ninterface Object {}\\ninterface RegExp {}\\ninterface String { charAt: any; }\\ninterface Array { length: number; [n: number]: T; }\\ninterface ReadonlyArray {}\\ninterface SymbolConstructor {\\n (desc?: string | number): symbol;\\n for(name: string): symbol;\\n readonly toStringTag: symbol;\\n}\\ndeclare var Symbol: SymbolConstructor;\\ninterface Symbol {\\n readonly [Symbol.toStringTag]: string;\\n}\\ndeclare const console: { log(msg: any): void; };\",\"affectsGlobalScope\":true,\"impliedNodeFormat\":1},{\"version\":\"19cd44ed7278957051fca663f821c916-export const World = \\\"hello\\\";\",\"signature\":\"5aad0de3e7b08bb6e110c7b97361b89e-export declare const World = \\\"hello\\\";\\n\",\"impliedNodeFormat\":1},{\"version\":\"2753a1085d587a7d57069e1105af24ec-export const someString: string = \\\"HELLO WORLD\\\";\\nexport function leftPad(s: string, n: number) { return s + n; }\\nexport function multiply(a: number, b: number) { return a * b; }\",\"signature\":\"da642d80443e7ccd327091080a82a43c-export declare const someString: string;\\nexport declare function leftPad(s: string, n: number): string;\\nexport declare function multiply(a: number, b: number): number;\\n\",\"impliedNodeFormat\":1},{\"version\":\"6ceab83400a6167be2fb5feab881ded0-declare const dts: any;\",\"affectsGlobalScope\":true,\"impliedNodeFormat\":1}],\"options\":{\"composite\":true,\"declaration\":true,\"declarationMap\":true,\"skipDefaultLibCheck\":true},\"latestChangedDtsFile\":\"./index.d.ts\"}") + sys.WriteFile("/user/username/projects/sample1/logic/tsconfig.tsbuildinfo", "{\"version\":\"FakeTsPreviousVersion\",\"root\":[4],\"fileNames\":[\"lib.es2025.full.d.ts\",\"../core/index.d.ts\",\"../core/anotherModule.d.ts\",\"./index.ts\"],\"fileInfos\":[{\"version\":\"8859c12c614ce56ba9a18e58384a198f-/// \\ninterface Boolean {}\\ninterface Function {}\\ninterface CallableFunction {}\\ninterface NewableFunction {}\\ninterface IArguments {}\\ninterface Number { toExponential: any; }\\ninterface Object {}\\ninterface RegExp {}\\ninterface String { charAt: any; }\\ninterface Array { length: number; [n: number]: T; }\\ninterface ReadonlyArray {}\\ninterface SymbolConstructor {\\n (desc?: string | number): symbol;\\n for(name: string): symbol;\\n readonly toStringTag: symbol;\\n}\\ndeclare var Symbol: SymbolConstructor;\\ninterface Symbol {\\n readonly [Symbol.toStringTag]: string;\\n}\\ndeclare const console: { log(msg: any): void; };\",\"affectsGlobalScope\":true,\"impliedNodeFormat\":1},\"fc70810d80f598d415c6f21c113a400b-export declare const someString: string;\\nexport declare function leftPad(s: string, n: number): string;\\nexport declare function multiply(a: number, b: number): number;\\n//# sourceMappingURL=index.d.ts.map\",\"5ef600f6f6585506cfe942fc161e76c5-export declare const World = \\\"hello\\\";\\n//# sourceMappingURL=anotherModule.d.ts.map\",{\"version\":\"590556060bc156a64834010df8cda255-import * as c from '../core/index';\\nexport function getSecondsInDay() {\\n return c.multiply(10, 15);\\n}\\nimport * as mod from '../core/anotherModule';\\nexport const m = mod;\",\"signature\":\"487f7216384ec40e22ff7dc40c01be4b-export declare function getSecondsInDay(): number;\\nimport * as mod from '../core/anotherModule';\\nexport declare const m: typeof mod;\\n\",\"impliedNodeFormat\":1}],\"fileIdsList\":[[2,3]],\"options\":{\"composite\":true,\"declaration\":true,\"skipDefaultLibCheck\":true,\"sourceMap\":true},\"referencedMap\":[[4,1]],\"latestChangedDtsFile\":\"./index.d.ts\"}") + sys.WriteFile("/user/username/projects/sample1/tests/tsconfig.tsbuildinfo", "{\"version\":\"FakeTsPreviousVersion\",\"root\":[5],\"fileNames\":[\"lib.es2025.full.d.ts\",\"../core/index.d.ts\",\"../core/anotherModule.d.ts\",\"../logic/index.d.ts\",\"./index.ts\"],\"fileInfos\":[{\"version\":\"8859c12c614ce56ba9a18e58384a198f-/// \\ninterface Boolean {}\\ninterface Function {}\\ninterface CallableFunction {}\\ninterface NewableFunction {}\\ninterface IArguments {}\\ninterface Number { toExponential: any; }\\ninterface Object {}\\ninterface RegExp {}\\ninterface String { charAt: any; }\\ninterface Array { length: number; [n: number]: T; }\\ninterface ReadonlyArray {}\\ninterface SymbolConstructor {\\n (desc?: string | number): symbol;\\n for(name: string): symbol;\\n readonly toStringTag: symbol;\\n}\\ndeclare var Symbol: SymbolConstructor;\\ninterface Symbol {\\n readonly [Symbol.toStringTag]: string;\\n}\\ndeclare const console: { log(msg: any): void; };\",\"affectsGlobalScope\":true,\"impliedNodeFormat\":1},\"fc70810d80f598d415c6f21c113a400b-export declare const someString: string;\\nexport declare function leftPad(s: string, n: number): string;\\nexport declare function multiply(a: number, b: number): number;\\n//# sourceMappingURL=index.d.ts.map\",\"5ef600f6f6585506cfe942fc161e76c5-export declare const World = \\\"hello\\\";\\n//# sourceMappingURL=anotherModule.d.ts.map\",\"487f7216384ec40e22ff7dc40c01be4b-export declare function getSecondsInDay(): number;\\nimport * as mod from '../core/anotherModule';\\nexport declare const m: typeof mod;\\n\",{\"version\":\"7fa4162f733e6b9e7f7d9d9410e62f61-import * as c from '../core/index';\\nimport * as logic from '../logic/index';\\n\\nc.leftPad(\\\"\\\", 10);\\nlogic.getSecondsInDay();\\n\\nimport * as mod from '../core/anotherModule';\\nexport const m = mod;\",\"signature\":\"4b3c99afe665034856f74c660f74d6fd-import * as mod from '../core/anotherModule';\\nexport declare const m: typeof mod;\\n\",\"impliedNodeFormat\":1}],\"fileIdsList\":[[3],[2,3,4]],\"options\":{\"composite\":true,\"declaration\":true,\"skipDefaultLibCheck\":true},\"referencedMap\":[[4,1],[5,2]],\"latestChangedDtsFile\":\"./index.d.ts\"}") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_rebuilds_from_start_if_force_option_is_set_test.go b/internal/execute/tsctests/tests/tsbuild_sample_rebuilds_from_start_if_force_option_is_set_test.go new file mode 100644 index 00000000000..265b3e33599 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_rebuilds_from_start_if_force_option_is_set_test.go @@ -0,0 +1,77 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_rebuilds_from_start_if_force_option_is_set(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "rebuilds from start if force option is set", + CommandLineArgs: []string{"--b", "tests"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "--force build", + CommandLineArgs: []string{"--b", "tests", "--verbose", "--force"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_rebuilds_when_extended_config_file_changes_test.go b/internal/execute/tsctests/tests/tsbuild_sample_rebuilds_when_extended_config_file_changes_test.go new file mode 100644 index 00000000000..0e3c149ac8d --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_rebuilds_when_extended_config_file_changes_test.go @@ -0,0 +1,86 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_rebuilds_when_extended_config_file_changes(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "rebuilds when extended config file changes", + CommandLineArgs: []string{"--b", "tests", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.base.json": `{ + "compilerOptions": { + "target": "es5" + } +}`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "extends": "./tsconfig.base.json", "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "change extended file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/tests/tsconfig.base.json", `{ + "compilerOptions": { } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_removes_all_files_it_built_test.go b/internal/execute/tsctests/tests/tsbuild_sample_removes_all_files_it_built_test.go new file mode 100644 index 00000000000..95b5327f82f --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_removes_all_files_it_built_test.go @@ -0,0 +1,82 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_removes_all_files_it_built(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "removes all files it built", + CommandLineArgs: []string{"--b", "tests"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "removes all files it built", + CommandLineArgs: []string{"--b", "tests", "--clean"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change --clean", + CommandLineArgs: []string{"--b", "tests", "--clean"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_reports_error_if_input_file_is_missing_test.go b/internal/execute/tsctests/tests/tsbuild_sample_reports_error_if_input_file_is_missing_test.go new file mode 100644 index 00000000000..9a7e2b866b3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_reports_error_if_input_file_is_missing_test.go @@ -0,0 +1,67 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_reports_error_if_input_file_is_missing(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "reports error if input file is missing", + CommandLineArgs: []string{"--b", "tests", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "files": ["anotherModule.ts", "index.ts", "some_decl.d.ts"], +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_reports_error_if_input_file_is_missing_with_force_test.go b/internal/execute/tsctests/tests/tsbuild_sample_reports_error_if_input_file_is_missing_with_force_test.go new file mode 100644 index 00000000000..84657ec0493 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_reports_error_if_input_file_is_missing_with_force_test.go @@ -0,0 +1,67 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_reports_error_if_input_file_is_missing_with_force(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "reports error if input file is missing with force", + CommandLineArgs: []string{"--b", "tests", "--verbose", "--force"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "files": ["anotherModule.ts", "index.ts", "some_decl.d.ts"], +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_sample_test.go b/internal/execute/tsctests/tests/tsbuild_sample_sample_test.go new file mode 100644 index 00000000000..a1239561e9a --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_sample_test.go @@ -0,0 +1,119 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_sample(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "sample", + CommandLineArgs: []string{"--b", "tests", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +export class someClass { }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-doesnt-change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; } +export class someClass { } +class someClass2 { }`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "when logic config changes declaration dir", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/logic/tsconfig.json", `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationDir": "decls", + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_test.go b/internal/execute/tsctests/tests/tsbuild_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_test.go new file mode 100644 index 00000000000..52baf886b7a --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_test.go @@ -0,0 +1,85 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "skips builds downstream projects if upstream projects have errors with stopBuildOnErrors", + CommandLineArgs: []string{"--b", "tests", "--verbose", "--stopBuildOnErrors"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }multiply();`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_when_test_does_not_reference_core_test.go b/internal/execute/tsctests/tests/tsbuild_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_when_test_does_not_reference_core_test.go new file mode 100644 index 00000000000..5417cc58172 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_when_test_does_not_reference_core_test.go @@ -0,0 +1,84 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_skips_builds_downstream_projects_if_upstream_projects_have_errors_with_stopBuildOnErrors_when_test_does_not_reference_core(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "skips builds downstream projects if upstream projects have errors with stopBuildOnErrors when test does not reference core", + CommandLineArgs: []string{"--b", "tests", "--verbose", "--stopBuildOnErrors"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }multiply();`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_tsbuildinfo_has_error_test.go b/internal/execute/tsctests/tests/tsbuild_sample_tsbuildinfo_has_error_test.go new file mode 100644 index 00000000000..51b68025bd9 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_tsbuildinfo_has_error_test.go @@ -0,0 +1,31 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_tsbuildinfo_has_error(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "tsbuildinfo has error", + CommandLineArgs: []string{"--b", "-i", "-v"}, + Files: tsctests.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", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "tsbuildinfo written has error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.tsbuildinfo", "Some random string{\"version\":\"FakeTSVersion\",\"root\":[2],\"fileNames\":[\"lib.es2025.full.d.ts\",\"./main.ts\"],\"fileInfos\":[{\"version\":\"8859c12c614ce56ba9a18e58384a198f-/// \\ninterface Boolean {}\\ninterface Function {}\\ninterface CallableFunction {}\\ninterface NewableFunction {}\\ninterface IArguments {}\\ninterface Number { toExponential: any; }\\ninterface Object {}\\ninterface RegExp {}\\ninterface String { charAt: any; }\\ninterface Array { length: number; [n: number]: T; }\\ninterface ReadonlyArray {}\\ninterface SymbolConstructor {\\n (desc?: string | number): symbol;\\n for(name: string): symbol;\\n readonly toStringTag: symbol;\\n}\\ndeclare var Symbol: SymbolConstructor;\\ninterface Symbol {\\n readonly [Symbol.toStringTag]: string;\\n}\\ndeclare const console: { log(msg: any): void; };\",\"affectsGlobalScope\":true,\"impliedNodeFormat\":1},\"28e8748a7acd58f4f59388926e914f86-export const x = 10;\"]}") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_when_declarationMap_changes_test.go b/internal/execute/tsctests/tests/tsbuild_sample_when_declarationMap_changes_test.go new file mode 100644 index 00000000000..2659ded998a --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_when_declarationMap_changes_test.go @@ -0,0 +1,100 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_when_declarationMap_changes(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "when declarationMap changes", + CommandLineArgs: []string{"--b", "tests", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Disable declarationMap", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/tsconfig.json", `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": false, + "skipDefaultLibCheck": true, + }, +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Enable declarationMap", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/tsconfig.json", `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_when_declaration_option_changes_test.go b/internal/execute/tsctests/tests/tsbuild_sample_when_declaration_option_changes_test.go new file mode 100644 index 00000000000..c81127fb242 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_when_declaration_option_changes_test.go @@ -0,0 +1,82 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_when_declaration_option_changes(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "when declaration option changes", + CommandLineArgs: []string{"--b", "core", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, "declaration": true, + "skipDefaultLibCheck": true, + }, +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_when_esModuleInterop_option_changes_test.go b/internal/execute/tsctests/tests/tsbuild_sample_when_esModuleInterop_option_changes_test.go new file mode 100644 index 00000000000..143229d3850 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_when_esModuleInterop_option_changes_test.go @@ -0,0 +1,92 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_when_esModuleInterop_option_changes(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "when esModuleInterop option changes", + CommandLineArgs: []string{"--b", "tests", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + "esModuleInterop": false, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/tests/tsconfig.json", `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + "esModuleInterop": true, + }, +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_when_input_file_text_does_not_change_but_its_modified_time_changes_test.go b/internal/execute/tsctests/tests/tsbuild_sample_when_input_file_text_does_not_change_but_its_modified_time_changes_test.go new file mode 100644 index 00000000000..700a9787988 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_when_input_file_text_does_not_change_but_its_modified_time_changes_test.go @@ -0,0 +1,81 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_when_input_file_text_does_not_change_but_its_modified_time_changes(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "when input file text does not change but its modified time changes", + CommandLineArgs: []string{"--b", "tests", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "upstream project changes without changing file text", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/index.ts", `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_when_logic_specifies_tsBuildInfoFile_test.go b/internal/execute/tsctests/tests/tsbuild_sample_when_logic_specifies_tsBuildInfoFile_test.go new file mode 100644 index 00000000000..d517ec412a3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_when_logic_specifies_tsBuildInfoFile_test.go @@ -0,0 +1,73 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_when_logic_specifies_tsBuildInfoFile(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "when logic specifies tsBuildInfoFile", + CommandLineArgs: []string{"--b", "tests", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "tsBuildInfoFile": "ownFile.tsbuildinfo", + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_when_module_option_changes_test.go b/internal/execute/tsctests/tests/tsbuild_sample_when_module_option_changes_test.go new file mode 100644 index 00000000000..07e77876a37 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_when_module_option_changes_test.go @@ -0,0 +1,82 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_when_module_option_changes(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "when module option changes", + CommandLineArgs: []string{"--b", "core", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "module": "node18", + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "module": "nodenext", + }, +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_sample_when_target_option_changes_test.go b/internal/execute/tsctests/tests/tsbuild_sample_when_target_option_changes_test.go new file mode 100644 index 00000000000..747d63c3ea9 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_sample_when_target_option_changes_test.go @@ -0,0 +1,90 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_sample_when_target_option_changes(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "sample", + SubScenario: "when target option changes", + CommandLineArgs: []string{"--b", "core", "--verbose"}, + Cwd: "/user/username/projects/sample1", + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.d.ts": `/// +/// `, + "/home/src/tslibs/TS/Lib/lib.esnext.full.d.ts": `/// +/// `, + "/user/username/projects/sample1/core/anotherModule.ts": "export const World = \"hello\";", + "/user/username/projects/sample1/core/index.ts": `export const someString: string = "HELLO WORLD"; +export function leftPad(s: string, n: number) { return s + n; } +export function multiply(a: number, b: number) { return a * b; }`, + "/user/username/projects/sample1/core/some_decl.d.ts": "declare const dts: any;", + "/user/username/projects/sample1/core/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "listFiles": true, + "listEmittedFiles": true, + "target": "esnext", + }, +}`, + "/user/username/projects/sample1/logic/index.ts": `import * as c from '../core/index'; +export function getSecondsInDay() { + return c.multiply(10, 15); +} +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/logic/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "sourceMap": true, + "skipDefaultLibCheck": true, + }, + "references": [ + { "path": "../core" }, + ], +}`, + "/user/username/projects/sample1/tests/index.ts": `import * as c from '../core/index'; +import * as logic from '../logic/index'; + +c.leftPad("", 10); +logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod;`, + "/user/username/projects/sample1/tests/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + { "path": "../logic" }, + ], + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental-declaration-changes", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/sample1/core/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "listFiles": true, + "listEmittedFiles": true, + "target": "es5", + }, +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_solution_does_not_have_empty_files_diagnostic_when_files_is_empty_and_references_are_provided_test.go b/internal/execute/tsctests/tests/tsbuild_solution_does_not_have_empty_files_diagnostic_when_files_is_empty_and_references_are_provided_test.go new file mode 100644 index 00000000000..ae454e5016b --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_solution_does_not_have_empty_files_diagnostic_when_files_is_empty_and_references_are_provided_test.go @@ -0,0 +1,43 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_solution_does_not_have_empty_files_diagnostic_when_files_is_empty_and_references_are_provided(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "solution", + SubScenario: "does not have empty files diagnostic when files is empty and references are provided", + CommandLineArgs: []string{"--b", "with-references"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/core/index.ts": "export function multiply(a: number, b: number) { return a * b; }", + "/home/src/workspaces/solution/core/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "skipDefaultLibCheck": true, + }, +}`, + "/home/src/workspaces/solution/with-references/tsconfig.json": `{ + "references": [ + { "path": "../core" }, + ], + "files": [], + "compilerOptions": { + "composite": true, + "declaration": true, + "forceConsistentCasingInFileNames": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_solution_has_empty_files_diagnostic_when_files_is_empty_and_no_references_are_provided_test.go b/internal/execute/tsctests/tests/tsbuild_solution_has_empty_files_diagnostic_when_files_is_empty_and_no_references_are_provided_test.go new file mode 100644 index 00000000000..a63a6fb1943 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_solution_has_empty_files_diagnostic_when_files_is_empty_and_no_references_are_provided_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_solution_has_empty_files_diagnostic_when_files_is_empty_and_no_references_are_provided(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "solution", + SubScenario: "has empty files diagnostic when files is empty and no references are provided", + CommandLineArgs: []string{"--b", "no-references"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/no-references/tsconfig.json": `{ + "references": [], + "files": [], + "compilerOptions": { + "composite": true, + "declaration": true, + "forceConsistentCasingInFileNames": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_solution_verify_that_subsequent_builds_after_initial_build_doesnt_build_anything_test.go b/internal/execute/tsctests/tests/tsbuild_solution_verify_that_subsequent_builds_after_initial_build_doesnt_build_anything_test.go new file mode 100644 index 00000000000..eb616813368 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_solution_verify_that_subsequent_builds_after_initial_build_doesnt_build_anything_test.go @@ -0,0 +1,70 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_solution_verify_that_subsequent_builds_after_initial_build_doesnt_build_anything(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "solution", + SubScenario: "verify that subsequent builds after initial build doesnt build anything", + CommandLineArgs: []string{"--b", "--v"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/src/folder/index.ts": "export const x = 10;", + "/home/src/workspaces/solution/src/folder/tsconfig.json": `{ + "files": ["index.ts"], + "compilerOptions": { + "composite": true + } +}`, + "/home/src/workspaces/solution/src/folder2/index.ts": "export const x = 10;", + "/home/src/workspaces/solution/src/folder2/tsconfig.json": `{ + "files": ["index.ts"], + "compilerOptions": { + "composite": true + } +}`, + "/home/src/workspaces/solution/src/tsconfig.json": ` { + "files": [], + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "./folder" }, + { "path": "./folder2" }, + ] +}`, + "/home/src/workspaces/solution/tests/index.ts": "export const x = 10;", + "/home/src/workspaces/solution/tests/tsconfig.json": `{ + "files": ["index.ts"], + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "../src" } + ] +}`, + "/home/src/workspaces/solution/tsconfig.json": `{ + "files": [], + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "./src" }, + { "path": "./tests" } + ] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_solution_when_solution_is_referenced_indirectly_test.go b/internal/execute/tsctests/tests/tsbuild_solution_when_solution_is_referenced_indirectly_test.go new file mode 100644 index 00000000000..0244897da9c --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_solution_when_solution_is_referenced_indirectly_test.go @@ -0,0 +1,51 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_solution_when_solution_is_referenced_indirectly(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "solution", + SubScenario: "when solution is referenced indirectly", + CommandLineArgs: []string{"--b", "project4", "--verbose", "--explainFiles"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project1/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [] +}`, + "/home/src/workspaces/solution/project2/src/b.ts": "export const b = 10;", + "/home/src/workspaces/solution/project2/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [] +}`, + "/home/src/workspaces/solution/project3/src/c.ts": "export const c = 10;", + "/home/src/workspaces/solution/project3/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [ + { "path": "../project1" }, + { "path": "../project2" } + ] +}`, + "/home/src/workspaces/solution/project4/src/d.ts": "export const d = 10;", + "/home/src/workspaces/solution/project4/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "references": [{ "path": "../project3" }] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "modify project3 file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/solution/project3/src/c.ts", "export const cc = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_transitiveReferences_builds_correctly_test.go b/internal/execute/tsctests/tests/tsbuild_transitiveReferences_builds_correctly_test.go new file mode 100644 index 00000000000..614893dbbb5 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_transitiveReferences_builds_correctly_test.go @@ -0,0 +1,56 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_transitiveReferences_builds_correctly(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "transitiveReferences", + SubScenario: "builds correctly", + CommandLineArgs: []string{"--b", "tsconfig.c.json", "--listFiles"}, + Cwd: "/user/username/projects/transitiveReferences", + Files: tsctests.FileMap{ + "/user/username/projects/transitiveReferences/a.ts": "export class A {}", + "/user/username/projects/transitiveReferences/b.ts": `import {A} from '@ref/a'; +export const b = new A();`, + "/user/username/projects/transitiveReferences/c.ts": `import {b} from './b'; +import {X} from "@ref/a"; +b; +X;`, + "/user/username/projects/transitiveReferences/refs/a.d.ts": `export class X {} +export class A {}`, + "/user/username/projects/transitiveReferences/tsconfig.a.json": `{ + "files": ["a.ts"], + "compilerOptions": { + "composite": true, + }, +}`, + "/user/username/projects/transitiveReferences/tsconfig.b.json": `{ + "files": ["b.ts"], + "compilerOptions": { + "composite": true, + "paths": { + "@ref/*": ["./*"], + }, + }, + "references": [{ "path": "tsconfig.a.json" }], +}`, + "/user/username/projects/transitiveReferences/tsconfig.c.json": `{ + "files": ["c.ts"], + "compilerOptions": { + "paths": { + "@ref/*": ["./refs/*"], + }, + }, + "references": [{ "path": "tsconfig.b.json" }], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsbuild_transitiveReferences_reports_error_about_module_not_found_with_node_resolution_with_external_module_name_test.go b/internal/execute/tsctests/tests/tsbuild_transitiveReferences_reports_error_about_module_not_found_with_node_resolution_with_external_module_name_test.go new file mode 100644 index 00000000000..d68411eddf8 --- /dev/null +++ b/internal/execute/tsctests/tests/tsbuild_transitiveReferences_reports_error_about_module_not_found_with_node_resolution_with_external_module_name_test.go @@ -0,0 +1,54 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsbuild_transitiveReferences_reports_error_about_module_not_found_with_node_resolution_with_external_module_name(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "transitiveReferences", + SubScenario: "reports error about module not found with node resolution with external module name", + CommandLineArgs: []string{"--b", "tsconfig.c.json", "--listFiles"}, + Cwd: "/user/username/projects/transitiveReferences", + Files: tsctests.FileMap{ + "/user/username/projects/transitiveReferences/a.ts": "export class A {}", + "/user/username/projects/transitiveReferences/b.ts": `import {A} from 'a'; +export const b = new A();`, + "/user/username/projects/transitiveReferences/c.ts": `import {b} from './b'; +import {X} from "@ref/a"; +b; +X;`, + "/user/username/projects/transitiveReferences/refs/a.d.ts": `export class X {} +export class A {}`, + "/user/username/projects/transitiveReferences/tsconfig.a.json": `{ + "files": ["a.ts"], + "compilerOptions": { + "composite": true, + }, +}`, + "/user/username/projects/transitiveReferences/tsconfig.b.json": `{ + "files": ["b.ts"], + "compilerOptions": { + "composite": true, + "module": "nodenext", + }, + "references": [{ "path": "tsconfig.a.json" }], +}`, + "/user/username/projects/transitiveReferences/tsconfig.c.json": `{ + "files": ["c.ts"], + "compilerOptions": { + "paths": { + "@ref/*": ["./refs/*"], + }, + }, + "references": [{ "path": "tsconfig.b.json" }], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_at_types_package_installed_later_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_at_types_package_installed_later_test.go new file mode 100644 index 00000000000..8e7e647e90e --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_at_types_package_installed_later_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_at_types_package_installed_later(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects at-types package installed later", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "import * as lib from \"untyped-lib\";", + "/home/src/workspaces/project/node_modules/untyped-lib/index.js": "module.exports = {};", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "install @types for the library", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/node_modules/@types/untyped-lib/index.d.ts", "declare module \"untyped-lib\" { export const value: string; }") + sys.WriteFile("/home/src/workspaces/project/node_modules/@types/untyped-lib/package.json", "{\"name\": \"@types/untyped-lib\", \"types\": \"index.d.ts\"}") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_change_in_symlinked_file_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_change_in_symlinked_file_test.go new file mode 100644 index 00000000000..7167e3c6ae4 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_change_in_symlinked_file_test.go @@ -0,0 +1,33 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTscWatch_commandLineWatch_watch_detects_change_in_symlinked_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects change in symlinked file", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "import { shared } from \"./link\";", + "/home/src/workspaces/project/link.ts": vfstest.Symlink("/home/src/workspaces/shared/index.ts"), + "/home/src/workspaces/project/tsconfig.json": "{}", + "/home/src/workspaces/shared/index.ts": "export const shared = \"v1\";", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "modify symlink target", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/shared/index.ts", "export const shared = \"v2\";") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_added_in_multiple_new_subdirectories_simultaneously_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_added_in_multiple_new_subdirectories_simultaneously_test.go new file mode 100644 index 00000000000..101a23a737d --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_added_in_multiple_new_subdirectories_simultaneously_test.go @@ -0,0 +1,34 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_file_added_in_multiple_new_subdirectories_simultaneously(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects file added in multiple new subdirectories simultaneously", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/a.ts": "export const a = 1;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": {}, + "include": ["src/**/*.ts"] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "create multiple new subdirs with files", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/models/user.ts", "export interface User { name: string; }") + sys.WriteFile("/home/src/workspaces/project/src/utils/format.ts", "export function format(s: string): string { return s.trim(); }") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_added_in_new_nested_subdirectory_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_added_in_new_nested_subdirectory_test.go new file mode 100644 index 00000000000..ca5151db8f4 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_added_in_new_nested_subdirectory_test.go @@ -0,0 +1,33 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_file_added_in_new_nested_subdirectory(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects file added in new nested subdirectory", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/a.ts": "export const a = 1;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": {}, + "include": ["src/**/*.ts"] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "create nested dir with ts file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/deep/nested/util.ts", "export const util = \"nested\";") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_added_to_previously_non_existent_include_path_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_added_to_previously_non_existent_include_path_test.go new file mode 100644 index 00000000000..8d6fab199c9 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_added_to_previously_non_existent_include_path_test.go @@ -0,0 +1,33 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_file_added_to_previously_non_existent_include_path(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects file added to previously non-existent include path", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "const x = 1;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": {}, + "include": ["index.ts", "src/**/*.ts"] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "create src dir with ts file matching include", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/helper.ts", "export const helper = \"added\";") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_deleted_and_new_file_added_simultaneously_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_deleted_and_new_file_added_simultaneously_test.go new file mode 100644 index 00000000000..8386ee744a1 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_deleted_and_new_file_added_simultaneously_test.go @@ -0,0 +1,33 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_file_deleted_and_new_file_added_simultaneously(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects file deleted and new file added simultaneously", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "import { b } from \"./b\";", + "/home/src/workspaces/project/b.ts": "export const b = 1;", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete b.ts and create c.ts with updated import", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/b.ts") + sys.WriteFile("/home/src/workspaces/project/a.ts", "import { c } from \"./c\";") + sys.WriteFile("/home/src/workspaces/project/c.ts", "export const c = 2;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_renamed_and_renamed_back_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_renamed_and_renamed_back_test.go new file mode 100644 index 00000000000..196ad8dc550 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_file_renamed_and_renamed_back_test.go @@ -0,0 +1,41 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_file_renamed_and_renamed_back(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects file renamed and renamed back", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/helper.ts": "export const helper = 1;", + "/home/src/workspaces/project/index.ts": "import { helper } from \"./helper\";", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "rename helper to helper2", + ExpectedDiff: "incremental resolves to .js output from prior build while clean build cannot find module", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/helper.ts") + sys.WriteFile("/home/src/workspaces/project/helper2.ts", "export const helper = 1;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "rename back to helper", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/helper2.ts") + sys.WriteFile("/home/src/workspaces/project/helper.ts", "export const helper = 1;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_import_path_restructured_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_import_path_restructured_test.go new file mode 100644 index 00000000000..8035fb3752a --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_import_path_restructured_test.go @@ -0,0 +1,33 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_import_path_restructured(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects import path restructured", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "import { util } from \"./lib/util\";", + "/home/src/workspaces/project/lib/util.ts": "export const util = \"v1\";", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "move file to new path and update import", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/lib/util.ts") + sys.WriteFile("/home/src/workspaces/project/index.ts", "import { util } from \"./src/util\";") + sys.WriteFile("/home/src/workspaces/project/src/util.ts", "export const util = \"v2\";") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_imported_directory_removed_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_imported_directory_removed_test.go new file mode 100644 index 00000000000..17f320e57a8 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_imported_directory_removed_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_imported_directory_removed(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects imported directory removed", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "import { util } from \"./lib/util\";", + "/home/src/workspaces/project/lib/util.ts": "export const util = \"hello\";", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "remove directory with imported file", + ExpectedDiff: "incremental resolves to .js output from prior build (TS7016) while clean build cannot find module at all (TS2307)", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/lib/util.ts") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_imported_file_added_in_new_directory_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_imported_file_added_in_new_directory_test.go new file mode 100644 index 00000000000..e916072e82c --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_imported_file_added_in_new_directory_test.go @@ -0,0 +1,30 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_imported_file_added_in_new_directory(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects imported file added in new directory", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "import { util } from \"./lib/util\";", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "create directory and imported file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/lib/util.ts", "export const util = \"hello\";") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_module_going_missing_then_coming_back_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_module_going_missing_then_coming_back_test.go new file mode 100644 index 00000000000..8e3c59dcc5b --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_module_going_missing_then_coming_back_test.go @@ -0,0 +1,39 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_module_going_missing_then_coming_back(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects module going missing then coming back", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "import { util } from \"./util\";", + "/home/src/workspaces/project/tsconfig.json": "{}", + "/home/src/workspaces/project/util.ts": "export const util = \"v1\";", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete util module", + ExpectedDiff: "incremental resolves to .js output from prior build while clean build cannot find module", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/util.ts") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "recreate util module with new content", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/util.ts", "export const util = \"v2\";") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_nested_subdirectory_removed_and_recreated_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_nested_subdirectory_removed_and_recreated_test.go new file mode 100644 index 00000000000..41f1ad2a22f --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_nested_subdirectory_removed_and_recreated_test.go @@ -0,0 +1,41 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_nested_subdirectory_removed_and_recreated(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects nested subdirectory removed and recreated", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/lib/helper.ts": "export const helper = \"v1\";", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": {}, + "include": ["src/**/*.ts"] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "remove nested dir", + ExpectedDiff: "incremental has prior state and does not report no-inputs error", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/src/lib/helper.ts") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "recreate nested dir with new content", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/lib/helper.ts", "export const helper = \"v2\";") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_new_file_in_existing_include_directory_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_new_file_in_existing_include_directory_test.go new file mode 100644 index 00000000000..f2b3fffe6a1 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_new_file_in_existing_include_directory_test.go @@ -0,0 +1,33 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_new_file_in_existing_include_directory(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects new file in existing include directory", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/a.ts": "export const a = 1;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": {}, + "include": ["src/**/*.ts"] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "add new file to existing src directory", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/b.ts", "export const b = 2;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_new_file_resolving_failed_import_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_new_file_resolving_failed_import_test.go new file mode 100644 index 00000000000..fe5936fd036 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_new_file_resolving_failed_import_test.go @@ -0,0 +1,30 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_new_file_resolving_failed_import(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects new file resolving failed import", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "import { b } from \"./b\";", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "create missing file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/b.ts", "export const b = 1;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_node_modules_package_added_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_node_modules_package_added_test.go new file mode 100644 index 00000000000..bdec278d56e --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_node_modules_package_added_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_node_modules_package_added(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects node modules package added", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "import { lib } from \"mylib\";", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "install package in node_modules", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/node_modules/mylib/index.d.ts", "export declare const lib: string;") + sys.WriteFile("/home/src/workspaces/project/node_modules/mylib/index.js", "exports.lib = \"hello\";") + sys.WriteFile("/home/src/workspaces/project/node_modules/mylib/package.json", "{\"name\": \"mylib\", \"main\": \"index.js\", \"types\": \"index.d.ts\"}") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_node_modules_package_removed_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_node_modules_package_removed_test.go new file mode 100644 index 00000000000..fe0a42c3332 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_node_modules_package_removed_test.go @@ -0,0 +1,35 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_node_modules_package_removed(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects node modules package removed", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "import { lib } from \"mylib\";", + "/home/src/workspaces/project/node_modules/mylib/index.d.ts": "export declare const lib: string;", + "/home/src/workspaces/project/node_modules/mylib/index.js": "exports.lib = \"hello\";", + "/home/src/workspaces/project/node_modules/mylib/package.json": "{\"name\": \"mylib\", \"main\": \"index.js\", \"types\": \"index.d.ts\"}", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "remove node_modules package", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/node_modules/mylib/index.d.ts") + sys.Remove("/home/src/workspaces/project/node_modules/mylib/index.js") + sys.Remove("/home/src/workspaces/project/node_modules/mylib/package.json") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_package_json_types_field_edited_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_package_json_types_field_edited_test.go new file mode 100644 index 00000000000..cbba3147b5d --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_package_json_types_field_edited_test.go @@ -0,0 +1,33 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_package_json_types_field_edited(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects package json types field edited", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "import { lib } from \"mylib\";", + "/home/src/workspaces/project/node_modules/mylib/new.d.ts": "export declare const lib: string;", + "/home/src/workspaces/project/node_modules/mylib/old.d.ts": "export declare const lib: number;", + "/home/src/workspaces/project/node_modules/mylib/package.json": "{\"name\": \"mylib\", \"types\": \"old.d.ts\"}", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "change package.json types field", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/node_modules/mylib/package.json", "{\"name\": \"mylib\", \"types\": \"new.d.ts\"}") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_scoped_package_installed_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_scoped_package_installed_test.go new file mode 100644 index 00000000000..a338e039274 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_detects_scoped_package_installed_test.go @@ -0,0 +1,31 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_detects_scoped_package_installed(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch detects scoped package installed", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "import { lib } from \"@scope/mylib\";", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "install scoped package", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/node_modules/@scope/mylib/index.d.ts", "export declare const lib: string;") + sys.WriteFile("/home/src/workspaces/project/node_modules/@scope/mylib/package.json", "{\"name\": \"@scope/mylib\", \"types\": \"index.d.ts\"}") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_handles_file_rapidly_recreated_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_handles_file_rapidly_recreated_test.go new file mode 100644 index 00000000000..b801e817eae --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_handles_file_rapidly_recreated_test.go @@ -0,0 +1,31 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_handles_file_rapidly_recreated(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch handles file rapidly recreated", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/data.ts": "export const val = \"original\";", + "/home/src/workspaces/project/index.ts": "import { val } from \"./data\";", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete and immediately recreate with new content", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/data.ts", "export const val = \"recreated\";") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_handles_tsconfig_deleted_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_handles_tsconfig_deleted_test.go new file mode 100644 index 00000000000..6958392996b --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_handles_tsconfig_deleted_test.go @@ -0,0 +1,31 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_handles_tsconfig_deleted(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch handles tsconfig deleted", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "const x = 1;", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete tsconfig", + ExpectedDiff: "incremental reports config read error while clean build without tsconfig prints usage help", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/tsconfig.json") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_handles_tsconfig_with_extends_base_modified_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_handles_tsconfig_with_extends_base_modified_test.go new file mode 100644 index 00000000000..e9e145b3713 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_handles_tsconfig_with_extends_base_modified_test.go @@ -0,0 +1,37 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_handles_tsconfig_with_extends_base_modified(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch handles tsconfig with extends base modified", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/base.json": `{ + "compilerOptions": { "strict": false } +}`, + "/home/src/workspaces/project/index.ts": "const x = null; const y: string = x;", + "/home/src/workspaces/project/tsconfig.json": `{ + "extends": "./base.json" +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "modify base config to enable strict", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/base.json", `{ + "compilerOptions": { "strict": true } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_file_is_modified_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_file_is_modified_test.go new file mode 100644 index 00000000000..06b729f0e5a --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_file_is_modified_test.go @@ -0,0 +1,30 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_rebuilds_when_file_is_modified(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch rebuilds when file is modified", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "const x: number = 1;", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "modify file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/index.ts", "const x: number = 2;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_source_file_is_deleted_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_source_file_is_deleted_test.go new file mode 100644 index 00000000000..408b947353d --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_source_file_is_deleted_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_rebuilds_when_source_file_is_deleted(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch rebuilds when source file is deleted", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "import { b } from \"./b\";", + "/home/src/workspaces/project/b.ts": "export const b = 1;", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete imported file", + ExpectedDiff: "incremental resolves to .js output from prior build (TS7016) while clean build cannot find module at all (TS2307)", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/b.ts") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_tsconfig_include_pattern_adds_file_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_tsconfig_include_pattern_adds_file_test.go new file mode 100644 index 00000000000..e7b0c3d2795 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_tsconfig_include_pattern_adds_file_test.go @@ -0,0 +1,37 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_rebuilds_when_tsconfig_include_pattern_adds_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch rebuilds when tsconfig include pattern adds file", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "const x = 1;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": {}, + "include": ["*.ts"] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "widen include pattern to add src dir", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/extra.ts", "export const extra = 2;") + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": {}, + "include": ["*.ts", "src/**/*.ts"] +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_tsconfig_is_modified_to_change_strict_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_tsconfig_is_modified_to_change_strict_test.go new file mode 100644 index 00000000000..a7f50a76b54 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_tsconfig_is_modified_to_change_strict_test.go @@ -0,0 +1,30 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_rebuilds_when_tsconfig_is_modified_to_change_strict(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch rebuilds when tsconfig is modified to change strict", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "const x = null; const y: string = x;", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "enable strict mode", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", "{\"compilerOptions\": {\"strict\": true}}") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_tsconfig_is_touched_but_content_unchanged_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_tsconfig_is_touched_but_content_unchanged_test.go new file mode 100644 index 00000000000..be9d8499a5b --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_rebuilds_when_tsconfig_is_touched_but_content_unchanged_test.go @@ -0,0 +1,30 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_rebuilds_when_tsconfig_is_touched_but_content_unchanged(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch rebuilds when tsconfig is touched but content unchanged", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "const x = 1;", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "touch tsconfig without changing content", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", "{}") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_skips_build_when_no_files_change_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_skips_build_when_no_files_change_test.go new file mode 100644 index 00000000000..ffdac1515ea --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_skips_build_when_no_files_change_test.go @@ -0,0 +1,27 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_skips_build_when_no_files_change(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch skips build when no files change", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "const x: number = 1;", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_with_no_tsconfig_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_with_no_tsconfig_test.go new file mode 100644 index 00000000000..82ce5406032 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_with_no_tsconfig_test.go @@ -0,0 +1,22 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_with_no_tsconfig(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch with no tsconfig", + CommandLineArgs: []string{"index.ts", "--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_with_tsconfig_and_incremental_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_with_tsconfig_and_incremental_test.go new file mode 100644 index 00000000000..3f5f05382d7 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_with_tsconfig_and_incremental_test.go @@ -0,0 +1,23 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_with_tsconfig_and_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch with tsconfig and incremental", + CommandLineArgs: []string{"--watch", "--incremental"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": "", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_with_tsconfig_files_list_entry_deleted_test.go b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_with_tsconfig_files_list_entry_deleted_test.go new file mode 100644 index 00000000000..d26a4f05fbd --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLineWatch_watch_with_tsconfig_files_list_entry_deleted_test.go @@ -0,0 +1,34 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLineWatch_watch_with_tsconfig_files_list_entry_deleted(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLineWatch", + SubScenario: "watch with tsconfig files list entry deleted", + CommandLineArgs: []string{"--watch"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a = 1;", + "/home/src/workspaces/project/b.ts": "export const b = 2;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": {}, + "files": ["a.ts", "b.ts"] +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete file listed in files array", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/b.ts") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLine_Initialized_TSConfig_with_watch_test.go b/internal/execute/tsctests/tests/tscWatch_commandLine_Initialized_TSConfig_with_watch_test.go new file mode 100644 index 00000000000..7c2e2055d9c --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLine_Initialized_TSConfig_with_watch_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLine_Initialized_TSConfig_with_watch(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Initialized TSConfig with --watch", + CommandLineArgs: []string{"--init", "--watch"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLine_Parse_watch_interval_option_test.go b/internal/execute/tsctests/tests/tscWatch_commandLine_Parse_watch_interval_option_test.go new file mode 100644 index 00000000000..79ab29d5da7 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLine_Parse_watch_interval_option_test.go @@ -0,0 +1,28 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLine_Parse_watch_interval_option(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Parse watch interval option", + CommandLineArgs: []string{"-w", "--watchInterval", "1000"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/first.ts": "export const a = 1", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "noEmit": true + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_commandLine_Parse_watch_interval_option_without_tsconfig_json_test.go b/internal/execute/tsctests/tests/tscWatch_commandLine_Parse_watch_interval_option_without_tsconfig_json_test.go new file mode 100644 index 00000000000..78fce77c7cc --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_commandLine_Parse_watch_interval_option_without_tsconfig_json_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_commandLine_Parse_watch_interval_option_without_tsconfig_json(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Parse watch interval option without tsconfig.json", + CommandLineArgs: []string{"-w", "--watchInterval", "1000"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_noEmit_dts_errors_test.go b/internal/execute/tsctests/tests/tscWatch_noEmit_dts_errors_test.go new file mode 100644 index 00000000000..f0f5494c396 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_noEmit_dts_errors_test.go @@ -0,0 +1,88 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_noEmit_dts_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors", + CommandLineArgs: []string{"-w"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "const a = class { private p = 10; };", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "noEmit": true, + "declaration": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "declaration": true + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "noEmit": true, + "declaration": true + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "declaration": true + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "noEmit": true, + "declaration": true + } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_noEmit_dts_errors_without_dts_enabled_test.go b/internal/execute/tsctests/tests/tscWatch_noEmit_dts_errors_without_dts_enabled_test.go new file mode 100644 index 00000000000..5b82b6e7f78 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_noEmit_dts_errors_without_dts_enabled_test.go @@ -0,0 +1,87 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_noEmit_dts_errors_without_dts_enabled(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors without dts enabled", + CommandLineArgs: []string{"-w"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "const a = class { private p = 10; };", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "noEmit": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "noEmit": true, + + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "noEmit": true, + + } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_noEmit_semantic_errors_test.go b/internal/execute/tsctests/tests/tscWatch_noEmit_semantic_errors_test.go new file mode 100644 index 00000000000..7f8906564ec --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_noEmit_semantic_errors_test.go @@ -0,0 +1,87 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_noEmit_semantic_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "semantic errors", + CommandLineArgs: []string{"-w"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "const a: number = \"hello\"", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "noEmit": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "noEmit": true, + + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "const a: number = \"hello\"") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "noEmit": true, + + } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tscWatch_noEmit_syntax_errors_test.go b/internal/execute/tsctests/tests/tscWatch_noEmit_syntax_errors_test.go new file mode 100644 index 00000000000..1f08adb0242 --- /dev/null +++ b/internal/execute/tsctests/tests/tscWatch_noEmit_syntax_errors_test.go @@ -0,0 +1,87 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTscWatch_noEmit_syntax_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "syntax errors", + CommandLineArgs: []string{"-w"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "const a = \"hello", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "noEmit": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no emit run after fixing error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "noEmit": true, + + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no emit run when error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "noEmit": true, + + } +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Config_with_references_and_empty_file_and_refers_to_config_with_noEmit_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Config_with_references_and_empty_file_and_refers_to_config_with_noEmit_test.go new file mode 100644 index 00000000000..91225bda6e7 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Config_with_references_and_empty_file_and_refers_to_config_with_noEmit_test.go @@ -0,0 +1,39 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Config_with_references_and_empty_file_and_refers_to_config_with_noEmit(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Config with references and empty file and refers to config with noEmit", + CommandLineArgs: []string{"-p", "."}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/packages/pkg1/index.ts": "export const a = 1;", + "/home/src/workspaces/project/packages/pkg1/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "noEmit": true + }, + "files": [ + "./index.ts", + ], + }`, + "/home/src/workspaces/project/tsconfig.json": `{ + "files": [], + "references": [ + { + "path": "./packages/pkg1" + }, + ], + }`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_advanced_options_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_advanced_options_test.go new file mode 100644 index 00000000000..744070c6a52 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_advanced_options_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Initialized_TSConfig_with_advanced_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Initialized TSConfig with advanced options", + CommandLineArgs: []string{"--init", "--declaration", "--declarationDir", "lib", "--skipLibCheck", "--noErrorTruncation"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_boolean_value_compiler_options_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_boolean_value_compiler_options_test.go new file mode 100644 index 00000000000..4af4e2f760c --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_boolean_value_compiler_options_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Initialized_TSConfig_with_boolean_value_compiler_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Initialized TSConfig with boolean value compiler options", + CommandLineArgs: []string{"--init", "--noUnusedLocals"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_enum_value_compiler_options_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_enum_value_compiler_options_test.go new file mode 100644 index 00000000000..9ac68ba90a8 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_enum_value_compiler_options_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Initialized_TSConfig_with_enum_value_compiler_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Initialized TSConfig with enum value compiler options", + CommandLineArgs: []string{"--init", "--target", "es5", "--jsx", "react"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_files_options_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_files_options_test.go new file mode 100644 index 00000000000..004c6f06b85 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_files_options_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Initialized_TSConfig_with_files_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Initialized TSConfig with files options", + CommandLineArgs: []string{"--init", "file0.st", "file1.ts", "file2.ts"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_help_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_help_test.go new file mode 100644 index 00000000000..6f127ef0f98 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_help_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Initialized_TSConfig_with_help(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Initialized TSConfig with --help", + CommandLineArgs: []string{"--init", "--help"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_incorrect_compiler_option_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_incorrect_compiler_option_test.go new file mode 100644 index 00000000000..ec7fbbef4d7 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_incorrect_compiler_option_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Initialized_TSConfig_with_incorrect_compiler_option(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Initialized TSConfig with incorrect compiler option", + CommandLineArgs: []string{"--init", "--someNonExistOption"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_incorrect_compiler_option_value_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_incorrect_compiler_option_value_test.go new file mode 100644 index 00000000000..ce5cdd4f7e7 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_incorrect_compiler_option_value_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Initialized_TSConfig_with_incorrect_compiler_option_value(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Initialized TSConfig with incorrect compiler option value", + CommandLineArgs: []string{"--init", "--lib", "nonExistLib,es5,es2015.promise"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_list_compiler_options_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_list_compiler_options_test.go new file mode 100644 index 00000000000..603c2e69e6b --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_list_compiler_options_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Initialized_TSConfig_with_list_compiler_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Initialized TSConfig with list compiler options", + CommandLineArgs: []string{"--init", "--types", "jquery,mocha"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_list_compiler_options_with_enum_value_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_list_compiler_options_with_enum_value_test.go new file mode 100644 index 00000000000..5f6340e601b --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_list_compiler_options_with_enum_value_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Initialized_TSConfig_with_list_compiler_options_with_enum_value(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Initialized TSConfig with list compiler options with enum value", + CommandLineArgs: []string{"--init", "--lib", "es5,es2015.core"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_tsconfig_json_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_tsconfig_json_test.go new file mode 100644 index 00000000000..df93fafc707 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Initialized_TSConfig_with_tsconfig_json_test.go @@ -0,0 +1,28 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Initialized_TSConfig_with_tsconfig_json(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Initialized TSConfig with tsconfig.json", + CommandLineArgs: []string{"--init"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/first.ts": "export const a = 1", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "noEmit": true + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Parse_enum_type_options_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Parse_enum_type_options_test.go new file mode 100644 index 00000000000..22d006a0bf4 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Parse_enum_type_options_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Parse_enum_type_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Parse enum type options", + CommandLineArgs: []string{"--moduleResolution", "nodenext ", "first.ts", "--module", "nodenext", "--target", "esnext", "--moduleDetection", "auto", "--jsx", "react", "--newLine", "crlf"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Parse_lib_option_with_file_name_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Parse_lib_option_with_file_name_test.go new file mode 100644 index 00000000000..d1423c60e9b --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Parse_lib_option_with_file_name_test.go @@ -0,0 +1,22 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Parse_lib_option_with_file_name(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Parse --lib option with file name", + CommandLineArgs: []string{"--lib", "es6 ", "first.ts"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/first.ts": "export const Key = Symbol()", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Parse_p_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Parse_p_test.go new file mode 100644 index 00000000000..77e7d0a4c76 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Parse_p_test.go @@ -0,0 +1,28 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Parse_p(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Parse -p", + CommandLineArgs: []string{"-p", "."}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/first.ts": "export const a = 1", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "noEmit": true + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Parse_p_with_path_to_tsconfig_file_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Parse_p_with_path_to_tsconfig_file_test.go new file mode 100644 index 00000000000..87944f51f74 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Parse_p_with_path_to_tsconfig_file_test.go @@ -0,0 +1,28 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Parse_p_with_path_to_tsconfig_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Parse -p with path to tsconfig file", + CommandLineArgs: []string{"-p", "/home/src/workspaces/project/tsconfig.json"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/first.ts": "export const a = 1", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "noEmit": true + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Parse_p_with_path_to_tsconfig_folder_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Parse_p_with_path_to_tsconfig_folder_test.go new file mode 100644 index 00000000000..ac3ccb07a0c --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Parse_p_with_path_to_tsconfig_folder_test.go @@ -0,0 +1,28 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Parse_p_with_path_to_tsconfig_folder(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Parse -p with path to tsconfig folder", + CommandLineArgs: []string{"-p", "/home/src/workspaces/project"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/first.ts": "export const a = 1", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "noEmit": true + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_Project_is_empty_string_test.go b/internal/execute/tsctests/tests/tsc_commandLine_Project_is_empty_string_test.go new file mode 100644 index 00000000000..5ee93428808 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_Project_is_empty_string_test.go @@ -0,0 +1,28 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_Project_is_empty_string(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "Project is empty string", + CommandLineArgs: []string{}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/first.ts": "export const a = 1", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "noEmit": true + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_adds_color_when_FORCE_COLOR_is_set_test.go b/internal/execute/tsctests/tests/tsc_commandLine_adds_color_when_FORCE_COLOR_is_set_test.go new file mode 100644 index 00000000000..8c953bd2112 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_adds_color_when_FORCE_COLOR_is_set_test.go @@ -0,0 +1,21 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_adds_color_when_FORCE_COLOR_is_set(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "adds color when FORCE_COLOR is set", + Env: map[string]string{ + "FORCE_COLOR": "true", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_bad_locale_test.go b/internal/execute/tsctests/tests/tsc_commandLine_bad_locale_test.go new file mode 100644 index 00000000000..b807a7bc411 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_bad_locale_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_bad_locale(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "bad locale", + CommandLineArgs: []string{"--locale", "whoops", "--version"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_does_not_add_color_when_NO_COLOR_is_set_even_if_FORCE_COLOR_is_set_test.go b/internal/execute/tsctests/tests/tsc_commandLine_does_not_add_color_when_NO_COLOR_is_set_even_if_FORCE_COLOR_is_set_test.go new file mode 100644 index 00000000000..045eb2f54de --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_does_not_add_color_when_NO_COLOR_is_set_even_if_FORCE_COLOR_is_set_test.go @@ -0,0 +1,22 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_does_not_add_color_when_NO_COLOR_is_set_even_if_FORCE_COLOR_is_set(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "does not add color when NO_COLOR is set even if FORCE_COLOR is set", + Env: map[string]string{ + "FORCE_COLOR": "true", + "NO_COLOR": "true", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_does_not_add_color_when_NO_COLOR_is_set_test.go b/internal/execute/tsctests/tests/tsc_commandLine_does_not_add_color_when_NO_COLOR_is_set_test.go new file mode 100644 index 00000000000..c012e17442d --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_does_not_add_color_when_NO_COLOR_is_set_test.go @@ -0,0 +1,21 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_does_not_add_color_when_NO_COLOR_is_set(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "does not add color when NO_COLOR is set", + Env: map[string]string{ + "NO_COLOR": "true", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_help_all_test.go b/internal/execute/tsctests/tests/tsc_commandLine_help_all_test.go new file mode 100644 index 00000000000..1710fd862cd --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_help_all_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_help_all(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "help all", + CommandLineArgs: []string{"--help", "--all"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_help_test.go b/internal/execute/tsctests/tests/tsc_commandLine_help_test.go new file mode 100644 index 00000000000..3af30be17a0 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_help_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_help(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "help", + CommandLineArgs: []string{"--help"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_locale_test.go b/internal/execute/tsctests/tests/tsc_commandLine_locale_test.go new file mode 100644 index 00000000000..57e5de57e7d --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_locale_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_locale(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "locale", + CommandLineArgs: []string{"--locale", "cs", "--version"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_show_help_with_ExitStatus_DiagnosticsPresent_OutputsSkipped_test.go b/internal/execute/tsctests/tests/tsc_commandLine_show_help_with_ExitStatus_DiagnosticsPresent_OutputsSkipped_test.go new file mode 100644 index 00000000000..957deb04207 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_show_help_with_ExitStatus_DiagnosticsPresent_OutputsSkipped_test.go @@ -0,0 +1,21 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_show_help_with_ExitStatus_DiagnosticsPresent_OutputsSkipped(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "show help with ExitStatus.DiagnosticsPresent_OutputsSkipped", + Env: map[string]string{ + "TS_TEST_TERMINAL_WIDTH": "120", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_commandLine_show_help_with_ExitStatus_DiagnosticsPresent_OutputsSkipped_when_host_cannot_provide_terminal_width_test.go b/internal/execute/tsctests/tests/tsc_commandLine_show_help_with_ExitStatus_DiagnosticsPresent_OutputsSkipped_when_host_cannot_provide_terminal_width_test.go new file mode 100644 index 00000000000..59839ac1e54 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_commandLine_show_help_with_ExitStatus_DiagnosticsPresent_OutputsSkipped_when_host_cannot_provide_terminal_width_test.go @@ -0,0 +1,18 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_commandLine_show_help_with_ExitStatus_DiagnosticsPresent_OutputsSkipped_when_host_cannot_provide_terminal_width(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "commandLine", + SubScenario: "show help with ExitStatus.DiagnosticsPresent_OutputsSkipped when host cannot provide terminal width", + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_composite_converting_to_modules_test.go b/internal/execute/tsctests/tests/tsc_composite_converting_to_modules_test.go new file mode 100644 index 00000000000..ed006a3200a --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_composite_converting_to_modules_test.go @@ -0,0 +1,39 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_composite_converting_to_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "composite", + SubScenario: "converting to modules", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/main.ts": "const x = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "module": "none", + "composite": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "convert to modules", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "module": "es2015", + "composite": true, + }, +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_composite_synthetic_jsx_import_of_ESM_module_from_CJS_module_error_on_jsx_element_test.go b/internal/execute/tsctests/tests/tsc_composite_synthetic_jsx_import_of_ESM_module_from_CJS_module_error_on_jsx_element_test.go new file mode 100644 index 00000000000..fb547fb93be --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_composite_synthetic_jsx_import_of_ESM_module_from_CJS_module_error_on_jsx_element_test.go @@ -0,0 +1,37 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_composite_synthetic_jsx_import_of_ESM_module_from_CJS_module_error_on_jsx_element(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "composite", + SubScenario: "synthetic jsx import of ESM module from CJS module error on jsx element", + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/node_modules/solid-js/jsx-runtime.d.ts": `export namespace JSX { + type IntrinsicElements = { div: {}; }; +}`, + "/home/src/projects/project/node_modules/solid-js/package.json": `{ + "name": "solid-js", + "type": "module" +}`, + "/home/src/projects/project/src/main.tsx": "export default
;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "module": "Node16", + "jsx": "react-jsx", + "jsxImportSource": "solid-js", + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_composite_synthetic_jsx_import_of_ESM_module_from_CJS_module_no_crash_no_jsx_element_test.go b/internal/execute/tsctests/tests/tsc_composite_synthetic_jsx_import_of_ESM_module_from_CJS_module_no_crash_no_jsx_element_test.go new file mode 100644 index 00000000000..96ad729edfe --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_composite_synthetic_jsx_import_of_ESM_module_from_CJS_module_no_crash_no_jsx_element_test.go @@ -0,0 +1,37 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_composite_synthetic_jsx_import_of_ESM_module_from_CJS_module_no_crash_no_jsx_element(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "composite", + SubScenario: "synthetic jsx import of ESM module from CJS module no crash no jsx element", + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/node_modules/solid-js/jsx-runtime.d.ts": `export namespace JSX { + type IntrinsicElements = { div: {}; }; +}`, + "/home/src/projects/project/node_modules/solid-js/package.json": `{ + "name": "solid-js", + "type": "module" +}`, + "/home/src/projects/project/src/main.ts": "export default 42;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "module": "Node16", + "jsx": "react-jsx", + "jsxImportSource": "solid-js", + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_composite_when_setting_composite_false_and_tsbuildinfo_as_null_on_command_line_but_has_tsbuild_info_in_config_test.go b/internal/execute/tsctests/tests/tsc_composite_when_setting_composite_false_and_tsbuildinfo_as_null_on_command_line_but_has_tsbuild_info_in_config_test.go new file mode 100644 index 00000000000..a9d52ebdba1 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_composite_when_setting_composite_false_and_tsbuildinfo_as_null_on_command_line_but_has_tsbuild_info_in_config_test.go @@ -0,0 +1,33 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_composite_when_setting_composite_false_and_tsbuildinfo_as_null_on_command_line_but_has_tsbuild_info_in_config(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "composite", + SubScenario: "when setting composite false and tsbuildinfo as null on command line but has tsbuild info in config", + CommandLineArgs: []string{"--composite", "false", "--tsBuildInfoFile", "null"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/main.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "composite": true, + "tsBuildInfoFile": "tsconfig.json.tsbuildinfo", + }, + "include": [ + "src/**/*.ts", + ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_composite_when_setting_composite_false_on_command_line_but_has_tsbuild_info_in_config_test.go b/internal/execute/tsctests/tests/tsc_composite_when_setting_composite_false_on_command_line_but_has_tsbuild_info_in_config_test.go new file mode 100644 index 00000000000..2300da30987 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_composite_when_setting_composite_false_on_command_line_but_has_tsbuild_info_in_config_test.go @@ -0,0 +1,33 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_composite_when_setting_composite_false_on_command_line_but_has_tsbuild_info_in_config(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "composite", + SubScenario: "when setting composite false on command line but has tsbuild info in config", + CommandLineArgs: []string{"--composite", "false"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/main.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "composite": true, + "tsBuildInfoFile": "tsconfig.json.tsbuildinfo", + }, + "include": [ + "src/**/*.ts", + ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_composite_when_setting_composite_false_on_command_line_test.go b/internal/execute/tsctests/tests/tsc_composite_when_setting_composite_false_on_command_line_test.go new file mode 100644 index 00000000000..105556b14e1 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_composite_when_setting_composite_false_on_command_line_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_composite_when_setting_composite_false_on_command_line(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "composite", + SubScenario: "when setting composite false on command line", + CommandLineArgs: []string{"--composite", "false"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/main.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "composite": true, + }, + "include": [ + "src/**/*.ts", + ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_composite_when_setting_composite_null_on_command_line_test.go b/internal/execute/tsctests/tests/tsc_composite_when_setting_composite_null_on_command_line_test.go new file mode 100644 index 00000000000..5138ad51fbd --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_composite_when_setting_composite_null_on_command_line_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_composite_when_setting_composite_null_on_command_line(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "composite", + SubScenario: "when setting composite null on command line", + CommandLineArgs: []string{"--composite", "null"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/main.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "composite": true, + }, + "include": [ + "src/**/*.ts", + ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_declarationEmit_reports_dts_generation_errors_test.go b/internal/execute/tsctests/tests/tsc_declarationEmit_reports_dts_generation_errors_test.go new file mode 100644 index 00000000000..0bd2ee8ca7a --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_declarationEmit_reports_dts_generation_errors_test.go @@ -0,0 +1,56 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_declarationEmit_reports_dts_generation_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "declarationEmit", + SubScenario: "reports dts generation errors", + CommandLineArgs: []string{"--explainFiles", "--listEmittedFiles"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": `import ky from 'ky'; +export const api = ky.extend({});`, + "/home/src/workspaces/project/node_modules/ky/distribution/index.d.ts": `type KyInstance = { + extend(options: Record): KyInstance; +} +declare const ky: KyInstance; +export default ky;`, + "/home/src/workspaces/project/node_modules/ky/package.json": `{ + "name": "ky", + "type": "module", + "main": "./distribution/index.js" +}`, + "/home/src/workspaces/project/package.json": `{ + "type": "module" +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "module": "NodeNext", + "moduleResolution": "NodeNext", + "composite": false, + "incremental": false, + "declaration": true, + "skipLibCheck": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "build -b", + CommandLineArgs: []string{"-b", "--explainFiles", "--listEmittedFiles", "--v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_declarationEmit_reports_dts_generation_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_declarationEmit_reports_dts_generation_errors_with_incremental_test.go new file mode 100644 index 00000000000..1ce710e9230 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_declarationEmit_reports_dts_generation_errors_with_incremental_test.go @@ -0,0 +1,56 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_declarationEmit_reports_dts_generation_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "declarationEmit", + SubScenario: "reports dts generation errors with incremental", + CommandLineArgs: []string{"--explainFiles", "--listEmittedFiles"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.ts": `import ky from 'ky'; +export const api = ky.extend({});`, + "/home/src/workspaces/project/node_modules/ky/distribution/index.d.ts": `type KyInstance = { + extend(options: Record): KyInstance; +} +declare const ky: KyInstance; +export default ky;`, + "/home/src/workspaces/project/node_modules/ky/package.json": `{ + "name": "ky", + "type": "module", + "main": "./distribution/index.js" +}`, + "/home/src/workspaces/project/package.json": `{ + "type": "module" +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "module": "NodeNext", + "moduleResolution": "NodeNext", + "composite": true, + "incremental": true, + "declaration": true, + "skipLibCheck": true, + "skipDefaultLibCheck": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "build -b", + CommandLineArgs: []string{"-b", "--explainFiles", "--listEmittedFiles", "--v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_declarationEmit_when_inferred_export_should_reuse_imported_type_alias_across_a_module_boundary_test.go b/internal/execute/tsctests/tests/tsc_declarationEmit_when_inferred_export_should_reuse_imported_type_alias_across_a_module_boundary_test.go new file mode 100644 index 00000000000..8977ca6d85c --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_declarationEmit_when_inferred_export_should_reuse_imported_type_alias_across_a_module_boundary_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_declarationEmit_when_inferred_export_should_reuse_imported_type_alias_across_a_module_boundary(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "declarationEmit", + SubScenario: "when inferred export should reuse imported type alias across a module boundary", + CommandLineArgs: []string{"--p", "tsconfig.json"}, + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.es2022.full.d.ts": `/// +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 Partial = { + [K in keyof T]?: T[K]; +};`, + "/home/src/workspaces/project/a.ts": `interface ISettings { + age: number; +} + +export type Settings = Partial;`, + "/home/src/workspaces/project/factory.ts": `import type { Settings } from "./a"; + +export const makeObj = () => ({ + fn: (s?: Settings): Settings | undefined => s, +});`, + "/home/src/workspaces/project/state.ts": `import { makeObj } from "./factory"; + +export const obj = makeObj();`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "declaration": true, + "emitDeclarationOnly": true, + "target": "es2022", + "module": "esnext", + }, + "files": ["./a.ts", "./factory.ts", "./state.ts"], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_declarationEmit_when_pkg_references_sibling_package_through_indirect_symlink_test.go b/internal/execute/tsctests/tests/tsc_declarationEmit_when_pkg_references_sibling_package_through_indirect_symlink_test.go new file mode 100644 index 00000000000..60537431164 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_declarationEmit_when_pkg_references_sibling_package_through_indirect_symlink_test.go @@ -0,0 +1,67 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsc_declarationEmit_when_pkg_references_sibling_package_through_indirect_symlink(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "declarationEmit", + SubScenario: "when pkg references sibling package through indirect symlink", + CommandLineArgs: []string{"-p", "pkg3", "--explainFiles"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/pkg1/dist/index.d.ts": "export * from './types';", + "/user/username/projects/myproject/pkg1/dist/types.d.ts": `export declare type A = { + id: string; +}; +export declare type B = { + id: number; +}; +export declare type IdType = A | B; +export declare class MetadataAccessor { + readonly key: string; + private constructor(); + toString(): string; + static create(key: string): MetadataAccessor; +}`, + "/user/username/projects/myproject/pkg1/package.json": `{ + "name": "@raymondfeng/pkg1", + "version": "1.0.0", + "main": "dist/index.js", + "typings": "dist/index.d.ts" +}`, + "/user/username/projects/myproject/pkg2/dist/index.d.ts": "export * from './types';", + "/user/username/projects/myproject/pkg2/dist/types.d.ts": "export {MetadataAccessor} from '@raymondfeng/pkg1';", + "/user/username/projects/myproject/pkg2/node_modules/@raymondfeng/pkg1": vfstest.Symlink("/user/username/projects/myproject/pkg1"), + "/user/username/projects/myproject/pkg2/package.json": `{ + "name": "@raymondfeng/pkg2", + "version": "1.0.0", + "main": "dist/index.js", + "typings": "dist/index.d.ts" +}`, + "/user/username/projects/myproject/pkg3/node_modules/@raymondfeng/pkg2": vfstest.Symlink("/user/username/projects/myproject/pkg2"), + "/user/username/projects/myproject/pkg3/src/index.ts": "export * from './keys';", + "/user/username/projects/myproject/pkg3/src/keys.ts": `import {MetadataAccessor} from "@raymondfeng/pkg2"; +export const ADMIN = MetadataAccessor.create('1');`, + "/user/username/projects/myproject/pkg3/tsconfig.json": `{ + "compilerOptions": { + "outDir": "dist", + "rootDir": "src", + "target": "es5", + "module": "commonjs", + "strict": true, + "esModuleInterop": true, + "declaration": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_declarationEmit_when_same_version_is_referenced_through_source_and_another_symlinked_package_test.go b/internal/execute/tsctests/tests/tsc_declarationEmit_when_same_version_is_referenced_through_source_and_another_symlinked_package_test.go new file mode 100644 index 00000000000..817ca5127e6 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_declarationEmit_when_same_version_is_referenced_through_source_and_another_symlinked_package_test.go @@ -0,0 +1,91 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsc_declarationEmit_when_same_version_is_referenced_through_source_and_another_symlinked_package(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "declarationEmit", + SubScenario: "when same version is referenced through source and another symlinked package", + CommandLineArgs: []string{"-p", "plugin-one", "--explainFiles"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/user/username/projects/myproject/plugin-one/action.ts": `import { actionCreatorFactory } from "typescript-fsa"; // Include version of shared lib +const action = actionCreatorFactory("somekey"); +const featureOne = action<{ route: string }>("feature-one"); +export const actions = { featureOne };`, + "/user/username/projects/myproject/plugin-one/index.ts": "import pluginTwo from \"plugin-two\"; // include this to add reference to symlink", + "/user/username/projects/myproject/plugin-one/node_modules/plugin-two": vfstest.Symlink("/user/username/projects/myproject/plugin-two"), + "/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/index.d.ts": `export interface Action { + type: string; + payload: Payload; +} +export declare type ActionCreator = { + type: string; + (payload: Payload): Action; +} +export interface ActionCreatorFactory { + (type: string): ActionCreator; +} +export declare function actionCreatorFactory(prefix?: string | null): ActionCreatorFactory; +export default actionCreatorFactory;`, + "/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/package.json": `{ + "name": "typescript-fsa", + "version": "3.0.0-beta-2" +}`, + "/user/username/projects/myproject/plugin-one/tsconfig.json": `{ + "compilerOptions": { + "target": "es5", + "declaration": true, + "traceResolution": true, + }, +}`, + "/user/username/projects/myproject/plugin-two/index.d.ts": `declare const _default: { + features: { + featureOne: { + actions: { + featureOne: { + (payload: { + name: string; + order: number; + }, meta?: { + [key: string]: any; + }): import("typescript-fsa").Action<{ + name: string; + order: number; + }>; + }; + }; + path: string; + }; + }; +}; +export default _default;`, + "/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/index.d.ts": `export interface Action { + type: string; + payload: Payload; +} +export declare type ActionCreator = { + type: string; + (payload: Payload): Action; +} +export interface ActionCreatorFactory { + (type: string): ActionCreator; +} +export declare function actionCreatorFactory(prefix?: string | null): ActionCreatorFactory; +export default actionCreatorFactory;`, + "/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/package.json": `{ + "name": "typescript-fsa", + "version": "3.0.0-beta-2" +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_declarationEmit_when_same_version_is_referenced_through_source_and_another_symlinked_package_with_indirect_link_test.go b/internal/execute/tsctests/tests/tsc_declarationEmit_when_same_version_is_referenced_through_source_and_another_symlinked_package_with_indirect_link_test.go new file mode 100644 index 00000000000..7724e2de52b --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_declarationEmit_when_same_version_is_referenced_through_source_and_another_symlinked_package_with_indirect_link_test.go @@ -0,0 +1,97 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsc_declarationEmit_when_same_version_is_referenced_through_source_and_another_symlinked_package_with_indirect_link(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "declarationEmit", + SubScenario: "when same version is referenced through source and another symlinked package with indirect link", + CommandLineArgs: []string{"-p", "plugin-one", "--explainFiles"}, + Cwd: "/user/username/projects/myproject", + Files: tsctests.FileMap{ + "/temp/yarn/data/link/plugin-two": vfstest.Symlink("/user/username/projects/myproject/plugin-two"), + "/user/username/projects/myproject/plugin-one/index.ts": `import pluginTwo from "plugin-two"; // include this to add reference to symlink +import { actionCreatorFactory } from "typescript-fsa"; // Include version of shared lib +const action = actionCreatorFactory("somekey"); +const featureOne = action<{ route: string }>("feature-one"); +export const actions = { featureOne };`, + "/user/username/projects/myproject/plugin-one/node_modules/plugin-two": vfstest.Symlink("/temp/yarn/data/link/plugin-two"), + "/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/index.d.ts": `export interface Action { + type: string; + payload: Payload; +} +export declare type ActionCreator = { + type: string; + (payload: Payload): Action; +} +export interface ActionCreatorFactory { + (type: string): ActionCreator; +} +export declare function actionCreatorFactory(prefix?: string | null): ActionCreatorFactory; +export default actionCreatorFactory;`, + "/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/package.json": `{ + "name": "typescript-fsa", + "version": "3.0.0-beta-2" +}`, + "/user/username/projects/myproject/plugin-one/tsconfig.json": `{ + "compilerOptions": { + "target": "es5", + "declaration": true, + "traceResolution": true, + }, +}`, + "/user/username/projects/myproject/plugin-two/dist/commonjs/index.d.ts": `declare const _default: { + features: { + featureOne: { + actions: { + featureOne: { + (payload: { + name: string; + order: number; + }, meta?: { + [key: string]: any; + }): import("typescript-fsa").Action<{ + name: string; + order: number; + }>; + }; + }; + path: string; + }; + }; +}; +export default _default;`, + "/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/index.d.ts": `export interface Action { + type: string; + payload: Payload; +} +export declare type ActionCreator = { + type: string; + (payload: Payload): Action; +} +export interface ActionCreatorFactory { + (type: string): ActionCreator; +} +export declare function actionCreatorFactory(prefix?: string | null): ActionCreatorFactory; +export default actionCreatorFactory;`, + "/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/package.json": `{ + "name": "typescript-fsa", + "version": "3.0.0-beta-2" +}`, + "/user/username/projects/myproject/plugin-two/package.json": `{ + "name": "plugin-two", + "version": "0.1.3", + "main": "dist/commonjs/index.js" +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_declarationEmit_when_using_Windows_paths_and_uppercase_letters_test.go b/internal/execute/tsctests/tests/tsc_declarationEmit_when_using_Windows_paths_and_uppercase_letters_test.go new file mode 100644 index 00000000000..c4844f82bca --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_declarationEmit_when_using_Windows_paths_and_uppercase_letters_test.go @@ -0,0 +1,60 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_declarationEmit_when_using_Windows_paths_and_uppercase_letters(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "declarationEmit", + SubScenario: "when using Windows paths and uppercase letters", + CommandLineArgs: []string{"-p", "D:\\Work\\pkg1", "--explainFiles"}, + Cwd: "D:/Work/pkg1", + IgnoreCase: true, + WindowsStyleRoot: "D:/", + Files: tsctests.FileMap{ + "D:/Work/pkg1/package.json": `{ + "name": "ts-specifier-bug", + "version": "1.0.0", + "main": "index.js" +}`, + "D:/Work/pkg1/src/main.ts": `import { PartialType } from './utils'; + +class Common {} + +export class Sub extends PartialType(Common) { + id: string; +}`, + "D:/Work/pkg1/src/utils/index.ts": `import { MyType, MyReturnType } from './type-helpers'; + +export function PartialType(classRef: MyType) { + abstract class PartialClassType { + constructor() {} + } + + return PartialClassType as MyReturnType; +}`, + "D:/Work/pkg1/src/utils/type-helpers.ts": `export type MyReturnType = { + new (...args: any[]): any; +}; + +export interface MyType extends Function { + new (...args: any[]): T; +}`, + "D:/Work/pkg1/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "target": "es2017", + "outDir": "./dist", + }, + "include": ["src"], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_extends_configDir_template_showConfig_test.go b/internal/execute/tsctests/tests/tsc_extends_configDir_template_showConfig_test.go new file mode 100644 index 00000000000..69d9643deda --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_extends_configDir_template_showConfig_test.go @@ -0,0 +1,54 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_extends_configDir_template_showConfig(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "extends", + SubScenario: "configDir template showConfig", + CommandLineArgs: []string{"--showConfig"}, + Cwd: "/home/src/projects/myproject", + Files: tsctests.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/*"], + }, + }, + "watchOptions": { + "excludeFiles": ["${configDir}/main.ts"], + }, +}`, + "/home/src/projects/myproject/main.ts": `// some comment +export const y = 10; +import { x } from "@myscope/sometype";`, + "/home/src/projects/myproject/tsconfig.json": `{ + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true, + }, +}`, + "/home/src/projects/myproject/types/sometype.ts": "export const x = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_extends_configDir_template_test.go b/internal/execute/tsctests/tests/tsc_extends_configDir_template_test.go new file mode 100644 index 00000000000..578ce16ab2e --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_extends_configDir_template_test.go @@ -0,0 +1,54 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_extends_configDir_template(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "extends", + SubScenario: "configDir template", + CommandLineArgs: []string{"--explainFiles"}, + Cwd: "/home/src/projects/myproject", + Files: tsctests.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/*"], + }, + }, + "watchOptions": { + "excludeFiles": ["${configDir}/main.ts"], + }, +}`, + "/home/src/projects/myproject/main.ts": `// some comment +export const y = 10; +import { x } from "@myscope/sometype";`, + "/home/src/projects/myproject/tsconfig.json": `{ + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true, + }, +}`, + "/home/src/projects/myproject/types/sometype.ts": "export const x = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_extends_configDir_template_with_commandline_test.go b/internal/execute/tsctests/tests/tsc_extends_configDir_template_with_commandline_test.go new file mode 100644 index 00000000000..b1ac23feeab --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_extends_configDir_template_with_commandline_test.go @@ -0,0 +1,54 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_extends_configDir_template_with_commandline(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "extends", + SubScenario: "configDir template with commandline", + CommandLineArgs: []string{"--explainFiles", "--outDir", "${configDir}/outDir"}, + Cwd: "/home/src/projects/myproject", + Files: tsctests.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/*"], + }, + }, + "watchOptions": { + "excludeFiles": ["${configDir}/main.ts"], + }, +}`, + "/home/src/projects/myproject/main.ts": `// some comment +export const y = 10; +import { x } from "@myscope/sometype";`, + "/home/src/projects/myproject/tsconfig.json": `{ + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true, + }, +}`, + "/home/src/projects/myproject/types/sometype.ts": "export const x = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_extends_resolves_the_symlink_path_test.go b/internal/execute/tsctests/tests/tsc_extends_resolves_the_symlink_path_test.go new file mode 100644 index 00000000000..a4b8e7f9e3e --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_extends_resolves_the_symlink_path_test.go @@ -0,0 +1,38 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsc_extends_resolves_the_symlink_path(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "extends", + SubScenario: "resolves the symlink path", + CommandLineArgs: []string{"-p", "src", "--extendedDiagnostics"}, + Cwd: "/users/user/projects/myproject", + Files: tsctests.FileMap{ + "/users/user/projects/myconfigs/node_modules/@something/tsconfig-base/tsconfig.json": `{ + "compilerOptions": { "composite": true } +}`, + "/users/user/projects/myconfigs/node_modules/@something/tsconfig-node/tsconfig.json": `{ + "extends": "@something/tsconfig-base/tsconfig.json", + "compilerOptions": { + "removeComments": true + } +}`, + "/users/user/projects/myproject/node_modules/@something/tsconfig-node": vfstest.Symlink("/users/user/projects/myconfigs/node_modules/@something/tsconfig-node"), + "/users/user/projects/myproject/src/index.ts": `// some comment +export const x = 10;`, + "/users/user/projects/myproject/src/tsconfig.json": `{ + "extends": "@something/tsconfig-node/tsconfig.json" +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_two_files_exist_on_disk_that_differs_only_in_casing_test.go b/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_two_files_exist_on_disk_that_differs_only_in_casing_test.go new file mode 100644 index 00000000000..7338dcfd020 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_two_files_exist_on_disk_that_differs_only_in_casing_test.go @@ -0,0 +1,26 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_forceConsistentCasingInFileNames_two_files_exist_on_disk_that_differs_only_in_casing(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "forceConsistentCasingInFileNames", + SubScenario: "two files exist on disk that differs only in casing", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/D.ts": "export const x = 10;", + "/home/src/workspaces/project/c.ts": "import {x} from \"./D\"", + "/home/src/workspaces/project/d.ts": "export const y = 20;", + "/home/src/workspaces/project/tsconfig.json": `{ + "files": ["c.ts", "d.ts"] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_when_file_is_included_from_multiple_places_with_different_casing_test.go b/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_when_file_is_included_from_multiple_places_with_different_casing_test.go new file mode 100644 index 00000000000..73301bd7288 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_when_file_is_included_from_multiple_places_with_different_casing_test.go @@ -0,0 +1,37 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_forceConsistentCasingInFileNames_when_file_is_included_from_multiple_places_with_different_casing(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "forceConsistentCasingInFileNames", + SubScenario: "when file is included from multiple places with different casing", + CommandLineArgs: []string{"--explainFiles"}, + Cwd: "/home/src/projects/project", + IgnoreCase: true, + Files: tsctests.FileMap{ + "/home/src/projects/project/node_modules/fp-ts/lib/struct.d.ts": "export function foo(): void", + "/home/src/projects/project/src/anotherFile.ts": `import * as xs1 from "fp-ts/lib/Struct"; +import * as xs2 from "fp-ts/lib/struct"; +import * as xs3 from "./Struct"; +import * as xs4 from "./struct";`, + "/home/src/projects/project/src/oneMore.ts": `import * as xs1 from "fp-ts/lib/Struct"; +import * as xs2 from "fp-ts/lib/struct"; +import * as xs3 from "./Struct"; +import * as xs4 from "./struct";`, + "/home/src/projects/project/src/struct.d.ts": `import * as xs1 from "fp-ts/lib/Struct"; +import * as xs2 from "fp-ts/lib/struct"; +import * as xs3 from "./Struct"; +import * as xs4 from "./struct";`, + "/home/src/projects/project/tsconfig.json": "{}", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_with_relative_and_non_relative_file_resolutions_test.go b/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_with_relative_and_non_relative_file_resolutions_test.go new file mode 100644 index 00000000000..53829d80c68 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_with_relative_and_non_relative_file_resolutions_test.go @@ -0,0 +1,28 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_forceConsistentCasingInFileNames_with_relative_and_non_relative_file_resolutions(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "forceConsistentCasingInFileNames", + SubScenario: "with relative and non relative file resolutions", + CommandLineArgs: []string{"/user/username/projects/myproject/src/struct.d.ts", "--forceConsistentCasingInFileNames", "--explainFiles"}, + Cwd: "/user/username/projects/myproject", + IgnoreCase: true, + Files: tsctests.FileMap{ + "/user/username/projects/myproject/node_modules/fp-ts/lib/struct.d.ts": "export function foo(): void", + "/user/username/projects/myproject/src/struct.d.ts": `import * as xs1 from "fp-ts/lib/Struct"; +import * as xs2 from "fp-ts/lib/struct"; +import * as xs3 from "./Struct"; +import * as xs4 from "./struct";`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_with_triple_slash_ref_from_file_test.go b/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_with_triple_slash_ref_from_file_test.go new file mode 100644 index 00000000000..440413048be --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_with_triple_slash_ref_from_file_test.go @@ -0,0 +1,24 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_forceConsistentCasingInFileNames_with_triple_slash_ref_from_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "forceConsistentCasingInFileNames", + SubScenario: "with triple slash ref from file", + IgnoreCase: true, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/c.ts": "/// ", + "/home/src/workspaces/project/src/d.ts": "declare class c { }", + "/home/src/workspaces/project/tsconfig.json": "{ }", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_with_type_ref_from_file_test.go b/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_with_type_ref_from_file_test.go new file mode 100644 index 00000000000..184389648b6 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_forceConsistentCasingInFileNames_with_type_ref_from_file_test.go @@ -0,0 +1,27 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_forceConsistentCasingInFileNames_with_type_ref_from_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "forceConsistentCasingInFileNames", + SubScenario: "with type ref from file", + CommandLineArgs: []string{"-p", "/user/username/projects/myproject", "--explainFiles", "--traceResolution"}, + Cwd: "/user/username/projects/myproject", + IgnoreCase: true, + Files: tsctests.FileMap{ + "/user/username/projects/myproject/src/file2.d.ts": `/// +declare const y: c;`, + "/user/username/projects/myproject/src/fileOne.d.ts": "declare class c { }", + "/user/username/projects/myproject/tsconfig.json": "{ }", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_generateTrace_generateTrace_generates_types_file_test.go b/internal/execute/tsctests/tests/tsc_generateTrace_generateTrace_generates_types_file_test.go new file mode 100644 index 00000000000..b277e6fe2b3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_generateTrace_generateTrace_generates_types_file_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_generateTrace_generateTrace_generates_types_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "generateTrace", + SubScenario: "generateTrace generates types file", + CommandLineArgs: []string{"--generateTrace", "/home/src/workspaces/project/trace", "--singleThreaded"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": `interface Person { + name: string; + age: number; +} +const p: Person = { name: "Alice", age: 30 };`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "noEmit": true + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_generateTrace_generateTrace_with_multiple_files_and_complex_types_test.go b/internal/execute/tsctests/tests/tsc_generateTrace_generateTrace_with_multiple_files_and_complex_types_test.go new file mode 100644 index 00000000000..ba6096dd836 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_generateTrace_generateTrace_with_multiple_files_and_complex_types_test.go @@ -0,0 +1,35 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_generateTrace_generateTrace_with_multiple_files_and_complex_types(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "generateTrace", + SubScenario: "generateTrace with multiple files and complex types", + CommandLineArgs: []string{"--generateTrace", "/home/src/workspaces/project/trace", "--singleThreaded"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/main.ts": `import { Container, Nullable } from "./types"; +const c: Container = { value: 42, map: (fn) => ({ value: fn(42), map: c.map }) }; +const n: Nullable = "hello";`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "noEmit": true + } +}`, + "/home/src/workspaces/project/types.ts": `export interface Container { + value: T; + map(fn: (x: T) => U): Container; +} +export type Nullable = T | null | undefined;`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_mixing_project_and_files_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_mixing_project_and_files_test.go new file mode 100644 index 00000000000..3f42d3eb621 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_mixing_project_and_files_test.go @@ -0,0 +1,27 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_mixing_project_and_files(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "mixing project and files", + CommandLineArgs: []string{"-p", ".", "src/a.ts", "c.ts"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "include": ["src"], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_mixing_project_and_files_when_config_file_absent_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_mixing_project_and_files_when_config_file_absent_test.go new file mode 100644 index 00000000000..656a960d6bb --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_mixing_project_and_files_when_config_file_absent_test.go @@ -0,0 +1,24 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_mixing_project_and_files_when_config_file_absent(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "mixing project and files when config file absent", + CommandLineArgs: []string{"-p", ".", "src/a.ts", "c.ts"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_mixing_project_and_files_when_config_file_absent_with_ignoreConfig_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_mixing_project_and_files_when_config_file_absent_with_ignoreConfig_test.go new file mode 100644 index 00000000000..46f2a040099 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_mixing_project_and_files_when_config_file_absent_with_ignoreConfig_test.go @@ -0,0 +1,24 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_mixing_project_and_files_when_config_file_absent_with_ignoreConfig(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "mixing project and files when config file absent with --ignoreConfig", + CommandLineArgs: []string{"-p", ".", "src/a.ts", "c.ts", "--ignoreConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_mixing_project_and_files_with_ignoreConfig_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_mixing_project_and_files_with_ignoreConfig_test.go new file mode 100644 index 00000000000..1ed4e2f45fd --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_mixing_project_and_files_with_ignoreConfig_test.go @@ -0,0 +1,27 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_mixing_project_and_files_with_ignoreConfig(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "mixing project and files with --ignoreConfig", + CommandLineArgs: []string{"-p", ".", "src/a.ts", "c.ts", "--ignoreConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "include": ["src"], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_files_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_files_test.go new file mode 100644 index 00000000000..cbc251890e6 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_files_test.go @@ -0,0 +1,27 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_specifying_files(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "specifying files", + CommandLineArgs: []string{"src/a.ts"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "include": ["src"], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_files_when_config_file_absent_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_files_when_config_file_absent_test.go new file mode 100644 index 00000000000..7f7cccd7ec3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_files_when_config_file_absent_test.go @@ -0,0 +1,24 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_specifying_files_when_config_file_absent(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "specifying files when config file absent", + CommandLineArgs: []string{"src/a.ts"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_files_when_config_file_absent_with_ignoreConfig_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_files_when_config_file_absent_with_ignoreConfig_test.go new file mode 100644 index 00000000000..e489553245d --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_files_when_config_file_absent_with_ignoreConfig_test.go @@ -0,0 +1,24 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_specifying_files_when_config_file_absent_with_ignoreConfig(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "specifying files when config file absent with --ignoreConfig", + CommandLineArgs: []string{"src/a.ts", "--ignoreConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_files_with_ignoreConfig_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_files_with_ignoreConfig_test.go new file mode 100644 index 00000000000..d4e87dab19b --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_files_with_ignoreConfig_test.go @@ -0,0 +1,27 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_specifying_files_with_ignoreConfig(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "specifying files with --ignoreConfig", + CommandLineArgs: []string{"src/a.ts", "--ignoreConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "include": ["src"], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_project_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_project_test.go new file mode 100644 index 00000000000..3fcc64dd1bf --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_project_test.go @@ -0,0 +1,27 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_specifying_project(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "specifying project", + CommandLineArgs: []string{"-p", "."}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "include": ["src"], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_project_when_config_file_absent_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_project_when_config_file_absent_test.go new file mode 100644 index 00000000000..f01fec7def0 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_project_when_config_file_absent_test.go @@ -0,0 +1,24 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_specifying_project_when_config_file_absent(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "specifying project when config file absent", + CommandLineArgs: []string{"-p", "."}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_project_when_config_file_absent_with_ignoreConfig_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_project_when_config_file_absent_with_ignoreConfig_test.go new file mode 100644 index 00000000000..f3d0de8a138 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_project_when_config_file_absent_with_ignoreConfig_test.go @@ -0,0 +1,24 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_specifying_project_when_config_file_absent_with_ignoreConfig(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "specifying project when config file absent with --ignoreConfig", + CommandLineArgs: []string{"-p", ".", "--ignoreConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_project_with_ignoreConfig_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_project_with_ignoreConfig_test.go new file mode 100644 index 00000000000..e9530a8688d --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_specifying_project_with_ignoreConfig_test.go @@ -0,0 +1,27 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_specifying_project_with_ignoreConfig(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "specifying project with --ignoreConfig", + CommandLineArgs: []string{"-p", ".", "--ignoreConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "include": ["src"], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_without_any_options_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_without_any_options_test.go new file mode 100644 index 00000000000..9b810c7d94b --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_without_any_options_test.go @@ -0,0 +1,26 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_without_any_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "without any options", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "include": ["src"], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_without_any_options_when_config_file_absent_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_without_any_options_when_config_file_absent_test.go new file mode 100644 index 00000000000..cc10c9d5a3f --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_without_any_options_when_config_file_absent_test.go @@ -0,0 +1,23 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_without_any_options_when_config_file_absent(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "without any options when config file absent", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_without_any_options_when_config_file_absent_with_ignoreConfig_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_without_any_options_when_config_file_absent_with_ignoreConfig_test.go new file mode 100644 index 00000000000..2997804477a --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_without_any_options_when_config_file_absent_with_ignoreConfig_test.go @@ -0,0 +1,24 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_without_any_options_when_config_file_absent_with_ignoreConfig(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "without any options when config file absent with --ignoreConfig", + CommandLineArgs: []string{"--ignoreConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_ignoreConfig_without_any_options_with_ignoreConfig_test.go b/internal/execute/tsctests/tests/tsc_ignoreConfig_without_any_options_with_ignoreConfig_test.go new file mode 100644 index 00000000000..afc17362e37 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_ignoreConfig_without_any_options_with_ignoreConfig_test.go @@ -0,0 +1,27 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_ignoreConfig_without_any_options_with_ignoreConfig(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "ignoreConfig", + SubScenario: "without any options with --ignoreConfig", + CommandLineArgs: []string{"--ignoreConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/c.ts": "export const c = 10;", + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "include": ["src"], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_Compile_incremental_with_case_insensitive_file_names_test.go b/internal/execute/tsctests/tests/tsc_incremental_Compile_incremental_with_case_insensitive_file_names_test.go new file mode 100644 index 00000000000..7b15afc8deb --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_Compile_incremental_with_case_insensitive_file_names_test.go @@ -0,0 +1,52 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_Compile_incremental_with_case_insensitive_file_names(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "Compile incremental with case insensitive file names", + CommandLineArgs: []string{"-p", "."}, + Cwd: "/home/project", + IgnoreCase: true, + Files: tsctests.FileMap{ + "/home/node_modules/lib1/index.d.ts": `import type { Foo } from 'someLib'; +export type { Foo as Foo1 };`, + "/home/node_modules/lib1/package.json": `{ + "name": "lib1" +}`, + "/home/node_modules/lib2/index.d.ts": `import type { Foo } from 'somelib'; +export type { Foo as Foo2 }; +export declare const foo2: Foo;`, + "/home/node_modules/lib2/package.json": `{ + "name": "lib2" +}`, + "/home/node_modules/otherLib/index.d.ts": "export type Str = string;", + "/home/node_modules/otherLib/package.json": `{ + "name": "otherlib" +}`, + "/home/node_modules/someLib/index.d.ts": `import type { Str } from 'otherLib'; +export type Foo = { foo: Str; };`, + "/home/node_modules/someLib/package.json": `{ + "name": "somelib" +}`, + "/home/project/src/index.ts": `import type { Foo1 } from 'lib1'; +import type { Foo2 } from 'lib2'; +export const foo1: Foo1 = { foo: "a" }; +export const foo2: Foo2 = { foo: "b" };`, + "/home/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_change_to_modifier_of_class_expression_field_test.go b/internal/execute/tsctests/tests/tsc_incremental_change_to_modifier_of_class_expression_field_test.go new file mode 100644 index 00000000000..455ec7a9b35 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_change_to_modifier_of_class_expression_field_test.go @@ -0,0 +1,102 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_change_to_modifier_of_class_expression_field(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "change to modifier of class expression field", + CommandLineArgs: []string{"--incremental"}, + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.d.ts": `/// +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": `const Messageable = () => { + return class MessageableClass { + public message = 'hello'; + } +}; +const wrapper = () => Messageable(); +type MessageablePerson = InstanceType>; +export default MessageablePerson;`, + "/home/src/workspaces/project/main.ts": `import MessageablePerson from './MessageablePerson.js'; +function logMessage( person: MessageablePerson ) { + console.log( person.message ); +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "module": "esnext" + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "modify public to protected", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/MessageablePerson.ts", `const Messageable = () => { + return class MessageableClass { + protected message = 'hello'; + } +}; +const wrapper = () => Messageable(); +type MessageablePerson = InstanceType>; +export default MessageablePerson;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "modify protected to public", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/MessageablePerson.ts", `const Messageable = () => { + return class MessageableClass { + public message = 'hello'; + } +}; +const wrapper = () => Messageable(); +type MessageablePerson = InstanceType>; +export default MessageablePerson;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_change_to_modifier_of_class_expression_field_with_declaration_emit_enabled_test.go b/internal/execute/tsctests/tests/tsc_incremental_change_to_modifier_of_class_expression_field_with_declaration_emit_enabled_test.go new file mode 100644 index 00000000000..740dd2cfc38 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_change_to_modifier_of_class_expression_field_with_declaration_emit_enabled_test.go @@ -0,0 +1,103 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_change_to_modifier_of_class_expression_field_with_declaration_emit_enabled(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "change to modifier of class expression field with declaration emit enabled", + CommandLineArgs: []string{"--incremental"}, + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.d.ts": `/// +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": `const Messageable = () => { + return class MessageableClass { + public message = 'hello'; + } +}; +const wrapper = () => Messageable(); +type MessageablePerson = InstanceType>; +export default MessageablePerson;`, + "/home/src/workspaces/project/main.ts": `import MessageablePerson from './MessageablePerson.js'; +function logMessage( person: MessageablePerson ) { + console.log( person.message ); +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "module": "esnext", + "declaration": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "modify public to protected", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/MessageablePerson.ts", `const Messageable = () => { + return class MessageableClass { + protected message = 'hello'; + } +}; +const wrapper = () => Messageable(); +type MessageablePerson = InstanceType>; +export default MessageablePerson;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "modify protected to public", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/MessageablePerson.ts", `const Messageable = () => { + return class MessageableClass { + public message = 'hello'; + } +}; +const wrapper = () => Messageable(); +type MessageablePerson = InstanceType>; +export default MessageablePerson;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_change_to_type_that_gets_used_as_global_through_export_in_another_file_test.go b/internal/execute/tsctests/tests/tsc_incremental_change_to_type_that_gets_used_as_global_through_export_in_another_file_test.go new file mode 100644 index 00000000000..b501ebd3a63 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_change_to_type_that_gets_used_as_global_through_export_in_another_file_test.go @@ -0,0 +1,36 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_change_to_type_that_gets_used_as_global_through_export_in_another_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "change to type that gets used as global through export in another file", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/class1.ts": `const a: MagicNumber = 1; +console.log(a);`, + "/home/src/workspaces/project/constants.ts": "export default 1;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true + } +}`, + "/home/src/workspaces/project/types.d.ts": "type MagicNumber = typeof import('./constants').default", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Modify imports used in global file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/constants.ts", "export default 2;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_change_to_type_that_gets_used_as_global_through_export_in_another_file_through_indirect_import_test.go b/internal/execute/tsctests/tests/tsc_incremental_change_to_type_that_gets_used_as_global_through_export_in_another_file_through_indirect_import_test.go new file mode 100644 index 00000000000..3585dbd809b --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_change_to_type_that_gets_used_as_global_through_export_in_another_file_through_indirect_import_test.go @@ -0,0 +1,37 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_change_to_type_that_gets_used_as_global_through_export_in_another_file_through_indirect_import(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "change to type that gets used as global through export in another file through indirect import", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/class1.ts": `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/tsconfig.json": `{ + "compilerOptions": { + "composite": true + } +}`, + "/home/src/workspaces/project/types.d.ts": "type MagicNumber = typeof import('./reexport').ConstantNumber", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Modify imports used in global file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/constants.ts", "export default 2;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_const_enums_aliased_in_different_file_test.go b/internal/execute/tsctests/tests/tsc_incremental_const_enums_aliased_in_different_file_test.go new file mode 100644 index 00000000000..1eeab88f8eb --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_const_enums_aliased_in_different_file_test.go @@ -0,0 +1,62 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_const_enums_aliased_in_different_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "const enums aliased in different file", + CommandLineArgs: []string{"-i", "a.ts", "--tsbuildinfofile", "a.tsbuildinfo"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": `import {A} from "./c" +let a = A.ONE`, + "/home/src/workspaces/project/b.d.ts": "export { AWorker as A } from \"./worker\";", + "/home/src/workspaces/project/c.ts": `import {A} from "./b" +let b = A.ONE +export {A}`, + "/home/src/workspaces/project/worker.d.ts": `export const enum AWorker { + ONE = 1 +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "change enum value", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/worker.d.ts", `export const enum AWorker { + ONE = 2 +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "change enum value again", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/worker.d.ts", `export const enum AWorker { + ONE = 3 +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "something else changes in b.d.ts", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/b.d.ts", "export { AWorker as A } from \"./worker\";export const randomThing = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "something else changes in b.d.ts again", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/b.d.ts", "export { AWorker as A } from \"./worker\";export const randomThing = 10;export const randomThing2 = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_const_enums_aliased_test.go b/internal/execute/tsctests/tests/tsc_incremental_const_enums_aliased_test.go new file mode 100644 index 00000000000..234a07dfbea --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_const_enums_aliased_test.go @@ -0,0 +1,73 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_const_enums_aliased(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "const enums aliased", + CommandLineArgs: []string{"-i", "a.ts", "--tsbuildinfofile", "a.tsbuildinfo"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": `import {A} from "./c" +let a = A.ONE`, + "/home/src/workspaces/project/b.d.ts": `export const enum AWorker { + ONE = 1 +} +export { AWorker as A };`, + "/home/src/workspaces/project/c.ts": `import {A} from "./b" +let b = A.ONE +export {A}`, + "/home/src/workspaces/project/worker.d.ts": `export const enum AWorker { + ONE = 1 +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "change enum value", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/b.d.ts", `export const enum AWorker { + ONE = 2 +} +export { AWorker as A };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "change enum value again", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/b.d.ts", `export const enum AWorker { + ONE = 3 +} +export { AWorker as A };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "something else changes in b.d.ts", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/b.d.ts", `export const enum AWorker { + ONE = 3 +} +export { AWorker as A };export const randomThing = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "something else changes in b.d.ts again", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/b.d.ts", `export const enum AWorker { + ONE = 3 +} +export { AWorker as A };export const randomThing = 10;export const randomThing2 = 10;`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_const_enums_test.go b/internal/execute/tsctests/tests/tsc_incremental_const_enums_test.go new file mode 100644 index 00000000000..50efce785c4 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_const_enums_test.go @@ -0,0 +1,68 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_const_enums(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "const enums", + CommandLineArgs: []string{"-i", "a.ts", "--tsbuildinfofile", "a.tsbuildinfo"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": `import {A} from "./c" +let a = A.ONE`, + "/home/src/workspaces/project/b.d.ts": `export const enum A { + ONE = 1 +}`, + "/home/src/workspaces/project/c.ts": `import {A} from "./b" +let b = A.ONE +export {A}`, + "/home/src/workspaces/project/worker.d.ts": `export const enum AWorker { + ONE = 1 +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "change enum value", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/b.d.ts", `export const enum A { + ONE = 2 +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "change enum value again", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/b.d.ts", `export const enum A { + ONE = 3 +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "something else changes in b.d.ts", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/b.d.ts", `export const enum A { + ONE = 3 +}export const randomThing = 10;`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "something else changes in b.d.ts again", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/b.d.ts", `export const enum A { + ONE = 3 +}export const randomThing = 10;export const randomThing2 = 10;`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_const_enums_with_refCycle_test.go b/internal/execute/tsctests/tests/tsc_incremental_const_enums_with_refCycle_test.go new file mode 100644 index 00000000000..aeee1bbda1a --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_const_enums_with_refCycle_test.go @@ -0,0 +1,56 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_const_enums_with_refCycle(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "const enums with refCycle", + CommandLineArgs: []string{}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/aworker.ts": "export const AWorker = 10", + "/home/src/workspaces/project/b.ts": `import { AWorker } from "./aworker" +import { A as ACycle } from "./c" +export const enum A { + ONE = 1 +}`, + "/home/src/workspaces/project/c.ts": `import {A} from "./b" +let b = A.ONE +export {A}`, + "/home/src/workspaces/project/file.ts": `import {A} from "./c" +let a = A.ONE`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "change aworker", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/aworker.ts", "export const AWorker = 20") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "change aworker and enum value", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/aworker.ts", "export const AWorker = 30") + sys.WriteFile("/home/src/workspaces/project/b.ts", `import { AWorker } from "./aworker" +import { A as ACycle } from "./c" +export const enum A { + ONE = 2 +}`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_generates_typerefs_correctly_test.go b/internal/execute/tsctests/tests/tsc_incremental_generates_typerefs_correctly_test.go new file mode 100644 index 00000000000..768810b4c3b --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_generates_typerefs_correctly_test.go @@ -0,0 +1,76 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_generates_typerefs_correctly(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "generates typerefs correctly", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/box.ts": `export interface Box { + unbox(): T +}`, + "/home/src/workspaces/project/src/bug.js": `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": `export type Wrap = { + [K in keyof C]: { wrapped: C[K] } +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "outDir", + "checkJs": true + }, + "include": ["src"], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "modify js file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/bug.js", `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;`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_internal_symbolname_in_tsbuildInfo_test.go b/internal/execute/tsctests/tests/tsc_incremental_internal_symbolname_in_tsbuildInfo_test.go new file mode 100644 index 00000000000..965d52e6886 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_internal_symbolname_in_tsbuildInfo_test.go @@ -0,0 +1,121 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_internal_symbolname_in_tsbuildInfo(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "internal symbolname in tsbuildInfo", + CommandLineArgs: []string{""}, + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.es2015.iterable.d.ts": `interface SymbolConstructor { + readonly iterator: unique symbol; +} +interface IteratorYieldResult { + done?: false; + value: TYield; +} +interface IteratorReturnResult { + done: true; + value: TReturn; +} +type IteratorResult = IteratorYieldResult | IteratorReturnResult; +interface Iterator { + // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. + next(...[value]: [] | [TNext]): IteratorResult; + return?(value?: TReturn): IteratorResult; + throw?(e?: any): IteratorResult; +} +interface Iterable { + [Symbol.iterator](): Iterator; +} +interface IterableIterator extends Iterator { + [Symbol.iterator](): IterableIterator; +} +interface IteratorObject extends Iterator { + [Symbol.iterator](): IteratorObject; +} +type BuiltinIteratorReturn = intrinsic; +interface ArrayIterator extends IteratorObject { + [Symbol.iterator](): ArrayIterator; +} +interface Array { + [Symbol.iterator](): ArrayIterator; + entries(): ArrayIterator<[number, T]>; + keys(): ArrayIterator; + values(): ArrayIterator; +}`, + "/home/src/tslibs/TS/Lib/lib.es2017.full.d.ts": `/// +interface File { +} +interface FileList { + readonly length: number; + item(index: number): File | null; + [index: number]: File; + [Symbol.iterator](): ArrayIterator; +}/// +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.ts": `const createFileListFromFiles = (files: File[]): FileList => { +const fileList: FileList = { + length: files.length, + item: (index: number): File | null => files[index] || null, + [Symbol.iterator]: function* (): IterableIterator { + for (const file of files) yield file; + }, + ...files, +} as unknown as FileList; + +return fileList; +};`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "target": "es2017", + "strict": true, + "esModuleInterop": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change with incremental", + CommandLineArgs: []string{"--incremental"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change with incremental that reads buildInfo", + CommandLineArgs: []string{"--incremental"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_js_file_with_import_in_jsdoc_in_composite_project_test.go b/internal/execute/tsctests/tests/tsc_incremental_js_file_with_import_in_jsdoc_in_composite_project_test.go new file mode 100644 index 00000000000..da52244e131 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_js_file_with_import_in_jsdoc_in_composite_project_test.go @@ -0,0 +1,44 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_js_file_with_import_in_jsdoc_in_composite_project(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "js file with import in jsdoc in composite project", + CommandLineArgs: []string{"--noEmit"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.js": `test("", async function () { + ;(/** @type {typeof import("a")} */ ({})) +}) + +test("", async function () { + ;(/** @type {typeof import("a")} */ a) +}) + +test("", async function () { + (/** @type {typeof import("a")} */ ({})) + ;(/** @type {typeof import("a")} */ ({})) +}) + +test("", async function () { + (/** @type {typeof import("a")} */ a) + ;(/** @type {typeof import("a")} */ a) +}) + +test("", async function () { + (/** @type {typeof import("a")} */ ({})) + ;(/** @type {typeof import("a")} */ ({})) +})`, + "/home/src/workspaces/project/tsconfig.json": "{\"compilerOptions\": {\"allowJs\": true, \"composite\": true}}", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_option_changes_with_composite_test.go b/internal/execute/tsctests/tests/tsc_incremental_option_changes_with_composite_test.go new file mode 100644 index 00000000000..cfbec6a4a23 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_option_changes_with_composite_test.go @@ -0,0 +1,103 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_option_changes_with_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "option changes with composite", + Files: tsctests.FileMap{ + "/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;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "with sourceMap", + CommandLineArgs: []string{"--sourceMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "should re-emit only js so they dont contain sourcemap", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration should not emit anything", + CommandLineArgs: []string{"--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration and declarationMap", + CommandLineArgs: []string{"--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "should re-emit only dts so they dont contain sourcemap", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with emitDeclarationOnly should not emit anything", + CommandLineArgs: []string{"--emitDeclarationOnly"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = 10;const aLocal = 100;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration should not emit anything", + CommandLineArgs: []string{"--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with inlineSourceMap", + CommandLineArgs: []string{"--inlineSourceMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with sourceMap", + CommandLineArgs: []string{"--sourceMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "declarationMap enabling", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.json", `{ + "compilerOptions": { + "composite": true, "declarationMap": true + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with sourceMap should not emit d.ts", + CommandLineArgs: []string{"--sourceMap"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_option_changes_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_incremental_option_changes_with_incremental_test.go new file mode 100644 index 00000000000..d5858f65753 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_option_changes_with_incremental_test.go @@ -0,0 +1,92 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_option_changes_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "option changes with incremental", + Files: tsctests.FileMap{ + "/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;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "with sourceMap", + CommandLineArgs: []string{"--sourceMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "should re-emit only js so they dont contain sourcemap", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration, emit Dts and should not emit js", + CommandLineArgs: []string{"--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration and declarationMap", + CommandLineArgs: []string{"--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "local change", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = 10;const aLocal = 100;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration and declarationMap", + CommandLineArgs: []string{"--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with inlineSourceMap", + CommandLineArgs: []string{"--inlineSourceMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with sourceMap", + CommandLineArgs: []string{"--sourceMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "emit js files", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration and declarationMap", + CommandLineArgs: []string{"--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "with declaration and declarationMap, should not re-emit", + CommandLineArgs: []string{"--declaration", "--declarationMap"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_react_jsx_emit_mode_with_no_backing_types_found_doesnt_crash_test.go b/internal/execute/tsctests/tests/tsc_incremental_react_jsx_emit_mode_with_no_backing_types_found_doesnt_crash_test.go new file mode 100644 index 00000000000..fd36585d4b8 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_react_jsx_emit_mode_with_no_backing_types_found_doesnt_crash_test.go @@ -0,0 +1,41 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_react_jsx_emit_mode_with_no_backing_types_found_doesnt_crash(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "react-jsx-emit-mode with no backing types found doesnt crash", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/node_modules/@types/react/index.d.ts": `export {}; +declare global { + namespace JSX { + interface Element {} + interface IntrinsicElements { + div: { + propA?: boolean; + }; + } + } +}`, + "/home/src/workspaces/project/node_modules/react/jsx-runtime.js": "export {}", + "/home/src/workspaces/project/src/index.tsx": "export const App = () =>
;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "module": "commonjs", + "jsx": "react-jsx", + "incremental": true, + "jsxImportSource": "react" + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_react_jsx_emit_mode_with_no_backing_types_found_doesnt_crash_under_strict_test.go b/internal/execute/tsctests/tests/tsc_incremental_react_jsx_emit_mode_with_no_backing_types_found_doesnt_crash_under_strict_test.go new file mode 100644 index 00000000000..bb4f8e7a78a --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_react_jsx_emit_mode_with_no_backing_types_found_doesnt_crash_under_strict_test.go @@ -0,0 +1,42 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_react_jsx_emit_mode_with_no_backing_types_found_doesnt_crash_under_strict(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "react-jsx-emit-mode with no backing types found doesnt crash under --strict", + CommandLineArgs: []string{"--strict"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/node_modules/@types/react/index.d.ts": `export {}; +declare global { + namespace JSX { + interface Element {} + interface IntrinsicElements { + div: { + propA?: boolean; + }; + } + } +}`, + "/home/src/workspaces/project/node_modules/react/jsx-runtime.js": "export {}", + "/home/src/workspaces/project/src/index.tsx": "export const App = () =>
;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "module": "commonjs", + "jsx": "react-jsx", + "incremental": true, + "jsxImportSource": "react" + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_serializing_composite_project_test.go b/internal/execute/tsctests/tests/tsc_incremental_serializing_composite_project_test.go new file mode 100644 index 00000000000..b22da0b5bba --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_serializing_composite_project_test.go @@ -0,0 +1,29 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_serializing_composite_project(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "serializing composite project", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.tsx": "export const a = 1;", + "/home/src/workspaces/project/other.ts": "export const b = 2;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "strict": true, + "module": "esnext", + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_serializing_error_chain_test.go b/internal/execute/tsctests/tests/tsc_incremental_serializing_error_chain_test.go new file mode 100644 index 00000000000..72d528a6eff --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_serializing_error_chain_test.go @@ -0,0 +1,45 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_serializing_error_chain(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "serializing error chain", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/index.tsx": `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": `{ + "compilerOptions": { + "incremental": true, + "strict": true, + "jsx": "react", + "module": "esnext", + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_tsbuildinfo_has_error_test.go b/internal/execute/tsctests/tests/tsc_incremental_tsbuildinfo_has_error_test.go new file mode 100644 index 00000000000..6c8aa4837f5 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_tsbuildinfo_has_error_test.go @@ -0,0 +1,31 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_tsbuildinfo_has_error(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "tsbuildinfo has error", + CommandLineArgs: []string{"-i"}, + Files: tsctests.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", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "tsbuildinfo written has error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/tsconfig.tsbuildinfo", "Some random string{\"version\":\"FakeTSVersion\",\"root\":[2],\"fileNames\":[\"lib.es2025.full.d.ts\",\"./main.ts\"],\"fileInfos\":[{\"version\":\"8859c12c614ce56ba9a18e58384a198f-/// \\ninterface Boolean {}\\ninterface Function {}\\ninterface CallableFunction {}\\ninterface NewableFunction {}\\ninterface IArguments {}\\ninterface Number { toExponential: any; }\\ninterface Object {}\\ninterface RegExp {}\\ninterface String { charAt: any; }\\ninterface Array { length: number; [n: number]: T; }\\ninterface ReadonlyArray {}\\ninterface SymbolConstructor {\\n (desc?: string | number): symbol;\\n for(name: string): symbol;\\n readonly toStringTag: symbol;\\n}\\ndeclare var Symbol: SymbolConstructor;\\ninterface Symbol {\\n readonly [Symbol.toStringTag]: string;\\n}\\ndeclare const console: { log(msg: any): void; };\",\"affectsGlobalScope\":true,\"impliedNodeFormat\":1},\"28e8748a7acd58f4f59388926e914f86-export const x = 10;\"]}") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_when_file_is_deleted_test.go b/internal/execute/tsctests/tests/tsc_incremental_when_file_is_deleted_test.go new file mode 100644 index 00000000000..9220dcbd1b4 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_when_file_is_deleted_test.go @@ -0,0 +1,35 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_when_file_is_deleted(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "when file is deleted", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/file1.ts": "export class C { }", + "/home/src/workspaces/project/file2.ts": "export class D { }", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "outDir" + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete file with imports", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/file2.ts") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_when_global_file_is_added_the_signatures_are_updated_test.go b/internal/execute/tsctests/tests/tsc_incremental_when_global_file_is_added_the_signatures_are_updated_test.go new file mode 100644 index 00000000000..2757cf9583d --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_when_global_file_is_added_the_signatures_are_updated_test.go @@ -0,0 +1,82 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_when_global_file_is_added_the_signatures_are_updated(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "when global file is added, the signatures are updated", + CommandLineArgs: []string{}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/anotherFileWithSameReferenes.ts": `/// +/// +function anotherFileWithSameReferenes() { }`, + "/home/src/workspaces/project/src/filePresent.ts": "function something() { return 10; }", + "/home/src/workspaces/project/src/main.ts": `/// +/// +function main() { }`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "composite": true }, + "include": ["src/**/*.ts"], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Modify main file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/main.ts", `/// +/// +function main() { }something();`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Modify main file again", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/main.ts", `/// +/// +function main() { }something();something();`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add new file and update main file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/main.ts", `/// +/// +/// +function main() { }something();something();foo();`) + sys.WriteFile("/home/src/workspaces/project/src/newFile.ts", "function foo() { return 20; }") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Write file that could not be resolved", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/fileNotFound.ts", "function something2() { return 20; }") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Modify main file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/main.ts", `/// +/// +/// +function main() { }something();something();foo();something();`) + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_when_passing_filename_for_buildinfo_on_commandline_test.go b/internal/execute/tsctests/tests/tsc_incremental_when_passing_filename_for_buildinfo_on_commandline_test.go new file mode 100644 index 00000000000..cb693f81aea --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_when_passing_filename_for_buildinfo_on_commandline_test.go @@ -0,0 +1,35 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_when_passing_filename_for_buildinfo_on_commandline(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "when passing filename for buildinfo on commandline", + CommandLineArgs: []string{"--incremental", "--tsBuildInfoFile", ".tsbuildinfo", "--explainFiles"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/main.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "target": "es5", + "module": "commonjs" + }, + "include": [ + "src/**/*.ts" + ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_when_passing_rootDir_from_commandline_test.go b/internal/execute/tsctests/tests/tsc_incremental_when_passing_rootDir_from_commandline_test.go new file mode 100644 index 00000000000..b983a9cdf02 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_when_passing_rootDir_from_commandline_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_when_passing_rootDir_from_commandline(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "when passing rootDir from commandline", + CommandLineArgs: []string{"--rootDir", "src"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/main.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "outDir": "dist" + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_when_passing_rootDir_is_in_the_tsconfig_test.go b/internal/execute/tsctests/tests/tsc_incremental_when_passing_rootDir_is_in_the_tsconfig_test.go new file mode 100644 index 00000000000..0a86a64171f --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_when_passing_rootDir_is_in_the_tsconfig_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_when_passing_rootDir_is_in_the_tsconfig(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "when passing rootDir is in the tsconfig", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/main.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "outDir": "dist", + "rootDir": "./" + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_when_there_is_bind_diagnostics_thats_ignored_test.go b/internal/execute/tsctests/tests/tsc_incremental_when_there_is_bind_diagnostics_thats_ignored_test.go new file mode 100644 index 00000000000..61ab11e149c --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_when_there_is_bind_diagnostics_thats_ignored_test.go @@ -0,0 +1,42 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_when_there_is_bind_diagnostics_thats_ignored(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "when there is bind diagnostics thats ignored", + CommandLineArgs: []string{""}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a = 10;", + "/home/src/workspaces/project/b.d.ts": `interface NoName { + Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => { + stop: () => Promise; + }; +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "skipLibCheck": true, + "incremental": true, + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change and tsc -b", + CommandLineArgs: []string{"-b", "-v"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_incremental_with_only_dts_files_test.go b/internal/execute/tsctests/tests/tsc_incremental_with_only_dts_files_test.go new file mode 100644 index 00000000000..5032d6e1659 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_incremental_with_only_dts_files_test.go @@ -0,0 +1,35 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_incremental_with_only_dts_files(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "incremental", + SubScenario: "with only dts files", + CommandLineArgs: []string{"--incremental"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/another.d.ts": "export const y = 10;", + "/home/src/workspaces/project/src/main.d.ts": "export const x = 10;", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "modify d.ts file", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/main.d.ts", "export const x = 10;export const xy = 100;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_libraryResolution_unknown_lib_test.go b/internal/execute/tsctests/tests/tsc_libraryResolution_unknown_lib_test.go new file mode 100644 index 00000000000..54f637eaf62 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_libraryResolution_unknown_lib_test.go @@ -0,0 +1,38 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_libraryResolution_unknown_lib(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "libraryResolution", + SubScenario: "unknown lib", + CommandLineArgs: []string{"-p", "project1", "--explainFiles"}, + Cwd: "/home/src/workspace/projects", + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.scripthost.d.ts": "interface ScriptHostInterface { }", + "/home/src/tslibs/TS/Lib/lib.webworker.d.ts": "interface WebWorkerInterface { }", + "/home/src/workspace/projects/project1/core.d.ts": "export const core = 10;", + "/home/src/workspace/projects/project1/file.ts": "export const file = 10;", + "/home/src/workspace/projects/project1/file2.ts": `/// +/// +/// `, + "/home/src/workspace/projects/project1/index.ts": "export const x = \"type1\";", + "/home/src/workspace/projects/project1/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "traceResolution": true, + "libReplacement": true + } +}`, + "/home/src/workspace/projects/project1/utils.d.ts": "export const y = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_libraryResolution_when_noLib_toggles_test.go b/internal/execute/tsctests/tests/tsc_libraryResolution_when_noLib_toggles_test.go new file mode 100644 index 00000000000..c40e6e14d50 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_libraryResolution_when_noLib_toggles_test.go @@ -0,0 +1,34 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_libraryResolution_when_noLib_toggles(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "libraryResolution", + SubScenario: "when noLib toggles", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.d.ts": "declare const a = \"hello\";", + "/home/src/workspaces/project/b.ts": "const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "incremental": true, + "lib": ["es6"], + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "with --noLib", + CommandLineArgs: []string{"--noLib"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_libraryResolution_with_config_test.go b/internal/execute/tsctests/tests/tsc_libraryResolution_with_config_test.go new file mode 100644 index 00000000000..20bd8b46435 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_libraryResolution_with_config_test.go @@ -0,0 +1,73 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_libraryResolution_with_config(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "libraryResolution", + SubScenario: "with config", + CommandLineArgs: []string{"-p", "project1", "--explainFiles"}, + Cwd: "/home/src/workspace/projects", + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.dom.d.ts": "interface DOMInterface { }", + "/home/src/tslibs/TS/Lib/lib.scripthost.d.ts": "interface ScriptHostInterface { }", + "/home/src/tslibs/TS/Lib/lib.webworker.d.ts": "interface WebWorkerInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/unlreated/index.d.ts": "export const unrelated = 10;", + "/home/src/workspace/projects/project1/core.d.ts": "export const core = 10;", + "/home/src/workspace/projects/project1/file.ts": "export const file = 10;", + "/home/src/workspace/projects/project1/file2.ts": `/// +/// +/// `, + "/home/src/workspace/projects/project1/index.ts": "export const x = \"type1\";", + "/home/src/workspace/projects/project1/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "typeRoots": ["./typeroot1"], + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": false + } +}`, + "/home/src/workspace/projects/project1/typeroot1/sometype/index.d.ts": "export type TheNum = \"type1\";", + "/home/src/workspace/projects/project1/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project2/index.ts": "export const y = 10", + "/home/src/workspace/projects/project2/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": false + } +}`, + "/home/src/workspace/projects/project2/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project3/index.ts": "export const z = 10", + "/home/src/workspace/projects/project3/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": false + } +}`, + "/home/src/workspace/projects/project3/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project4/index.ts": "export const z = 10", + "/home/src/workspace/projects/project4/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["esnext", "dom", "webworker"], + "traceResolution": true, + "libReplacement": false + } +}`, + "/home/src/workspace/projects/project4/utils.d.ts": "export const y = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_libraryResolution_with_config_with_libReplacement_test.go b/internal/execute/tsctests/tests/tsc_libraryResolution_with_config_with_libReplacement_test.go new file mode 100644 index 00000000000..f6fe0765745 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_libraryResolution_with_config_with_libReplacement_test.go @@ -0,0 +1,120 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_libraryResolution_with_config_with_libReplacement(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "libraryResolution", + SubScenario: "with config with libReplacement", + CommandLineArgs: []string{"-p", "project1", "--explainFiles"}, + Cwd: "/home/src/workspace/projects", + Files: tsctests.FileMap{ + "/home/src/tslibs/TS/Lib/lib.dom.d.ts": "interface DOMInterface { }", + "/home/src/tslibs/TS/Lib/lib.scripthost.d.ts": "interface ScriptHostInterface { }", + "/home/src/tslibs/TS/Lib/lib.webworker.d.ts": "interface WebWorkerInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/lib-dom/index.d.ts": "interface DOMInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/lib-es5/index.d.ts": `/// +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/workspace/projects/node_modules/@typescript/lib-esnext/index.d.ts": `/// +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/workspace/projects/node_modules/@typescript/lib-scripthost/index.d.ts": "interface ScriptHostInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/lib-webworker/index.d.ts": "interface WebWorkerInterface { }", + "/home/src/workspace/projects/node_modules/@typescript/unlreated/index.d.ts": "export const unrelated = 10;", + "/home/src/workspace/projects/project1/core.d.ts": "export const core = 10;", + "/home/src/workspace/projects/project1/file.ts": "export const file = 10;", + "/home/src/workspace/projects/project1/file2.ts": `/// +/// +/// `, + "/home/src/workspace/projects/project1/index.ts": "export const x = \"type1\";", + "/home/src/workspace/projects/project1/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "typeRoots": ["./typeroot1"], + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": true + } +}`, + "/home/src/workspace/projects/project1/typeroot1/sometype/index.d.ts": "export type TheNum = \"type1\";", + "/home/src/workspace/projects/project1/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project2/index.ts": "export const y = 10", + "/home/src/workspace/projects/project2/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": true + } +}`, + "/home/src/workspace/projects/project2/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project3/index.ts": "export const z = 10", + "/home/src/workspace/projects/project3/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["es5", "dom"], + "traceResolution": true, + "libReplacement": true + } +}`, + "/home/src/workspace/projects/project3/utils.d.ts": "export const y = 10;", + "/home/src/workspace/projects/project4/index.ts": "export const z = 10", + "/home/src/workspace/projects/project4/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "lib": ["esnext", "dom", "webworker"], + "traceResolution": true, + "libReplacement": true + } +}`, + "/home/src/workspace/projects/project4/utils.d.ts": "export const y = 10;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_listFilesOnly_combined_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_listFilesOnly_combined_with_incremental_test.go new file mode 100644 index 00000000000..1bbd1fcbe50 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_listFilesOnly_combined_with_incremental_test.go @@ -0,0 +1,37 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_listFilesOnly_combined_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "listFilesOnly", + SubScenario: "combined with incremental", + CommandLineArgs: []string{"--incremental", "--listFilesOnly"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/test.ts": "export const x = 1;", + "/home/src/workspaces/project/tsconfig.json": "{}", + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental actual build", + CommandLineArgs: []string{"--incremental"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "incremental should not build", + CommandLineArgs: []string{"--incremental"}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_listFilesOnly_loose_file_test.go b/internal/execute/tsctests/tests/tsc_listFilesOnly_loose_file_test.go new file mode 100644 index 00000000000..46cf6812f36 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_listFilesOnly_loose_file_test.go @@ -0,0 +1,22 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_listFilesOnly_loose_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "listFilesOnly", + SubScenario: "loose file", + CommandLineArgs: []string{"test.ts", "--listFilesOnly"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/test.ts": "export const x = 1;", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_moduleResolution_alternateResult_test.go b/internal/execute/tsctests/tests/tsc_moduleResolution_alternateResult_test.go new file mode 100644 index 00000000000..31493af0e3c --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_moduleResolution_alternateResult_test.go @@ -0,0 +1,250 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_moduleResolution_alternateResult(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleResolution", + SubScenario: "alternateResult", + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/index.mts": `import { foo } from "foo"; +import { bar } from "bar"; +import { foo2 } from "foo2"; +import { bar2 } from "bar2";`, + "/home/src/projects/project/node_modules/@types/bar/index.d.ts": "export declare const bar: number;", + "/home/src/projects/project/node_modules/@types/bar/package.json": `{ + "name": "@types/bar", + "version": "1.0.0", + "types": "index.d.ts", + "exports": { + ".": { + + "require": "./index.d.ts" + } + } +}`, + "/home/src/projects/project/node_modules/@types/bar2/index.d.ts": "export declare const bar2: number;", + "/home/src/projects/project/node_modules/@types/bar2/package.json": `{ + "name": "@types/bar2", + "version": "1.0.0", + "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "require": "./index.d.ts" + } + } +}`, + "/home/src/projects/project/node_modules/bar/index.js": "module.exports = { bar: 1 };", + "/home/src/projects/project/node_modules/bar/index.mjs": "export const bar = 1;", + "/home/src/projects/project/node_modules/bar/package.json": `{ + "name": "bar", + "version": "1.0.0", + "main": "index.js", + + "exports": { + ".": { + + "import": "./index.mjs", + "require": "./index.js" + } + } +}`, + "/home/src/projects/project/node_modules/bar2/index.js": "module.exports = { bar2: 1 };", + "/home/src/projects/project/node_modules/bar2/index.mjs": "export const bar2 = 1;", + "/home/src/projects/project/node_modules/bar2/package.json": `{ + "name": "bar2", + "version": "1.0.0", + "main": "index.js", + + "exports": { + ".": { + + "import": "./index.mjs", + "require": "./index.js" + } + } +}`, + "/home/src/projects/project/node_modules/foo/index.d.ts": "export declare const foo: number;", + "/home/src/projects/project/node_modules/foo/index.js": "module.exports = { foo: 1 };", + "/home/src/projects/project/node_modules/foo/index.mjs": "export const foo = 1;", + "/home/src/projects/project/node_modules/foo/package.json": `{ + "name": "foo", + "version": "1.0.0", + "main": "index.js", + "types": "index.d.ts", + "exports": { + ".": { + + "import": "./index.mjs", + "require": "./index.js" + } + } +}`, + "/home/src/projects/project/node_modules/foo2/index.d.ts": "export declare const foo2: number;", + "/home/src/projects/project/node_modules/foo2/index.js": "module.exports = { foo2: 1 };", + "/home/src/projects/project/node_modules/foo2/index.mjs": "export const foo2 = 1;", + "/home/src/projects/project/node_modules/foo2/package.json": `{ + "name": "foo2", + "version": "1.0.0", + "main": "index.js", + "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./index.mjs", + "require": "./index.js" + } + } +}`, + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "module": "node16", + "moduleResolution": "node16", + "traceResolution": true, + "incremental": true, + "strict": true, + "types": [], + }, + "files": ["index.mts"], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete the alternateResult in @types", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/projects/project/node_modules/@types/bar/index.d.ts") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete the node10Result in package/types", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/projects/project/node_modules/foo/index.d.ts") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "add the alternateResult in @types", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/node_modules/@types/bar/index.d.ts", "export declare const bar: number;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "add the alternateResult in package/types", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/node_modules/foo/index.d.ts", "export declare const foo: number;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "update package.json from @types so error is fixed", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/node_modules/@types/bar/package.json", `{ + "name": "@types/bar", + "version": "1.0.0", + "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "require": "./index.d.ts" + } + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "update package.json so error is fixed", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/node_modules/foo/package.json", `{ + "name": "foo", + "version": "1.0.0", + "main": "index.js", + "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./index.mjs", + "require": "./index.js" + } + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "update package.json from @types so error is introduced", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/node_modules/@types/bar2/package.json", `{ + "name": "@types/bar2", + "version": "1.0.0", + "types": "index.d.ts", + "exports": { + ".": { + + "require": "./index.d.ts" + } + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "update package.json so error is introduced", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/node_modules/foo2/package.json", `{ + "name": "foo2", + "version": "1.0.0", + "main": "index.js", + "types": "index.d.ts", + "exports": { + ".": { + + "import": "./index.mjs", + "require": "./index.js" + } + } +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete the alternateResult in @types", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/projects/project/node_modules/@types/bar2/index.d.ts") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete the node10Result in package/types", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/projects/project/node_modules/foo2/index.d.ts") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "add the alternateResult in @types", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/node_modules/@types/bar2/index.d.ts", "export declare const bar2: number;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "add the ndoe10Result in package/types", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/node_modules/foo2/index.d.ts", "export declare const foo2: number;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_moduleResolution_package_json_scope_test.go b/internal/execute/tsctests/tests/tsc_moduleResolution_package_json_scope_test.go new file mode 100644 index 00000000000..6581bee19b8 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_moduleResolution_package_json_scope_test.go @@ -0,0 +1,49 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_moduleResolution_package_json_scope(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleResolution", + SubScenario: "package json scope", + CommandLineArgs: []string{"-p", "src", "--explainFiles", "--extendedDiagnostics"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/package.json": `{ + "name": "app", + "version": "1.0.0" +}`, + "/home/src/workspaces/project/src/fileA.ts": `import { foo } from "./fileB.mjs"; +foo();`, + "/home/src/workspaces/project/src/fileB.mts": "export function foo() {}", + "/home/src/workspaces/project/src/main.ts": "export const x = 10;", + "/home/src/workspaces/project/src/tsconfig.json": `{ + "compilerOptions": { + "target": "ES2016", + "composite": true, + "module": "Node16", + "traceResolution": true, + }, + "files": [ + "main.ts", + "fileA.ts", + "fileB.mts", + ], +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "Delete package.json", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/package.json") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_moduleResolution_pnpm_style_layout_test.go b/internal/execute/tsctests/tests/tsc_moduleResolution_pnpm_style_layout_test.go new file mode 100644 index 00000000000..0a68c52f4db --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_moduleResolution_pnpm_style_layout_test.go @@ -0,0 +1,117 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +func TestTsc_moduleResolution_pnpm_style_layout(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "moduleResolution", + SubScenario: "pnpm style layout", + CommandLineArgs: []string{"--traceResolution", "--explainFiles"}, + Cwd: "/home/src/projects/component-type-checker/packages/app", + Files: tsctests.FileMap{ + "/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.1/node_modules/@component-type-checker/button/package.json": `{ + "name": "@component-type-checker/button", + "version": "0.0.1", + "main": "./src/index.ts" +}`, + "/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.1/node_modules/@component-type-checker/button/src/index.ts": `export interface Button { + a: number; + b: number; +} +export function createButton(): Button { + return { + a: 0, + b: 1, + }; +}`, + "/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button/package.json": `{ + "name": "@component-type-checker/button", + "version": "0.0.2", + "main": "./src/index.ts" +}`, + "/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button/src/index.ts": `export interface Button { + a: number; + c: number; +} +export function createButton(): Button { + return { + a: 0, + c: 2, + }; +}`, + "/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/button": vfstest.Symlink("/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.1/node_modules/@component-type-checker/button"), + "/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/components/package.json": `{ + "name": "@component-type-checker/components", + "version": "0.0.1", + "main": "./src/index.ts", + "peerDependencies": { + "@component-type-checker/button": "*" + }, + "devDependencies": { + "@component-type-checker/button": "0.0.2" + } +}`, + "/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/components/src/index.ts": "export { createButton, Button } from \"@component-type-checker/button\";", + "/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button": vfstest.Symlink("/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button"), + "/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/components/package.json": `{ + "name": "@component-type-checker/components", + "version": "0.0.1", + "main": "./src/index.ts", + "peerDependencies": { + "@component-type-checker/button": "*" + }, + "devDependencies": { + "@component-type-checker/button": "0.0.2" + } +}`, + "/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/components/src/index.ts": "export { createButton, Button } from \"@component-type-checker/button\";", + "/home/src/projects/component-type-checker/packages/app/node_modules/@component-type-checker/button": vfstest.Symlink("/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button"), + "/home/src/projects/component-type-checker/packages/app/node_modules/@component-type-checker/components": vfstest.Symlink("/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/components"), + "/home/src/projects/component-type-checker/packages/app/node_modules/@component-type-checker/sdk": vfstest.Symlink("/home/src/projects/component-type-checker/packages/sdk"), + "/home/src/projects/component-type-checker/packages/app/package.json": `{ + "name": "app", + "version": "1.0.0", + "dependencies": { + "@component-type-checker/button": "0.0.2", + "@component-type-checker/components": "0.0.1", + "@component-type-checker/sdk": "0.0.2" + } +}`, + "/home/src/projects/component-type-checker/packages/app/src/app.tsx": `import { VERSION } from "@component-type-checker/sdk"; +import { Button } from "@component-type-checker/components"; +import { createButton } from "@component-type-checker/button"; +const button: Button = createButton();`, + "/home/src/projects/component-type-checker/packages/app/tsconfig.json": `{ + "compilerOptions": { + "target": "es5", + "module": "esnext", + "lib": ["ES5"], + "outDir": "dist", + }, + "include": ["src"], +}`, + "/home/src/projects/component-type-checker/packages/sdk/node_modules/@component-type-checker/button": vfstest.Symlink("/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.1/node_modules/@component-type-checker/button"), + "/home/src/projects/component-type-checker/packages/sdk/node_modules/@component-type-checker/components": vfstest.Symlink("/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/components"), + "/home/src/projects/component-type-checker/packages/sdk/package.json": `{ + "name": "@component-type-checker/sdk1", + "version": "0.0.2", + "main": "./src/index.ts", + "dependencies": { + "@component-type-checker/components": "0.0.1", + "@component-type-checker/button": "0.0.1" + } +}`, + "/home/src/projects/component-type-checker/packages/sdk/src/index.ts": `export { Button, createButton } from "@component-type-checker/components"; +export const VERSION = "0.0.2";`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noCheck_dts_errors_test.go b/internal/execute/tsctests/tests/tsc_noCheck_dts_errors_test.go new file mode 100644 index 00000000000..d1db9d5dd9b --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noCheck_dts_errors_test.go @@ -0,0 +1,122 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noCheck_dts_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noCheck", + SubScenario: "dts errors", + CommandLineArgs: []string{"--noCheck"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a = class { private p = 10; };", + "/home/src/workspaces/project/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "incremental": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add file with error", + CommandLineArgs: []string{}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/c.ts", "export const c: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noCheck_dts_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_noCheck_dts_errors_with_incremental_test.go new file mode 100644 index 00000000000..6c8de113e9e --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noCheck_dts_errors_with_incremental_test.go @@ -0,0 +1,122 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noCheck_dts_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noCheck", + SubScenario: "dts errors with incremental", + CommandLineArgs: []string{"--noCheck"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a = class { private p = 10; };", + "/home/src/workspaces/project/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "incremental": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add file with error", + CommandLineArgs: []string{}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/c.ts", "export const c: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noCheck_semantic_errors_test.go b/internal/execute/tsctests/tests/tsc_noCheck_semantic_errors_test.go new file mode 100644 index 00000000000..e0cfcd56640 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noCheck_semantic_errors_test.go @@ -0,0 +1,122 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noCheck_semantic_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noCheck", + SubScenario: "semantic errors", + CommandLineArgs: []string{"--noCheck"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a: number = \"hello\";", + "/home/src/workspaces/project/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "incremental": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add file with error", + CommandLineArgs: []string{}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/c.ts", "export const c: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noCheck_semantic_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_noCheck_semantic_errors_with_incremental_test.go new file mode 100644 index 00000000000..159904325d0 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noCheck_semantic_errors_with_incremental_test.go @@ -0,0 +1,122 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noCheck_semantic_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noCheck", + SubScenario: "semantic errors with incremental", + CommandLineArgs: []string{"--noCheck"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a: number = \"hello\";", + "/home/src/workspaces/project/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "incremental": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add file with error", + CommandLineArgs: []string{}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/c.ts", "export const c: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noCheck_syntax_errors_test.go b/internal/execute/tsctests/tests/tsc_noCheck_syntax_errors_test.go new file mode 100644 index 00000000000..9ed64c37f67 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noCheck_syntax_errors_test.go @@ -0,0 +1,122 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noCheck_syntax_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noCheck", + SubScenario: "syntax errors", + CommandLineArgs: []string{"--noCheck"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a = \"hello", + "/home/src/workspaces/project/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "incremental": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add file with error", + CommandLineArgs: []string{}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/c.ts", "export const c: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noCheck_syntax_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_noCheck_syntax_errors_with_incremental_test.go new file mode 100644 index 00000000000..bc3198562a6 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noCheck_syntax_errors_with_incremental_test.go @@ -0,0 +1,122 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noCheck_syntax_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noCheck", + SubScenario: "syntax errors with incremental", + CommandLineArgs: []string{"--noCheck"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "export const a = \"hello", + "/home/src/workspaces/project/b.ts": "export const b = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "declaration": true, + "incremental": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Add file with error", + CommandLineArgs: []string{}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/c.ts", "export const c: number = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix `a` error with noCheck", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with checking", + CommandLineArgs: []string{}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_dts_errors_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_dts_errors_test.go new file mode 100644 index 00000000000..c3817522a97 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_dts_errors_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_dts_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "dts errors", + CommandLineArgs: []string{}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_dts_errors_with_declaration_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_dts_errors_with_declaration_test.go new file mode 100644 index 00000000000..ccaaaffb62e --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_dts_errors_with_declaration_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_dts_errors_with_declaration(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "dts errors with declaration", + CommandLineArgs: []string{}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_dts_errors_with_declaration_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_dts_errors_with_declaration_with_incremental_test.go new file mode 100644 index 00000000000..b88a7f14516 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_dts_errors_with_declaration_with_incremental_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_dts_errors_with_declaration_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "dts errors with declaration with incremental", + CommandLineArgs: []string{}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_dts_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_dts_errors_with_incremental_test.go new file mode 100644 index 00000000000..3e5d0de8dd5 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_dts_errors_with_incremental_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_dts_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "dts errors with incremental", + CommandLineArgs: []string{}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +export const a = class { private p = 10; };`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +export const a = class { p = 10; };`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_file_deleted_before_fixing_error_with_noEmitOnError_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_file_deleted_before_fixing_error_with_noEmitOnError_test.go new file mode 100644 index 00000000000..0ba8cd4ddb3 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_file_deleted_before_fixing_error_with_noEmitOnError_test.go @@ -0,0 +1,36 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_file_deleted_before_fixing_error_with_noEmitOnError(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "file deleted before fixing error with noEmitOnError", + CommandLineArgs: []string{"-i"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/file1.ts": "export const x: 30 = \"hello\";", + "/home/src/workspaces/project/file2.ts": "export class D { }", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "outDir": "outDir", + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "delete file without error", + Edit: func(sys *tsctests.TestSys) { + sys.Remove("/home/src/workspaces/project/file2.ts") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_semantic_errors_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_semantic_errors_test.go new file mode 100644 index 00000000000..987b326c6da --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_semantic_errors_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_semantic_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "semantic errors", + CommandLineArgs: []string{}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a: string = 10;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_semantic_errors_with_declaration_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_semantic_errors_with_declaration_test.go new file mode 100644 index 00000000000..f8c75965419 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_semantic_errors_with_declaration_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_semantic_errors_with_declaration(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "semantic errors with declaration", + CommandLineArgs: []string{}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a: string = 10;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_semantic_errors_with_declaration_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_semantic_errors_with_declaration_with_incremental_test.go new file mode 100644 index 00000000000..abf8268302d --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_semantic_errors_with_declaration_with_incremental_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_semantic_errors_with_declaration_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "semantic errors with declaration with incremental", + CommandLineArgs: []string{}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a: string = 10;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_semantic_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_semantic_errors_with_incremental_test.go new file mode 100644 index 00000000000..965a15a9883 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_semantic_errors_with_incremental_test.go @@ -0,0 +1,53 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_semantic_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "semantic errors with incremental", + CommandLineArgs: []string{}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a: string = 10;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_syntax_errors_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_syntax_errors_test.go new file mode 100644 index 00000000000..d89d38ad34c --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_syntax_errors_test.go @@ -0,0 +1,57 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_syntax_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "syntax errors", + CommandLineArgs: []string{}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_syntax_errors_with_declaration_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_syntax_errors_with_declaration_test.go new file mode 100644 index 00000000000..009fa346d99 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_syntax_errors_with_declaration_test.go @@ -0,0 +1,57 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_syntax_errors_with_declaration(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "syntax errors with declaration", + CommandLineArgs: []string{}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": false, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_syntax_errors_with_declaration_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_syntax_errors_with_declaration_with_incremental_test.go new file mode 100644 index 00000000000..e0ead6a4954 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_syntax_errors_with_declaration_with_incremental_test.go @@ -0,0 +1,57 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_syntax_errors_with_declaration_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "syntax errors with declaration with incremental", + CommandLineArgs: []string{}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": true, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_syntax_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_syntax_errors_with_incremental_test.go new file mode 100644 index 00000000000..44331bb05df --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_syntax_errors_with_incremental_test.go @@ -0,0 +1,57 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_syntax_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "syntax errors with incremental", + CommandLineArgs: []string{}, + Cwd: "/user/username/projects/noEmitOnError", + Files: tsctests.FileMap{ + "/user/username/projects/noEmitOnError/shared/types/db.ts": `export interface A { + name: string; +}`, + "/user/username/projects/noEmitOnError/src/main.ts": `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +;`, + "/user/username/projects/noEmitOnError/src/other.ts": `console.log("hi"); +export { }`, + "/user/username/projects/noEmitOnError/tsconfig.json": `{ + "compilerOptions": { + "outDir": "./dev-build", + "declaration": false, + "incremental": true, + "noEmitOnError": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/user/username/projects/noEmitOnError/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmitOnError_when_declarationMap_changes_test.go b/internal/execute/tsctests/tests/tsc_noEmitOnError_when_declarationMap_changes_test.go new file mode 100644 index 00000000000..435111b747a --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmitOnError_when_declarationMap_changes_test.go @@ -0,0 +1,45 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmitOnError_when_declarationMap_changes(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmitOnError", + SubScenario: "when declarationMap changes", + Files: tsctests.FileMap{ + "/home/src/workspaces/project/a.ts": "const x = 10;", + "/home/src/workspaces/project/b.ts": "const y = 10;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "noEmitOnError": true, + "declaration": true, + "composite": true, + }, +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "error and enable declarationMap", + CommandLineArgs: []string{"--declarationMap"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "const x: 20 = 10;") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "fix error declarationMap", + CommandLineArgs: []string{"--declarationMap"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/a.ts", "const x = 10;") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_changes_composite_test.go b/internal/execute/tsctests/tests/tsc_noEmit_changes_composite_test.go new file mode 100644 index 00000000000..da3edb38287 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_changes_composite_test.go @@ -0,0 +1,147 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_changes_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "changes composite", + CommandLineArgs: []string{}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/class.ts": `export class classC { + prop = 1; +}`, + "/home/src/workspaces/project/src/directUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/indirectClass.ts": `import { classC } from './class'; +export class indirectClass { + classC = new classC(); +}`, + "/home/src/workspaces/project/src/indirectUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/noChangeFile.ts": `export function writeLog(s: string) { +}`, + "/home/src/workspaces/project/src/noChangeFileWithEmitSpecificError.ts": `function someFunc(arguments: boolean, ...rest: any[]) { +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "composite": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error but still noEmit", + CommandLineArgs: []string{"--noEmit"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error and emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and no emit", + CommandLineArgs: []string{"--noEmit"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_changes_incremental_declaration_test.go b/internal/execute/tsctests/tests/tsc_noEmit_changes_incremental_declaration_test.go new file mode 100644 index 00000000000..e0e38a2445e --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_changes_incremental_declaration_test.go @@ -0,0 +1,147 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_changes_incremental_declaration(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "changes incremental declaration", + CommandLineArgs: []string{}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/class.ts": `export class classC { + prop = 1; +}`, + "/home/src/workspaces/project/src/directUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/indirectClass.ts": `import { classC } from './class'; +export class indirectClass { + classC = new classC(); +}`, + "/home/src/workspaces/project/src/indirectUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/noChangeFile.ts": `export function writeLog(s: string) { +}`, + "/home/src/workspaces/project/src/noChangeFileWithEmitSpecificError.ts": `function someFunc(arguments: boolean, ...rest: any[]) { +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "incremental": true, "declaration": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error but still noEmit", + CommandLineArgs: []string{"--noEmit"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error and emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and no emit", + CommandLineArgs: []string{"--noEmit"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_changes_incremental_test.go b/internal/execute/tsctests/tests/tsc_noEmit_changes_incremental_test.go new file mode 100644 index 00000000000..64537d288e8 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_changes_incremental_test.go @@ -0,0 +1,147 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_changes_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "changes incremental", + CommandLineArgs: []string{}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/class.ts": `export class classC { + prop = 1; +}`, + "/home/src/workspaces/project/src/directUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/indirectClass.ts": `import { classC } from './class'; +export class indirectClass { + classC = new classC(); +}`, + "/home/src/workspaces/project/src/indirectUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/noChangeFile.ts": `export function writeLog(s: string) { +}`, + "/home/src/workspaces/project/src/noChangeFileWithEmitSpecificError.ts": `function someFunc(arguments: boolean, ...rest: any[]) { +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "incremental": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error but still noEmit", + CommandLineArgs: []string{"--noEmit"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error and emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and no emit", + CommandLineArgs: []string{"--noEmit"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with noEmit", + CommandLineArgs: []string{"--noEmit"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_changes_with_initial_noEmit_composite_test.go b/internal/execute/tsctests/tests/tsc_noEmit_changes_with_initial_noEmit_composite_test.go new file mode 100644 index 00000000000..acaaa2bfda8 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_changes_with_initial_noEmit_composite_test.go @@ -0,0 +1,68 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_changes_with_initial_noEmit_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "changes with initial noEmit composite", + CommandLineArgs: []string{"--noEmit"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/class.ts": `export class classC { + prop = 1; +}`, + "/home/src/workspaces/project/src/directUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/indirectClass.ts": `import { classC } from './class'; +export class indirectClass { + classC = new classC(); +}`, + "/home/src/workspaces/project/src/indirectUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/noChangeFile.ts": `export function writeLog(s: string) { +}`, + "/home/src/workspaces/project/src/noChangeFileWithEmitSpecificError.ts": `function someFunc(arguments: boolean, ...rest: any[]) { +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "composite": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with emit", + CommandLineArgs: []string{}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and no emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_changes_with_initial_noEmit_incremental_declaration_test.go b/internal/execute/tsctests/tests/tsc_noEmit_changes_with_initial_noEmit_incremental_declaration_test.go new file mode 100644 index 00000000000..deb8fe190c8 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_changes_with_initial_noEmit_incremental_declaration_test.go @@ -0,0 +1,68 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_changes_with_initial_noEmit_incremental_declaration(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "changes with initial noEmit incremental declaration", + CommandLineArgs: []string{"--noEmit"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/class.ts": `export class classC { + prop = 1; +}`, + "/home/src/workspaces/project/src/directUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/indirectClass.ts": `import { classC } from './class'; +export class indirectClass { + classC = new classC(); +}`, + "/home/src/workspaces/project/src/indirectUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/noChangeFile.ts": `export function writeLog(s: string) { +}`, + "/home/src/workspaces/project/src/noChangeFileWithEmitSpecificError.ts": `function someFunc(arguments: boolean, ...rest: any[]) { +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "incremental": true, "declaration": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with emit", + CommandLineArgs: []string{}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and no emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_changes_with_initial_noEmit_incremental_test.go b/internal/execute/tsctests/tests/tsc_noEmit_changes_with_initial_noEmit_incremental_test.go new file mode 100644 index 00000000000..0c233f00027 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_changes_with_initial_noEmit_incremental_test.go @@ -0,0 +1,68 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_changes_with_initial_noEmit_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "changes with initial noEmit incremental", + CommandLineArgs: []string{"--noEmit"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/class.ts": `export class classC { + prop = 1; +}`, + "/home/src/workspaces/project/src/directUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/indirectClass.ts": `import { classC } from './class'; +export class indirectClass { + classC = new classC(); +}`, + "/home/src/workspaces/project/src/indirectUse.ts": `import { indirectClass } from './indirectClass'; +new indirectClass().classC.prop;`, + "/home/src/workspaces/project/src/noChangeFile.ts": `export function writeLog(s: string) { +}`, + "/home/src/workspaces/project/src/noChangeFileWithEmitSpecificError.ts": `function someFunc(arguments: boolean, ...rest: any[]) { +}`, + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { "incremental": true } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error with emit", + CommandLineArgs: []string{}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop1 = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error and no emit", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/workspaces/project/src/class.ts", `export class classC { + prop = 1; +}`) + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "No Change run with emit", + CommandLineArgs: []string{}, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_test.go b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_test.go new file mode 100644 index 00000000000..9be91bd6f30 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_dts_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors", + CommandLineArgs: []string{"--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": false, + "declaration": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_with_declaration_enable_changes_with_multiple_files_test.go b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_with_declaration_enable_changes_with_multiple_files_test.go new file mode 100644 index 00000000000..ee5521392f4 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_with_declaration_enable_changes_with_multiple_files_test.go @@ -0,0 +1,79 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_dts_errors_with_declaration_enable_changes_with_multiple_files(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors with declaration enable changes with multiple files", + CommandLineArgs: []string{"--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a = class { private p = 10; };", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/c.ts": "export const c = class { private p = 10; };", + "/home/src/projects/project/d.ts": "export const d = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration enabled noEmit - Should report errors", + CommandLineArgs: []string{"--noEmit", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration and declarationMap noEmit - Should report errors", + CommandLineArgs: []string{"--noEmit", "--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Dts Emit with error", + CommandLineArgs: []string{"--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix the error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = class { public p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration enabled noEmit", + CommandLineArgs: []string{"--noEmit", "--declaration"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "With declaration and declarationMap noEmit", + CommandLineArgs: []string{"--noEmit", "--declaration", "--declarationMap"}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix the another ", + CommandLineArgs: []string{"--noEmit", "--declaration", "--declarationMap"}, + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/c.ts", "export const c = class { public p = 10; };") + }, + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_with_incremental_as_modules_test.go b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_with_incremental_as_modules_test.go new file mode 100644 index 00000000000..c7849a50d1b --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_with_incremental_as_modules_test.go @@ -0,0 +1,70 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_dts_errors_with_incremental_as_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors with incremental as modules", + CommandLineArgs: []string{"--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a = class { private p = 10; };", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_with_incremental_test.go new file mode 100644 index 00000000000..8990a8d2fbb --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_with_incremental_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_dts_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors with incremental", + CommandLineArgs: []string{"--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_without_dts_enabled_test.go b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_without_dts_enabled_test.go new file mode 100644 index 00000000000..10f525f8891 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_without_dts_enabled_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_dts_errors_without_dts_enabled(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors without dts enabled", + CommandLineArgs: []string{"--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": false, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_without_dts_enabled_with_incremental_as_modules_test.go b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_without_dts_enabled_with_incremental_as_modules_test.go new file mode 100644 index 00000000000..577291295ee --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_without_dts_enabled_with_incremental_as_modules_test.go @@ -0,0 +1,70 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_dts_errors_without_dts_enabled_with_incremental_as_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors without dts enabled with incremental as modules", + CommandLineArgs: []string{"--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a = class { private p = 10; };", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_without_dts_enabled_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_without_dts_enabled_with_incremental_test.go new file mode 100644 index 00000000000..8853ccda720 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_dts_errors_without_dts_enabled_with_incremental_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_dts_errors_without_dts_enabled_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "dts errors without dts enabled with incremental", + CommandLineArgs: []string{"--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = class { private p = 10; };", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = class { private p = 10; };") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_semantic_errors_test.go b/internal/execute/tsctests/tests/tsc_noEmit_semantic_errors_test.go new file mode 100644 index 00000000000..ca4cfc6e503 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_semantic_errors_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_semantic_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "semantic errors", + CommandLineArgs: []string{"--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a: number = \"hello\"", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": false, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a: number = \"hello\"") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_semantic_errors_with_incremental_as_modules_test.go b/internal/execute/tsctests/tests/tsc_noEmit_semantic_errors_with_incremental_as_modules_test.go new file mode 100644 index 00000000000..ba55266b290 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_semantic_errors_with_incremental_as_modules_test.go @@ -0,0 +1,70 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_semantic_errors_with_incremental_as_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "semantic errors with incremental as modules", + CommandLineArgs: []string{"--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a: number = \"hello\"", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a: number = \"hello\"") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_semantic_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_noEmit_semantic_errors_with_incremental_test.go new file mode 100644 index 00000000000..f13363a1316 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_semantic_errors_with_incremental_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_semantic_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "semantic errors with incremental", + CommandLineArgs: []string{"--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a: number = \"hello\"", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a: number = \"hello\"") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_syntax_errors_test.go b/internal/execute/tsctests/tests/tsc_noEmit_syntax_errors_test.go new file mode 100644 index 00000000000..fc6e7122081 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_syntax_errors_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_syntax_errors(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "syntax errors", + CommandLineArgs: []string{"--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = \"hello", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": false, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_syntax_errors_with_incremental_as_modules_test.go b/internal/execute/tsctests/tests/tsc_noEmit_syntax_errors_with_incremental_as_modules_test.go new file mode 100644 index 00000000000..b1ef4f422d4 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_syntax_errors_with_incremental_as_modules_test.go @@ -0,0 +1,70 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_syntax_errors_with_incremental_as_modules(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "syntax errors with incremental as modules", + CommandLineArgs: []string{"--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "export const a = \"hello", + "/home/src/projects/project/b.ts": "export const b = 10;", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "export const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_syntax_errors_with_incremental_test.go b/internal/execute/tsctests/tests/tsc_noEmit_syntax_errors_with_incremental_test.go new file mode 100644 index 00000000000..5909a165969 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_syntax_errors_with_incremental_test.go @@ -0,0 +1,69 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_syntax_errors_with_incremental(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "syntax errors with incremental", + CommandLineArgs: []string{"--noEmit"}, + Cwd: "/home/src/projects/project", + Files: tsctests.FileMap{ + "/home/src/projects/project/a.ts": "const a = \"hello", + "/home/src/projects/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "declaration": false + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Fix error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello\";") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit after fixing error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Introduce error", + Edit: func(sys *tsctests.TestSys) { + sys.WriteFile("/home/src/projects/project/a.ts", "const a = \"hello") + }, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "Emit when error", + CommandLineArgs: []string{}, + }) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_noEmit_when_project_has_strict_true_test.go b/internal/execute/tsctests/tests/tsc_noEmit_when_project_has_strict_true_test.go new file mode 100644 index 00000000000..6c2e97db7f5 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_noEmit_when_project_has_strict_true_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_noEmit_when_project_has_strict_true(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "noEmit", + SubScenario: "when project has strict true", + CommandLineArgs: []string{"--noEmit"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/class1.ts": "export class class1 {}", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "incremental": true, + "strict": true + } +}`, + }, + } + test.Start(t) + + test.Edit(&tsctests.TestEdit{ + Caption: "no change", + }) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_default_import_interop_uses_referenced_project_settings_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_default_import_interop_uses_referenced_project_settings_test.go new file mode 100644 index 00000000000..ca9de44b153 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_default_import_interop_uses_referenced_project_settings_test.go @@ -0,0 +1,61 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_default_import_interop_uses_referenced_project_settings(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "default import interop uses referenced project settings", + CommandLineArgs: []string{"--p", "app", "--pretty", "false"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/app/src/index.ts": `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": "export const local = 0;", + "/home/src/workspaces/project/app/tsconfig.json": `{ + "compilerOptions": { + "module": "esnext", + "moduleResolution": "bundler", + "rootDir": "src", + "outDir": "dist", + }, + "include": ["src"], + "references": [ + { "path": "../lib" }, + ], +}`, + "/home/src/workspaces/project/lib/dist/a.d.ts": "export declare const a = 0;", + "/home/src/workspaces/project/lib/src/a.ts": "export const a = 0;", + "/home/src/workspaces/project/lib/tsconfig.json": `{ + "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": "export declare const ambiguous: number;", + "/home/src/workspaces/project/node_modules/ambiguous-package/package.json": `{ + "name": "ambiguous-package" +}`, + "/home/src/workspaces/project/node_modules/esm-package/index.d.ts": "export declare const esm: number;", + "/home/src/workspaces/project/node_modules/esm-package/package.json": `{ + "name": "esm-package", + "type": "module" +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_default_setup_was_created_correctly_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_default_setup_was_created_correctly_test.go new file mode 100644 index 00000000000..c9f177c8684 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_default_setup_was_created_correctly_test.go @@ -0,0 +1,38 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_default_setup_was_created_correctly(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "default setup was created correctly", + CommandLineArgs: []string{"--p", "primary/tsconfig.json"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/primary/a.ts": "export { };", + "/home/src/workspaces/project/primary/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + } +}`, + "/home/src/workspaces/project/secondary/b.ts": "import * as mod_1 from \"../primary/a\";", + "/home/src/workspaces/project/secondary/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + }, + "references": [{ + "path": "../primary" + }] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_does_not_error_when_the_referenced_project_doesnt_have_composite_if_its_a_container_project_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_does_not_error_when_the_referenced_project_doesnt_have_composite_if_its_a_container_project_test.go new file mode 100644 index 00000000000..1b46340afac --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_does_not_error_when_the_referenced_project_doesnt_have_composite_if_its_a_container_project_test.go @@ -0,0 +1,39 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_does_not_error_when_the_referenced_project_doesnt_have_composite_if_its_a_container_project(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "does not error when the referenced project doesnt have composite if its a container project", + CommandLineArgs: []string{"--p", "reference/tsconfig.json"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/primary/a.ts": "export { };", + "/home/src/workspaces/project/primary/tsconfig.json": `{ + "compilerOptions": { + "composite": false, + "outDir": "bin", + } +}`, + "/home/src/workspaces/project/reference/b.ts": "import * as mod_1 from \"../primary/a\";", + "/home/src/workspaces/project/reference/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + }, + "files": [ ], + "references": [{ + "path": "../primary" + }] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_doesnt_infer_the_rootDir_from_source_paths_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_doesnt_infer_the_rootDir_from_source_paths_test.go new file mode 100644 index 00000000000..db1dc705676 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_doesnt_infer_the_rootDir_from_source_paths_test.go @@ -0,0 +1,29 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_doesnt_infer_the_rootDir_from_source_paths(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "doesnt infer the rootDir from source paths", + CommandLineArgs: []string{"--p", "alpha/tsconfig.json"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/alpha/src/a.ts": "export const m: number = 3;", + "/home/src/workspaces/project/alpha/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + }, + "references": [] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_a_file_is_outside_the_rootdir_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_a_file_is_outside_the_rootdir_test.go new file mode 100644 index 00000000000..311c1db2614 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_a_file_is_outside_the_rootdir_test.go @@ -0,0 +1,30 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_errors_when_a_file_is_outside_the_rootdir(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "errors when a file is outside the rootdir", + CommandLineArgs: []string{"--p", "alpha/tsconfig.json"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/alpha/src/a.ts": "import * as b from '../../beta/b'", + "/home/src/workspaces/project/alpha/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + }, + "references": [] +}`, + "/home/src/workspaces/project/beta/b.ts": "export { }", + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_declaration_false_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_declaration_false_test.go new file mode 100644 index 00000000000..97d986f682f --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_declaration_false_test.go @@ -0,0 +1,29 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_errors_when_declaration_false(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "errors when declaration = false", + CommandLineArgs: []string{"--p", "primary/tsconfig.json"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/primary/a.ts": "export { };", + "/home/src/workspaces/project/primary/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + "declaration": false + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_the_file_list_is_not_exhaustive_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_the_file_list_is_not_exhaustive_test.go new file mode 100644 index 00000000000..9b87982800c --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_the_file_list_is_not_exhaustive_test.go @@ -0,0 +1,30 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_errors_when_the_file_list_is_not_exhaustive(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "errors when the file list is not exhaustive", + CommandLineArgs: []string{"--p", "primary/tsconfig.json"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/primary/a.ts": "import * as b from './b'", + "/home/src/workspaces/project/primary/b.ts": "export {}", + "/home/src/workspaces/project/primary/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + }, + "files": [ "a.ts" ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_the_referenced_project_doesnt_exist_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_the_referenced_project_doesnt_exist_test.go new file mode 100644 index 00000000000..7e4dd479b12 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_the_referenced_project_doesnt_exist_test.go @@ -0,0 +1,31 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_errors_when_the_referenced_project_doesnt_exist(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "errors when the referenced project doesnt exist", + CommandLineArgs: []string{"--p", "primary/tsconfig.json"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/primary/a.ts": "export { };", + "/home/src/workspaces/project/primary/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + }, + "references": [{ + "path": "../foo" + }] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_the_referenced_project_doesnt_have_composite_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_the_referenced_project_doesnt_have_composite_test.go new file mode 100644 index 00000000000..0c9028db574 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_errors_when_the_referenced_project_doesnt_have_composite_test.go @@ -0,0 +1,37 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_errors_when_the_referenced_project_doesnt_have_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "errors when the referenced project doesnt have composite", + CommandLineArgs: []string{"--p", "reference/tsconfig.json"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/primary/a.ts": "export { };", + "/home/src/workspaces/project/primary/tsconfig.json": `{ + "compilerOptions": { + "composite": false, + "outDir": "bin", + } +}`, + "/home/src/workspaces/project/reference/b.ts": "import * as mod_1 from \"../primary/a\";", + "/home/src/workspaces/project/reference/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + }, + "files": [ "b.ts" ], + "references": [ { "path": "../primary" } ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_importing_const_enum_from_referenced_project_with_preserveConstEnums_and_verbatimModuleSyntax_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_importing_const_enum_from_referenced_project_with_preserveConstEnums_and_verbatimModuleSyntax_test.go new file mode 100644 index 00000000000..e916810a09d --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_importing_const_enum_from_referenced_project_with_preserveConstEnums_and_verbatimModuleSyntax_test.go @@ -0,0 +1,54 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_importing_const_enum_from_referenced_project_with_preserveConstEnums_and_verbatimModuleSyntax(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "importing const enum from referenced project with preserveConstEnums and verbatimModuleSyntax", + CommandLineArgs: []string{"--p", "project", "--pretty", "false"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/no-preserve/index.d.ts": "export declare const enum F { A = 1 }", + "/home/src/workspaces/solution/no-preserve/index.ts": "export const enum E { A = 1 }", + "/home/src/workspaces/solution/no-preserve/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "preserveConstEnums": false, + }, +}`, + "/home/src/workspaces/solution/preserve/index.d.ts": "export declare const enum E { A = 1 }", + "/home/src/workspaces/solution/preserve/index.ts": "export const enum E { A = 1 }", + "/home/src/workspaces/solution/preserve/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "preserveConstEnums": true, + }, +}`, + "/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": `{ + "compilerOptions": { + "module": "preserve", + "verbatimModuleSyntax": true, + }, + "references": [ + { "path": "../preserve" }, + { "path": "../no-preserve" }, + ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_issues_a_nice_error_when_the_input_file_is_missing_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_issues_a_nice_error_when_the_input_file_is_missing_test.go new file mode 100644 index 00000000000..8147181a6bc --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_issues_a_nice_error_when_the_input_file_is_missing_test.go @@ -0,0 +1,37 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_issues_a_nice_error_when_the_input_file_is_missing(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "issues a nice error when the input file is missing", + CommandLineArgs: []string{"--p", "beta/tsconfig.json"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/alpha/a.ts": "export const m: number = 3;", + "/home/src/workspaces/project/alpha/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + }, + "references": [] +}`, + "/home/src/workspaces/project/beta/b.ts": "import { m } from '../alpha/a'", + "/home/src/workspaces/project/beta/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + }, + "references": [ { "path": "../alpha" } ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_issues_a_nice_error_when_the_input_file_is_missing_when_module_reference_is_not_relative_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_issues_a_nice_error_when_the_input_file_is_missing_when_module_reference_is_not_relative_test.go new file mode 100644 index 00000000000..cfa6f75d853 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_issues_a_nice_error_when_the_input_file_is_missing_when_module_reference_is_not_relative_test.go @@ -0,0 +1,39 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_issues_a_nice_error_when_the_input_file_is_missing_when_module_reference_is_not_relative(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "issues a nice error when the input file is missing when module reference is not relative", + CommandLineArgs: []string{"--p", "beta/tsconfig.json"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/alpha/a.ts": "export const m: number = 3;", + "/home/src/workspaces/project/alpha/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + } +}`, + "/home/src/workspaces/project/beta/b.ts": "import { m } from '@alpha/a'", + "/home/src/workspaces/project/beta/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + "paths": { + "@alpha/*": ["../alpha/*"], + }, + }, + "references": [ { "path": "../alpha" } ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_redirects_to_the_output_dts_file_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_redirects_to_the_output_dts_file_test.go new file mode 100644 index 00000000000..f8e0d94603c --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_redirects_to_the_output_dts_file_test.go @@ -0,0 +1,37 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_redirects_to_the_output_dts_file(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "redirects to the output dts file", + CommandLineArgs: []string{"--p", "beta/tsconfig.json", "--explainFiles"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/alpha/a.ts": "export const m: number = 3;", + "/home/src/workspaces/project/alpha/bin/a.d.ts": "export { };", + "/home/src/workspaces/project/alpha/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + } +}`, + "/home/src/workspaces/project/beta/b.ts": "import { m } from '../alpha/a'", + "/home/src/workspaces/project/beta/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "outDir": "bin", + }, + "references": [ { "path": "../alpha" } ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_referenced_project_with_esnext_module_disallows_synthetic_default_imports_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_referenced_project_with_esnext_module_disallows_synthetic_default_imports_test.go new file mode 100644 index 00000000000..6f7f0db1495 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_referenced_project_with_esnext_module_disallows_synthetic_default_imports_test.go @@ -0,0 +1,47 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_referenced_project_with_esnext_module_disallows_synthetic_default_imports(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "referenced project with esnext module disallows synthetic default imports", + CommandLineArgs: []string{"--p", "app", "--pretty", "false"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/app/index.ts": `import TestSrc from '../lib/src/utils'; // Error +import TestDecl from '../lib/dist/utils'; // Error +console.log(TestSrc.test()); +console.log(TestDecl.test());`, + "/home/src/workspaces/project/app/tsconfig.json": `{ + "compilerOptions": { + "module": "esnext", + "moduleResolution": "bundler" + }, + "references": [ + { "path": "../lib" } + ] +}`, + "/home/src/workspaces/project/lib/dist/utils.d.ts": "export declare const test: () => string;", + "/home/src/workspaces/project/lib/src/utils.ts": "export const test = () => 'test';", + "/home/src/workspaces/project/lib/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "module": "esnext", + "moduleResolution": "bundler", + "rootDir": "src", + "outDir": "dist" + }, + "include": ["src"] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_referencing_ambient_const_enum_from_referenced_project_with_preserveConstEnums_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_referencing_ambient_const_enum_from_referenced_project_with_preserveConstEnums_test.go new file mode 100644 index 00000000000..f0913415d97 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_referencing_ambient_const_enum_from_referenced_project_with_preserveConstEnums_test.go @@ -0,0 +1,40 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_referencing_ambient_const_enum_from_referenced_project_with_preserveConstEnums(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "referencing ambient const enum from referenced project with preserveConstEnums", + CommandLineArgs: []string{"--p", "project"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/index.ts": "import { E } from \"../utils\"; E.A;", + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "compilerOptions": { + "isolatedModules": true, + }, + "references": [ + { "path": "../utils" }, + ], +}`, + "/home/src/workspaces/solution/utils/index.d.ts": "export declare const enum E { A = 1 }", + "/home/src/workspaces/solution/utils/index.ts": "export const enum E { A = 1 }", + "/home/src/workspaces/solution/utils/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "declaration": true, + "preserveConstEnums": true, + }, +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_rewriteRelativeImportExtensionsProjectReferences1_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_rewriteRelativeImportExtensionsProjectReferences1_test.go new file mode 100644 index 00000000000..b6db1ce5f82 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_rewriteRelativeImportExtensionsProjectReferences1_test.go @@ -0,0 +1,58 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_rewriteRelativeImportExtensionsProjectReferences1(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "rewriteRelativeImportExtensionsProjectReferences1", + CommandLineArgs: []string{"-p", "packages/main", "--pretty", "false"}, + Cwd: "/home/src/workspaces", + Files: tsctests.FileMap{ + "/home/src/workspaces/packages/common/dist/index.d.ts": "export {};", + "/home/src/workspaces/packages/common/package.json": `{ + "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": "export {};", + "/home/src/workspaces/packages/common/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "rootDir": "src", + "outDir": "dist", + "module": "nodenext" + } +}`, + "/home/src/workspaces/packages/main/package.json": `{ + "type": "module" +}`, + "/home/src/workspaces/packages/main/src/index.ts": "import {} from \"../../common/src/index.ts\";", + "/home/src/workspaces/packages/main/tsconfig.json": `{ + "compilerOptions": { + "module": "nodenext", + "rewriteRelativeImportExtensions": true, + "rootDir": "src", + "outDir": "dist" + }, + "references": [ + { "path": "../common" } + ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_rewriteRelativeImportExtensionsProjectReferences2_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_rewriteRelativeImportExtensionsProjectReferences2_test.go new file mode 100644 index 00000000000..7c375e313a7 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_rewriteRelativeImportExtensionsProjectReferences2_test.go @@ -0,0 +1,45 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_rewriteRelativeImportExtensionsProjectReferences2(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "rewriteRelativeImportExtensionsProjectReferences2", + CommandLineArgs: []string{"--p", "src/services", "--pretty", "false"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/dist/compiler/parser.d.ts": "export {};", + "/home/src/workspaces/solution/src/compiler/parser.ts": "export {};", + "/home/src/workspaces/solution/src/compiler/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": {} +}`, + "/home/src/workspaces/solution/src/services/services.ts": "import {} from \"../compiler/parser.ts\";", + "/home/src/workspaces/solution/src/services/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": {}, + "references": [ + { "path": "../compiler" } + ] +}`, + "/home/src/workspaces/solution/src/tsconfig-base.json": `{ + "compilerOptions": { + "module": "nodenext", + "composite": true, + "rootDir": ".", + "outDir": "../dist", + "rewriteRelativeImportExtensions": true + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_rewriteRelativeImportExtensionsProjectReferences3_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_rewriteRelativeImportExtensionsProjectReferences3_test.go new file mode 100644 index 00000000000..61cb5e806fa --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_rewriteRelativeImportExtensionsProjectReferences3_test.go @@ -0,0 +1,49 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_rewriteRelativeImportExtensionsProjectReferences3(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "rewriteRelativeImportExtensionsProjectReferences3", + CommandLineArgs: []string{"--p", "src/services", "--pretty", "false"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/dist/compiler/parser.d.ts": "export {};", + "/home/src/workspaces/solution/src/compiler/parser.ts": "export {};", + "/home/src/workspaces/solution/src/compiler/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "../../dist/compiler" + } +}`, + "/home/src/workspaces/solution/src/services/services.ts": "import {} from \"../compiler/parser.ts\";", + "/home/src/workspaces/solution/src/services/tsconfig.json": `{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "../../dist/services" + }, + "references": [ + { "path": "../compiler" } + ] +}`, + "/home/src/workspaces/solution/src/tsconfig-base.json": `{ + "compilerOptions": { + "module": "nodenext", + "composite": true, + "rewriteRelativeImportExtensions": true + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_when_project_contains_invalid_project_reference_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_when_project_contains_invalid_project_reference_test.go new file mode 100644 index 00000000000..211e9772ebd --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_when_project_contains_invalid_project_reference_test.go @@ -0,0 +1,28 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_when_project_contains_invalid_project_reference(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "when project contains invalid project reference", + CommandLineArgs: []string{"--p", "project"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/home/src/workspaces/solution/project/index.ts": "export const x = 10;", + "/home/src/workspaces/solution/project/tsconfig.json": `{ + "references": [ + { "path": "../utils" }, + ], +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_when_project_reference_is_not_built_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_when_project_reference_is_not_built_test.go new file mode 100644 index 00000000000..24bf757f84c --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_when_project_reference_is_not_built_test.go @@ -0,0 +1,34 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_when_project_reference_is_not_built(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "when project reference is not built", + CommandLineArgs: []string{"--p", "project"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/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/utils/index.ts": "export const x = 10;", + "/home/src/workspaces/solution/utils/tsconfig.json": `{ + "compilerOptions": { + "composite": true + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_when_project_references_composite_project_with_noEmit_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_when_project_references_composite_project_with_noEmit_test.go new file mode 100644 index 00000000000..0f71a8c5558 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_when_project_references_composite_project_with_noEmit_test.go @@ -0,0 +1,35 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_when_project_references_composite_project_with_noEmit(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "when project references composite project with noEmit", + CommandLineArgs: []string{"--p", "project"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/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/utils/index.ts": "export const x = 10;", + "/home/src/workspaces/solution/utils/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "noEmit": true + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_projectReferences_when_project_references_composite_test.go b/internal/execute/tsctests/tests/tsc_projectReferences_when_project_references_composite_test.go new file mode 100644 index 00000000000..607090b6a96 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_projectReferences_when_project_references_composite_test.go @@ -0,0 +1,35 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_projectReferences_when_project_references_composite(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "projectReferences", + SubScenario: "when project references composite", + CommandLineArgs: []string{"--p", "project"}, + Cwd: "/home/src/workspaces/solution", + Files: tsctests.FileMap{ + "/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/utils/index.d.ts": "export declare const x = 10;", + "/home/src/workspaces/solution/utils/index.ts": "export const x = 10;", + "/home/src/workspaces/solution/utils/tsconfig.json": `{ + "compilerOptions": { + "composite": true + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Default_initialized_TSConfig_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Default_initialized_TSConfig_test.go new file mode 100644 index 00000000000..5454e923a74 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Default_initialized_TSConfig_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Default_initialized_TSConfig(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Default initialized TSConfig", + CommandLineArgs: []string{"--showConfig"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_advanced_options_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_advanced_options_test.go new file mode 100644 index 00000000000..128b865d27f --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_advanced_options_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_advanced_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with advanced options", + CommandLineArgs: []string{"--showConfig", "--declaration", "--declarationDir", "lib", "--skipLibCheck", "--noErrorTruncation"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_boolean_value_compiler_options_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_boolean_value_compiler_options_test.go new file mode 100644 index 00000000000..77daf37e4a4 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_boolean_value_compiler_options_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_boolean_value_compiler_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with boolean value compiler options", + CommandLineArgs: []string{"--showConfig", "--noUnusedLocals"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_compileOnSave_and_more_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_compileOnSave_and_more_test.go new file mode 100644 index 00000000000..928c9fd8fcb --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_compileOnSave_and_more_test.go @@ -0,0 +1,41 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_compileOnSave_and_more(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with compileOnSave and more", + CommandLineArgs: []string{"-p", "tsconfig.json", "--showConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/index.ts": "export const a = 1;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "esModuleInterop": true, + "target": "es5", + "module": "commonjs", + "strict": true + }, + "compileOnSave": true, + "exclude": [ + "dist" + ], + "files": [], + "include": [ + "src/*" + ], + "references": [ + { "path": "./test" } + ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_enum_value_compiler_options_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_enum_value_compiler_options_test.go new file mode 100644 index 00000000000..a1370cbb1e1 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_enum_value_compiler_options_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_enum_value_compiler_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with enum value compiler options", + CommandLineArgs: []string{"--showConfig", "--target", "es5", "--jsx", "react"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_exclude_and_outDir_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_exclude_and_outDir_test.go new file mode 100644 index 00000000000..dcb3b0f735f --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_exclude_and_outDir_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_exclude_and_outDir(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with exclude and outDir", + CommandLineArgs: []string{"-p", "tsconfig.json", "--showConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/bin/tool.ts": "export const b = 2;", + "/home/src/workspaces/project/src/index.ts": "export const a = 1;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "outDir": "./build" + }, + "exclude": [ + "build" + ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_exclude_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_exclude_test.go new file mode 100644 index 00000000000..fabeed3b0f0 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_exclude_test.go @@ -0,0 +1,31 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_exclude(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with exclude", + CommandLineArgs: []string{"-p", "tsconfig.json", "--showConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/index.ts": "export const a = 1;", + "/home/src/workspaces/project/test/test1.ts": "import { a } from \"../src\";", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true + }, + "exclude": [ + "test" + ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_files_and_include_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_files_and_include_test.go new file mode 100644 index 00000000000..1d9e80fb822 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_files_and_include_test.go @@ -0,0 +1,34 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_files_and_include(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with files and include", + CommandLineArgs: []string{"-p", "tsconfig.json", "--showConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/extra.ts": "export const c = 3;", + "/home/src/workspaces/project/src/main.ts": "export const a = 1;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true + }, + "files": [ + "extra.ts" + ], + "include": [ + "src/**/*" + ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_files_options_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_files_options_test.go new file mode 100644 index 00000000000..d153fdc214a --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_files_options_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_files_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with files options", + CommandLineArgs: []string{"--showConfig", "file0.ts", "file1.ts", "file2.ts"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_include_filtering_files_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_include_filtering_files_test.go new file mode 100644 index 00000000000..cdc2f1c1454 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_include_filtering_files_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_include_filtering_files(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with include filtering files", + CommandLineArgs: []string{"-p", "tsconfig.json", "--showConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/extra.ts": "export const c = 3;", + "/home/src/workspaces/project/src/main.ts": "export const a = 1;", + "/home/src/workspaces/project/src/util.ts": "export const b = 2;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true + }, + "include": [ + "src/**/*" + ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_incorrect_compiler_option_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_incorrect_compiler_option_test.go new file mode 100644 index 00000000000..04325af3aa8 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_incorrect_compiler_option_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_incorrect_compiler_option(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with incorrect compiler option", + CommandLineArgs: []string{"--showConfig", "--someNonExistOption"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_incorrect_compiler_option_value_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_incorrect_compiler_option_value_test.go new file mode 100644 index 00000000000..b9d6115d921 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_incorrect_compiler_option_value_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_incorrect_compiler_option_value(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with incorrect compiler option value", + CommandLineArgs: []string{"--showConfig", "--lib", "nonExistLib,es5,es2015.promise"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_list_compiler_options_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_list_compiler_options_test.go new file mode 100644 index 00000000000..48447f71ff8 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_list_compiler_options_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_list_compiler_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with list compiler options", + CommandLineArgs: []string{"--showConfig", "--types", "jquery,mocha"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_list_compiler_options_with_enum_value_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_list_compiler_options_with_enum_value_test.go new file mode 100644 index 00000000000..b989712ca8d --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_list_compiler_options_with_enum_value_test.go @@ -0,0 +1,19 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_list_compiler_options_with_enum_value(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with list compiler options with enum value", + CommandLineArgs: []string{"--showConfig", "--lib", "es5,es2015.core"}, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_paths_and_more_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_paths_and_more_test.go new file mode 100644 index 00000000000..2babdd8989b --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_paths_and_more_test.go @@ -0,0 +1,49 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_paths_and_more(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with paths and more", + CommandLineArgs: []string{"-p", "tsconfig.json", "--showConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/index.ts": "export const a = 1;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "allowJs": true, + "outDir": "./lib", + "esModuleInterop": true, + "module": "commonjs", + "moduleResolution": "node", + "target": "ES2017", + "sourceMap": true, + "baseUrl": ".", + "paths": { + "@root/*": ["./*"], + "@configs/*": ["src/configs/*"], + "@common/*": ["src/common/*"], + "*": [ + "node_modules/*", + "src/types/*" + ] + }, + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "resolveJsonModule": true + }, + "include": [ + "./src/**/*" + ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_references_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_references_test.go new file mode 100644 index 00000000000..b51bdbdcca9 --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_references_test.go @@ -0,0 +1,32 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_references(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with references", + CommandLineArgs: []string{"-p", "tsconfig.json", "--showConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/index.ts": "export const a = 1;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "composite": true, + "strict": true + }, + "references": [ + { "path": "./packages/a" }, + { "path": "./packages/b" } + ] +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_transitively_implied_options_test.go b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_transitively_implied_options_test.go new file mode 100644 index 00000000000..7b588c0f0cb --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_showConfig_Show_TSConfig_with_transitively_implied_options_test.go @@ -0,0 +1,27 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_showConfig_Show_TSConfig_with_transitively_implied_options(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "showConfig", + SubScenario: "Show TSConfig with transitively implied options", + CommandLineArgs: []string{"-p", "tsconfig.json", "--showConfig"}, + Files: tsctests.FileMap{ + "/home/src/workspaces/project/src/index.ts": "export const a = 1;", + "/home/src/workspaces/project/tsconfig.json": `{ + "compilerOptions": { + "module": "nodenext" + } +}`, + }, + } + test.Start(t) + test.End() +} diff --git a/internal/execute/tsctests/tests/tsc_typeAcquisition_parse_tsconfig_with_typeAcquisition_test.go b/internal/execute/tsctests/tests/tsc_typeAcquisition_parse_tsconfig_with_typeAcquisition_test.go new file mode 100644 index 00000000000..3797dd74a5f --- /dev/null +++ b/internal/execute/tsctests/tests/tsc_typeAcquisition_parse_tsconfig_with_typeAcquisition_test.go @@ -0,0 +1,33 @@ +// Code generated by tsctests; DO NOT EDIT. + +package tests + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/execute/tsctests" +) + +func TestTsc_typeAcquisition_parse_tsconfig_with_typeAcquisition(t *testing.T) { + test := &tsctests.TestSpec{ + Scenario: "typeAcquisition", + SubScenario: "parse tsconfig with typeAcquisition", + CommandLineArgs: []string{}, + Files: tsctests.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, + }, +}`, + }, + } + test.Start(t) + test.End() +}