diff --git a/tsc/internal/compiler/checkerpool.go b/tsc/internal/compiler/checkerpool.go index 00a0ce436006e..ad1694c8f892b 100644 --- a/tsc/internal/compiler/checkerpool.go +++ b/tsc/internal/compiler/checkerpool.go @@ -33,6 +33,7 @@ type checkerPool struct { checkers []*checker.Checker locks []*sync.Mutex fileAssociations map[*ast.SourceFile]*checker.Checker + associations []int // from ProgramFactories.AssignCheckers, if set } var _ CheckerPool = (*checkerPool)(nil) @@ -307,20 +308,35 @@ func newCheckerPool(program *Program) *checkerPool { } func newCheckerPoolWithTracing(program *Program, tr *tracing.Tracing) *checkerPool { + return newCheckerPoolWithAssignment(program, tr, nil) +} + +// newCheckerPoolWithAssignment is newCheckerPoolWithTracing with the checker +// of each file given by assign, if set; see ProgramFactories.AssignCheckers. +func newCheckerPoolWithAssignment(program *Program, tr *tracing.Tracing, assign func([]*ast.SourceFile) []int) *checkerPool { + var associations []int checkerCount := 4 - if program.SingleThreaded() { + if assign != nil { + associations = assign(program.files) checkerCount = 1 - } else if c := program.Options().Checkers; c != nil { - checkerCount = *c + if len(associations) > 0 { + checkerCount = slices.Max(associations) + 1 + } + } else { + if program.SingleThreaded() { + checkerCount = 1 + } else if c := program.Options().Checkers; c != nil { + checkerCount = *c + } + checkerCount = max(min(checkerCount, len(program.files), 256), 1) } - checkerCount = max(min(checkerCount, len(program.files), 256), 1) - pool := &checkerPool{ - program: program, - checkers: make([]*checker.Checker, checkerCount), - locks: make([]*sync.Mutex, checkerCount), - tracing: tr, + program: program, + checkers: make([]*checker.Checker, checkerCount), + locks: make([]*sync.Mutex, checkerCount), + tracing: tr, + associations: associations, } return pool @@ -380,8 +396,11 @@ func (p *checkerPool) createCheckers() { wg.RunAndWait() - associations := make([]int, len(p.program.files)) - if checkerCount > 1 { + associations := p.associations + if associations == nil { + associations = make([]int, len(p.program.files)) + } + if checkerCount > 1 && p.associations == nil { baseWeights := make([]int, len(p.program.files)) importCounts := make([]int, len(p.program.files)) isDeclarationFile := make([]bool, len(p.program.files)) diff --git a/tsc/internal/compiler/program.go b/tsc/internal/compiler/program.go index 92fc11e59372a..91fdd3d5e379c 100644 --- a/tsc/internal/compiler/program.go +++ b/tsc/internal/compiler/program.go @@ -60,6 +60,9 @@ type ProgramHosts struct { type ProgramFactories struct { CreateCheckerPool func(*Program) CheckerPool CreateModuleResolver func(module.ResolverOptions) module.Resolver + // AssignCheckers, for testing, returns the index of the checker for each + // file of the program, in place of the usual checker count and assignment. + AssignCheckers func(files []*ast.SourceFile) []int } func (p *ProgramConfig) canUseProjectReferenceSource() bool { @@ -324,7 +327,7 @@ func NewProgram(opts ProgramOptions) *Program { defer opts.Tracing.Push(tracing.PhaseProgram, "createProgram", map[string]any{"configFilePath": opts.Config.CompilerOptions().ConfigFilePath}, true)() } p.processedFiles, p.resolutionData, p.moduleResolutionError = processAllProgramFiles(opts, p.SingleThreaded()) - p.initCheckerPool(opts.CreateCheckerPool) + p.initCheckerPool(opts.CreateCheckerPool, opts.AssignCheckers) p.verifyCompilerOptions() p.collectContentMapperOptionDiagnostics() return p @@ -445,11 +448,11 @@ func (p *Program) ReuseProgram( } } result.replaceSyntheticImports(newFile, newSupplementalFiles) - result.initCheckerPool(createCheckerPool) + result.initCheckerPool(createCheckerPool, nil) return result, newFile, true } -func (p *Program) initCheckerPool(create func(*Program) CheckerPool) { +func (p *Program) initCheckerPool(create func(*Program) CheckerPool, assign func([]*ast.SourceFile) []int) { if !p.finishedProcessing { panic("Program must finish processing files before initializing checker pool") } @@ -457,7 +460,7 @@ func (p *Program) initCheckerPool(create func(*Program) CheckerPool) { if create != nil { p.checkerPool = create(p) } else { - pool := newCheckerPoolWithTracing(p, p.hosts.Tracing) + pool := newCheckerPoolWithAssignment(p, p.hosts.Tracing, assign) p.checkerPool = pool p.compilerCheckerPool = pool } diff --git a/tsc/internal/testrunner/compiler_runner.go b/tsc/internal/testrunner/compiler_runner.go index 6f2712632b5b8..3ea3d64238042 100644 --- a/tsc/internal/testrunner/compiler_runner.go +++ b/tsc/internal/testrunner/compiler_runner.go @@ -13,6 +13,7 @@ import ( "github.com/microsoft/TypeScript/tsc/internal/ast" "github.com/microsoft/TypeScript/tsc/internal/checker" + "github.com/microsoft/TypeScript/tsc/internal/collections" "github.com/microsoft/TypeScript/tsc/internal/core" "github.com/microsoft/TypeScript/tsc/internal/repo" "github.com/microsoft/TypeScript/tsc/internal/testutil" @@ -166,8 +167,21 @@ func (r *CompilerBaselineRunner) runTest(t *testing.T, filename string) { } } +// When a program checks its files on several checkers, these tests can see different results depending on which +// checker answers a query first. +var concurrentSkippedTests = map[string]string{ + "checkOrderCircularDefaults.ts": "Circular default results depend on which checker resolves the cycle first.", + "checkOrderSpreadCycle.ts": "Spread cycle results depend on which checker resolves the cycle first.", + "checkOrderStableInstantiationErrors.ts": "Instantiation limit errors depend on which checker instantiates first.", +} + func (r *CompilerBaselineRunner) runSingleConfigTest(t *testing.T, testName string, test *compilerFileBasedTest, config *harnessutil.NamedTestConfiguration) { t.Parallel() + if !testutil.TestProgramIsSingleThreaded() { + if msg, ok := concurrentSkippedTests[tspath.GetBaseFileName(test.filename)]; ok { + t.Skipf("Skipping in concurrent mode: %s", msg) + } + } defer testutil.RecoverAndFail(t, "Panic on compiler test "+test.filename) payload := makeUnitsFromTest(test.content, test.filename) @@ -186,6 +200,14 @@ func (r *CompilerBaselineRunner) runSingleConfigTest(t *testing.T, testName stri compilerTest.verifyParentPointers(t) } +// compilerTestVaryBy adds harness options that may vary to the compiler options +// that may vary. +var compilerTestVaryBy = func() *collections.Set[string] { + s := compilerVaryBy.Clone() + s.Add("checkorder") + return s +}() + type compilerFileBasedTest struct { filename string content string @@ -198,7 +220,7 @@ func getCompilerFileBasedTest(t *testing.T, filename string) *compilerFileBasedT panic("Could not read test file: " + filename) } settings := extractCompilerSettings(content) - configurations := harnessutil.GetFileBasedTestConfigurations(t, settings, compilerVaryBy) + configurations := harnessutil.GetFileBasedTestConfigurations(t, settings, compilerTestVaryBy) return &compilerFileBasedTest{ filename: filename, content: content, diff --git a/tsc/internal/testutil/baseline/baseline.go b/tsc/internal/testutil/baseline/baseline.go index 539728ce16579..bdec15966b34a 100644 --- a/tsc/internal/testutil/baseline/baseline.go +++ b/tsc/internal/testutil/baseline/baseline.go @@ -65,7 +65,9 @@ func writeComparison(t *testing.T, actualContent string, local, reference string if actualContent == NoContent { if err := os.WriteFile(local+".delete", []byte{}, 0o644); err != nil { t.Error(fmt.Errorf("failed to write the local baseline file %s: %w", local+".delete", err)) + return } + t.Errorf("the baseline file %s should be deleted. (Run `hereby baseline-accept` if the deletion is correct.)", reference) return } if err := os.WriteFile(local, []byte(actualContent), 0o644); err != nil { diff --git a/tsc/internal/testutil/harnessutil/checkorderfuzz.go b/tsc/internal/testutil/harnessutil/checkorderfuzz.go new file mode 100644 index 0000000000000..f9b36ddb5b9d7 --- /dev/null +++ b/tsc/internal/testutil/harnessutil/checkorderfuzz.go @@ -0,0 +1,391 @@ +package harnessutil + +import ( + "context" + "fmt" + "hash/fnv" + "math/rand/v2" + "os" + "regexp" + "strconv" + "strings" + "testing" + + "github.com/microsoft/TypeScript/tsc/internal/ast" + "github.com/microsoft/TypeScript/tsc/internal/checker" + "github.com/microsoft/TypeScript/tsc/internal/compiler" + "github.com/microsoft/TypeScript/tsc/internal/core" + "github.com/microsoft/TypeScript/tsc/internal/scanner" + "github.com/microsoft/TypeScript/tsc/internal/tsoptions" + "github.com/microsoft/TypeScript/tsc/internal/tspath" +) + +// Setting TS_CHECK_ORDER_FUZZ=n checks each test that has no checkOrder +// option n more times, each time in a fresh program that first answers a +// random selection of queries in a random order: the type, symbol, +// contextual type or resolved signature of a node, or the diagnostics of a +// file. A test fails if its diagnostics, or any of those results for any +// node, then differ from checking in program order, and reports the smallest list of queries that still makes them +// differ. TS_CHECK_ORDER_FUZZ_SEED=s runs only seed s. + +type fuzzQuery struct { + file *ast.SourceFile + node *ast.Node // nil to get the diagnostics of file + index int // of node in fuzzNodes(file) + kind fuzzQueryKind +} + +type fuzzQueryKind int + +const ( + fuzzQueryType fuzzQueryKind = iota + fuzzQuerySymbol + fuzzQueryContextualType + fuzzQuerySignature + fuzzQueryDiagnostics + fuzzQueryEmit +) + +var fuzzQueryKindNames = [...]string{ + fuzzQueryType: "type", + fuzzQuerySymbol: "symbol", + fuzzQueryContextualType: "contextual type", + fuzzQuerySignature: "signature", +} + +func (q fuzzQuery) String() string { + switch q.kind { + case fuzzQueryDiagnostics: + return fmt.Sprintf("diagnostics of %s", q.file.FileName()) + case fuzzQueryEmit: + return fmt.Sprintf("emit of %s", q.file.FileName()) + } + kind := fuzzQueryKindNames[q.kind] + if ast.PositionIsSynthesized(q.node.Pos()) { + return fmt.Sprintf("%s of synthesized %s %d in %s", kind, q.node.Kind, q.index, q.file.FileName()) + } + pos := scanner.GetTokenPosOfNode(q.node, q.file, false) + line, character := scanner.GetECMALineAndUTF16CharacterOfPosition(q.file, pos) + return fmt.Sprintf("%s of %s at %s(%d,%d)", kind, scanner.GetTextOfNode(q.node), q.file.FileName(), line+1, int(character)+1) +} + +// fuzzResult is what a check order must not change: diagnostics, emitted +// files, and the result of every query of every queryable node. +type fuzzResult []string + +func fuzzCheckOrder(t *testing.T, host compiler.CompilerHost, config *tsoptions.ParsedCommandLine, harnessOptions *HarnessOptions) { + n, _ := strconv.Atoi(os.Getenv("TS_CHECK_ORDER_FUZZ")) + if t == nil || n <= 0 || harnessOptions.CheckOrder != "" && harnessOptions.CheckOrder != "default" { + return + } + options := config.CompilerOptions().Clone() + options.TraceResolution = core.TSFalse + fuzzConfig := tsoptions.NewParsedCommandLine(options, config.FileNames(), config.ProjectReferences(), config.BaseDirectory(), config.CaseSensitivity()) + fuzzConfig.ParsedConfig.ContentMappers = config.ContentMappers() + fuzzConfig.ConfigFile = config.ConfigFile + fuzzConfig.Errors = config.Errors + + ctx := context.Background() + expected := fuzzRun(ctx, host, fuzzConfig, nil, nil) + seeds := make([]uint64, n) + for i := range seeds { + seeds[i] = uint64(i) + } + if s := os.Getenv("TS_CHECK_ORDER_FUZZ_SEED"); s != "" { + seed, err := strconv.ParseUint(s, 10, 64) + if err != nil { + t.Fatalf("invalid TS_CHECK_ORDER_FUZZ_SEED: %v", err) + } + seeds = []uint64{seed} + } + h := fnv.New64a() + h.Write([]byte(t.Name())) + stream := h.Sum64() + for _, seed := range seeds { + rng := rand.New(rand.NewPCG(seed, stream)) + queries := fuzzQueries(createProgram(host, fuzzConfig), rng) + assign := fuzzAssignCheckers(rng) + diverges := func(queries []fuzzQuery) bool { + return fuzzDiff(expected, fuzzRun(ctx, host, fuzzConfig, assign, queries)) != "" + } + if !diverges(queries) { + continue + } + var b strings.Builder + fmt.Fprintf(&b, "check order fuzzing with TS_CHECK_ORDER_FUZZ_SEED=%d changed results", seed) + if assign != nil { + b.WriteString(" with files checked by checkers:\n") + program := createProgram(host, fuzzConfig).Program() + files := program.GetSourceFiles() + for i, c := range assign(files) { + if !program.IsSourceFileDefaultLibrary(files[i].PathKey()) { + fmt.Fprintf(&b, " %s: %d\n", files[i].FileName(), c) + } + } + } else { + b.WriteString("\n") + } + if diverges(nil) { + queries = nil + } else { + queries = fuzzMinimize(queries, diverges) + b.WriteString("after querying:\n") + for _, q := range queries { + fmt.Fprintf(&b, " %s\n", q) + } + } + b.WriteString("results in program order (-) and after the queries (+):\n") + b.WriteString(fuzzDiff(expected, fuzzRun(ctx, host, fuzzConfig, assign, queries))) + t.Error(b.String()) + } +} + +// fuzzQueries returns the queries for one seed: a random selection of every +// possible query, often only a few so that the first query matters. +func fuzzQueries(program compiler.ProgramLike, rng *rand.Rand) []fuzzQuery { + var queries []fuzzQuery + for _, file := range fuzzCheckedFiles(program) { + queries = append(queries, fuzzQuery{file: file, kind: fuzzQueryDiagnostics}, fuzzQuery{file: file, kind: fuzzQueryEmit}) + for i, node := range fuzzNodes(file) { + for _, kind := range fuzzNodeQueryKinds(node) { + queries = append(queries, fuzzQuery{file, node, i, kind}) + } + } + } + rng.Shuffle(len(queries), func(i, j int) { queries[i], queries[j] = queries[j], queries[i] }) + if len(queries) == 0 { + return nil + } + switch rng.IntN(3) { + case 0: + return queries[:1+rng.IntN(min(len(queries), 4))] + case 1: + return queries[:rng.IntN(len(queries)+1)] + default: + return queries + } +} + +// fuzzMinimize returns a 1-minimal sublist of queries for which diverges +// still holds (Zeller's ddmin). +func fuzzMinimize(queries []fuzzQuery, diverges func([]fuzzQuery) bool) []fuzzQuery { + n := 2 + for len(queries) >= 2 { + chunk := (len(queries) + n - 1) / n + reduced := false + for start := 0; start < len(queries); start += chunk { + complement := append(queries[:start:start], queries[min(start+chunk, len(queries)):]...) + if diverges(complement) { + queries = complement + n = max(n-1, 2) + reduced = true + break + } + } + if !reduced { + if n >= len(queries) { + break + } + n = min(n*2, len(queries)) + } + } + return queries +} + +func fuzzCheckedFiles(program compiler.ProgramLike) []*ast.SourceFile { + var files []*ast.SourceFile + for _, file := range program.GetSourceFiles() { + if !program.Program().SkipTypeChecking(file, false) { + files = append(files, file) + } + } + return files +} + +// fuzzNodes returns the nodes of file that queryNodes queries. +func fuzzNodes(file *ast.SourceFile) []*ast.Node { + var nodes []*ast.Node + var visit func(n *ast.Node) bool + visit = func(n *ast.Node) bool { + if n.Flags&ast.NodeFlagsReparsed == 0 && (ast.IsExpressionNode(n) || n.Kind == ast.KindIdentifier || ast.IsDeclarationName(n)) { + nodes = append(nodes, n) + } + n.ForEachChild(visit) + return false + } + file.AsNode().ForEachChild(visit) + return nodes +} + +func fuzzHasType(node *ast.Node) bool { + return !ast.IsOmittedExpression(node) +} + +// fuzzNodeQueryKinds returns the kinds of query that apply to node. +func fuzzNodeQueryKinds(node *ast.Node) []fuzzQueryKind { + kinds := make([]fuzzQueryKind, 0, 4) + if fuzzHasType(node) { + kinds = append(kinds, fuzzQueryType) + if ast.IsExpression(node) { + kinds = append(kinds, fuzzQueryContextualType) + } + } + kinds = append(kinds, fuzzQuerySymbol) + if ast.IsCallLikeExpression(node) { + kinds = append(kinds, fuzzQuerySignature) + } + return kinds +} + +// fuzzSymbolIDs matches the symbol IDs that the names of unique symbol +// properties end with, which depend on the order symbols were created in. +var fuzzSymbolIDs = regexp.MustCompile(`(\\uFFFD@[^@"]*)@\d+`) + +// fuzzQueryResult answers a query of a node, returning its result as text, +// or "" if it has none. +func fuzzQueryResult(c *checker.Checker, node *ast.Node, kind fuzzQueryKind) string { + return fuzzSymbolIDs.ReplaceAllString(fuzzQueryResultWithIDs(c, node, kind), "$1") +} + +func fuzzQueryResultWithIDs(c *checker.Checker, node *ast.Node, kind fuzzQueryKind) string { + switch kind { + case fuzzQueryType: + return c.TypeToString(c.GetTypeAtLocation(node)) + case fuzzQuerySymbol: + if symbol := c.GetSymbolAtLocation(node); symbol != nil { + return c.SymbolToString(symbol) + } + case fuzzQueryContextualType: + if t := c.GetContextualType(node, checker.ContextFlagsNone); t != nil { + return c.TypeToString(t) + } + case fuzzQuerySignature: + if signature := c.GetResolvedSignature(node); signature != nil { + return c.SignatureToStringEx(signature, nil, checker.TypeFormatFlagsNone, nil) + } + } + return "" +} + +// fuzzAssignCheckers returns, for half of the seeds, a random assignment of +// files to up to four checkers, so that results cannot depend on which +// files share a checker. +func fuzzAssignCheckers(rng *rand.Rand) func([]*ast.SourceFile) []int { + if rng.IntN(2) == 0 { + return nil + } + count := 2 + rng.IntN(3) + seed := rng.Uint64() + return func(files []*ast.SourceFile) []int { + r := rand.New(rand.NewPCG(seed, 0)) + associations := make([]int, len(files)) + for i := range associations { + associations[i] = r.IntN(count) + } + return associations + } +} + +// fuzzRun answers queries, given in the files of the program that +// fuzzQueries was given, in a fresh program, then returns its results. +func fuzzRun(ctx context.Context, host compiler.CompilerHost, config *tsoptions.ParsedCommandLine, assign func([]*ast.SourceFile) []int, queries []fuzzQuery) fuzzResult { + program := createProgramWithCheckers(host, config, assign) + files := fuzzCheckedFiles(program) + // Queries name nodes of another program over the same files, so find + // the same nodes here by their index. + nodesByFile := make(map[string][]*ast.Node) + for _, file := range files { + nodesByFile[string(file.FileName())] = fuzzNodes(file) + } + for _, q := range queries { + file := program.GetSourceFile(q.file.FileName()) + switch q.kind { + case fuzzQueryDiagnostics: + program.GetSemanticDiagnostics(ctx, file) + continue + case fuzzQueryEmit: + program.Emit(ctx, compiler.EmitOptions{TargetSourceFiles: []*ast.SourceFile{file}, WriteFile: fuzzDiscardOutput}) + continue + } + node := nodesByFile[string(file.FileName())][q.index] + c, done := program.Program().GetTypeCheckerForFile(ctx, file) + fuzzQueryResult(c, node, q.kind) + done() + } + + var diags []*ast.Diagnostic + diags = append(diags, program.GetSyntacticDiagnostics(ctx, nil)...) + diags = append(diags, program.GetSemanticDiagnostics(ctx, nil)...) + diags = append(diags, program.GetGlobalDiagnostics(ctx)...) + if program.Options().GetEmitDeclarations() { + diags = append(diags, program.GetDeclarationDiagnostics(ctx, nil)...) + } + var result fuzzResult + for _, d := range compiler.SortAndDeduplicateDiagnostics(diags) { + var b strings.Builder + fuzzFormatDiagnostic(&b, d, "") + result = append(result, b.String()) + } + program.Emit(ctx, compiler.EmitOptions{WriteFile: func(fileName tspath.RootedFilePath, text string, data *compiler.WriteFileData) error { + result = append(result, fmt.Sprintf("emit of %s:\n%s", fileName, text)) + return nil + }}) + for _, file := range files { + c, done := program.Program().GetTypeCheckerForFile(ctx, file) + for i, node := range nodesByFile[string(file.FileName())] { + for _, kind := range fuzzNodeQueryKinds(node) { + if r := fuzzQueryResult(c, node, kind); r != "" { + result = append(result, fmt.Sprintf("%s: %s", fuzzQuery{file, node, i, kind}, r)) + } + } + } + done() + } + return result +} + +func fuzzDiscardOutput(tspath.RootedFilePath, string, *compiler.WriteFileData) error { + return nil +} + +func fuzzFormatDiagnostic(b *strings.Builder, d *ast.Diagnostic, indent string) { + b.WriteString(indent) + if d.File() != nil { + line, character := scanner.GetECMALineAndUTF16CharacterOfPosition(d.File(), d.Pos()) + fmt.Fprintf(b, "%s(%d,%d): ", d.File().FileName(), line+1, int(character)+1) + } + fmt.Fprintf(b, "TS%d: %s", d.Code(), d.String()) + for _, chained := range d.MessageChain() { + b.WriteString("\n") + fuzzFormatDiagnostic(b, chained, indent+" ") + } + for _, related := range d.RelatedInformation() { + b.WriteString("\n") + fuzzFormatDiagnostic(b, related, indent+" related ") + } +} + +// fuzzDiff describes how actual differs from expected, or returns "". +func fuzzDiff(expected, actual fuzzResult) string { + count := make(map[string]int) + for _, line := range expected { + count[line]++ + } + for _, line := range actual { + count[line]-- + } + var b strings.Builder + for _, line := range expected { + if count[line] > 0 { + count[line]-- + fmt.Fprintf(&b, "- %s\n", line) + } + } + for _, line := range actual { + if count[line] < 0 { + count[line]++ + fmt.Fprintf(&b, "+ %s\n", line) + } + } + return b.String() +} diff --git a/tsc/internal/testutil/harnessutil/harnessutil.go b/tsc/internal/testutil/harnessutil/harnessutil.go index bca59282a69fa..80a235f00b0d0 100644 --- a/tsc/internal/testutil/harnessutil/harnessutil.go +++ b/tsc/internal/testutil/harnessutil/harnessutil.go @@ -18,6 +18,7 @@ import ( "github.com/microsoft/TypeScript/tsc/internal/ast" "github.com/microsoft/TypeScript/tsc/internal/bundled" + "github.com/microsoft/TypeScript/tsc/internal/checker" "github.com/microsoft/TypeScript/tsc/internal/collections" "github.com/microsoft/TypeScript/tsc/internal/compiler" "github.com/microsoft/TypeScript/tsc/internal/contentmapper" @@ -76,6 +77,7 @@ type HarnessOptions struct { ReportDiagnostics bool CaptureSuggestions bool TypescriptVersion string + CheckOrder string } func CompileFiles( @@ -226,6 +228,7 @@ func CompileFilesEx( result := compileFilesWithHost(host, config, harnessOptions) result.Symlinks = symlinks result.Trace = host.tracer.String() + fuzzCheckOrder(t, host, config, harnessOptions) result.Repeat = func(testConfig TestConfiguration) *CompilationResult { newHarnessOptions := *harnessOptions newCompilerOptions := compilerOptions.Clone() @@ -362,6 +365,28 @@ var harnessCommandLineOptions = []*tsoptions.CommandLineOption{ Name: "captureSuggestions", Kind: tsoptions.CommandLineOptionTypeBoolean, }, + // Changes the order in which the checker is queried; see checkOrders + { + Name: "checkOrder", + Kind: tsoptions.CommandLineOptionTypeString, + }, +} + +// Checker results should not depend on the order in which files and +// locations are queried. These orders let tests demonstrate that. Each +// applies to both checking and emit, which queries the checker too. +var checkOrders = []string{ + // Check and emit all files in program order. + "default", + // Check and emit files one at a time in reverse program order. + "reverse", + // Check and emit each file with a fresh program that has checked + // nothing else. + "isolated", + // Before checking or emitting, ask for the type, symbol, contextual + // type and resolved signature of every expression and name in each + // file, innermost and last first, as an editor might. + "typesfirst", } func getHarnessOption(name string) *tsoptions.CommandLineOption { @@ -407,6 +432,12 @@ func parseHarnessOption(t *testing.T, key string, value any, harnessOptions *Har harnessOptions.CaptureSuggestions = value.(bool) case "typescriptVersion": harnessOptions.TypescriptVersion = value.(string) + case "checkOrder": + order := strings.ToLower(value.(string)) + if !slices.Contains(checkOrders, order) { + t.Fatalf("Unknown check order '%s'.", value) + } + harnessOptions.CheckOrder = order default: t.Fatalf("Unknown harness option '%s'.", key) } @@ -644,8 +675,7 @@ func compileFilesWithHost( preErrors = append(preErrors, preProgram.GetConfigFileParsingDiagnostics()...) preErrors = append(preErrors, preProgram.GetProgramDiagnostics()...) preErrors = append(preErrors, preProgram.GetSyntacticDiagnostics(ctx, nil)...) - preErrors = append(preErrors, preProgram.GetSemanticDiagnostics(ctx, nil)...) - preErrors = append(preErrors, preProgram.GetGlobalDiagnostics(ctx)...) + preErrors = append(preErrors, getCheckerDiagnostics(ctx, host, preConfig, preProgram, harnessOptions.CheckOrder)...) if harnessOptions.CaptureSuggestions { preErrors = append(preErrors, preProgram.GetSuggestionDiagnostics(ctx, nil)...) } @@ -655,13 +685,12 @@ func compileFilesWithHost( preErrors = compiler.SortAndDeduplicateDiagnostics(preErrors) postProgram := createProgram(host, config) - emitResult := postProgram.Emit(ctx, compiler.EmitOptions{}) + emitResult := emitInOrder(ctx, host, config, postProgram, harnessOptions.CheckOrder) var postErrors []*ast.Diagnostic postErrors = append(postErrors, postProgram.GetConfigFileParsingDiagnostics()...) postErrors = append(postErrors, postProgram.GetProgramDiagnostics()...) postErrors = append(postErrors, postProgram.GetSyntacticDiagnostics(ctx, nil)...) - postErrors = append(postErrors, postProgram.GetSemanticDiagnostics(ctx, nil)...) - postErrors = append(postErrors, postProgram.GetGlobalDiagnostics(ctx)...) + postErrors = append(postErrors, getCheckerDiagnostics(ctx, host, config, postProgram, harnessOptions.CheckOrder)...) if postProgram.Options().GetEmitDeclarations() { postErrors = append(postErrors, postProgram.GetDeclarationDiagnostics(ctx, nil)...) } @@ -701,6 +730,113 @@ func compileFilesWithHost( return newCompilationResult(host, harnessOptions.CurrentDirectory, config.CompilerOptions(), postProgram, emitResult, errors, harnessOptions) } +// getCheckerDiagnostics returns the semantic and global diagnostics of +// program, querying the checker in the given order. +func getCheckerDiagnostics(ctx context.Context, host compiler.CompilerHost, config *tsoptions.ParsedCommandLine, program compiler.ProgramLike, order string) []*ast.Diagnostic { + var files []*ast.SourceFile + for _, file := range program.GetSourceFiles() { + if !program.Program().SkipTypeChecking(file, false) { + files = append(files, file) + } + } + var result []*ast.Diagnostic + switch order { + case "", "default": + result = append(result, program.GetSemanticDiagnostics(ctx, nil)...) + result = append(result, program.GetGlobalDiagnostics(ctx)...) + case "reverse": + for _, file := range slices.Backward(files) { + result = append(result, program.GetSemanticDiagnostics(ctx, file)...) + } + result = append(result, program.GetGlobalDiagnostics(ctx)...) + case "isolated": + for _, file := range files { + isolated := createProgram(host, config) + isolatedFile := isolated.GetSourceFile(file.FileName()) + result = append(result, isolated.GetSemanticDiagnostics(ctx, isolatedFile)...) + result = append(result, isolated.GetGlobalDiagnostics(ctx)...) + } + case "typesfirst": + for _, file := range slices.Backward(files) { + c, done := program.Program().GetTypeCheckerForFile(ctx, file) + queryNodes(c, file) + done() + } + result = append(result, program.GetSemanticDiagnostics(ctx, nil)...) + result = append(result, program.GetGlobalDiagnostics(ctx)...) + default: + panic("unknown check order " + order) + } + return compiler.SortAndDeduplicateDiagnostics(result) +} + +// emitInOrder emits program, querying the checker in the given order: each +// file emitted separately, in reverse or in a program of its own, or after +// querying every node of every file in reverse. +func emitInOrder(ctx context.Context, host compiler.CompilerHost, config *tsoptions.ParsedCommandLine, program compiler.ProgramLike, order string) *compiler.EmitResult { + options := program.Options() + if order == "" || order == "default" || options.OutFile != "" || options.NoEmitOnError.IsTrue() { + // Emitting files separately would change what a bundle or an emit + // blocked by errors contains. + return program.Emit(ctx, compiler.EmitOptions{}) + } + files := program.GetSourceFiles() + if order == "typesfirst" { + for _, file := range slices.Backward(files) { + if program.Program().SkipTypeChecking(file, false) { + continue + } + c, done := program.Program().GetTypeCheckerForFile(ctx, file) + queryNodes(c, file) + done() + } + return program.Emit(ctx, compiler.EmitOptions{}) + } + result := &compiler.EmitResult{} + emitFile := func(p compiler.ProgramLike, file *ast.SourceFile) { + r := p.Emit(ctx, compiler.EmitOptions{TargetSourceFiles: []*ast.SourceFile{file}}) + result.EmitSkipped = result.EmitSkipped || r.EmitSkipped + result.Diagnostics = append(result.Diagnostics, r.Diagnostics...) + result.EmittedFiles = append(result.EmittedFiles, r.EmittedFiles...) + result.SourceMaps = append(result.SourceMaps, r.SourceMaps...) + } + switch order { + case "reverse": + for _, file := range slices.Backward(files) { + emitFile(program, file) + } + case "isolated": + for _, file := range files { + isolated := createProgram(host, config) + emitFile(isolated, isolated.GetSourceFile(file.FileName())) + } + default: + panic("unknown check order " + order) + } + result.Diagnostics = compiler.SortAndDeduplicateDiagnostics(result.Diagnostics) + return result +} + +func queryNodes(c *checker.Checker, file *ast.SourceFile) { + var nodes []*ast.Node + var visit func(n *ast.Node) bool + visit = func(n *ast.Node) bool { + if n.Flags&ast.NodeFlagsReparsed == 0 { + nodes = append(nodes, n) + } + n.ForEachChild(visit) + return false + } + file.AsNode().ForEachChild(visit) + for _, n := range slices.Backward(nodes) { + if ast.IsExpressionNode(n) || n.Kind == ast.KindIdentifier || ast.IsDeclarationName(n) { + for _, kind := range fuzzNodeQueryKinds(n) { + fuzzQueryResult(c, n, kind) + } + } + } +} + type CompilationResult struct { Diagnostics []*ast.Diagnostic Result *compiler.EmitResult @@ -971,6 +1107,10 @@ func getTestBuildInfoReader(host compiler.CompilerHost) *testBuildInfoReader { } func createProgram(host compiler.CompilerHost, config *tsoptions.ParsedCommandLine) compiler.ProgramLike { + return createProgramWithCheckers(host, config, nil) +} + +func createProgramWithCheckers(host compiler.CompilerHost, config *tsoptions.ParsedCommandLine, assignCheckers func([]*ast.SourceFile) []int) compiler.ProgramLike { var singleThreaded core.Tristate if testutil.TestProgramIsSingleThreaded() { singleThreaded = core.TSTrue @@ -980,6 +1120,7 @@ func createProgram(host compiler.CompilerHost, config *tsoptions.ParsedCommandLi Config: config, Host: host, SingleThreaded: singleThreaded, + AssignCheckers: assignCheckers, } program := compiler.NewProgram(programOptions) if config.CompilerOptions().Incremental.IsTrue() { @@ -1159,6 +1300,9 @@ func getValueOfOptionString(t *testing.T, option string, value string) tsoptions func tryGetValueOfOptionString(option string, value string) (tsoptions.CompilerOptionsValue, bool) { optionDecl := getCommandLineOption(option) + if optionDecl == nil { + optionDecl = getHarnessOption(option) + } if optionDecl == nil { return nil, false } diff --git a/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=default).errors.txt new file mode 100644 index 0000000000000..5a959d4e04b62 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=default).errors.txt @@ -0,0 +1,69 @@ +badExport.ts(1,10): error TS2304: Cannot find name 'foo'. +badExport.ts(1,17): error TS1003: Identifier expected. +badExport.ts(1,20): error TS1128: Declaration or statement expected. +badExport2.ts(1,10): error TS1003: Identifier expected. +badExport2.ts(1,16): error TS2304: Cannot find name 'foo'. +badExport2.ts(1,20): error TS1128: Declaration or statement expected. +badImport.ts(1,10): error TS1003: Identifier expected. +badImport.ts(1,10): error TS1141: String literal expected. +badImport.ts(1,20): error TS1128: Declaration or statement expected. +badImport.ts(1,22): error TS1434: Unexpected keyword or identifier. +badImport.ts(1,22): error TS2304: Cannot find name 'from'. +badImport2.ts(1,17): error TS1003: Identifier expected. +badImport2.ts(1,17): error TS1141: String literal expected. +badImport2.ts(1,20): error TS1128: Declaration or statement expected. +badImport2.ts(1,22): error TS1434: Unexpected keyword or identifier. +badImport2.ts(1,22): error TS2304: Cannot find name 'from'. + + +==== foo.ts (0 errors) ==== + const foo = 0n; + export { foo as "0n" }; + +==== correctUse.ts (0 errors) ==== + import { "0n" as foo } from "./foo"; + export { foo as "0n" }; + +==== badImport.ts (5 errors) ==== + import { 0n as foo } from "./foo"; + ~~ +!!! error TS1003: Identifier expected. + ~~~~~~~~~ +!!! error TS1141: String literal expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS1434: Unexpected keyword or identifier. + ~~~~ +!!! error TS2304: Cannot find name 'from'. + +==== badImport2.ts (5 errors) ==== + import { foo as 0n } from "./foo"; + ~~ +!!! error TS1003: Identifier expected. + ~~ +!!! error TS1141: String literal expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS1434: Unexpected keyword or identifier. + ~~~~ +!!! error TS2304: Cannot find name 'from'. + +==== badExport.ts (3 errors) ==== + export { foo as 0n }; + ~~~ +!!! error TS2304: Cannot find name 'foo'. + ~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1128: Declaration or statement expected. + +==== badExport2.ts (3 errors) ==== + export { 0n as foo }; + ~~ +!!! error TS1003: Identifier expected. + ~~~ +!!! error TS2304: Cannot find name 'foo'. + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=default).js new file mode 100644 index 0000000000000..139c1991c8c3f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=default).js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/bigintArbirtraryIdentifier.ts] //// + +//// [foo.ts] +const foo = 0n; +export { foo as "0n" }; + +//// [correctUse.ts] +import { "0n" as foo } from "./foo"; +export { foo as "0n" }; + +//// [badImport.ts] +import { 0n as foo } from "./foo"; + +//// [badImport2.ts] +import { foo as 0n } from "./foo"; + +//// [badExport.ts] +export { foo as 0n }; + +//// [badExport2.ts] +export { 0n as foo }; + +//// [foo.js] +const foo = 0n; +export { foo as "0n" }; +//// [correctUse.js] +import { "0n" as foo } from "./foo"; +export { foo as "0n" }; +//// [badImport.js] +from; +"./foo"; +export {}; +//// [badImport2.js] +from; +"./foo"; +export {}; +//// [badExport.js] +export { foo as }; +0n; +; +//// [badExport2.js] +0n; +; +export {}; diff --git a/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=default).symbols new file mode 100644 index 0000000000000..8ef83a9eaec97 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=default).symbols @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/bigintArbirtraryIdentifier.ts] //// + +=== foo.ts === +const foo = 0n; +>foo : Symbol(foo, Decl(foo.ts, 0, 5)) + +export { foo as "0n" }; +>foo : Symbol(foo, Decl(foo.ts, 0, 5)) +>"0n" : Symbol("0n", Decl(foo.ts, 1, 8)) + +=== correctUse.ts === +import { "0n" as foo } from "./foo"; +>foo : Symbol(foo, Decl(correctUse.ts, 0, 8)) + +export { foo as "0n" }; +>foo : Symbol(foo, Decl(correctUse.ts, 0, 8)) +>"0n" : Symbol("0n", Decl(correctUse.ts, 1, 8)) + +=== badImport.ts === +import { 0n as foo } from "./foo"; +>foo : Symbol(foo) + +=== badImport2.ts === +import { foo as 0n } from "./foo"; +> : Symbol((Missing), Decl(badImport2.ts, 0, 8)) + +=== badExport.ts === +export { foo as 0n }; +> : Symbol((Missing), Decl(badExport.ts, 0, 8)) + +=== badExport2.ts === +export { 0n as foo }; +>foo : Symbol(foo) + diff --git a/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=default).types new file mode 100644 index 0000000000000..c3f2d2ceb5859 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=default).types @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/bigintArbirtraryIdentifier.ts] //// + +=== foo.ts === +const foo = 0n; +>foo : 0n +>0n : 0n + +export { foo as "0n" }; +>foo : 0n +>"0n" : 0n + +=== correctUse.ts === +import { "0n" as foo } from "./foo"; +>foo : 0n + +export { foo as "0n" }; +>foo : 0n +>"0n" : 0n + +=== badImport.ts === +import { 0n as foo } from "./foo"; +>0n as foo : foo +>0n : 0n +>from : any +>"./foo" : "./foo" + +=== badImport2.ts === +import { foo as 0n } from "./foo"; +>foo : any +> : any +>from : any +>"./foo" : "./foo" + +=== badExport.ts === +export { foo as 0n }; +>foo : any +> : any +>0n : 0n + +=== badExport2.ts === +export { 0n as foo }; +>0n as foo : foo +>0n : 0n + diff --git a/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..e70af53237c1f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=typesfirst).errors.txt @@ -0,0 +1,72 @@ +badExport.ts(1,10): error TS2304: Cannot find name 'foo'. +badExport.ts(1,17): error TS1003: Identifier expected. +badExport.ts(1,20): error TS1128: Declaration or statement expected. +badExport2.ts(1,10): error TS1003: Identifier expected. +badExport2.ts(1,16): error TS2304: Cannot find name 'foo'. +badExport2.ts(1,20): error TS1128: Declaration or statement expected. +badImport.ts(1,10): error TS1003: Identifier expected. +badImport.ts(1,10): error TS1141: String literal expected. +badImport.ts(1,16): error TS2304: Cannot find name 'foo'. +badImport.ts(1,20): error TS1128: Declaration or statement expected. +badImport.ts(1,22): error TS1434: Unexpected keyword or identifier. +badImport.ts(1,22): error TS2304: Cannot find name 'from'. +badImport2.ts(1,17): error TS1003: Identifier expected. +badImport2.ts(1,17): error TS1141: String literal expected. +badImport2.ts(1,20): error TS1128: Declaration or statement expected. +badImport2.ts(1,22): error TS1434: Unexpected keyword or identifier. +badImport2.ts(1,22): error TS2304: Cannot find name 'from'. + + +==== foo.ts (0 errors) ==== + const foo = 0n; + export { foo as "0n" }; + +==== correctUse.ts (0 errors) ==== + import { "0n" as foo } from "./foo"; + export { foo as "0n" }; + +==== badImport.ts (6 errors) ==== + import { 0n as foo } from "./foo"; + ~~ +!!! error TS1003: Identifier expected. + ~~~~~~~~~ +!!! error TS1141: String literal expected. + ~~~ +!!! error TS2304: Cannot find name 'foo'. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS1434: Unexpected keyword or identifier. + ~~~~ +!!! error TS2304: Cannot find name 'from'. + +==== badImport2.ts (5 errors) ==== + import { foo as 0n } from "./foo"; + ~~ +!!! error TS1003: Identifier expected. + ~~ +!!! error TS1141: String literal expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS1434: Unexpected keyword or identifier. + ~~~~ +!!! error TS2304: Cannot find name 'from'. + +==== badExport.ts (3 errors) ==== + export { foo as 0n }; + ~~~ +!!! error TS2304: Cannot find name 'foo'. + ~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1128: Declaration or statement expected. + +==== badExport2.ts (3 errors) ==== + export { 0n as foo }; + ~~ +!!! error TS1003: Identifier expected. + ~~~ +!!! error TS2304: Cannot find name 'foo'. + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=typesfirst).js new file mode 100644 index 0000000000000..139c1991c8c3f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=typesfirst).js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/bigintArbirtraryIdentifier.ts] //// + +//// [foo.ts] +const foo = 0n; +export { foo as "0n" }; + +//// [correctUse.ts] +import { "0n" as foo } from "./foo"; +export { foo as "0n" }; + +//// [badImport.ts] +import { 0n as foo } from "./foo"; + +//// [badImport2.ts] +import { foo as 0n } from "./foo"; + +//// [badExport.ts] +export { foo as 0n }; + +//// [badExport2.ts] +export { 0n as foo }; + +//// [foo.js] +const foo = 0n; +export { foo as "0n" }; +//// [correctUse.js] +import { "0n" as foo } from "./foo"; +export { foo as "0n" }; +//// [badImport.js] +from; +"./foo"; +export {}; +//// [badImport2.js] +from; +"./foo"; +export {}; +//// [badExport.js] +export { foo as }; +0n; +; +//// [badExport2.js] +0n; +; +export {}; diff --git a/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..8ef83a9eaec97 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=typesfirst).symbols @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/bigintArbirtraryIdentifier.ts] //// + +=== foo.ts === +const foo = 0n; +>foo : Symbol(foo, Decl(foo.ts, 0, 5)) + +export { foo as "0n" }; +>foo : Symbol(foo, Decl(foo.ts, 0, 5)) +>"0n" : Symbol("0n", Decl(foo.ts, 1, 8)) + +=== correctUse.ts === +import { "0n" as foo } from "./foo"; +>foo : Symbol(foo, Decl(correctUse.ts, 0, 8)) + +export { foo as "0n" }; +>foo : Symbol(foo, Decl(correctUse.ts, 0, 8)) +>"0n" : Symbol("0n", Decl(correctUse.ts, 1, 8)) + +=== badImport.ts === +import { 0n as foo } from "./foo"; +>foo : Symbol(foo) + +=== badImport2.ts === +import { foo as 0n } from "./foo"; +> : Symbol((Missing), Decl(badImport2.ts, 0, 8)) + +=== badExport.ts === +export { foo as 0n }; +> : Symbol((Missing), Decl(badExport.ts, 0, 8)) + +=== badExport2.ts === +export { 0n as foo }; +>foo : Symbol(foo) + diff --git a/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=typesfirst).types new file mode 100644 index 0000000000000..c3f2d2ceb5859 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/bigintArbirtraryIdentifier(checkorder=typesfirst).types @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/bigintArbirtraryIdentifier.ts] //// + +=== foo.ts === +const foo = 0n; +>foo : 0n +>0n : 0n + +export { foo as "0n" }; +>foo : 0n +>"0n" : 0n + +=== correctUse.ts === +import { "0n" as foo } from "./foo"; +>foo : 0n + +export { foo as "0n" }; +>foo : 0n +>"0n" : 0n + +=== badImport.ts === +import { 0n as foo } from "./foo"; +>0n as foo : foo +>0n : 0n +>from : any +>"./foo" : "./foo" + +=== badImport2.ts === +import { foo as 0n } from "./foo"; +>foo : any +> : any +>from : any +>"./foo" : "./foo" + +=== badExport.ts === +export { foo as 0n }; +>foo : any +> : any +>0n : 0n + +=== badExport2.ts === +export { 0n as foo }; +>0n as foo : foo +>0n : 0n + diff --git a/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=default).errors.txt new file mode 100644 index 0000000000000..fa22beceb33e2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=default).errors.txt @@ -0,0 +1,27 @@ +weird.js(1,1): error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? +weird.js(1,23): error TS7006: Parameter 'BaseClass' implicitly has an 'any' type. +weird.js(9,17): error TS7006: Parameter 'error' implicitly has an 'any' type. + + +==== weird.js (3 errors) ==== + someFunction(function(BaseClass) { + ~~~~~~~~~~~~ +!!! error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~~ +!!! error TS7006: Parameter 'BaseClass' implicitly has an 'any' type. + 'use strict'; + const DEFAULT_MESSAGE = "nop!"; + class Hello extends BaseClass { + constructor() { + super(); + this.foo = "bar"; + } + _render(error) { + ~~~~~ +!!! error TS7006: Parameter 'error' implicitly has an 'any' type. + const message = error.message || DEFAULT_MESSAGE; + } + } + }); + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=default).symbols new file mode 100644 index 0000000000000..99ddd57e9d8cd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=default).symbols @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts] //// + +=== weird.js === +someFunction(function(BaseClass) { +>BaseClass : Symbol(BaseClass, Decl(weird.js, 0, 22)) + + 'use strict'; + const DEFAULT_MESSAGE = "nop!"; +>DEFAULT_MESSAGE : Symbol(DEFAULT_MESSAGE, Decl(weird.js, 2, 9)) + + class Hello extends BaseClass { +>Hello : Symbol(Hello, Decl(weird.js, 2, 35)) +>BaseClass : Symbol(BaseClass, Decl(weird.js, 0, 22)) + + constructor() { + super(); + this.foo = "bar"; +>this.foo : Symbol(Hello.foo, Decl(weird.js, 5, 20)) +>this : Symbol(Hello, Decl(weird.js, 2, 35)) +>foo : Symbol(Hello.foo, Decl(weird.js, 5, 20)) + } + _render(error) { +>_render : Symbol(Hello._render, Decl(weird.js, 7, 9)) +>error : Symbol(error, Decl(weird.js, 8, 16)) + + const message = error.message || DEFAULT_MESSAGE; +>message : Symbol(message, Decl(weird.js, 9, 17)) +>error : Symbol(error, Decl(weird.js, 8, 16)) +>DEFAULT_MESSAGE : Symbol(DEFAULT_MESSAGE, Decl(weird.js, 2, 9)) + } + } +}); + diff --git a/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=default).types new file mode 100644 index 0000000000000..7f98768cc3b3e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=default).types @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts] //// + +=== weird.js === +someFunction(function(BaseClass) { +>someFunction(function(BaseClass) { 'use strict'; const DEFAULT_MESSAGE = "nop!"; class Hello extends BaseClass { constructor() { super(); this.foo = "bar"; } _render(error) { const message = error.message || DEFAULT_MESSAGE; } }}) : any +>someFunction : any +>function(BaseClass) { 'use strict'; const DEFAULT_MESSAGE = "nop!"; class Hello extends BaseClass { constructor() { super(); this.foo = "bar"; } _render(error) { const message = error.message || DEFAULT_MESSAGE; } }} : (BaseClass: any) => void +>BaseClass : any + + 'use strict'; +>'use strict' : "use strict" + + const DEFAULT_MESSAGE = "nop!"; +>DEFAULT_MESSAGE : "nop!" +>"nop!" : "nop!" + + class Hello extends BaseClass { +>Hello : Hello +>BaseClass : any + + constructor() { + super(); +>super() : void +>super : any + + this.foo = "bar"; +>this.foo = "bar" : "bar" +>this.foo : any +>this : this +>foo : any +>"bar" : "bar" + } + _render(error) { +>_render : (error: any) => void +>error : any + + const message = error.message || DEFAULT_MESSAGE; +>message : any +>error.message || DEFAULT_MESSAGE : any +>error.message : any +>error : any +>message : any +>DEFAULT_MESSAGE : "nop!" + } + } +}); + diff --git a/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..a15bd4d38db0d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=typesfirst).errors.txt @@ -0,0 +1,24 @@ +weird.js(1,1): error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? +weird.js(9,17): error TS7006: Parameter 'error' implicitly has an 'any' type. + + +==== weird.js (2 errors) ==== + someFunction(function(BaseClass) { + ~~~~~~~~~~~~ +!!! error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + 'use strict'; + const DEFAULT_MESSAGE = "nop!"; + class Hello extends BaseClass { + constructor() { + super(); + this.foo = "bar"; + } + _render(error) { + ~~~~~ +!!! error TS7006: Parameter 'error' implicitly has an 'any' type. + const message = error.message || DEFAULT_MESSAGE; + } + } + }); + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..99ddd57e9d8cd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=typesfirst).symbols @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts] //// + +=== weird.js === +someFunction(function(BaseClass) { +>BaseClass : Symbol(BaseClass, Decl(weird.js, 0, 22)) + + 'use strict'; + const DEFAULT_MESSAGE = "nop!"; +>DEFAULT_MESSAGE : Symbol(DEFAULT_MESSAGE, Decl(weird.js, 2, 9)) + + class Hello extends BaseClass { +>Hello : Symbol(Hello, Decl(weird.js, 2, 35)) +>BaseClass : Symbol(BaseClass, Decl(weird.js, 0, 22)) + + constructor() { + super(); + this.foo = "bar"; +>this.foo : Symbol(Hello.foo, Decl(weird.js, 5, 20)) +>this : Symbol(Hello, Decl(weird.js, 2, 35)) +>foo : Symbol(Hello.foo, Decl(weird.js, 5, 20)) + } + _render(error) { +>_render : Symbol(Hello._render, Decl(weird.js, 7, 9)) +>error : Symbol(error, Decl(weird.js, 8, 16)) + + const message = error.message || DEFAULT_MESSAGE; +>message : Symbol(message, Decl(weird.js, 9, 17)) +>error : Symbol(error, Decl(weird.js, 8, 16)) +>DEFAULT_MESSAGE : Symbol(DEFAULT_MESSAGE, Decl(weird.js, 2, 9)) + } + } +}); + diff --git a/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=typesfirst).types new file mode 100644 index 0000000000000..7f98768cc3b3e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkIndexConstraintOfJavascriptClassExpression(checkorder=typesfirst).types @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts] //// + +=== weird.js === +someFunction(function(BaseClass) { +>someFunction(function(BaseClass) { 'use strict'; const DEFAULT_MESSAGE = "nop!"; class Hello extends BaseClass { constructor() { super(); this.foo = "bar"; } _render(error) { const message = error.message || DEFAULT_MESSAGE; } }}) : any +>someFunction : any +>function(BaseClass) { 'use strict'; const DEFAULT_MESSAGE = "nop!"; class Hello extends BaseClass { constructor() { super(); this.foo = "bar"; } _render(error) { const message = error.message || DEFAULT_MESSAGE; } }} : (BaseClass: any) => void +>BaseClass : any + + 'use strict'; +>'use strict' : "use strict" + + const DEFAULT_MESSAGE = "nop!"; +>DEFAULT_MESSAGE : "nop!" +>"nop!" : "nop!" + + class Hello extends BaseClass { +>Hello : Hello +>BaseClass : any + + constructor() { + super(); +>super() : void +>super : any + + this.foo = "bar"; +>this.foo = "bar" : "bar" +>this.foo : any +>this : this +>foo : any +>"bar" : "bar" + } + _render(error) { +>_render : (error: any) => void +>error : any + + const message = error.message || DEFAULT_MESSAGE; +>message : any +>error.message || DEFAULT_MESSAGE : any +>error.message : any +>error : any +>message : any +>DEFAULT_MESSAGE : "nop!" + } + } +}); + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=default).errors.txt new file mode 100644 index 0000000000000..fbdc7623ca157 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=default).errors.txt @@ -0,0 +1,24 @@ +a.ts(5,11): error TS2322: Type 'string' is not assignable to type 'number'. +a.ts(5,23): error TS1062: Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method. +b.ts(2,11): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== a.ts (2 errors) ==== + type S = string | Promise; + declare const s: S; + declare const p: Promise; + async function f1() { + const a: number = await p; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~~~~~~~ +!!! error TS1062: Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method. + } + +==== b.ts (1 errors) ==== + async function f2() { + const b: number = await s; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=default).symbols new file mode 100644 index 0000000000000..9bdecefb54f4f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=default).symbols @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/checkOrderAwaitedCycle.ts] //// + +=== a.ts === +type S = string | Promise; +>S : Symbol(S, Decl(a.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>S : Symbol(S, Decl(a.ts, 0, 0)) + +declare const s: S; +>s : Symbol(s, Decl(a.ts, 1, 13)) +>S : Symbol(S, Decl(a.ts, 0, 0)) + +declare const p: Promise; +>p : Symbol(p, Decl(a.ts, 2, 13)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>S : Symbol(S, Decl(a.ts, 0, 0)) + +async function f1() { +>f1 : Symbol(f1, Decl(a.ts, 2, 28)) + + const a: number = await p; +>a : Symbol(a, Decl(a.ts, 4, 9)) +>p : Symbol(p, Decl(a.ts, 2, 13)) +} + +=== b.ts === +async function f2() { +>f2 : Symbol(f2, Decl(b.ts, 0, 0)) + + const b: number = await s; +>b : Symbol(b, Decl(b.ts, 1, 9)) +>s : Symbol(s, Decl(a.ts, 1, 13)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=default).types new file mode 100644 index 0000000000000..6cbf09f81f2c8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=default).types @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/checkOrderAwaitedCycle.ts] //// + +=== a.ts === +type S = string | Promise; +>S : S + +declare const s: S; +>s : S + +declare const p: Promise; +>p : Promise + +async function f1() { +>f1 : () => Promise + + const a: number = await p; +>a : number +>await p : string +>p : Promise +} + +=== b.ts === +async function f2() { +>f2 : () => Promise + + const b: number = await s; +>b : number +>await s : string +>s : S +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=isolated).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=isolated).errors.txt new file mode 100644 index 0000000000000..126b9485926f5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=isolated).errors.txt @@ -0,0 +1,27 @@ +a.ts(5,11): error TS2322: Type 'string' is not assignable to type 'number'. +a.ts(5,23): error TS1062: Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method. +b.ts(2,11): error TS2322: Type 'string' is not assignable to type 'number'. +b.ts(2,23): error TS1062: Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method. + + +==== a.ts (2 errors) ==== + type S = string | Promise; + declare const s: S; + declare const p: Promise; + async function f1() { + const a: number = await p; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~~~~~~~ +!!! error TS1062: Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method. + } + +==== b.ts (2 errors) ==== + async function f2() { + const b: number = await s; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~~~~~~~ +!!! error TS1062: Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=isolated).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=isolated).symbols new file mode 100644 index 0000000000000..9bdecefb54f4f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=isolated).symbols @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/checkOrderAwaitedCycle.ts] //// + +=== a.ts === +type S = string | Promise; +>S : Symbol(S, Decl(a.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>S : Symbol(S, Decl(a.ts, 0, 0)) + +declare const s: S; +>s : Symbol(s, Decl(a.ts, 1, 13)) +>S : Symbol(S, Decl(a.ts, 0, 0)) + +declare const p: Promise; +>p : Symbol(p, Decl(a.ts, 2, 13)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>S : Symbol(S, Decl(a.ts, 0, 0)) + +async function f1() { +>f1 : Symbol(f1, Decl(a.ts, 2, 28)) + + const a: number = await p; +>a : Symbol(a, Decl(a.ts, 4, 9)) +>p : Symbol(p, Decl(a.ts, 2, 13)) +} + +=== b.ts === +async function f2() { +>f2 : Symbol(f2, Decl(b.ts, 0, 0)) + + const b: number = await s; +>b : Symbol(b, Decl(b.ts, 1, 9)) +>s : Symbol(s, Decl(a.ts, 1, 13)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=isolated).types b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=isolated).types new file mode 100644 index 0000000000000..6cbf09f81f2c8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=isolated).types @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/checkOrderAwaitedCycle.ts] //// + +=== a.ts === +type S = string | Promise; +>S : S + +declare const s: S; +>s : S + +declare const p: Promise; +>p : Promise + +async function f1() { +>f1 : () => Promise + + const a: number = await p; +>a : number +>await p : string +>p : Promise +} + +=== b.ts === +async function f2() { +>f2 : () => Promise + + const b: number = await s; +>b : number +>await s : string +>s : S +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=reverse).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=reverse).errors.txt new file mode 100644 index 0000000000000..55a3e6d752ab1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=reverse).errors.txt @@ -0,0 +1,24 @@ +a.ts(5,11): error TS2322: Type 'string' is not assignable to type 'number'. +b.ts(2,11): error TS2322: Type 'string' is not assignable to type 'number'. +b.ts(2,23): error TS1062: Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method. + + +==== a.ts (1 errors) ==== + type S = string | Promise; + declare const s: S; + declare const p: Promise; + async function f1() { + const a: number = await p; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + } + +==== b.ts (2 errors) ==== + async function f2() { + const b: number = await s; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~~~~~~~ +!!! error TS1062: Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=reverse).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=reverse).symbols new file mode 100644 index 0000000000000..9bdecefb54f4f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=reverse).symbols @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/checkOrderAwaitedCycle.ts] //// + +=== a.ts === +type S = string | Promise; +>S : Symbol(S, Decl(a.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>S : Symbol(S, Decl(a.ts, 0, 0)) + +declare const s: S; +>s : Symbol(s, Decl(a.ts, 1, 13)) +>S : Symbol(S, Decl(a.ts, 0, 0)) + +declare const p: Promise; +>p : Symbol(p, Decl(a.ts, 2, 13)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>S : Symbol(S, Decl(a.ts, 0, 0)) + +async function f1() { +>f1 : Symbol(f1, Decl(a.ts, 2, 28)) + + const a: number = await p; +>a : Symbol(a, Decl(a.ts, 4, 9)) +>p : Symbol(p, Decl(a.ts, 2, 13)) +} + +=== b.ts === +async function f2() { +>f2 : Symbol(f2, Decl(b.ts, 0, 0)) + + const b: number = await s; +>b : Symbol(b, Decl(b.ts, 1, 9)) +>s : Symbol(s, Decl(a.ts, 1, 13)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=reverse).types b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=reverse).types new file mode 100644 index 0000000000000..6cbf09f81f2c8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=reverse).types @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/checkOrderAwaitedCycle.ts] //// + +=== a.ts === +type S = string | Promise; +>S : S + +declare const s: S; +>s : S + +declare const p: Promise; +>p : Promise + +async function f1() { +>f1 : () => Promise + + const a: number = await p; +>a : number +>await p : string +>p : Promise +} + +=== b.ts === +async function f2() { +>f2 : () => Promise + + const b: number = await s; +>b : number +>await s : string +>s : S +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..55a3e6d752ab1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=typesfirst).errors.txt @@ -0,0 +1,24 @@ +a.ts(5,11): error TS2322: Type 'string' is not assignable to type 'number'. +b.ts(2,11): error TS2322: Type 'string' is not assignable to type 'number'. +b.ts(2,23): error TS1062: Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method. + + +==== a.ts (1 errors) ==== + type S = string | Promise; + declare const s: S; + declare const p: Promise; + async function f1() { + const a: number = await p; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + } + +==== b.ts (2 errors) ==== + async function f2() { + const b: number = await s; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~~~~~~~ +!!! error TS1062: Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..9bdecefb54f4f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=typesfirst).symbols @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/checkOrderAwaitedCycle.ts] //// + +=== a.ts === +type S = string | Promise; +>S : Symbol(S, Decl(a.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>S : Symbol(S, Decl(a.ts, 0, 0)) + +declare const s: S; +>s : Symbol(s, Decl(a.ts, 1, 13)) +>S : Symbol(S, Decl(a.ts, 0, 0)) + +declare const p: Promise; +>p : Symbol(p, Decl(a.ts, 2, 13)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>S : Symbol(S, Decl(a.ts, 0, 0)) + +async function f1() { +>f1 : Symbol(f1, Decl(a.ts, 2, 28)) + + const a: number = await p; +>a : Symbol(a, Decl(a.ts, 4, 9)) +>p : Symbol(p, Decl(a.ts, 2, 13)) +} + +=== b.ts === +async function f2() { +>f2 : Symbol(f2, Decl(b.ts, 0, 0)) + + const b: number = await s; +>b : Symbol(b, Decl(b.ts, 1, 9)) +>s : Symbol(s, Decl(a.ts, 1, 13)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=typesfirst).types new file mode 100644 index 0000000000000..6cbf09f81f2c8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderAwaitedCycle(checkorder=typesfirst).types @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/checkOrderAwaitedCycle.ts] //// + +=== a.ts === +type S = string | Promise; +>S : S + +declare const s: S; +>s : S + +declare const p: Promise; +>p : Promise + +async function f1() { +>f1 : () => Promise + + const a: number = await p; +>a : number +>await p : string +>p : Promise +} + +=== b.ts === +async function f2() { +>f2 : () => Promise + + const b: number = await s; +>b : number +>await s : string +>s : S +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=default).errors.txt new file mode 100644 index 0000000000000..938f4b7bb63d2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=default).errors.txt @@ -0,0 +1,38 @@ +checkOrderCircularConstraint.ts(4,19): error TS2313: Type parameter 'T' has a circular constraint. +checkOrderCircularConstraint.ts(7,19): error TS2339: Property 'foo' does not exist on type 'T'. +checkOrderCircularConstraint.ts(8,21): error TS2351: This expression is not constructable. + Type 'unknown' has no construct signatures. +checkOrderCircularConstraint.ts(9,17): error TS7053: Element implicitly has an 'any' type because expression of type '1' can't be used to index type 'unknown'. + Property '1' does not exist on type 'unknown'. +checkOrderCircularConstraint.ts(10,17): error TS2349: This expression is not callable. + Type 'unknown' has no call signatures. + + +==== checkOrderCircularConstraint.ts (5 errors) ==== + // A circular constraint of a declared type parameter is reported at its + // declaration, regardless of which use resolves the constraint first. + + class A { + ~ +!!! error TS2313: Type parameter 'T' has a circular constraint. +!!! related TS2751 checkOrderCircularConstraint.ts:7:17: Circularity originates in type at this location. + foo() { + var x!: T; + var a = x.foo(); + ~~~ +!!! error TS2339: Property 'foo' does not exist on type 'T'. + var b = new x(123); + ~ +!!! error TS2351: This expression is not constructable. +!!! error TS2351: Type 'unknown' has no construct signatures. + var c = x[1]; + ~~~~ +!!! error TS7053: Element implicitly has an 'any' type because expression of type '1' can't be used to index type 'unknown'. +!!! error TS7053: Property '1' does not exist on type 'unknown'. + var d = x(); + ~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Type 'unknown' has no call signatures. + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=default).js new file mode 100644 index 0000000000000..3c72daa68bbd3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=default).js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/checkOrderCircularConstraint.ts] //// + +//// [checkOrderCircularConstraint.ts] +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. + +class A { + foo() { + var x!: T; + var a = x.foo(); + var b = new x(123); + var c = x[1]; + var d = x(); + } +} + + +//// [checkOrderCircularConstraint.js] +"use strict"; +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. +class A { + foo() { + var x; + var a = x.foo(); + var b = new x(123); + var c = x[1]; + var d = x(); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=default).symbols new file mode 100644 index 0000000000000..9b87b04754b9f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=default).symbols @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/checkOrderCircularConstraint.ts] //// + +=== checkOrderCircularConstraint.ts === +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. + +class A { +>A : Symbol(A, Decl(checkOrderCircularConstraint.ts, 0, 0)) +>T : Symbol(T, Decl(checkOrderCircularConstraint.ts, 3, 8)) +>T : Symbol(T, Decl(checkOrderCircularConstraint.ts, 3, 8)) + + foo() { +>foo : Symbol(A.foo, Decl(checkOrderCircularConstraint.ts, 3, 22)) + + var x!: T; +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) +>T : Symbol(T, Decl(checkOrderCircularConstraint.ts, 3, 8)) + + var a = x.foo(); +>a : Symbol(a, Decl(checkOrderCircularConstraint.ts, 6, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + + var b = new x(123); +>b : Symbol(b, Decl(checkOrderCircularConstraint.ts, 7, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + + var c = x[1]; +>c : Symbol(c, Decl(checkOrderCircularConstraint.ts, 8, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + + var d = x(); +>d : Symbol(d, Decl(checkOrderCircularConstraint.ts, 9, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=default).types new file mode 100644 index 0000000000000..370c13c086d5a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=default).types @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/checkOrderCircularConstraint.ts] //// + +=== checkOrderCircularConstraint.ts === +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. + +class A { +>A : A + + foo() { +>foo : () => void + + var x!: T; +>x : T + + var a = x.foo(); +>a : any +>x.foo() : any +>x.foo : any +>x : T +>foo : any + + var b = new x(123); +>b : any +>new x(123) : any +>x : T +>123 : 123 + + var c = x[1]; +>c : any +>x[1] : any +>x : T +>1 : 1 + + var d = x(); +>d : any +>x() : any +>x : T + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=isolated).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=isolated).errors.txt new file mode 100644 index 0000000000000..9309ae4c7eb15 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=isolated).errors.txt @@ -0,0 +1,37 @@ +checkOrderCircularConstraint.ts(4,19): error TS2313: Type parameter 'T' has a circular constraint. +checkOrderCircularConstraint.ts(7,19): error TS2339: Property 'foo' does not exist on type 'T'. +checkOrderCircularConstraint.ts(8,21): error TS2351: This expression is not constructable. + Type 'unknown' has no construct signatures. +checkOrderCircularConstraint.ts(9,17): error TS7053: Element implicitly has an 'any' type because expression of type '1' can't be used to index type 'unknown'. + Property '1' does not exist on type 'unknown'. +checkOrderCircularConstraint.ts(10,17): error TS2349: This expression is not callable. + Type 'unknown' has no call signatures. + + +==== checkOrderCircularConstraint.ts (5 errors) ==== + // A circular constraint of a declared type parameter is reported at its + // declaration, regardless of which use resolves the constraint first. + + class A { + ~ +!!! error TS2313: Type parameter 'T' has a circular constraint. + foo() { + var x!: T; + var a = x.foo(); + ~~~ +!!! error TS2339: Property 'foo' does not exist on type 'T'. + var b = new x(123); + ~ +!!! error TS2351: This expression is not constructable. +!!! error TS2351: Type 'unknown' has no construct signatures. + var c = x[1]; + ~~~~ +!!! error TS7053: Element implicitly has an 'any' type because expression of type '1' can't be used to index type 'unknown'. +!!! error TS7053: Property '1' does not exist on type 'unknown'. + var d = x(); + ~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Type 'unknown' has no call signatures. + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=isolated).js b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=isolated).js new file mode 100644 index 0000000000000..3c72daa68bbd3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=isolated).js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/checkOrderCircularConstraint.ts] //// + +//// [checkOrderCircularConstraint.ts] +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. + +class A { + foo() { + var x!: T; + var a = x.foo(); + var b = new x(123); + var c = x[1]; + var d = x(); + } +} + + +//// [checkOrderCircularConstraint.js] +"use strict"; +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. +class A { + foo() { + var x; + var a = x.foo(); + var b = new x(123); + var c = x[1]; + var d = x(); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=isolated).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=isolated).symbols new file mode 100644 index 0000000000000..9b87b04754b9f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=isolated).symbols @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/checkOrderCircularConstraint.ts] //// + +=== checkOrderCircularConstraint.ts === +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. + +class A { +>A : Symbol(A, Decl(checkOrderCircularConstraint.ts, 0, 0)) +>T : Symbol(T, Decl(checkOrderCircularConstraint.ts, 3, 8)) +>T : Symbol(T, Decl(checkOrderCircularConstraint.ts, 3, 8)) + + foo() { +>foo : Symbol(A.foo, Decl(checkOrderCircularConstraint.ts, 3, 22)) + + var x!: T; +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) +>T : Symbol(T, Decl(checkOrderCircularConstraint.ts, 3, 8)) + + var a = x.foo(); +>a : Symbol(a, Decl(checkOrderCircularConstraint.ts, 6, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + + var b = new x(123); +>b : Symbol(b, Decl(checkOrderCircularConstraint.ts, 7, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + + var c = x[1]; +>c : Symbol(c, Decl(checkOrderCircularConstraint.ts, 8, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + + var d = x(); +>d : Symbol(d, Decl(checkOrderCircularConstraint.ts, 9, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=isolated).types b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=isolated).types new file mode 100644 index 0000000000000..370c13c086d5a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=isolated).types @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/checkOrderCircularConstraint.ts] //// + +=== checkOrderCircularConstraint.ts === +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. + +class A { +>A : A + + foo() { +>foo : () => void + + var x!: T; +>x : T + + var a = x.foo(); +>a : any +>x.foo() : any +>x.foo : any +>x : T +>foo : any + + var b = new x(123); +>b : any +>new x(123) : any +>x : T +>123 : 123 + + var c = x[1]; +>c : any +>x[1] : any +>x : T +>1 : 1 + + var d = x(); +>d : any +>x() : any +>x : T + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=reverse).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=reverse).errors.txt new file mode 100644 index 0000000000000..938f4b7bb63d2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=reverse).errors.txt @@ -0,0 +1,38 @@ +checkOrderCircularConstraint.ts(4,19): error TS2313: Type parameter 'T' has a circular constraint. +checkOrderCircularConstraint.ts(7,19): error TS2339: Property 'foo' does not exist on type 'T'. +checkOrderCircularConstraint.ts(8,21): error TS2351: This expression is not constructable. + Type 'unknown' has no construct signatures. +checkOrderCircularConstraint.ts(9,17): error TS7053: Element implicitly has an 'any' type because expression of type '1' can't be used to index type 'unknown'. + Property '1' does not exist on type 'unknown'. +checkOrderCircularConstraint.ts(10,17): error TS2349: This expression is not callable. + Type 'unknown' has no call signatures. + + +==== checkOrderCircularConstraint.ts (5 errors) ==== + // A circular constraint of a declared type parameter is reported at its + // declaration, regardless of which use resolves the constraint first. + + class A { + ~ +!!! error TS2313: Type parameter 'T' has a circular constraint. +!!! related TS2751 checkOrderCircularConstraint.ts:7:17: Circularity originates in type at this location. + foo() { + var x!: T; + var a = x.foo(); + ~~~ +!!! error TS2339: Property 'foo' does not exist on type 'T'. + var b = new x(123); + ~ +!!! error TS2351: This expression is not constructable. +!!! error TS2351: Type 'unknown' has no construct signatures. + var c = x[1]; + ~~~~ +!!! error TS7053: Element implicitly has an 'any' type because expression of type '1' can't be used to index type 'unknown'. +!!! error TS7053: Property '1' does not exist on type 'unknown'. + var d = x(); + ~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Type 'unknown' has no call signatures. + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=reverse).js b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=reverse).js new file mode 100644 index 0000000000000..3c72daa68bbd3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=reverse).js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/checkOrderCircularConstraint.ts] //// + +//// [checkOrderCircularConstraint.ts] +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. + +class A { + foo() { + var x!: T; + var a = x.foo(); + var b = new x(123); + var c = x[1]; + var d = x(); + } +} + + +//// [checkOrderCircularConstraint.js] +"use strict"; +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. +class A { + foo() { + var x; + var a = x.foo(); + var b = new x(123); + var c = x[1]; + var d = x(); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=reverse).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=reverse).symbols new file mode 100644 index 0000000000000..9b87b04754b9f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=reverse).symbols @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/checkOrderCircularConstraint.ts] //// + +=== checkOrderCircularConstraint.ts === +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. + +class A { +>A : Symbol(A, Decl(checkOrderCircularConstraint.ts, 0, 0)) +>T : Symbol(T, Decl(checkOrderCircularConstraint.ts, 3, 8)) +>T : Symbol(T, Decl(checkOrderCircularConstraint.ts, 3, 8)) + + foo() { +>foo : Symbol(A.foo, Decl(checkOrderCircularConstraint.ts, 3, 22)) + + var x!: T; +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) +>T : Symbol(T, Decl(checkOrderCircularConstraint.ts, 3, 8)) + + var a = x.foo(); +>a : Symbol(a, Decl(checkOrderCircularConstraint.ts, 6, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + + var b = new x(123); +>b : Symbol(b, Decl(checkOrderCircularConstraint.ts, 7, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + + var c = x[1]; +>c : Symbol(c, Decl(checkOrderCircularConstraint.ts, 8, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + + var d = x(); +>d : Symbol(d, Decl(checkOrderCircularConstraint.ts, 9, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=reverse).types b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=reverse).types new file mode 100644 index 0000000000000..370c13c086d5a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=reverse).types @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/checkOrderCircularConstraint.ts] //// + +=== checkOrderCircularConstraint.ts === +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. + +class A { +>A : A + + foo() { +>foo : () => void + + var x!: T; +>x : T + + var a = x.foo(); +>a : any +>x.foo() : any +>x.foo : any +>x : T +>foo : any + + var b = new x(123); +>b : any +>new x(123) : any +>x : T +>123 : 123 + + var c = x[1]; +>c : any +>x[1] : any +>x : T +>1 : 1 + + var d = x(); +>d : any +>x() : any +>x : T + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..ef7991cfbe407 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=typesfirst).errors.txt @@ -0,0 +1,38 @@ +checkOrderCircularConstraint.ts(4,19): error TS2313: Type parameter 'T' has a circular constraint. +checkOrderCircularConstraint.ts(7,19): error TS2339: Property 'foo' does not exist on type 'T'. +checkOrderCircularConstraint.ts(8,21): error TS2351: This expression is not constructable. + Type 'unknown' has no construct signatures. +checkOrderCircularConstraint.ts(9,17): error TS7053: Element implicitly has an 'any' type because expression of type '1' can't be used to index type 'unknown'. + Property '1' does not exist on type 'unknown'. +checkOrderCircularConstraint.ts(10,17): error TS2349: This expression is not callable. + Type 'unknown' has no call signatures. + + +==== checkOrderCircularConstraint.ts (5 errors) ==== + // A circular constraint of a declared type parameter is reported at its + // declaration, regardless of which use resolves the constraint first. + + class A { + ~ +!!! error TS2313: Type parameter 'T' has a circular constraint. +!!! related TS2751 checkOrderCircularConstraint.ts:10:17: Circularity originates in type at this location. + foo() { + var x!: T; + var a = x.foo(); + ~~~ +!!! error TS2339: Property 'foo' does not exist on type 'T'. + var b = new x(123); + ~ +!!! error TS2351: This expression is not constructable. +!!! error TS2351: Type 'unknown' has no construct signatures. + var c = x[1]; + ~~~~ +!!! error TS7053: Element implicitly has an 'any' type because expression of type '1' can't be used to index type 'unknown'. +!!! error TS7053: Property '1' does not exist on type 'unknown'. + var d = x(); + ~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Type 'unknown' has no call signatures. + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=typesfirst).js new file mode 100644 index 0000000000000..3c72daa68bbd3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=typesfirst).js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/checkOrderCircularConstraint.ts] //// + +//// [checkOrderCircularConstraint.ts] +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. + +class A { + foo() { + var x!: T; + var a = x.foo(); + var b = new x(123); + var c = x[1]; + var d = x(); + } +} + + +//// [checkOrderCircularConstraint.js] +"use strict"; +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. +class A { + foo() { + var x; + var a = x.foo(); + var b = new x(123); + var c = x[1]; + var d = x(); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..9b87b04754b9f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=typesfirst).symbols @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/checkOrderCircularConstraint.ts] //// + +=== checkOrderCircularConstraint.ts === +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. + +class A { +>A : Symbol(A, Decl(checkOrderCircularConstraint.ts, 0, 0)) +>T : Symbol(T, Decl(checkOrderCircularConstraint.ts, 3, 8)) +>T : Symbol(T, Decl(checkOrderCircularConstraint.ts, 3, 8)) + + foo() { +>foo : Symbol(A.foo, Decl(checkOrderCircularConstraint.ts, 3, 22)) + + var x!: T; +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) +>T : Symbol(T, Decl(checkOrderCircularConstraint.ts, 3, 8)) + + var a = x.foo(); +>a : Symbol(a, Decl(checkOrderCircularConstraint.ts, 6, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + + var b = new x(123); +>b : Symbol(b, Decl(checkOrderCircularConstraint.ts, 7, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + + var c = x[1]; +>c : Symbol(c, Decl(checkOrderCircularConstraint.ts, 8, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + + var d = x(); +>d : Symbol(d, Decl(checkOrderCircularConstraint.ts, 9, 11)) +>x : Symbol(x, Decl(checkOrderCircularConstraint.ts, 5, 11)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=typesfirst).types new file mode 100644 index 0000000000000..370c13c086d5a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularConstraint(checkorder=typesfirst).types @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/checkOrderCircularConstraint.ts] //// + +=== checkOrderCircularConstraint.ts === +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. + +class A { +>A : A + + foo() { +>foo : () => void + + var x!: T; +>x : T + + var a = x.foo(); +>a : any +>x.foo() : any +>x.foo : any +>x : T +>foo : any + + var b = new x(123); +>b : any +>new x(123) : any +>x : T +>123 : 123 + + var c = x[1]; +>c : any +>x[1] : any +>x : T +>1 : 1 + + var d = x(); +>d : any +>x() : any +>x : T + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=default).errors.txt new file mode 100644 index 0000000000000..5c28d3ee0a214 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=default).errors.txt @@ -0,0 +1,15 @@ +a.ts(2,24): error TS2716: Type parameter 'T' has a circular default. + + +==== a.ts (1 errors) ==== + import type { B } from "./b"; + export interface A { a: T } + ~ +!!! error TS2716: Type parameter 'T' has a circular default. + export declare const a: A; + +==== b.ts (0 errors) ==== + import type { A } from "./a"; + export interface B { b: U } + export declare const b: B; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=default).js new file mode 100644 index 0000000000000..8f10482f060d7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=default).js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/checkOrderCircularDefaults.ts] //// + +//// [a.ts] +import type { B } from "./b"; +export interface A { a: T } +export declare const a: A; + +//// [b.ts] +import type { A } from "./a"; +export interface B { b: U } +export declare const b: B; + + +//// [b.js] +export {}; +//// [a.js] +export {}; + + +//// [b.d.ts] +import type { A } from "./a"; +export interface B { + b: U; +} +export declare const b: B; +//// [a.d.ts] +import type { B } from "./b"; +export interface A { + a: T; +} +export declare const a: A; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=default).symbols new file mode 100644 index 0000000000000..72d2e540fd379 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=default).symbols @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/checkOrderCircularDefaults.ts] //// + +=== a.ts === +import type { B } from "./b"; +>B : Symbol(B, Decl(a.ts, 0, 13)) + +export interface A { a: T } +>A : Symbol(A, Decl(a.ts, 0, 29)) +>T : Symbol(T, Decl(a.ts, 1, 19)) +>B : Symbol(B, Decl(a.ts, 0, 13)) +>a : Symbol(A.a, Decl(a.ts, 1, 27)) +>T : Symbol(T, Decl(a.ts, 1, 19)) + +export declare const a: A; +>a : Symbol(a, Decl(a.ts, 2, 20)) +>A : Symbol(A, Decl(a.ts, 0, 29)) + +=== b.ts === +import type { A } from "./a"; +>A : Symbol(A, Decl(b.ts, 0, 13)) + +export interface B { b: U } +>B : Symbol(B, Decl(b.ts, 0, 29)) +>U : Symbol(U, Decl(b.ts, 1, 19)) +>A : Symbol(A, Decl(b.ts, 0, 13)) +>b : Symbol(B.b, Decl(b.ts, 1, 27)) +>U : Symbol(U, Decl(b.ts, 1, 19)) + +export declare const b: B; +>b : Symbol(b, Decl(b.ts, 2, 20)) +>B : Symbol(B, Decl(b.ts, 0, 29)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=default).types new file mode 100644 index 0000000000000..145f91d78caf3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=default).types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/checkOrderCircularDefaults.ts] //// + +=== a.ts === +import type { B } from "./b"; +>B : B + +export interface A { a: T } +>a : T + +export declare const a: A; +>a : A + +=== b.ts === +import type { A } from "./a"; +>A : A + +export interface B { b: U } +>b : U + +export declare const b: B; +>b : B> + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=isolated).js b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=isolated).js new file mode 100644 index 0000000000000..8f10482f060d7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=isolated).js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/checkOrderCircularDefaults.ts] //// + +//// [a.ts] +import type { B } from "./b"; +export interface A { a: T } +export declare const a: A; + +//// [b.ts] +import type { A } from "./a"; +export interface B { b: U } +export declare const b: B; + + +//// [b.js] +export {}; +//// [a.js] +export {}; + + +//// [b.d.ts] +import type { A } from "./a"; +export interface B { + b: U; +} +export declare const b: B; +//// [a.d.ts] +import type { B } from "./b"; +export interface A { + a: T; +} +export declare const a: A; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=isolated).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=isolated).symbols new file mode 100644 index 0000000000000..72d2e540fd379 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=isolated).symbols @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/checkOrderCircularDefaults.ts] //// + +=== a.ts === +import type { B } from "./b"; +>B : Symbol(B, Decl(a.ts, 0, 13)) + +export interface A { a: T } +>A : Symbol(A, Decl(a.ts, 0, 29)) +>T : Symbol(T, Decl(a.ts, 1, 19)) +>B : Symbol(B, Decl(a.ts, 0, 13)) +>a : Symbol(A.a, Decl(a.ts, 1, 27)) +>T : Symbol(T, Decl(a.ts, 1, 19)) + +export declare const a: A; +>a : Symbol(a, Decl(a.ts, 2, 20)) +>A : Symbol(A, Decl(a.ts, 0, 29)) + +=== b.ts === +import type { A } from "./a"; +>A : Symbol(A, Decl(b.ts, 0, 13)) + +export interface B { b: U } +>B : Symbol(B, Decl(b.ts, 0, 29)) +>U : Symbol(U, Decl(b.ts, 1, 19)) +>A : Symbol(A, Decl(b.ts, 0, 13)) +>b : Symbol(B.b, Decl(b.ts, 1, 27)) +>U : Symbol(U, Decl(b.ts, 1, 19)) + +export declare const b: B; +>b : Symbol(b, Decl(b.ts, 2, 20)) +>B : Symbol(B, Decl(b.ts, 0, 29)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=isolated).types b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=isolated).types new file mode 100644 index 0000000000000..145f91d78caf3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=isolated).types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/checkOrderCircularDefaults.ts] //// + +=== a.ts === +import type { B } from "./b"; +>B : B + +export interface A { a: T } +>a : T + +export declare const a: A; +>a : A + +=== b.ts === +import type { A } from "./a"; +>A : A + +export interface B { b: U } +>b : U + +export declare const b: B; +>b : B> + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=reverse).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=reverse).errors.txt new file mode 100644 index 0000000000000..4dee4171e029f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=reverse).errors.txt @@ -0,0 +1,15 @@ +b.ts(2,24): error TS2716: Type parameter 'U' has a circular default. + + +==== a.ts (0 errors) ==== + import type { B } from "./b"; + export interface A { a: T } + export declare const a: A; + +==== b.ts (1 errors) ==== + import type { A } from "./a"; + export interface B { b: U } + ~ +!!! error TS2716: Type parameter 'U' has a circular default. + export declare const b: B; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=reverse).js b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=reverse).js new file mode 100644 index 0000000000000..8f10482f060d7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=reverse).js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/checkOrderCircularDefaults.ts] //// + +//// [a.ts] +import type { B } from "./b"; +export interface A { a: T } +export declare const a: A; + +//// [b.ts] +import type { A } from "./a"; +export interface B { b: U } +export declare const b: B; + + +//// [b.js] +export {}; +//// [a.js] +export {}; + + +//// [b.d.ts] +import type { A } from "./a"; +export interface B { + b: U; +} +export declare const b: B; +//// [a.d.ts] +import type { B } from "./b"; +export interface A { + a: T; +} +export declare const a: A; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=reverse).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=reverse).symbols new file mode 100644 index 0000000000000..72d2e540fd379 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=reverse).symbols @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/checkOrderCircularDefaults.ts] //// + +=== a.ts === +import type { B } from "./b"; +>B : Symbol(B, Decl(a.ts, 0, 13)) + +export interface A { a: T } +>A : Symbol(A, Decl(a.ts, 0, 29)) +>T : Symbol(T, Decl(a.ts, 1, 19)) +>B : Symbol(B, Decl(a.ts, 0, 13)) +>a : Symbol(A.a, Decl(a.ts, 1, 27)) +>T : Symbol(T, Decl(a.ts, 1, 19)) + +export declare const a: A; +>a : Symbol(a, Decl(a.ts, 2, 20)) +>A : Symbol(A, Decl(a.ts, 0, 29)) + +=== b.ts === +import type { A } from "./a"; +>A : Symbol(A, Decl(b.ts, 0, 13)) + +export interface B { b: U } +>B : Symbol(B, Decl(b.ts, 0, 29)) +>U : Symbol(U, Decl(b.ts, 1, 19)) +>A : Symbol(A, Decl(b.ts, 0, 13)) +>b : Symbol(B.b, Decl(b.ts, 1, 27)) +>U : Symbol(U, Decl(b.ts, 1, 19)) + +export declare const b: B; +>b : Symbol(b, Decl(b.ts, 2, 20)) +>B : Symbol(B, Decl(b.ts, 0, 29)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=reverse).types b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=reverse).types new file mode 100644 index 0000000000000..a88d998c374ec --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=reverse).types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/checkOrderCircularDefaults.ts] //// + +=== a.ts === +import type { B } from "./b"; +>B : B + +export interface A { a: T } +>a : T + +export declare const a: A; +>a : A> + +=== b.ts === +import type { A } from "./a"; +>A : A + +export interface B { b: U } +>b : U + +export declare const b: B; +>b : B + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..5c28d3ee0a214 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=typesfirst).errors.txt @@ -0,0 +1,15 @@ +a.ts(2,24): error TS2716: Type parameter 'T' has a circular default. + + +==== a.ts (1 errors) ==== + import type { B } from "./b"; + export interface A { a: T } + ~ +!!! error TS2716: Type parameter 'T' has a circular default. + export declare const a: A; + +==== b.ts (0 errors) ==== + import type { A } from "./a"; + export interface B { b: U } + export declare const b: B; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=typesfirst).js new file mode 100644 index 0000000000000..8f10482f060d7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=typesfirst).js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/checkOrderCircularDefaults.ts] //// + +//// [a.ts] +import type { B } from "./b"; +export interface A { a: T } +export declare const a: A; + +//// [b.ts] +import type { A } from "./a"; +export interface B { b: U } +export declare const b: B; + + +//// [b.js] +export {}; +//// [a.js] +export {}; + + +//// [b.d.ts] +import type { A } from "./a"; +export interface B { + b: U; +} +export declare const b: B; +//// [a.d.ts] +import type { B } from "./b"; +export interface A { + a: T; +} +export declare const a: A; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..72d2e540fd379 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=typesfirst).symbols @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/checkOrderCircularDefaults.ts] //// + +=== a.ts === +import type { B } from "./b"; +>B : Symbol(B, Decl(a.ts, 0, 13)) + +export interface A { a: T } +>A : Symbol(A, Decl(a.ts, 0, 29)) +>T : Symbol(T, Decl(a.ts, 1, 19)) +>B : Symbol(B, Decl(a.ts, 0, 13)) +>a : Symbol(A.a, Decl(a.ts, 1, 27)) +>T : Symbol(T, Decl(a.ts, 1, 19)) + +export declare const a: A; +>a : Symbol(a, Decl(a.ts, 2, 20)) +>A : Symbol(A, Decl(a.ts, 0, 29)) + +=== b.ts === +import type { A } from "./a"; +>A : Symbol(A, Decl(b.ts, 0, 13)) + +export interface B { b: U } +>B : Symbol(B, Decl(b.ts, 0, 29)) +>U : Symbol(U, Decl(b.ts, 1, 19)) +>A : Symbol(A, Decl(b.ts, 0, 13)) +>b : Symbol(B.b, Decl(b.ts, 1, 27)) +>U : Symbol(U, Decl(b.ts, 1, 19)) + +export declare const b: B; +>b : Symbol(b, Decl(b.ts, 2, 20)) +>B : Symbol(B, Decl(b.ts, 0, 29)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=typesfirst).types new file mode 100644 index 0000000000000..145f91d78caf3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderCircularDefaults(checkorder=typesfirst).types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/checkOrderCircularDefaults.ts] //// + +=== a.ts === +import type { B } from "./b"; +>B : B + +export interface A { a: T } +>a : T + +export declare const a: A; +>a : A + +=== b.ts === +import type { A } from "./a"; +>A : A + +export interface B { b: U } +>b : U + +export declare const b: B; +>b : B> + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=default).errors.txt new file mode 100644 index 0000000000000..0570bff3e21f0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=default).errors.txt @@ -0,0 +1,25 @@ +checkOrderEmitBeforeCheck.ts(9,5): error TS2502: '"each"' is referenced directly or indirectly in its own type annotation. +checkOrderEmitBeforeCheck.ts(15,1): error TS2615: Type of property '"each"' circularly references itself in mapped type '{ [P in keyof ListWidget]: undefined extends ListWidget[P] ? never : P; }'. + + +==== checkOrderEmitBeforeCheck.ts (2 errors) ==== + // The circularity in the mapped type is found by checking the annotation of + // "each". Emitting first must not instead report it at the use import + // elision visits, nor cache the result without the error. + type NonOptionalKeys = { [P in keyof T]: undefined extends T[P] ? never : P }[keyof T]; + type Child = { [P in NonOptionalKeys]: T[P] } + + export interface ListWidget { + "type": "list", + "each": Child; + ~~~~~~ +!!! error TS2502: '"each"' is referenced directly or indirectly in its own type annotation. + } + + type ListChild = Child + + declare let x: ListChild; + x.type; + ~ +!!! error TS2615: Type of property '"each"' circularly references itself in mapped type '{ [P in keyof ListWidget]: undefined extends ListWidget[P] ? never : P; }'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=default).js new file mode 100644 index 0000000000000..0ceb03c6477d2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=default).js @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/checkOrderEmitBeforeCheck.ts] //// + +//// [checkOrderEmitBeforeCheck.ts] +// The circularity in the mapped type is found by checking the annotation of +// "each". Emitting first must not instead report it at the use import +// elision visits, nor cache the result without the error. +type NonOptionalKeys = { [P in keyof T]: undefined extends T[P] ? never : P }[keyof T]; +type Child = { [P in NonOptionalKeys]: T[P] } + +export interface ListWidget { + "type": "list", + "each": Child; +} + +type ListChild = Child + +declare let x: ListChild; +x.type; + + +//// [checkOrderEmitBeforeCheck.js] +x.type; +export {}; + + +//// [checkOrderEmitBeforeCheck.d.ts] +type NonOptionalKeys = { + [P in keyof T]: undefined extends T[P] ? never : P; +}[keyof T]; +type Child = { + [P in NonOptionalKeys]: T[P]; +}; +export interface ListWidget { + "type": "list"; + "each": Child; +} +export {}; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=default).symbols new file mode 100644 index 0000000000000..9de1daaccd55e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=default).symbols @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/checkOrderEmitBeforeCheck.ts] //// + +=== checkOrderEmitBeforeCheck.ts === +// The circularity in the mapped type is found by checking the annotation of +// "each". Emitting first must not instead report it at the use import +// elision visits, nor cache the result without the error. +type NonOptionalKeys = { [P in keyof T]: undefined extends T[P] ? never : P }[keyof T]; +>NonOptionalKeys : Symbol(NonOptionalKeys, Decl(checkOrderEmitBeforeCheck.ts, 0, 0)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 3, 21)) +>P : Symbol(P, Decl(checkOrderEmitBeforeCheck.ts, 3, 29)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 3, 21)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 3, 21)) +>P : Symbol(P, Decl(checkOrderEmitBeforeCheck.ts, 3, 29)) +>P : Symbol(P, Decl(checkOrderEmitBeforeCheck.ts, 3, 29)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 3, 21)) + +type Child = { [P in NonOptionalKeys]: T[P] } +>Child : Symbol(Child, Decl(checkOrderEmitBeforeCheck.ts, 3, 90)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 4, 11)) +>P : Symbol(P, Decl(checkOrderEmitBeforeCheck.ts, 4, 19)) +>NonOptionalKeys : Symbol(NonOptionalKeys, Decl(checkOrderEmitBeforeCheck.ts, 0, 0)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 4, 11)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 4, 11)) +>P : Symbol(P, Decl(checkOrderEmitBeforeCheck.ts, 4, 19)) + +export interface ListWidget { +>ListWidget : Symbol(ListWidget, Decl(checkOrderEmitBeforeCheck.ts, 4, 51)) + + "type": "list", +>"type" : Symbol(ListWidget["type"], Decl(checkOrderEmitBeforeCheck.ts, 6, 29)) + + "each": Child; +>"each" : Symbol(ListWidget["each"], Decl(checkOrderEmitBeforeCheck.ts, 7, 19)) +>Child : Symbol(Child, Decl(checkOrderEmitBeforeCheck.ts, 3, 90)) +>ListWidget : Symbol(ListWidget, Decl(checkOrderEmitBeforeCheck.ts, 4, 51)) +} + +type ListChild = Child +>ListChild : Symbol(ListChild, Decl(checkOrderEmitBeforeCheck.ts, 9, 1)) +>Child : Symbol(Child, Decl(checkOrderEmitBeforeCheck.ts, 3, 90)) +>ListWidget : Symbol(ListWidget, Decl(checkOrderEmitBeforeCheck.ts, 4, 51)) + +declare let x: ListChild; +>x : Symbol(x, Decl(checkOrderEmitBeforeCheck.ts, 13, 11)) +>ListChild : Symbol(ListChild, Decl(checkOrderEmitBeforeCheck.ts, 9, 1)) + +x.type; +>x : Symbol(x, Decl(checkOrderEmitBeforeCheck.ts, 13, 11)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=default).types new file mode 100644 index 0000000000000..dfa8cb7adbabd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=default).types @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/checkOrderEmitBeforeCheck.ts] //// + +=== checkOrderEmitBeforeCheck.ts === +// The circularity in the mapped type is found by checking the annotation of +// "each". Emitting first must not instead report it at the use import +// elision visits, nor cache the result without the error. +type NonOptionalKeys = { [P in keyof T]: undefined extends T[P] ? never : P }[keyof T]; +>NonOptionalKeys : NonOptionalKeys + +type Child = { [P in NonOptionalKeys]: T[P] } +>Child : Child + +export interface ListWidget { + "type": "list", +>"type" : "list" + + "each": Child; +>"each" : any +} + +type ListChild = Child +>ListChild : ListChild + +declare let x: ListChild; +>x : ListChild + +x.type; +>x.type : any +>x : ListChild +>type : any + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=isolated).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=isolated).errors.txt new file mode 100644 index 0000000000000..c220c7e1092af --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=isolated).errors.txt @@ -0,0 +1,25 @@ +checkOrderEmitBeforeCheck.ts(9,5): error TS2502: '"each"' is referenced directly or indirectly in its own type annotation. +checkOrderEmitBeforeCheck.ts(9,13): error TS2615: Type of property '"each"' circularly references itself in mapped type '{ [P in keyof ListWidget]: undefined extends ListWidget[P] ? never : P; }'. + + +==== checkOrderEmitBeforeCheck.ts (2 errors) ==== + // The circularity in the mapped type is found by checking the annotation of + // "each". Emitting first must not instead report it at the use import + // elision visits, nor cache the result without the error. + type NonOptionalKeys = { [P in keyof T]: undefined extends T[P] ? never : P }[keyof T]; + type Child = { [P in NonOptionalKeys]: T[P] } + + export interface ListWidget { + "type": "list", + "each": Child; + ~~~~~~ +!!! error TS2502: '"each"' is referenced directly or indirectly in its own type annotation. + ~~~~~~~~~~~~~~~~~ +!!! error TS2615: Type of property '"each"' circularly references itself in mapped type '{ [P in keyof ListWidget]: undefined extends ListWidget[P] ? never : P; }'. + } + + type ListChild = Child + + declare let x: ListChild; + x.type; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=isolated).js b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=isolated).js new file mode 100644 index 0000000000000..0ceb03c6477d2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=isolated).js @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/checkOrderEmitBeforeCheck.ts] //// + +//// [checkOrderEmitBeforeCheck.ts] +// The circularity in the mapped type is found by checking the annotation of +// "each". Emitting first must not instead report it at the use import +// elision visits, nor cache the result without the error. +type NonOptionalKeys = { [P in keyof T]: undefined extends T[P] ? never : P }[keyof T]; +type Child = { [P in NonOptionalKeys]: T[P] } + +export interface ListWidget { + "type": "list", + "each": Child; +} + +type ListChild = Child + +declare let x: ListChild; +x.type; + + +//// [checkOrderEmitBeforeCheck.js] +x.type; +export {}; + + +//// [checkOrderEmitBeforeCheck.d.ts] +type NonOptionalKeys = { + [P in keyof T]: undefined extends T[P] ? never : P; +}[keyof T]; +type Child = { + [P in NonOptionalKeys]: T[P]; +}; +export interface ListWidget { + "type": "list"; + "each": Child; +} +export {}; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=isolated).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=isolated).symbols new file mode 100644 index 0000000000000..9de1daaccd55e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=isolated).symbols @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/checkOrderEmitBeforeCheck.ts] //// + +=== checkOrderEmitBeforeCheck.ts === +// The circularity in the mapped type is found by checking the annotation of +// "each". Emitting first must not instead report it at the use import +// elision visits, nor cache the result without the error. +type NonOptionalKeys = { [P in keyof T]: undefined extends T[P] ? never : P }[keyof T]; +>NonOptionalKeys : Symbol(NonOptionalKeys, Decl(checkOrderEmitBeforeCheck.ts, 0, 0)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 3, 21)) +>P : Symbol(P, Decl(checkOrderEmitBeforeCheck.ts, 3, 29)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 3, 21)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 3, 21)) +>P : Symbol(P, Decl(checkOrderEmitBeforeCheck.ts, 3, 29)) +>P : Symbol(P, Decl(checkOrderEmitBeforeCheck.ts, 3, 29)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 3, 21)) + +type Child = { [P in NonOptionalKeys]: T[P] } +>Child : Symbol(Child, Decl(checkOrderEmitBeforeCheck.ts, 3, 90)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 4, 11)) +>P : Symbol(P, Decl(checkOrderEmitBeforeCheck.ts, 4, 19)) +>NonOptionalKeys : Symbol(NonOptionalKeys, Decl(checkOrderEmitBeforeCheck.ts, 0, 0)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 4, 11)) +>T : Symbol(T, Decl(checkOrderEmitBeforeCheck.ts, 4, 11)) +>P : Symbol(P, Decl(checkOrderEmitBeforeCheck.ts, 4, 19)) + +export interface ListWidget { +>ListWidget : Symbol(ListWidget, Decl(checkOrderEmitBeforeCheck.ts, 4, 51)) + + "type": "list", +>"type" : Symbol(ListWidget["type"], Decl(checkOrderEmitBeforeCheck.ts, 6, 29)) + + "each": Child; +>"each" : Symbol(ListWidget["each"], Decl(checkOrderEmitBeforeCheck.ts, 7, 19)) +>Child : Symbol(Child, Decl(checkOrderEmitBeforeCheck.ts, 3, 90)) +>ListWidget : Symbol(ListWidget, Decl(checkOrderEmitBeforeCheck.ts, 4, 51)) +} + +type ListChild = Child +>ListChild : Symbol(ListChild, Decl(checkOrderEmitBeforeCheck.ts, 9, 1)) +>Child : Symbol(Child, Decl(checkOrderEmitBeforeCheck.ts, 3, 90)) +>ListWidget : Symbol(ListWidget, Decl(checkOrderEmitBeforeCheck.ts, 4, 51)) + +declare let x: ListChild; +>x : Symbol(x, Decl(checkOrderEmitBeforeCheck.ts, 13, 11)) +>ListChild : Symbol(ListChild, Decl(checkOrderEmitBeforeCheck.ts, 9, 1)) + +x.type; +>x : Symbol(x, Decl(checkOrderEmitBeforeCheck.ts, 13, 11)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=isolated).types b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=isolated).types new file mode 100644 index 0000000000000..dfa8cb7adbabd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEmitBeforeCheck(checkorder=isolated).types @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/checkOrderEmitBeforeCheck.ts] //// + +=== checkOrderEmitBeforeCheck.ts === +// The circularity in the mapped type is found by checking the annotation of +// "each". Emitting first must not instead report it at the use import +// elision visits, nor cache the result without the error. +type NonOptionalKeys = { [P in keyof T]: undefined extends T[P] ? never : P }[keyof T]; +>NonOptionalKeys : NonOptionalKeys + +type Child = { [P in NonOptionalKeys]: T[P] } +>Child : Child + +export interface ListWidget { + "type": "list", +>"type" : "list" + + "each": Child; +>"each" : any +} + +type ListChild = Child +>ListChild : ListChild + +declare let x: ListChild; +>x : ListChild + +x.type; +>x.type : any +>x : ListChild +>type : any + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=default).js new file mode 100644 index 0000000000000..fe0caa60a4dc6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=default).js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/checkOrderEnumComputedMember.ts] //// + +//// [checkOrderEnumComputedMember.ts] +enum E { + A = 0, + B = E.A.valueOf(), + C = 1, +} + +const member: Extract = E.C; + + +//// [checkOrderEnumComputedMember.js] +"use strict"; +var E; +(function (E) { + E[E["A"] = 0] = "A"; + E[E["B"] = E.A.valueOf()] = "B"; + E[E["C"] = 1] = "C"; +})(E || (E = {})); +const member = E.C; + + +//// [checkOrderEnumComputedMember.d.ts] +declare enum E { + A = 0, + B, + C = 1 +} +declare const member: Extract; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=default).symbols new file mode 100644 index 0000000000000..543ee2b641c26 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=default).symbols @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/checkOrderEnumComputedMember.ts] //// + +=== checkOrderEnumComputedMember.ts === +enum E { +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) + + A = 0, +>A : Symbol(E.A, Decl(checkOrderEnumComputedMember.ts, 0, 8)) + + B = E.A.valueOf(), +>B : Symbol(E.B, Decl(checkOrderEnumComputedMember.ts, 1, 10)) +>E.A.valueOf : Symbol(Number.valueOf, Decl(lib.es5.d.ts, --, --)) +>E.A : Symbol(E.A, Decl(checkOrderEnumComputedMember.ts, 0, 8)) +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) +>A : Symbol(E.A, Decl(checkOrderEnumComputedMember.ts, 0, 8)) +>valueOf : Symbol(Number.valueOf, Decl(lib.es5.d.ts, --, --)) + + C = 1, +>C : Symbol(E.C, Decl(checkOrderEnumComputedMember.ts, 2, 22)) +} + +const member: Extract = E.C; +>member : Symbol(member, Decl(checkOrderEnumComputedMember.ts, 6, 5)) +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) +>E.C : Symbol(E.C, Decl(checkOrderEnumComputedMember.ts, 2, 22)) +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) +>C : Symbol(E.C, Decl(checkOrderEnumComputedMember.ts, 2, 22)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=default).types new file mode 100644 index 0000000000000..39ddeced5f433 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=default).types @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/checkOrderEnumComputedMember.ts] //// + +=== checkOrderEnumComputedMember.ts === +enum E { +>E : E + + A = 0, +>A : E.A +>0 : 0 + + B = E.A.valueOf(), +>B : E.B +>E.A.valueOf() : number +>E.A.valueOf : () => number +>E.A : E.A +>E : typeof E +>A : E.A +>valueOf : () => number + + C = 1, +>C : E.C +>1 : 1 +} + +const member: Extract = E.C; +>member : E.C +>E.C : E.C +>E : typeof E +>C : E.C + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=isolated).js b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=isolated).js new file mode 100644 index 0000000000000..fe0caa60a4dc6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=isolated).js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/checkOrderEnumComputedMember.ts] //// + +//// [checkOrderEnumComputedMember.ts] +enum E { + A = 0, + B = E.A.valueOf(), + C = 1, +} + +const member: Extract = E.C; + + +//// [checkOrderEnumComputedMember.js] +"use strict"; +var E; +(function (E) { + E[E["A"] = 0] = "A"; + E[E["B"] = E.A.valueOf()] = "B"; + E[E["C"] = 1] = "C"; +})(E || (E = {})); +const member = E.C; + + +//// [checkOrderEnumComputedMember.d.ts] +declare enum E { + A = 0, + B, + C = 1 +} +declare const member: Extract; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=isolated).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=isolated).symbols new file mode 100644 index 0000000000000..543ee2b641c26 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=isolated).symbols @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/checkOrderEnumComputedMember.ts] //// + +=== checkOrderEnumComputedMember.ts === +enum E { +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) + + A = 0, +>A : Symbol(E.A, Decl(checkOrderEnumComputedMember.ts, 0, 8)) + + B = E.A.valueOf(), +>B : Symbol(E.B, Decl(checkOrderEnumComputedMember.ts, 1, 10)) +>E.A.valueOf : Symbol(Number.valueOf, Decl(lib.es5.d.ts, --, --)) +>E.A : Symbol(E.A, Decl(checkOrderEnumComputedMember.ts, 0, 8)) +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) +>A : Symbol(E.A, Decl(checkOrderEnumComputedMember.ts, 0, 8)) +>valueOf : Symbol(Number.valueOf, Decl(lib.es5.d.ts, --, --)) + + C = 1, +>C : Symbol(E.C, Decl(checkOrderEnumComputedMember.ts, 2, 22)) +} + +const member: Extract = E.C; +>member : Symbol(member, Decl(checkOrderEnumComputedMember.ts, 6, 5)) +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) +>E.C : Symbol(E.C, Decl(checkOrderEnumComputedMember.ts, 2, 22)) +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) +>C : Symbol(E.C, Decl(checkOrderEnumComputedMember.ts, 2, 22)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=isolated).types b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=isolated).types new file mode 100644 index 0000000000000..7ec12ac791f04 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=isolated).types @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/checkOrderEnumComputedMember.ts] //// + +=== checkOrderEnumComputedMember.ts === +enum E { +>E : E + + A = 0, +>A : E.A +>0 : 0 + + B = E.A.valueOf(), +>B : E.B +>E.A.valueOf() : number +>E.A.valueOf : () => number +>E.A : E.A +>E : typeof E +>A : E.A +>valueOf : () => number + + C = 1, +>C : E.C +>1 : 1 +} + +const member: Extract = E.C; +>member : never +>E.C : E.C +>E : typeof E +>C : E.C + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=reverse).js b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=reverse).js new file mode 100644 index 0000000000000..fe0caa60a4dc6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=reverse).js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/checkOrderEnumComputedMember.ts] //// + +//// [checkOrderEnumComputedMember.ts] +enum E { + A = 0, + B = E.A.valueOf(), + C = 1, +} + +const member: Extract = E.C; + + +//// [checkOrderEnumComputedMember.js] +"use strict"; +var E; +(function (E) { + E[E["A"] = 0] = "A"; + E[E["B"] = E.A.valueOf()] = "B"; + E[E["C"] = 1] = "C"; +})(E || (E = {})); +const member = E.C; + + +//// [checkOrderEnumComputedMember.d.ts] +declare enum E { + A = 0, + B, + C = 1 +} +declare const member: Extract; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=reverse).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=reverse).symbols new file mode 100644 index 0000000000000..543ee2b641c26 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=reverse).symbols @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/checkOrderEnumComputedMember.ts] //// + +=== checkOrderEnumComputedMember.ts === +enum E { +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) + + A = 0, +>A : Symbol(E.A, Decl(checkOrderEnumComputedMember.ts, 0, 8)) + + B = E.A.valueOf(), +>B : Symbol(E.B, Decl(checkOrderEnumComputedMember.ts, 1, 10)) +>E.A.valueOf : Symbol(Number.valueOf, Decl(lib.es5.d.ts, --, --)) +>E.A : Symbol(E.A, Decl(checkOrderEnumComputedMember.ts, 0, 8)) +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) +>A : Symbol(E.A, Decl(checkOrderEnumComputedMember.ts, 0, 8)) +>valueOf : Symbol(Number.valueOf, Decl(lib.es5.d.ts, --, --)) + + C = 1, +>C : Symbol(E.C, Decl(checkOrderEnumComputedMember.ts, 2, 22)) +} + +const member: Extract = E.C; +>member : Symbol(member, Decl(checkOrderEnumComputedMember.ts, 6, 5)) +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) +>E.C : Symbol(E.C, Decl(checkOrderEnumComputedMember.ts, 2, 22)) +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) +>C : Symbol(E.C, Decl(checkOrderEnumComputedMember.ts, 2, 22)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=reverse).types b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=reverse).types new file mode 100644 index 0000000000000..39ddeced5f433 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=reverse).types @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/checkOrderEnumComputedMember.ts] //// + +=== checkOrderEnumComputedMember.ts === +enum E { +>E : E + + A = 0, +>A : E.A +>0 : 0 + + B = E.A.valueOf(), +>B : E.B +>E.A.valueOf() : number +>E.A.valueOf : () => number +>E.A : E.A +>E : typeof E +>A : E.A +>valueOf : () => number + + C = 1, +>C : E.C +>1 : 1 +} + +const member: Extract = E.C; +>member : E.C +>E.C : E.C +>E : typeof E +>C : E.C + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=typesfirst).js new file mode 100644 index 0000000000000..fe0caa60a4dc6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=typesfirst).js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/checkOrderEnumComputedMember.ts] //// + +//// [checkOrderEnumComputedMember.ts] +enum E { + A = 0, + B = E.A.valueOf(), + C = 1, +} + +const member: Extract = E.C; + + +//// [checkOrderEnumComputedMember.js] +"use strict"; +var E; +(function (E) { + E[E["A"] = 0] = "A"; + E[E["B"] = E.A.valueOf()] = "B"; + E[E["C"] = 1] = "C"; +})(E || (E = {})); +const member = E.C; + + +//// [checkOrderEnumComputedMember.d.ts] +declare enum E { + A = 0, + B, + C = 1 +} +declare const member: Extract; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..543ee2b641c26 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=typesfirst).symbols @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/checkOrderEnumComputedMember.ts] //// + +=== checkOrderEnumComputedMember.ts === +enum E { +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) + + A = 0, +>A : Symbol(E.A, Decl(checkOrderEnumComputedMember.ts, 0, 8)) + + B = E.A.valueOf(), +>B : Symbol(E.B, Decl(checkOrderEnumComputedMember.ts, 1, 10)) +>E.A.valueOf : Symbol(Number.valueOf, Decl(lib.es5.d.ts, --, --)) +>E.A : Symbol(E.A, Decl(checkOrderEnumComputedMember.ts, 0, 8)) +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) +>A : Symbol(E.A, Decl(checkOrderEnumComputedMember.ts, 0, 8)) +>valueOf : Symbol(Number.valueOf, Decl(lib.es5.d.ts, --, --)) + + C = 1, +>C : Symbol(E.C, Decl(checkOrderEnumComputedMember.ts, 2, 22)) +} + +const member: Extract = E.C; +>member : Symbol(member, Decl(checkOrderEnumComputedMember.ts, 6, 5)) +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) +>E.C : Symbol(E.C, Decl(checkOrderEnumComputedMember.ts, 2, 22)) +>E : Symbol(E, Decl(checkOrderEnumComputedMember.ts, 0, 0)) +>C : Symbol(E.C, Decl(checkOrderEnumComputedMember.ts, 2, 22)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=typesfirst).types new file mode 100644 index 0000000000000..39ddeced5f433 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderEnumComputedMember(checkorder=typesfirst).types @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/checkOrderEnumComputedMember.ts] //// + +=== checkOrderEnumComputedMember.ts === +enum E { +>E : E + + A = 0, +>A : E.A +>0 : 0 + + B = E.A.valueOf(), +>B : E.B +>E.A.valueOf() : number +>E.A.valueOf : () => number +>E.A : E.A +>E : typeof E +>A : E.A +>valueOf : () => number + + C = 1, +>C : E.C +>1 : 1 +} + +const member: Extract = E.C; +>member : E.C +>E.C : E.C +>E : typeof E +>C : E.C + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=default).errors.txt new file mode 100644 index 0000000000000..22ee511f52182 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=default).errors.txt @@ -0,0 +1,22 @@ +checkOrderLateBoundMembers.ts(6,9): error TS2300: Duplicate identifier 'foo'. +checkOrderLateBoundMembers.ts(7,5): error TS2300: Duplicate identifier 'foo'. +checkOrderLateBoundMembers.ts(8,9): error TS2300: Duplicate identifier 'foo'. + + +==== checkOrderLateBoundMembers.ts (3 errors) ==== + // Resolving the name in a computed property name looks it up in the members + // of the enclosing interface. That must not late-bind those same members, + // or the accessors would not merge with the property when asked first. + const foo = "foo" + interface I { + get [foo](): number; + ~~~~~ +!!! error TS2300: Duplicate identifier 'foo'. + foo: number; + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. + set [foo](value: number); + ~~~~~ +!!! error TS2300: Duplicate identifier 'foo'. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=default).symbols new file mode 100644 index 0000000000000..5d947b8a60834 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=default).symbols @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/checkOrderLateBoundMembers.ts] //// + +=== checkOrderLateBoundMembers.ts === +// Resolving the name in a computed property name looks it up in the members +// of the enclosing interface. That must not late-bind those same members, +// or the accessors would not merge with the property when asked first. +const foo = "foo" +>foo : Symbol(foo, Decl(checkOrderLateBoundMembers.ts, 3, 5)) + +interface I { +>I : Symbol(I, Decl(checkOrderLateBoundMembers.ts, 3, 17)) + + get [foo](): number; +>[foo] : Symbol(I.foo, Decl(checkOrderLateBoundMembers.ts, 5, 24), Decl(checkOrderLateBoundMembers.ts, 4, 13), Decl(checkOrderLateBoundMembers.ts, 6, 16)) +>foo : Symbol(foo, Decl(checkOrderLateBoundMembers.ts, 3, 5)) + + foo: number; +>foo : Symbol(I.foo, Decl(checkOrderLateBoundMembers.ts, 5, 24), Decl(checkOrderLateBoundMembers.ts, 4, 13), Decl(checkOrderLateBoundMembers.ts, 6, 16)) + + set [foo](value: number); +>[foo] : Symbol(I.foo, Decl(checkOrderLateBoundMembers.ts, 5, 24), Decl(checkOrderLateBoundMembers.ts, 4, 13), Decl(checkOrderLateBoundMembers.ts, 6, 16)) +>foo : Symbol(foo, Decl(checkOrderLateBoundMembers.ts, 3, 5)) +>value : Symbol(value, Decl(checkOrderLateBoundMembers.ts, 7, 14)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=default).types new file mode 100644 index 0000000000000..d6be33f1e73b4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=default).types @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/checkOrderLateBoundMembers.ts] //// + +=== checkOrderLateBoundMembers.ts === +// Resolving the name in a computed property name looks it up in the members +// of the enclosing interface. That must not late-bind those same members, +// or the accessors would not merge with the property when asked first. +const foo = "foo" +>foo : "foo" +>"foo" : "foo" + +interface I { + get [foo](): number; +>[foo] : number +>foo : "foo" + + foo: number; +>foo : number + + set [foo](value: number); +>[foo] : number +>foo : "foo" +>value : number +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=isolated).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=isolated).errors.txt new file mode 100644 index 0000000000000..22ee511f52182 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=isolated).errors.txt @@ -0,0 +1,22 @@ +checkOrderLateBoundMembers.ts(6,9): error TS2300: Duplicate identifier 'foo'. +checkOrderLateBoundMembers.ts(7,5): error TS2300: Duplicate identifier 'foo'. +checkOrderLateBoundMembers.ts(8,9): error TS2300: Duplicate identifier 'foo'. + + +==== checkOrderLateBoundMembers.ts (3 errors) ==== + // Resolving the name in a computed property name looks it up in the members + // of the enclosing interface. That must not late-bind those same members, + // or the accessors would not merge with the property when asked first. + const foo = "foo" + interface I { + get [foo](): number; + ~~~~~ +!!! error TS2300: Duplicate identifier 'foo'. + foo: number; + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. + set [foo](value: number); + ~~~~~ +!!! error TS2300: Duplicate identifier 'foo'. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=isolated).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=isolated).symbols new file mode 100644 index 0000000000000..5d947b8a60834 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=isolated).symbols @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/checkOrderLateBoundMembers.ts] //// + +=== checkOrderLateBoundMembers.ts === +// Resolving the name in a computed property name looks it up in the members +// of the enclosing interface. That must not late-bind those same members, +// or the accessors would not merge with the property when asked first. +const foo = "foo" +>foo : Symbol(foo, Decl(checkOrderLateBoundMembers.ts, 3, 5)) + +interface I { +>I : Symbol(I, Decl(checkOrderLateBoundMembers.ts, 3, 17)) + + get [foo](): number; +>[foo] : Symbol(I.foo, Decl(checkOrderLateBoundMembers.ts, 5, 24), Decl(checkOrderLateBoundMembers.ts, 4, 13), Decl(checkOrderLateBoundMembers.ts, 6, 16)) +>foo : Symbol(foo, Decl(checkOrderLateBoundMembers.ts, 3, 5)) + + foo: number; +>foo : Symbol(I.foo, Decl(checkOrderLateBoundMembers.ts, 5, 24), Decl(checkOrderLateBoundMembers.ts, 4, 13), Decl(checkOrderLateBoundMembers.ts, 6, 16)) + + set [foo](value: number); +>[foo] : Symbol(I.foo, Decl(checkOrderLateBoundMembers.ts, 5, 24), Decl(checkOrderLateBoundMembers.ts, 4, 13), Decl(checkOrderLateBoundMembers.ts, 6, 16)) +>foo : Symbol(foo, Decl(checkOrderLateBoundMembers.ts, 3, 5)) +>value : Symbol(value, Decl(checkOrderLateBoundMembers.ts, 7, 14)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=isolated).types b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=isolated).types new file mode 100644 index 0000000000000..d6be33f1e73b4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=isolated).types @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/checkOrderLateBoundMembers.ts] //// + +=== checkOrderLateBoundMembers.ts === +// Resolving the name in a computed property name looks it up in the members +// of the enclosing interface. That must not late-bind those same members, +// or the accessors would not merge with the property when asked first. +const foo = "foo" +>foo : "foo" +>"foo" : "foo" + +interface I { + get [foo](): number; +>[foo] : number +>foo : "foo" + + foo: number; +>foo : number + + set [foo](value: number); +>[foo] : number +>foo : "foo" +>value : number +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=reverse).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=reverse).errors.txt new file mode 100644 index 0000000000000..22ee511f52182 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=reverse).errors.txt @@ -0,0 +1,22 @@ +checkOrderLateBoundMembers.ts(6,9): error TS2300: Duplicate identifier 'foo'. +checkOrderLateBoundMembers.ts(7,5): error TS2300: Duplicate identifier 'foo'. +checkOrderLateBoundMembers.ts(8,9): error TS2300: Duplicate identifier 'foo'. + + +==== checkOrderLateBoundMembers.ts (3 errors) ==== + // Resolving the name in a computed property name looks it up in the members + // of the enclosing interface. That must not late-bind those same members, + // or the accessors would not merge with the property when asked first. + const foo = "foo" + interface I { + get [foo](): number; + ~~~~~ +!!! error TS2300: Duplicate identifier 'foo'. + foo: number; + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. + set [foo](value: number); + ~~~~~ +!!! error TS2300: Duplicate identifier 'foo'. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=reverse).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=reverse).symbols new file mode 100644 index 0000000000000..5d947b8a60834 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=reverse).symbols @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/checkOrderLateBoundMembers.ts] //// + +=== checkOrderLateBoundMembers.ts === +// Resolving the name in a computed property name looks it up in the members +// of the enclosing interface. That must not late-bind those same members, +// or the accessors would not merge with the property when asked first. +const foo = "foo" +>foo : Symbol(foo, Decl(checkOrderLateBoundMembers.ts, 3, 5)) + +interface I { +>I : Symbol(I, Decl(checkOrderLateBoundMembers.ts, 3, 17)) + + get [foo](): number; +>[foo] : Symbol(I.foo, Decl(checkOrderLateBoundMembers.ts, 5, 24), Decl(checkOrderLateBoundMembers.ts, 4, 13), Decl(checkOrderLateBoundMembers.ts, 6, 16)) +>foo : Symbol(foo, Decl(checkOrderLateBoundMembers.ts, 3, 5)) + + foo: number; +>foo : Symbol(I.foo, Decl(checkOrderLateBoundMembers.ts, 5, 24), Decl(checkOrderLateBoundMembers.ts, 4, 13), Decl(checkOrderLateBoundMembers.ts, 6, 16)) + + set [foo](value: number); +>[foo] : Symbol(I.foo, Decl(checkOrderLateBoundMembers.ts, 5, 24), Decl(checkOrderLateBoundMembers.ts, 4, 13), Decl(checkOrderLateBoundMembers.ts, 6, 16)) +>foo : Symbol(foo, Decl(checkOrderLateBoundMembers.ts, 3, 5)) +>value : Symbol(value, Decl(checkOrderLateBoundMembers.ts, 7, 14)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=reverse).types b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=reverse).types new file mode 100644 index 0000000000000..d6be33f1e73b4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=reverse).types @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/checkOrderLateBoundMembers.ts] //// + +=== checkOrderLateBoundMembers.ts === +// Resolving the name in a computed property name looks it up in the members +// of the enclosing interface. That must not late-bind those same members, +// or the accessors would not merge with the property when asked first. +const foo = "foo" +>foo : "foo" +>"foo" : "foo" + +interface I { + get [foo](): number; +>[foo] : number +>foo : "foo" + + foo: number; +>foo : number + + set [foo](value: number); +>[foo] : number +>foo : "foo" +>value : number +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..22ee511f52182 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=typesfirst).errors.txt @@ -0,0 +1,22 @@ +checkOrderLateBoundMembers.ts(6,9): error TS2300: Duplicate identifier 'foo'. +checkOrderLateBoundMembers.ts(7,5): error TS2300: Duplicate identifier 'foo'. +checkOrderLateBoundMembers.ts(8,9): error TS2300: Duplicate identifier 'foo'. + + +==== checkOrderLateBoundMembers.ts (3 errors) ==== + // Resolving the name in a computed property name looks it up in the members + // of the enclosing interface. That must not late-bind those same members, + // or the accessors would not merge with the property when asked first. + const foo = "foo" + interface I { + get [foo](): number; + ~~~~~ +!!! error TS2300: Duplicate identifier 'foo'. + foo: number; + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. + set [foo](value: number); + ~~~~~ +!!! error TS2300: Duplicate identifier 'foo'. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..5d947b8a60834 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=typesfirst).symbols @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/checkOrderLateBoundMembers.ts] //// + +=== checkOrderLateBoundMembers.ts === +// Resolving the name in a computed property name looks it up in the members +// of the enclosing interface. That must not late-bind those same members, +// or the accessors would not merge with the property when asked first. +const foo = "foo" +>foo : Symbol(foo, Decl(checkOrderLateBoundMembers.ts, 3, 5)) + +interface I { +>I : Symbol(I, Decl(checkOrderLateBoundMembers.ts, 3, 17)) + + get [foo](): number; +>[foo] : Symbol(I.foo, Decl(checkOrderLateBoundMembers.ts, 5, 24), Decl(checkOrderLateBoundMembers.ts, 4, 13), Decl(checkOrderLateBoundMembers.ts, 6, 16)) +>foo : Symbol(foo, Decl(checkOrderLateBoundMembers.ts, 3, 5)) + + foo: number; +>foo : Symbol(I.foo, Decl(checkOrderLateBoundMembers.ts, 5, 24), Decl(checkOrderLateBoundMembers.ts, 4, 13), Decl(checkOrderLateBoundMembers.ts, 6, 16)) + + set [foo](value: number); +>[foo] : Symbol(I.foo, Decl(checkOrderLateBoundMembers.ts, 5, 24), Decl(checkOrderLateBoundMembers.ts, 4, 13), Decl(checkOrderLateBoundMembers.ts, 6, 16)) +>foo : Symbol(foo, Decl(checkOrderLateBoundMembers.ts, 3, 5)) +>value : Symbol(value, Decl(checkOrderLateBoundMembers.ts, 7, 14)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=typesfirst).types new file mode 100644 index 0000000000000..d6be33f1e73b4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderLateBoundMembers(checkorder=typesfirst).types @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/checkOrderLateBoundMembers.ts] //// + +=== checkOrderLateBoundMembers.ts === +// Resolving the name in a computed property name looks it up in the members +// of the enclosing interface. That must not late-bind those same members, +// or the accessors would not merge with the property when asked first. +const foo = "foo" +>foo : "foo" +>"foo" : "foo" + +interface I { + get [foo](): number; +>[foo] : number +>foo : "foo" + + foo: number; +>foo : number + + set [foo](value: number); +>[foo] : number +>foo : "foo" +>value : number +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=default).js new file mode 100644 index 0000000000000..1d37a15bf23bd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=default).js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/checkOrderModuleExportsAlias.ts] //// + +//// [index.js] +module.exports.i = function i() {} +module.exports.ii = module.exports.i; + + +//// [index.js] +"use strict"; +module.exports.i = function i() { }; +module.exports.ii = module.exports.i; + + +//// [index.d.ts] +export declare var i: () => void; +export declare var ii: () => void; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=default).symbols new file mode 100644 index 0000000000000..f14879d6cea9a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=default).symbols @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/checkOrderModuleExportsAlias.ts] //// + +=== index.js === +module.exports.i = function i() {} +>module.exports.i : Symbol(i, Decl(index.js, 0, 0)) +>module.exports : Symbol(exports, Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol(exports, Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 0, 18)) + +module.exports.ii = module.exports.i; +>module.exports.ii : Symbol(ii, Decl(index.js, 0, 34)) +>module.exports : Symbol(exports, Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol(exports, Decl(index.js, 0, 0)) +>ii : Symbol(ii, Decl(index.js, 0, 34)) +>module.exports.i : Symbol(i, Decl(index.js, 0, 0)) +>module.exports : Symbol(exports, Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol(exports, Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 0, 0)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=default).types new file mode 100644 index 0000000000000..f940f148c6541 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=default).types @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/checkOrderModuleExportsAlias.ts] //// + +=== index.js === +module.exports.i = function i() {} +>module.exports.i = function i() {} : () => void +>module.exports.i : () => void +>module.exports : typeof import(".") +>module : { exports: typeof import("."); } +>exports : typeof import(".") +>i : () => void +>function i() {} : () => void +>i : () => void + +module.exports.ii = module.exports.i; +>module.exports.ii = module.exports.i : () => void +>module.exports.ii : () => void +>module.exports : typeof import(".") +>module : { exports: typeof import("."); } +>exports : typeof import(".") +>ii : () => void +>module.exports.i : () => void +>module.exports : typeof import(".") +>module : { exports: typeof import("."); } +>exports : typeof import(".") +>i : () => void + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=isolated).js b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=isolated).js new file mode 100644 index 0000000000000..1d37a15bf23bd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=isolated).js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/checkOrderModuleExportsAlias.ts] //// + +//// [index.js] +module.exports.i = function i() {} +module.exports.ii = module.exports.i; + + +//// [index.js] +"use strict"; +module.exports.i = function i() { }; +module.exports.ii = module.exports.i; + + +//// [index.d.ts] +export declare var i: () => void; +export declare var ii: () => void; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=isolated).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=isolated).symbols new file mode 100644 index 0000000000000..f14879d6cea9a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=isolated).symbols @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/checkOrderModuleExportsAlias.ts] //// + +=== index.js === +module.exports.i = function i() {} +>module.exports.i : Symbol(i, Decl(index.js, 0, 0)) +>module.exports : Symbol(exports, Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol(exports, Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 0, 18)) + +module.exports.ii = module.exports.i; +>module.exports.ii : Symbol(ii, Decl(index.js, 0, 34)) +>module.exports : Symbol(exports, Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol(exports, Decl(index.js, 0, 0)) +>ii : Symbol(ii, Decl(index.js, 0, 34)) +>module.exports.i : Symbol(i, Decl(index.js, 0, 0)) +>module.exports : Symbol(exports, Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol(exports, Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 0, 0)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=isolated).types b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=isolated).types new file mode 100644 index 0000000000000..f940f148c6541 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=isolated).types @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/checkOrderModuleExportsAlias.ts] //// + +=== index.js === +module.exports.i = function i() {} +>module.exports.i = function i() {} : () => void +>module.exports.i : () => void +>module.exports : typeof import(".") +>module : { exports: typeof import("."); } +>exports : typeof import(".") +>i : () => void +>function i() {} : () => void +>i : () => void + +module.exports.ii = module.exports.i; +>module.exports.ii = module.exports.i : () => void +>module.exports.ii : () => void +>module.exports : typeof import(".") +>module : { exports: typeof import("."); } +>exports : typeof import(".") +>ii : () => void +>module.exports.i : () => void +>module.exports : typeof import(".") +>module : { exports: typeof import("."); } +>exports : typeof import(".") +>i : () => void + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=reverse).js b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=reverse).js new file mode 100644 index 0000000000000..1d37a15bf23bd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=reverse).js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/checkOrderModuleExportsAlias.ts] //// + +//// [index.js] +module.exports.i = function i() {} +module.exports.ii = module.exports.i; + + +//// [index.js] +"use strict"; +module.exports.i = function i() { }; +module.exports.ii = module.exports.i; + + +//// [index.d.ts] +export declare var i: () => void; +export declare var ii: () => void; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=reverse).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=reverse).symbols new file mode 100644 index 0000000000000..f14879d6cea9a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=reverse).symbols @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/checkOrderModuleExportsAlias.ts] //// + +=== index.js === +module.exports.i = function i() {} +>module.exports.i : Symbol(i, Decl(index.js, 0, 0)) +>module.exports : Symbol(exports, Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol(exports, Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 0, 18)) + +module.exports.ii = module.exports.i; +>module.exports.ii : Symbol(ii, Decl(index.js, 0, 34)) +>module.exports : Symbol(exports, Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol(exports, Decl(index.js, 0, 0)) +>ii : Symbol(ii, Decl(index.js, 0, 34)) +>module.exports.i : Symbol(i, Decl(index.js, 0, 0)) +>module.exports : Symbol(exports, Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol(exports, Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 0, 0)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=reverse).types b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=reverse).types new file mode 100644 index 0000000000000..f940f148c6541 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=reverse).types @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/checkOrderModuleExportsAlias.ts] //// + +=== index.js === +module.exports.i = function i() {} +>module.exports.i = function i() {} : () => void +>module.exports.i : () => void +>module.exports : typeof import(".") +>module : { exports: typeof import("."); } +>exports : typeof import(".") +>i : () => void +>function i() {} : () => void +>i : () => void + +module.exports.ii = module.exports.i; +>module.exports.ii = module.exports.i : () => void +>module.exports.ii : () => void +>module.exports : typeof import(".") +>module : { exports: typeof import("."); } +>exports : typeof import(".") +>ii : () => void +>module.exports.i : () => void +>module.exports : typeof import(".") +>module : { exports: typeof import("."); } +>exports : typeof import(".") +>i : () => void + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=typesfirst).js new file mode 100644 index 0000000000000..1d37a15bf23bd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=typesfirst).js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/checkOrderModuleExportsAlias.ts] //// + +//// [index.js] +module.exports.i = function i() {} +module.exports.ii = module.exports.i; + + +//// [index.js] +"use strict"; +module.exports.i = function i() { }; +module.exports.ii = module.exports.i; + + +//// [index.d.ts] +export declare var i: () => void; +export declare var ii: () => void; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..f14879d6cea9a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=typesfirst).symbols @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/checkOrderModuleExportsAlias.ts] //// + +=== index.js === +module.exports.i = function i() {} +>module.exports.i : Symbol(i, Decl(index.js, 0, 0)) +>module.exports : Symbol(exports, Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol(exports, Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 0, 18)) + +module.exports.ii = module.exports.i; +>module.exports.ii : Symbol(ii, Decl(index.js, 0, 34)) +>module.exports : Symbol(exports, Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol(exports, Decl(index.js, 0, 0)) +>ii : Symbol(ii, Decl(index.js, 0, 34)) +>module.exports.i : Symbol(i, Decl(index.js, 0, 0)) +>module.exports : Symbol(exports, Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 0, 0)) +>exports : Symbol(exports, Decl(index.js, 0, 0)) +>i : Symbol(i, Decl(index.js, 0, 0)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=typesfirst).types new file mode 100644 index 0000000000000..f940f148c6541 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderModuleExportsAlias(checkorder=typesfirst).types @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/checkOrderModuleExportsAlias.ts] //// + +=== index.js === +module.exports.i = function i() {} +>module.exports.i = function i() {} : () => void +>module.exports.i : () => void +>module.exports : typeof import(".") +>module : { exports: typeof import("."); } +>exports : typeof import(".") +>i : () => void +>function i() {} : () => void +>i : () => void + +module.exports.ii = module.exports.i; +>module.exports.ii = module.exports.i : () => void +>module.exports.ii : () => void +>module.exports : typeof import(".") +>module : { exports: typeof import("."); } +>exports : typeof import(".") +>ii : () => void +>module.exports.i : () => void +>module.exports : typeof import(".") +>module : { exports: typeof import("."); } +>exports : typeof import(".") +>i : () => void + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=default).js new file mode 100644 index 0000000000000..749ae4044d77f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=default).js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/checkOrderParameterInTypeQuery.ts] //// + +//// [checkOrderParameterInTypeQuery.ts] +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. + +export class C2 { + #a = 1; + test1() { + class C { + test1(a: C2): typeof a.#a { + return 1; + } + } + return new C().test1(this); + } +} + + +//// [checkOrderParameterInTypeQuery.js] +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. +export class C2 { + #a = 1; + test1() { + class C { + test1(a) { + return 1; + } + } + return new C().test1(this); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=default).symbols new file mode 100644 index 0000000000000..7f3da2b79534f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=default).symbols @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/checkOrderParameterInTypeQuery.ts] //// + +=== checkOrderParameterInTypeQuery.ts === +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. + +export class C2 { +>C2 : Symbol(C2, Decl(checkOrderParameterInTypeQuery.ts, 0, 0)) + + #a = 1; +>#a : Symbol(C2.#a, Decl(checkOrderParameterInTypeQuery.ts, 4, 17)) + + test1() { +>test1 : Symbol(C2.test1, Decl(checkOrderParameterInTypeQuery.ts, 5, 11)) + + class C { +>C : Symbol(C, Decl(checkOrderParameterInTypeQuery.ts, 6, 13)) + + test1(a: C2): typeof a.#a { +>test1 : Symbol(C.test1, Decl(checkOrderParameterInTypeQuery.ts, 7, 17)) +>a : Symbol(a, Decl(checkOrderParameterInTypeQuery.ts, 8, 18)) +>C2 : Symbol(C2, Decl(checkOrderParameterInTypeQuery.ts, 0, 0)) +>a.#a : Symbol(C2.#a, Decl(checkOrderParameterInTypeQuery.ts, 4, 17)) +>a : Symbol(a, Decl(checkOrderParameterInTypeQuery.ts, 8, 18)) + + return 1; + } + } + return new C().test1(this); +>new C().test1 : Symbol(C.test1, Decl(checkOrderParameterInTypeQuery.ts, 7, 17)) +>C : Symbol(C, Decl(checkOrderParameterInTypeQuery.ts, 6, 13)) +>test1 : Symbol(C.test1, Decl(checkOrderParameterInTypeQuery.ts, 7, 17)) +>this : Symbol(C2, Decl(checkOrderParameterInTypeQuery.ts, 0, 0)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=default).types new file mode 100644 index 0000000000000..c7f091d02bcb0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=default).types @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/checkOrderParameterInTypeQuery.ts] //// + +=== checkOrderParameterInTypeQuery.ts === +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. + +export class C2 { +>C2 : C2 + + #a = 1; +>#a : number +>1 : 1 + + test1() { +>test1 : () => number + + class C { +>C : C + + test1(a: C2): typeof a.#a { +>test1 : (a: C2) => typeof a.#a +>a : C2 +>a.#a : number +>a : C2 + + return 1; +>1 : 1 + } + } + return new C().test1(this); +>new C().test1(this) : number +>new C().test1 : (a: C2) => typeof a.#a +>new C() : C +>C : typeof C +>test1 : (a: C2) => typeof a.#a +>this : this + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=isolated).js b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=isolated).js new file mode 100644 index 0000000000000..749ae4044d77f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=isolated).js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/checkOrderParameterInTypeQuery.ts] //// + +//// [checkOrderParameterInTypeQuery.ts] +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. + +export class C2 { + #a = 1; + test1() { + class C { + test1(a: C2): typeof a.#a { + return 1; + } + } + return new C().test1(this); + } +} + + +//// [checkOrderParameterInTypeQuery.js] +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. +export class C2 { + #a = 1; + test1() { + class C { + test1(a) { + return 1; + } + } + return new C().test1(this); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=isolated).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=isolated).symbols new file mode 100644 index 0000000000000..7f3da2b79534f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=isolated).symbols @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/checkOrderParameterInTypeQuery.ts] //// + +=== checkOrderParameterInTypeQuery.ts === +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. + +export class C2 { +>C2 : Symbol(C2, Decl(checkOrderParameterInTypeQuery.ts, 0, 0)) + + #a = 1; +>#a : Symbol(C2.#a, Decl(checkOrderParameterInTypeQuery.ts, 4, 17)) + + test1() { +>test1 : Symbol(C2.test1, Decl(checkOrderParameterInTypeQuery.ts, 5, 11)) + + class C { +>C : Symbol(C, Decl(checkOrderParameterInTypeQuery.ts, 6, 13)) + + test1(a: C2): typeof a.#a { +>test1 : Symbol(C.test1, Decl(checkOrderParameterInTypeQuery.ts, 7, 17)) +>a : Symbol(a, Decl(checkOrderParameterInTypeQuery.ts, 8, 18)) +>C2 : Symbol(C2, Decl(checkOrderParameterInTypeQuery.ts, 0, 0)) +>a.#a : Symbol(C2.#a, Decl(checkOrderParameterInTypeQuery.ts, 4, 17)) +>a : Symbol(a, Decl(checkOrderParameterInTypeQuery.ts, 8, 18)) + + return 1; + } + } + return new C().test1(this); +>new C().test1 : Symbol(C.test1, Decl(checkOrderParameterInTypeQuery.ts, 7, 17)) +>C : Symbol(C, Decl(checkOrderParameterInTypeQuery.ts, 6, 13)) +>test1 : Symbol(C.test1, Decl(checkOrderParameterInTypeQuery.ts, 7, 17)) +>this : Symbol(C2, Decl(checkOrderParameterInTypeQuery.ts, 0, 0)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=isolated).types b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=isolated).types new file mode 100644 index 0000000000000..0c9c1f6dcfb8d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=isolated).types @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/checkOrderParameterInTypeQuery.ts] //// + +=== checkOrderParameterInTypeQuery.ts === +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. + +export class C2 { +>C2 : C2 + + #a = 1; +>#a : number +>1 : 1 + + test1() { +>test1 : () => number + + class C { +>C : C + + test1(a: C2): typeof a.#a { +>test1 : (a: C2) => typeof a.#a +>a : C2 +>a.#a : number +>a : C2 + + return 1; +>1 : 1 + } + } + return new C().test1(this); +>new C().test1(this) : number +>new C().test1 : (a: C2) => number +>new C() : C +>C : typeof C +>test1 : (a: C2) => number +>this : this + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=reverse).js b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=reverse).js new file mode 100644 index 0000000000000..749ae4044d77f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=reverse).js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/checkOrderParameterInTypeQuery.ts] //// + +//// [checkOrderParameterInTypeQuery.ts] +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. + +export class C2 { + #a = 1; + test1() { + class C { + test1(a: C2): typeof a.#a { + return 1; + } + } + return new C().test1(this); + } +} + + +//// [checkOrderParameterInTypeQuery.js] +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. +export class C2 { + #a = 1; + test1() { + class C { + test1(a) { + return 1; + } + } + return new C().test1(this); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=reverse).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=reverse).symbols new file mode 100644 index 0000000000000..7f3da2b79534f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=reverse).symbols @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/checkOrderParameterInTypeQuery.ts] //// + +=== checkOrderParameterInTypeQuery.ts === +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. + +export class C2 { +>C2 : Symbol(C2, Decl(checkOrderParameterInTypeQuery.ts, 0, 0)) + + #a = 1; +>#a : Symbol(C2.#a, Decl(checkOrderParameterInTypeQuery.ts, 4, 17)) + + test1() { +>test1 : Symbol(C2.test1, Decl(checkOrderParameterInTypeQuery.ts, 5, 11)) + + class C { +>C : Symbol(C, Decl(checkOrderParameterInTypeQuery.ts, 6, 13)) + + test1(a: C2): typeof a.#a { +>test1 : Symbol(C.test1, Decl(checkOrderParameterInTypeQuery.ts, 7, 17)) +>a : Symbol(a, Decl(checkOrderParameterInTypeQuery.ts, 8, 18)) +>C2 : Symbol(C2, Decl(checkOrderParameterInTypeQuery.ts, 0, 0)) +>a.#a : Symbol(C2.#a, Decl(checkOrderParameterInTypeQuery.ts, 4, 17)) +>a : Symbol(a, Decl(checkOrderParameterInTypeQuery.ts, 8, 18)) + + return 1; + } + } + return new C().test1(this); +>new C().test1 : Symbol(C.test1, Decl(checkOrderParameterInTypeQuery.ts, 7, 17)) +>C : Symbol(C, Decl(checkOrderParameterInTypeQuery.ts, 6, 13)) +>test1 : Symbol(C.test1, Decl(checkOrderParameterInTypeQuery.ts, 7, 17)) +>this : Symbol(C2, Decl(checkOrderParameterInTypeQuery.ts, 0, 0)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=reverse).types b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=reverse).types new file mode 100644 index 0000000000000..c7f091d02bcb0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=reverse).types @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/checkOrderParameterInTypeQuery.ts] //// + +=== checkOrderParameterInTypeQuery.ts === +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. + +export class C2 { +>C2 : C2 + + #a = 1; +>#a : number +>1 : 1 + + test1() { +>test1 : () => number + + class C { +>C : C + + test1(a: C2): typeof a.#a { +>test1 : (a: C2) => typeof a.#a +>a : C2 +>a.#a : number +>a : C2 + + return 1; +>1 : 1 + } + } + return new C().test1(this); +>new C().test1(this) : number +>new C().test1 : (a: C2) => typeof a.#a +>new C() : C +>C : typeof C +>test1 : (a: C2) => typeof a.#a +>this : this + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=typesfirst).js new file mode 100644 index 0000000000000..749ae4044d77f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=typesfirst).js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/checkOrderParameterInTypeQuery.ts] //// + +//// [checkOrderParameterInTypeQuery.ts] +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. + +export class C2 { + #a = 1; + test1() { + class C { + test1(a: C2): typeof a.#a { + return 1; + } + } + return new C().test1(this); + } +} + + +//// [checkOrderParameterInTypeQuery.js] +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. +export class C2 { + #a = 1; + test1() { + class C { + test1(a) { + return 1; + } + } + return new C().test1(this); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..7f3da2b79534f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=typesfirst).symbols @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/checkOrderParameterInTypeQuery.ts] //// + +=== checkOrderParameterInTypeQuery.ts === +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. + +export class C2 { +>C2 : Symbol(C2, Decl(checkOrderParameterInTypeQuery.ts, 0, 0)) + + #a = 1; +>#a : Symbol(C2.#a, Decl(checkOrderParameterInTypeQuery.ts, 4, 17)) + + test1() { +>test1 : Symbol(C2.test1, Decl(checkOrderParameterInTypeQuery.ts, 5, 11)) + + class C { +>C : Symbol(C, Decl(checkOrderParameterInTypeQuery.ts, 6, 13)) + + test1(a: C2): typeof a.#a { +>test1 : Symbol(C.test1, Decl(checkOrderParameterInTypeQuery.ts, 7, 17)) +>a : Symbol(a, Decl(checkOrderParameterInTypeQuery.ts, 8, 18)) +>C2 : Symbol(C2, Decl(checkOrderParameterInTypeQuery.ts, 0, 0)) +>a.#a : Symbol(C2.#a, Decl(checkOrderParameterInTypeQuery.ts, 4, 17)) +>a : Symbol(a, Decl(checkOrderParameterInTypeQuery.ts, 8, 18)) + + return 1; + } + } + return new C().test1(this); +>new C().test1 : Symbol(C.test1, Decl(checkOrderParameterInTypeQuery.ts, 7, 17)) +>C : Symbol(C, Decl(checkOrderParameterInTypeQuery.ts, 6, 13)) +>test1 : Symbol(C.test1, Decl(checkOrderParameterInTypeQuery.ts, 7, 17)) +>this : Symbol(C2, Decl(checkOrderParameterInTypeQuery.ts, 0, 0)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=typesfirst).types new file mode 100644 index 0000000000000..0c9c1f6dcfb8d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderParameterInTypeQuery(checkorder=typesfirst).types @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/checkOrderParameterInTypeQuery.ts] //// + +=== checkOrderParameterInTypeQuery.ts === +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. + +export class C2 { +>C2 : C2 + + #a = 1; +>#a : number +>1 : 1 + + test1() { +>test1 : () => number + + class C { +>C : C + + test1(a: C2): typeof a.#a { +>test1 : (a: C2) => typeof a.#a +>a : C2 +>a.#a : number +>a : C2 + + return 1; +>1 : 1 + } + } + return new C().test1(this); +>new C().test1(this) : number +>new C().test1 : (a: C2) => number +>new C() : C +>C : typeof C +>test1 : (a: C2) => number +>this : this + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=default).errors.txt new file mode 100644 index 0000000000000..3fd3738f9b7f2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=default).errors.txt @@ -0,0 +1,36 @@ +join.ts(3,5): error TS2322: Type '[string, ...Recur[]]' is not assignable to type 'Recur'. + Type '[string, ...Recur[]]' is not assignable to type 'Recur[number][]'. + Type 'string | Recur' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + Type 'string' is not assignable to type '(T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +recur.ts(3,9): error TS2536: Type 'number' cannot be used to index type 'Recur'. + + +==== recur.ts (1 errors) ==== + export type Recur = + (T extends (unknown[]) ? {} : { [K in keyof T]?: Recur}) | + [...Recur[number][]]; + ~~~~~~~~~~~~~~~~ +!!! error TS2536: Type 'number' cannot be used to index type 'Recur'. + +==== join.ts (1 errors) ==== + import { Recur } from "./recur"; + export function join(l: Recur[]): Recur { + return ['marker', ...l]; + ~~~~~~ +!!! error TS2322: Type '[string, ...Recur[]]' is not assignable to type 'Recur'. +!!! error TS2322: Type '[string, ...Recur[]]' is not assignable to type 'Recur[number][]'. +!!! error TS2322: Type 'string | Recur' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +!!! error TS2322: Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +!!! error TS2322: Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +!!! error TS2322: Type 'string' is not assignable to type '(T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + } + +==== a.ts (0 errors) ==== + import { Recur } from "./recur"; + import { join } from "./join"; + function a(l: Recur[]): void { + const x: Recur | undefined = join(l); + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=default).symbols new file mode 100644 index 0000000000000..d9f42dc0817f8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=default).symbols @@ -0,0 +1,58 @@ +//// [tests/cases/compiler/checkOrderRecursiveIndexedAccess.ts] //// + +=== recur.ts === +export type Recur = +>Recur : Symbol(Recur, Decl(recur.ts, 0, 0)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) + + (T extends (unknown[]) ? {} : { [K in keyof T]?: Recur}) | +>T : Symbol(T, Decl(recur.ts, 0, 18)) +>K : Symbol(K, Decl(recur.ts, 1, 38)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) +>Recur : Symbol(Recur, Decl(recur.ts, 0, 0)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) +>K : Symbol(K, Decl(recur.ts, 1, 38)) + + [...Recur[number][]]; +>Recur : Symbol(Recur, Decl(recur.ts, 0, 0)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) + +=== join.ts === +import { Recur } from "./recur"; +>Recur : Symbol(Recur, Decl(join.ts, 0, 8)) + +export function join(l: Recur[]): Recur { +>join : Symbol(join, Decl(join.ts, 0, 32)) +>T : Symbol(T, Decl(join.ts, 1, 21)) +>l : Symbol(l, Decl(join.ts, 1, 24)) +>Recur : Symbol(Recur, Decl(join.ts, 0, 8)) +>T : Symbol(T, Decl(join.ts, 1, 21)) +>Recur : Symbol(Recur, Decl(join.ts, 0, 8)) +>T : Symbol(T, Decl(join.ts, 1, 21)) + + return ['marker', ...l]; +>l : Symbol(l, Decl(join.ts, 1, 24)) +} + +=== a.ts === +import { Recur } from "./recur"; +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) + +import { join } from "./join"; +>join : Symbol(join, Decl(a.ts, 1, 8)) + +function a(l: Recur[]): void { +>a : Symbol(a, Decl(a.ts, 1, 30)) +>T : Symbol(T, Decl(a.ts, 2, 11)) +>l : Symbol(l, Decl(a.ts, 2, 14)) +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) +>T : Symbol(T, Decl(a.ts, 2, 11)) + + const x: Recur | undefined = join(l); +>x : Symbol(x, Decl(a.ts, 3, 9)) +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) +>T : Symbol(T, Decl(a.ts, 2, 11)) +>join : Symbol(join, Decl(a.ts, 1, 8)) +>l : Symbol(l, Decl(a.ts, 2, 14)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=default).types new file mode 100644 index 0000000000000..833609532a4c1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=default).types @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/checkOrderRecursiveIndexedAccess.ts] //// + +=== recur.ts === +export type Recur = +>Recur : Recur + + (T extends (unknown[]) ? {} : { [K in keyof T]?: Recur}) | + [...Recur[number][]]; + +=== join.ts === +import { Recur } from "./recur"; +>Recur : any + +export function join(l: Recur[]): Recur { +>join : (l: Recur[]) => Recur +>l : Recur[] + + return ['marker', ...l]; +>['marker', ...l] : [string, ...Recur[]] +>'marker' : "marker" +>...l : Recur +>l : Recur[] +} + +=== a.ts === +import { Recur } from "./recur"; +>Recur : any + +import { join } from "./join"; +>join : (l: Recur[]) => Recur + +function a(l: Recur[]): void { +>a : (l: Recur[]) => void +>l : Recur[] + + const x: Recur | undefined = join(l); +>x : Recur | undefined +>join(l) : Recur +>join : (l: Recur[]) => Recur +>l : Recur[] +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=isolated).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=isolated).errors.txt new file mode 100644 index 0000000000000..3fd3738f9b7f2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=isolated).errors.txt @@ -0,0 +1,36 @@ +join.ts(3,5): error TS2322: Type '[string, ...Recur[]]' is not assignable to type 'Recur'. + Type '[string, ...Recur[]]' is not assignable to type 'Recur[number][]'. + Type 'string | Recur' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + Type 'string' is not assignable to type '(T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +recur.ts(3,9): error TS2536: Type 'number' cannot be used to index type 'Recur'. + + +==== recur.ts (1 errors) ==== + export type Recur = + (T extends (unknown[]) ? {} : { [K in keyof T]?: Recur}) | + [...Recur[number][]]; + ~~~~~~~~~~~~~~~~ +!!! error TS2536: Type 'number' cannot be used to index type 'Recur'. + +==== join.ts (1 errors) ==== + import { Recur } from "./recur"; + export function join(l: Recur[]): Recur { + return ['marker', ...l]; + ~~~~~~ +!!! error TS2322: Type '[string, ...Recur[]]' is not assignable to type 'Recur'. +!!! error TS2322: Type '[string, ...Recur[]]' is not assignable to type 'Recur[number][]'. +!!! error TS2322: Type 'string | Recur' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +!!! error TS2322: Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +!!! error TS2322: Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +!!! error TS2322: Type 'string' is not assignable to type '(T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + } + +==== a.ts (0 errors) ==== + import { Recur } from "./recur"; + import { join } from "./join"; + function a(l: Recur[]): void { + const x: Recur | undefined = join(l); + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=isolated).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=isolated).symbols new file mode 100644 index 0000000000000..d9f42dc0817f8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=isolated).symbols @@ -0,0 +1,58 @@ +//// [tests/cases/compiler/checkOrderRecursiveIndexedAccess.ts] //// + +=== recur.ts === +export type Recur = +>Recur : Symbol(Recur, Decl(recur.ts, 0, 0)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) + + (T extends (unknown[]) ? {} : { [K in keyof T]?: Recur}) | +>T : Symbol(T, Decl(recur.ts, 0, 18)) +>K : Symbol(K, Decl(recur.ts, 1, 38)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) +>Recur : Symbol(Recur, Decl(recur.ts, 0, 0)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) +>K : Symbol(K, Decl(recur.ts, 1, 38)) + + [...Recur[number][]]; +>Recur : Symbol(Recur, Decl(recur.ts, 0, 0)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) + +=== join.ts === +import { Recur } from "./recur"; +>Recur : Symbol(Recur, Decl(join.ts, 0, 8)) + +export function join(l: Recur[]): Recur { +>join : Symbol(join, Decl(join.ts, 0, 32)) +>T : Symbol(T, Decl(join.ts, 1, 21)) +>l : Symbol(l, Decl(join.ts, 1, 24)) +>Recur : Symbol(Recur, Decl(join.ts, 0, 8)) +>T : Symbol(T, Decl(join.ts, 1, 21)) +>Recur : Symbol(Recur, Decl(join.ts, 0, 8)) +>T : Symbol(T, Decl(join.ts, 1, 21)) + + return ['marker', ...l]; +>l : Symbol(l, Decl(join.ts, 1, 24)) +} + +=== a.ts === +import { Recur } from "./recur"; +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) + +import { join } from "./join"; +>join : Symbol(join, Decl(a.ts, 1, 8)) + +function a(l: Recur[]): void { +>a : Symbol(a, Decl(a.ts, 1, 30)) +>T : Symbol(T, Decl(a.ts, 2, 11)) +>l : Symbol(l, Decl(a.ts, 2, 14)) +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) +>T : Symbol(T, Decl(a.ts, 2, 11)) + + const x: Recur | undefined = join(l); +>x : Symbol(x, Decl(a.ts, 3, 9)) +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) +>T : Symbol(T, Decl(a.ts, 2, 11)) +>join : Symbol(join, Decl(a.ts, 1, 8)) +>l : Symbol(l, Decl(a.ts, 2, 14)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=isolated).types b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=isolated).types new file mode 100644 index 0000000000000..833609532a4c1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=isolated).types @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/checkOrderRecursiveIndexedAccess.ts] //// + +=== recur.ts === +export type Recur = +>Recur : Recur + + (T extends (unknown[]) ? {} : { [K in keyof T]?: Recur}) | + [...Recur[number][]]; + +=== join.ts === +import { Recur } from "./recur"; +>Recur : any + +export function join(l: Recur[]): Recur { +>join : (l: Recur[]) => Recur +>l : Recur[] + + return ['marker', ...l]; +>['marker', ...l] : [string, ...Recur[]] +>'marker' : "marker" +>...l : Recur +>l : Recur[] +} + +=== a.ts === +import { Recur } from "./recur"; +>Recur : any + +import { join } from "./join"; +>join : (l: Recur[]) => Recur + +function a(l: Recur[]): void { +>a : (l: Recur[]) => void +>l : Recur[] + + const x: Recur | undefined = join(l); +>x : Recur | undefined +>join(l) : Recur +>join : (l: Recur[]) => Recur +>l : Recur[] +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=reverse).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=reverse).errors.txt new file mode 100644 index 0000000000000..3fd3738f9b7f2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=reverse).errors.txt @@ -0,0 +1,36 @@ +join.ts(3,5): error TS2322: Type '[string, ...Recur[]]' is not assignable to type 'Recur'. + Type '[string, ...Recur[]]' is not assignable to type 'Recur[number][]'. + Type 'string | Recur' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + Type 'string' is not assignable to type '(T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +recur.ts(3,9): error TS2536: Type 'number' cannot be used to index type 'Recur'. + + +==== recur.ts (1 errors) ==== + export type Recur = + (T extends (unknown[]) ? {} : { [K in keyof T]?: Recur}) | + [...Recur[number][]]; + ~~~~~~~~~~~~~~~~ +!!! error TS2536: Type 'number' cannot be used to index type 'Recur'. + +==== join.ts (1 errors) ==== + import { Recur } from "./recur"; + export function join(l: Recur[]): Recur { + return ['marker', ...l]; + ~~~~~~ +!!! error TS2322: Type '[string, ...Recur[]]' is not assignable to type 'Recur'. +!!! error TS2322: Type '[string, ...Recur[]]' is not assignable to type 'Recur[number][]'. +!!! error TS2322: Type 'string | Recur' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +!!! error TS2322: Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +!!! error TS2322: Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +!!! error TS2322: Type 'string' is not assignable to type '(T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + } + +==== a.ts (0 errors) ==== + import { Recur } from "./recur"; + import { join } from "./join"; + function a(l: Recur[]): void { + const x: Recur | undefined = join(l); + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=reverse).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=reverse).symbols new file mode 100644 index 0000000000000..d9f42dc0817f8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=reverse).symbols @@ -0,0 +1,58 @@ +//// [tests/cases/compiler/checkOrderRecursiveIndexedAccess.ts] //// + +=== recur.ts === +export type Recur = +>Recur : Symbol(Recur, Decl(recur.ts, 0, 0)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) + + (T extends (unknown[]) ? {} : { [K in keyof T]?: Recur}) | +>T : Symbol(T, Decl(recur.ts, 0, 18)) +>K : Symbol(K, Decl(recur.ts, 1, 38)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) +>Recur : Symbol(Recur, Decl(recur.ts, 0, 0)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) +>K : Symbol(K, Decl(recur.ts, 1, 38)) + + [...Recur[number][]]; +>Recur : Symbol(Recur, Decl(recur.ts, 0, 0)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) + +=== join.ts === +import { Recur } from "./recur"; +>Recur : Symbol(Recur, Decl(join.ts, 0, 8)) + +export function join(l: Recur[]): Recur { +>join : Symbol(join, Decl(join.ts, 0, 32)) +>T : Symbol(T, Decl(join.ts, 1, 21)) +>l : Symbol(l, Decl(join.ts, 1, 24)) +>Recur : Symbol(Recur, Decl(join.ts, 0, 8)) +>T : Symbol(T, Decl(join.ts, 1, 21)) +>Recur : Symbol(Recur, Decl(join.ts, 0, 8)) +>T : Symbol(T, Decl(join.ts, 1, 21)) + + return ['marker', ...l]; +>l : Symbol(l, Decl(join.ts, 1, 24)) +} + +=== a.ts === +import { Recur } from "./recur"; +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) + +import { join } from "./join"; +>join : Symbol(join, Decl(a.ts, 1, 8)) + +function a(l: Recur[]): void { +>a : Symbol(a, Decl(a.ts, 1, 30)) +>T : Symbol(T, Decl(a.ts, 2, 11)) +>l : Symbol(l, Decl(a.ts, 2, 14)) +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) +>T : Symbol(T, Decl(a.ts, 2, 11)) + + const x: Recur | undefined = join(l); +>x : Symbol(x, Decl(a.ts, 3, 9)) +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) +>T : Symbol(T, Decl(a.ts, 2, 11)) +>join : Symbol(join, Decl(a.ts, 1, 8)) +>l : Symbol(l, Decl(a.ts, 2, 14)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=reverse).types b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=reverse).types new file mode 100644 index 0000000000000..833609532a4c1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=reverse).types @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/checkOrderRecursiveIndexedAccess.ts] //// + +=== recur.ts === +export type Recur = +>Recur : Recur + + (T extends (unknown[]) ? {} : { [K in keyof T]?: Recur}) | + [...Recur[number][]]; + +=== join.ts === +import { Recur } from "./recur"; +>Recur : any + +export function join(l: Recur[]): Recur { +>join : (l: Recur[]) => Recur +>l : Recur[] + + return ['marker', ...l]; +>['marker', ...l] : [string, ...Recur[]] +>'marker' : "marker" +>...l : Recur +>l : Recur[] +} + +=== a.ts === +import { Recur } from "./recur"; +>Recur : any + +import { join } from "./join"; +>join : (l: Recur[]) => Recur + +function a(l: Recur[]): void { +>a : (l: Recur[]) => void +>l : Recur[] + + const x: Recur | undefined = join(l); +>x : Recur | undefined +>join(l) : Recur +>join : (l: Recur[]) => Recur +>l : Recur[] +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..3fd3738f9b7f2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=typesfirst).errors.txt @@ -0,0 +1,36 @@ +join.ts(3,5): error TS2322: Type '[string, ...Recur[]]' is not assignable to type 'Recur'. + Type '[string, ...Recur[]]' is not assignable to type 'Recur[number][]'. + Type 'string | Recur' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + Type 'string' is not assignable to type '(T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +recur.ts(3,9): error TS2536: Type 'number' cannot be used to index type 'Recur'. + + +==== recur.ts (1 errors) ==== + export type Recur = + (T extends (unknown[]) ? {} : { [K in keyof T]?: Recur}) | + [...Recur[number][]]; + ~~~~~~~~~~~~~~~~ +!!! error TS2536: Type 'number' cannot be used to index type 'Recur'. + +==== join.ts (1 errors) ==== + import { Recur } from "./recur"; + export function join(l: Recur[]): Recur { + return ['marker', ...l]; + ~~~~~~ +!!! error TS2322: Type '[string, ...Recur[]]' is not assignable to type 'Recur'. +!!! error TS2322: Type '[string, ...Recur[]]' is not assignable to type 'Recur[number][]'. +!!! error TS2322: Type 'string | Recur' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +!!! error TS2322: Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +!!! error TS2322: Type 'string' is not assignable to type 'Recur[number] & (T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. +!!! error TS2322: Type 'string' is not assignable to type '(T extends unknown[] ? {} : { [K in keyof T]?: Recur | undefined; })[number]'. + } + +==== a.ts (0 errors) ==== + import { Recur } from "./recur"; + import { join } from "./join"; + function a(l: Recur[]): void { + const x: Recur | undefined = join(l); + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..d9f42dc0817f8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=typesfirst).symbols @@ -0,0 +1,58 @@ +//// [tests/cases/compiler/checkOrderRecursiveIndexedAccess.ts] //// + +=== recur.ts === +export type Recur = +>Recur : Symbol(Recur, Decl(recur.ts, 0, 0)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) + + (T extends (unknown[]) ? {} : { [K in keyof T]?: Recur}) | +>T : Symbol(T, Decl(recur.ts, 0, 18)) +>K : Symbol(K, Decl(recur.ts, 1, 38)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) +>Recur : Symbol(Recur, Decl(recur.ts, 0, 0)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) +>K : Symbol(K, Decl(recur.ts, 1, 38)) + + [...Recur[number][]]; +>Recur : Symbol(Recur, Decl(recur.ts, 0, 0)) +>T : Symbol(T, Decl(recur.ts, 0, 18)) + +=== join.ts === +import { Recur } from "./recur"; +>Recur : Symbol(Recur, Decl(join.ts, 0, 8)) + +export function join(l: Recur[]): Recur { +>join : Symbol(join, Decl(join.ts, 0, 32)) +>T : Symbol(T, Decl(join.ts, 1, 21)) +>l : Symbol(l, Decl(join.ts, 1, 24)) +>Recur : Symbol(Recur, Decl(join.ts, 0, 8)) +>T : Symbol(T, Decl(join.ts, 1, 21)) +>Recur : Symbol(Recur, Decl(join.ts, 0, 8)) +>T : Symbol(T, Decl(join.ts, 1, 21)) + + return ['marker', ...l]; +>l : Symbol(l, Decl(join.ts, 1, 24)) +} + +=== a.ts === +import { Recur } from "./recur"; +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) + +import { join } from "./join"; +>join : Symbol(join, Decl(a.ts, 1, 8)) + +function a(l: Recur[]): void { +>a : Symbol(a, Decl(a.ts, 1, 30)) +>T : Symbol(T, Decl(a.ts, 2, 11)) +>l : Symbol(l, Decl(a.ts, 2, 14)) +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) +>T : Symbol(T, Decl(a.ts, 2, 11)) + + const x: Recur | undefined = join(l); +>x : Symbol(x, Decl(a.ts, 3, 9)) +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) +>T : Symbol(T, Decl(a.ts, 2, 11)) +>join : Symbol(join, Decl(a.ts, 1, 8)) +>l : Symbol(l, Decl(a.ts, 2, 14)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=typesfirst).types new file mode 100644 index 0000000000000..833609532a4c1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderRecursiveIndexedAccess(checkorder=typesfirst).types @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/checkOrderRecursiveIndexedAccess.ts] //// + +=== recur.ts === +export type Recur = +>Recur : Recur + + (T extends (unknown[]) ? {} : { [K in keyof T]?: Recur}) | + [...Recur[number][]]; + +=== join.ts === +import { Recur } from "./recur"; +>Recur : any + +export function join(l: Recur[]): Recur { +>join : (l: Recur[]) => Recur +>l : Recur[] + + return ['marker', ...l]; +>['marker', ...l] : [string, ...Recur[]] +>'marker' : "marker" +>...l : Recur +>l : Recur[] +} + +=== a.ts === +import { Recur } from "./recur"; +>Recur : any + +import { join } from "./join"; +>join : (l: Recur[]) => Recur + +function a(l: Recur[]): void { +>a : (l: Recur[]) => void +>l : Recur[] + + const x: Recur | undefined = join(l); +>x : Recur | undefined +>join(l) : Recur +>join : (l: Recur[]) => Recur +>l : Recur[] +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=default).js new file mode 100644 index 0000000000000..433d0bfbb69b5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=default).js @@ -0,0 +1,87 @@ +//// [tests/cases/compiler/checkOrderSpreadCycle.ts] //// + +//// [ma.js] +export { v as pa } from "./xa"; +export const ma = 1; + +//// [mb.js] +export { v as pb } from "./xb"; +export const mb = 1; + +//// [xa.js] +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + +//// [xb.js] +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + +//// [ia.js] +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + + +//// [xb.js] +"use strict"; +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; +//// [mb.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.mb = exports.pb = void 0; +var xb_1 = require("./xb"); +Object.defineProperty(exports, "pb", { enumerable: true, get: function () { return xb_1.v; } }); +exports.mb = 1; +//// [xa.js] +"use strict"; +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; +//// [ma.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ma = exports.pa = void 0; +var xa_1 = require("./xa"); +Object.defineProperty(exports, "pa", { enumerable: true, get: function () { return xa_1.v; } }); +exports.ma = 1; +//// [ia.js] +"use strict"; +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + + +//// [xb.d.ts] +declare const _exports: { + v: {}; +}; +export = _exports; +//// [mb.d.ts] +export { v as pb } from "./xb"; +export declare const mb = 1; +//// [xa.d.ts] +declare const _exports: { + v: { + pb: {}; + mb: 1; + }; +}; +export = _exports; +//// [ma.d.ts] +export { v as pa } from "./xa"; +export declare const ma = 1; +//// [ia.d.ts] +declare const _exports: { + v: { + pa: { + pb: {}; + mb: 1; + }; + ma: 1; + }; +}; +export = _exports; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=default).symbols new file mode 100644 index 0000000000000..4359b0af3b06c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=default).symbols @@ -0,0 +1,54 @@ +//// [tests/cases/compiler/checkOrderSpreadCycle.ts] //// + +=== /ia.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : Symbol(M, Decl(ia.js, 1, 5)) + +module.exports = { v: { ...M } }; +>module.exports : Symbol(exports, Decl(ia.js, 0, 0)) +>module : Symbol(module, Decl(ia.js, 0, 0)) +>exports : Symbol(exports, Decl(ia.js, 0, 0)) +>v : Symbol(v, Decl(ia.js, 2, 18)) +>M : Symbol(M, Decl(ia.js, 1, 5)) + +=== /ma.js === +export { v as pa } from "./xa"; +>v : Symbol(v, Decl(xa.js, 2, 18)) +>pa : Symbol(pa, Decl(ma.js, 0, 8)) + +export const ma = 1; +>ma : Symbol(ma, Decl(ma.js, 1, 12)) + +=== /mb.js === +export { v as pb } from "./xb"; +>v : Symbol(v, Decl(xb.js, 2, 18)) +>pb : Symbol(pb, Decl(mb.js, 0, 8)) + +export const mb = 1; +>mb : Symbol(mb, Decl(mb.js, 1, 12)) + +=== /xa.js === +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +>M : Symbol(M, Decl(xa.js, 1, 5)) + +module.exports = { v: { ...M } }; +>module.exports : Symbol(exports, Decl(xa.js, 0, 0)) +>module : Symbol(module, Decl(xa.js, 0, 0)) +>exports : Symbol(exports, Decl(xa.js, 0, 0)) +>v : Symbol(v, Decl(xa.js, 2, 18)) +>M : Symbol(M, Decl(xa.js, 1, 5)) + +=== /xb.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : Symbol(M, Decl(xb.js, 1, 5)) + +module.exports = { v: { ...M } }; +>module.exports : Symbol(exports, Decl(xb.js, 0, 0)) +>module : Symbol(module, Decl(xb.js, 0, 0)) +>exports : Symbol(exports, Decl(xb.js, 0, 0)) +>v : Symbol(v, Decl(xb.js, 2, 18)) +>M : Symbol(M, Decl(xb.js, 1, 5)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=default).types new file mode 100644 index 0000000000000..901461cf3d36b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=default).types @@ -0,0 +1,68 @@ +//// [tests/cases/compiler/checkOrderSpreadCycle.ts] //// + +=== /ia.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : typeof import("./ma") +>(null) : any + +module.exports = { v: { ...M } }; +>module.exports = { v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>module.exports : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>module : { exports: { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; }; } +>exports : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>{ v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>v : { pa: { pb: {}; mb: 1; }; ma: 1; } +>{ ...M } : { pa: { pb: {}; mb: 1; }; ma: 1; } +>M : typeof import("./ma") + +=== /ma.js === +export { v as pa } from "./xa"; +>v : { pb: {}; mb: 1; } +>pa : { pb: {}; mb: 1; } + +export const ma = 1; +>ma : 1 +>1 : 1 + +=== /mb.js === +export { v as pb } from "./xb"; +>v : {} +>pb : {} + +export const mb = 1; +>mb : 1 +>1 : 1 + +=== /xa.js === +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +>M : typeof import("./mb") +>(null) : any + +module.exports = { v: { ...M } }; +>module.exports = { v: { ...M } } : { v: { pb: {}; mb: 1; }; } +>module.exports : { v: { pb: {}; mb: 1; }; } +>module : { exports: { v: { pb: {}; mb: 1; }; }; } +>exports : { v: { pb: {}; mb: 1; }; } +>{ v: { ...M } } : { v: { pb: {}; mb: 1; }; } +>v : { pb: {}; mb: 1; } +>{ ...M } : { pb: {}; mb: 1; } +>M : typeof import("./mb") + +=== /xb.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : typeof import("./ma") +>(null) : any + +module.exports = { v: { ...M } }; +>module.exports = { v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>module.exports : { v: {}; } +>module : { exports: { v: {}; }; } +>exports : { v: {}; } +>{ v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>v : { pa: { pb: {}; mb: 1; }; ma: 1; } +>{ ...M } : { pa: { pb: {}; mb: 1; }; ma: 1; } +>M : typeof import("./ma") + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=isolated).js b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=isolated).js new file mode 100644 index 0000000000000..8621be455c50d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=isolated).js @@ -0,0 +1,80 @@ +//// [tests/cases/compiler/checkOrderSpreadCycle.ts] //// + +//// [ma.js] +export { v as pa } from "./xa"; +export const ma = 1; + +//// [mb.js] +export { v as pb } from "./xb"; +export const mb = 1; + +//// [xa.js] +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + +//// [xb.js] +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + +//// [ia.js] +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + + +//// [xb.js] +"use strict"; +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; +//// [mb.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.mb = exports.pb = void 0; +var xb_1 = require("./xb"); +Object.defineProperty(exports, "pb", { enumerable: true, get: function () { return xb_1.v; } }); +exports.mb = 1; +//// [xa.js] +"use strict"; +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; +//// [ma.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ma = exports.pa = void 0; +var xa_1 = require("./xa"); +Object.defineProperty(exports, "pa", { enumerable: true, get: function () { return xa_1.v; } }); +exports.ma = 1; +//// [ia.js] +"use strict"; +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + + +//// [xb.d.ts] +declare const _exports: any; +export = _exports; +//// [mb.d.ts] +export { v as pb } from "./xb"; +export declare const mb = 1; +//// [xa.d.ts] +declare const _exports: any; +export = _exports; +//// [ma.d.ts] +export { v as pa } from "./xa"; +export declare const ma = 1; +//// [ia.d.ts] +declare const _exports: { + v: { + pa: { + pb: {}; + mb: 1; + }; + ma: 1; + }; +}; +export = _exports; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=isolated).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=isolated).symbols new file mode 100644 index 0000000000000..4359b0af3b06c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=isolated).symbols @@ -0,0 +1,54 @@ +//// [tests/cases/compiler/checkOrderSpreadCycle.ts] //// + +=== /ia.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : Symbol(M, Decl(ia.js, 1, 5)) + +module.exports = { v: { ...M } }; +>module.exports : Symbol(exports, Decl(ia.js, 0, 0)) +>module : Symbol(module, Decl(ia.js, 0, 0)) +>exports : Symbol(exports, Decl(ia.js, 0, 0)) +>v : Symbol(v, Decl(ia.js, 2, 18)) +>M : Symbol(M, Decl(ia.js, 1, 5)) + +=== /ma.js === +export { v as pa } from "./xa"; +>v : Symbol(v, Decl(xa.js, 2, 18)) +>pa : Symbol(pa, Decl(ma.js, 0, 8)) + +export const ma = 1; +>ma : Symbol(ma, Decl(ma.js, 1, 12)) + +=== /mb.js === +export { v as pb } from "./xb"; +>v : Symbol(v, Decl(xb.js, 2, 18)) +>pb : Symbol(pb, Decl(mb.js, 0, 8)) + +export const mb = 1; +>mb : Symbol(mb, Decl(mb.js, 1, 12)) + +=== /xa.js === +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +>M : Symbol(M, Decl(xa.js, 1, 5)) + +module.exports = { v: { ...M } }; +>module.exports : Symbol(exports, Decl(xa.js, 0, 0)) +>module : Symbol(module, Decl(xa.js, 0, 0)) +>exports : Symbol(exports, Decl(xa.js, 0, 0)) +>v : Symbol(v, Decl(xa.js, 2, 18)) +>M : Symbol(M, Decl(xa.js, 1, 5)) + +=== /xb.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : Symbol(M, Decl(xb.js, 1, 5)) + +module.exports = { v: { ...M } }; +>module.exports : Symbol(exports, Decl(xb.js, 0, 0)) +>module : Symbol(module, Decl(xb.js, 0, 0)) +>exports : Symbol(exports, Decl(xb.js, 0, 0)) +>v : Symbol(v, Decl(xb.js, 2, 18)) +>M : Symbol(M, Decl(xb.js, 1, 5)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=isolated).types b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=isolated).types new file mode 100644 index 0000000000000..901461cf3d36b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=isolated).types @@ -0,0 +1,68 @@ +//// [tests/cases/compiler/checkOrderSpreadCycle.ts] //// + +=== /ia.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : typeof import("./ma") +>(null) : any + +module.exports = { v: { ...M } }; +>module.exports = { v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>module.exports : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>module : { exports: { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; }; } +>exports : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>{ v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>v : { pa: { pb: {}; mb: 1; }; ma: 1; } +>{ ...M } : { pa: { pb: {}; mb: 1; }; ma: 1; } +>M : typeof import("./ma") + +=== /ma.js === +export { v as pa } from "./xa"; +>v : { pb: {}; mb: 1; } +>pa : { pb: {}; mb: 1; } + +export const ma = 1; +>ma : 1 +>1 : 1 + +=== /mb.js === +export { v as pb } from "./xb"; +>v : {} +>pb : {} + +export const mb = 1; +>mb : 1 +>1 : 1 + +=== /xa.js === +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +>M : typeof import("./mb") +>(null) : any + +module.exports = { v: { ...M } }; +>module.exports = { v: { ...M } } : { v: { pb: {}; mb: 1; }; } +>module.exports : { v: { pb: {}; mb: 1; }; } +>module : { exports: { v: { pb: {}; mb: 1; }; }; } +>exports : { v: { pb: {}; mb: 1; }; } +>{ v: { ...M } } : { v: { pb: {}; mb: 1; }; } +>v : { pb: {}; mb: 1; } +>{ ...M } : { pb: {}; mb: 1; } +>M : typeof import("./mb") + +=== /xb.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : typeof import("./ma") +>(null) : any + +module.exports = { v: { ...M } }; +>module.exports = { v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>module.exports : { v: {}; } +>module : { exports: { v: {}; }; } +>exports : { v: {}; } +>{ v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>v : { pa: { pb: {}; mb: 1; }; ma: 1; } +>{ ...M } : { pa: { pb: {}; mb: 1; }; ma: 1; } +>M : typeof import("./ma") + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=reverse).js b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=reverse).js new file mode 100644 index 0000000000000..433d0bfbb69b5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=reverse).js @@ -0,0 +1,87 @@ +//// [tests/cases/compiler/checkOrderSpreadCycle.ts] //// + +//// [ma.js] +export { v as pa } from "./xa"; +export const ma = 1; + +//// [mb.js] +export { v as pb } from "./xb"; +export const mb = 1; + +//// [xa.js] +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + +//// [xb.js] +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + +//// [ia.js] +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + + +//// [xb.js] +"use strict"; +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; +//// [mb.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.mb = exports.pb = void 0; +var xb_1 = require("./xb"); +Object.defineProperty(exports, "pb", { enumerable: true, get: function () { return xb_1.v; } }); +exports.mb = 1; +//// [xa.js] +"use strict"; +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; +//// [ma.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ma = exports.pa = void 0; +var xa_1 = require("./xa"); +Object.defineProperty(exports, "pa", { enumerable: true, get: function () { return xa_1.v; } }); +exports.ma = 1; +//// [ia.js] +"use strict"; +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + + +//// [xb.d.ts] +declare const _exports: { + v: {}; +}; +export = _exports; +//// [mb.d.ts] +export { v as pb } from "./xb"; +export declare const mb = 1; +//// [xa.d.ts] +declare const _exports: { + v: { + pb: {}; + mb: 1; + }; +}; +export = _exports; +//// [ma.d.ts] +export { v as pa } from "./xa"; +export declare const ma = 1; +//// [ia.d.ts] +declare const _exports: { + v: { + pa: { + pb: {}; + mb: 1; + }; + ma: 1; + }; +}; +export = _exports; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=reverse).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=reverse).symbols new file mode 100644 index 0000000000000..4359b0af3b06c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=reverse).symbols @@ -0,0 +1,54 @@ +//// [tests/cases/compiler/checkOrderSpreadCycle.ts] //// + +=== /ia.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : Symbol(M, Decl(ia.js, 1, 5)) + +module.exports = { v: { ...M } }; +>module.exports : Symbol(exports, Decl(ia.js, 0, 0)) +>module : Symbol(module, Decl(ia.js, 0, 0)) +>exports : Symbol(exports, Decl(ia.js, 0, 0)) +>v : Symbol(v, Decl(ia.js, 2, 18)) +>M : Symbol(M, Decl(ia.js, 1, 5)) + +=== /ma.js === +export { v as pa } from "./xa"; +>v : Symbol(v, Decl(xa.js, 2, 18)) +>pa : Symbol(pa, Decl(ma.js, 0, 8)) + +export const ma = 1; +>ma : Symbol(ma, Decl(ma.js, 1, 12)) + +=== /mb.js === +export { v as pb } from "./xb"; +>v : Symbol(v, Decl(xb.js, 2, 18)) +>pb : Symbol(pb, Decl(mb.js, 0, 8)) + +export const mb = 1; +>mb : Symbol(mb, Decl(mb.js, 1, 12)) + +=== /xa.js === +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +>M : Symbol(M, Decl(xa.js, 1, 5)) + +module.exports = { v: { ...M } }; +>module.exports : Symbol(exports, Decl(xa.js, 0, 0)) +>module : Symbol(module, Decl(xa.js, 0, 0)) +>exports : Symbol(exports, Decl(xa.js, 0, 0)) +>v : Symbol(v, Decl(xa.js, 2, 18)) +>M : Symbol(M, Decl(xa.js, 1, 5)) + +=== /xb.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : Symbol(M, Decl(xb.js, 1, 5)) + +module.exports = { v: { ...M } }; +>module.exports : Symbol(exports, Decl(xb.js, 0, 0)) +>module : Symbol(module, Decl(xb.js, 0, 0)) +>exports : Symbol(exports, Decl(xb.js, 0, 0)) +>v : Symbol(v, Decl(xb.js, 2, 18)) +>M : Symbol(M, Decl(xb.js, 1, 5)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=reverse).types b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=reverse).types new file mode 100644 index 0000000000000..901461cf3d36b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=reverse).types @@ -0,0 +1,68 @@ +//// [tests/cases/compiler/checkOrderSpreadCycle.ts] //// + +=== /ia.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : typeof import("./ma") +>(null) : any + +module.exports = { v: { ...M } }; +>module.exports = { v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>module.exports : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>module : { exports: { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; }; } +>exports : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>{ v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>v : { pa: { pb: {}; mb: 1; }; ma: 1; } +>{ ...M } : { pa: { pb: {}; mb: 1; }; ma: 1; } +>M : typeof import("./ma") + +=== /ma.js === +export { v as pa } from "./xa"; +>v : { pb: {}; mb: 1; } +>pa : { pb: {}; mb: 1; } + +export const ma = 1; +>ma : 1 +>1 : 1 + +=== /mb.js === +export { v as pb } from "./xb"; +>v : {} +>pb : {} + +export const mb = 1; +>mb : 1 +>1 : 1 + +=== /xa.js === +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +>M : typeof import("./mb") +>(null) : any + +module.exports = { v: { ...M } }; +>module.exports = { v: { ...M } } : { v: { pb: {}; mb: 1; }; } +>module.exports : { v: { pb: {}; mb: 1; }; } +>module : { exports: { v: { pb: {}; mb: 1; }; }; } +>exports : { v: { pb: {}; mb: 1; }; } +>{ v: { ...M } } : { v: { pb: {}; mb: 1; }; } +>v : { pb: {}; mb: 1; } +>{ ...M } : { pb: {}; mb: 1; } +>M : typeof import("./mb") + +=== /xb.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : typeof import("./ma") +>(null) : any + +module.exports = { v: { ...M } }; +>module.exports = { v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>module.exports : { v: {}; } +>module : { exports: { v: {}; }; } +>exports : { v: {}; } +>{ v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>v : { pa: { pb: {}; mb: 1; }; ma: 1; } +>{ ...M } : { pa: { pb: {}; mb: 1; }; ma: 1; } +>M : typeof import("./ma") + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=typesfirst).js new file mode 100644 index 0000000000000..433d0bfbb69b5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=typesfirst).js @@ -0,0 +1,87 @@ +//// [tests/cases/compiler/checkOrderSpreadCycle.ts] //// + +//// [ma.js] +export { v as pa } from "./xa"; +export const ma = 1; + +//// [mb.js] +export { v as pb } from "./xb"; +export const mb = 1; + +//// [xa.js] +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + +//// [xb.js] +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + +//// [ia.js] +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + + +//// [xb.js] +"use strict"; +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; +//// [mb.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.mb = exports.pb = void 0; +var xb_1 = require("./xb"); +Object.defineProperty(exports, "pb", { enumerable: true, get: function () { return xb_1.v; } }); +exports.mb = 1; +//// [xa.js] +"use strict"; +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; +//// [ma.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ma = exports.pa = void 0; +var xa_1 = require("./xa"); +Object.defineProperty(exports, "pa", { enumerable: true, get: function () { return xa_1.v; } }); +exports.ma = 1; +//// [ia.js] +"use strict"; +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + + +//// [xb.d.ts] +declare const _exports: { + v: {}; +}; +export = _exports; +//// [mb.d.ts] +export { v as pb } from "./xb"; +export declare const mb = 1; +//// [xa.d.ts] +declare const _exports: { + v: { + pb: {}; + mb: 1; + }; +}; +export = _exports; +//// [ma.d.ts] +export { v as pa } from "./xa"; +export declare const ma = 1; +//// [ia.d.ts] +declare const _exports: { + v: { + pa: { + pb: {}; + mb: 1; + }; + ma: 1; + }; +}; +export = _exports; diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..4359b0af3b06c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=typesfirst).symbols @@ -0,0 +1,54 @@ +//// [tests/cases/compiler/checkOrderSpreadCycle.ts] //// + +=== /ia.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : Symbol(M, Decl(ia.js, 1, 5)) + +module.exports = { v: { ...M } }; +>module.exports : Symbol(exports, Decl(ia.js, 0, 0)) +>module : Symbol(module, Decl(ia.js, 0, 0)) +>exports : Symbol(exports, Decl(ia.js, 0, 0)) +>v : Symbol(v, Decl(ia.js, 2, 18)) +>M : Symbol(M, Decl(ia.js, 1, 5)) + +=== /ma.js === +export { v as pa } from "./xa"; +>v : Symbol(v, Decl(xa.js, 2, 18)) +>pa : Symbol(pa, Decl(ma.js, 0, 8)) + +export const ma = 1; +>ma : Symbol(ma, Decl(ma.js, 1, 12)) + +=== /mb.js === +export { v as pb } from "./xb"; +>v : Symbol(v, Decl(xb.js, 2, 18)) +>pb : Symbol(pb, Decl(mb.js, 0, 8)) + +export const mb = 1; +>mb : Symbol(mb, Decl(mb.js, 1, 12)) + +=== /xa.js === +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +>M : Symbol(M, Decl(xa.js, 1, 5)) + +module.exports = { v: { ...M } }; +>module.exports : Symbol(exports, Decl(xa.js, 0, 0)) +>module : Symbol(module, Decl(xa.js, 0, 0)) +>exports : Symbol(exports, Decl(xa.js, 0, 0)) +>v : Symbol(v, Decl(xa.js, 2, 18)) +>M : Symbol(M, Decl(xa.js, 1, 5)) + +=== /xb.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : Symbol(M, Decl(xb.js, 1, 5)) + +module.exports = { v: { ...M } }; +>module.exports : Symbol(exports, Decl(xb.js, 0, 0)) +>module : Symbol(module, Decl(xb.js, 0, 0)) +>exports : Symbol(exports, Decl(xb.js, 0, 0)) +>v : Symbol(v, Decl(xb.js, 2, 18)) +>M : Symbol(M, Decl(xb.js, 1, 5)) + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=typesfirst).types new file mode 100644 index 0000000000000..901461cf3d36b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderSpreadCycle(checkorder=typesfirst).types @@ -0,0 +1,68 @@ +//// [tests/cases/compiler/checkOrderSpreadCycle.ts] //// + +=== /ia.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : typeof import("./ma") +>(null) : any + +module.exports = { v: { ...M } }; +>module.exports = { v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>module.exports : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>module : { exports: { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; }; } +>exports : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>{ v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>v : { pa: { pb: {}; mb: 1; }; ma: 1; } +>{ ...M } : { pa: { pb: {}; mb: 1; }; ma: 1; } +>M : typeof import("./ma") + +=== /ma.js === +export { v as pa } from "./xa"; +>v : { pb: {}; mb: 1; } +>pa : { pb: {}; mb: 1; } + +export const ma = 1; +>ma : 1 +>1 : 1 + +=== /mb.js === +export { v as pb } from "./xb"; +>v : {} +>pb : {} + +export const mb = 1; +>mb : 1 +>1 : 1 + +=== /xa.js === +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +>M : typeof import("./mb") +>(null) : any + +module.exports = { v: { ...M } }; +>module.exports = { v: { ...M } } : { v: { pb: {}; mb: 1; }; } +>module.exports : { v: { pb: {}; mb: 1; }; } +>module : { exports: { v: { pb: {}; mb: 1; }; }; } +>exports : { v: { pb: {}; mb: 1; }; } +>{ v: { ...M } } : { v: { pb: {}; mb: 1; }; } +>v : { pb: {}; mb: 1; } +>{ ...M } : { pb: {}; mb: 1; } +>M : typeof import("./mb") + +=== /xb.js === +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +>M : typeof import("./ma") +>(null) : any + +module.exports = { v: { ...M } }; +>module.exports = { v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>module.exports : { v: {}; } +>module : { exports: { v: {}; }; } +>exports : { v: {}; } +>{ v: { ...M } } : { v: { pa: { pb: {}; mb: 1; }; ma: 1; }; } +>v : { pa: { pb: {}; mb: 1; }; ma: 1; } +>{ ...M } : { pa: { pb: {}; mb: 1; }; ma: 1; } +>M : typeof import("./ma") + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=default).errors.txt new file mode 100644 index 0000000000000..735d4e676a17d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=default).errors.txt @@ -0,0 +1,35 @@ +a.ts(2,15): error TS2589: Type instantiation is excessively deep and possibly infinite. + + +==== lib.ts (0 errors) ==== + export type Dec = + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; + export type Recur = + N extends 0 ? S : Recur, `${S}_${S}`>; + +==== a.ts (1 errors) ==== + import { Recur } from "./lib"; + export let a: Recur<5, "a">; + ~~~~~~~~~~~~~ +!!! error TS2589: Type instantiation is excessively deep and possibly infinite. + +==== b.ts (0 errors) ==== + import { Recur } from "./lib"; + export let b: Recur<5, "a">; + +==== c.ts (0 errors) ==== + class T { + declare a: A; + declare b: any; + } + class L extends T {} + export class X extends L { + declare a: 'a' | 'b'; + declare b: number; + m() { + this.a; + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=default).js new file mode 100644 index 0000000000000..854a59f625301 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=default).js @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/checkOrderStableInstantiationErrors.ts] //// + +//// [lib.ts] +export type Dec = + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; +export type Recur = + N extends 0 ? S : Recur, `${S}_${S}`>; + +//// [a.ts] +import { Recur } from "./lib"; +export let a: Recur<5, "a">; + +//// [b.ts] +import { Recur } from "./lib"; +export let b: Recur<5, "a">; + +//// [c.ts] +class T { + declare a: A; + declare b: any; +} +class L extends T {} +export class X extends L { + declare a: 'a' | 'b'; + declare b: number; + m() { + this.a; + } +} + + +//// [lib.js] +export {}; +//// [a.js] +export let a; +//// [b.js] +export let b; +//// [c.js] +class T { +} +class L extends T { +} +export class X extends L { + m() { + this.a; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=default).symbols new file mode 100644 index 0000000000000..c98e5279b2d56 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=default).symbols @@ -0,0 +1,90 @@ +//// [tests/cases/compiler/checkOrderStableInstantiationErrors.ts] //// + +=== lib.ts === +export type Dec = +>Dec : Symbol(Dec, Decl(lib.ts, 0, 0)) +>N : Symbol(N, Decl(lib.ts, 0, 16)) + + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : +>N : Symbol(N, Decl(lib.ts, 0, 16)) +>N : Symbol(N, Decl(lib.ts, 0, 16)) +>N : Symbol(N, Decl(lib.ts, 0, 16)) + + N extends 2 ? any : +>N : Symbol(N, Decl(lib.ts, 0, 16)) + + N extends 1 ? 0 : 0; +>N : Symbol(N, Decl(lib.ts, 0, 16)) + +export type Recur = +>Recur : Symbol(Recur, Decl(lib.ts, 3, 24)) +>N : Symbol(N, Decl(lib.ts, 4, 18)) +>S : Symbol(S, Decl(lib.ts, 4, 35)) + + N extends 0 ? S : Recur, `${S}_${S}`>; +>N : Symbol(N, Decl(lib.ts, 4, 18)) +>S : Symbol(S, Decl(lib.ts, 4, 35)) +>Recur : Symbol(Recur, Decl(lib.ts, 3, 24)) +>Dec : Symbol(Dec, Decl(lib.ts, 0, 0)) +>N : Symbol(N, Decl(lib.ts, 4, 18)) +>S : Symbol(S, Decl(lib.ts, 4, 35)) +>S : Symbol(S, Decl(lib.ts, 4, 35)) + +=== a.ts === +import { Recur } from "./lib"; +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) + +export let a: Recur<5, "a">; +>a : Symbol(a, Decl(a.ts, 1, 10)) +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) + +=== b.ts === +import { Recur } from "./lib"; +>Recur : Symbol(Recur, Decl(b.ts, 0, 8)) + +export let b: Recur<5, "a">; +>b : Symbol(b, Decl(b.ts, 1, 10)) +>Recur : Symbol(Recur, Decl(b.ts, 0, 8)) + +=== c.ts === +class T { +>T : Symbol(T, Decl(c.ts, 0, 0)) +>A : Symbol(A, Decl(c.ts, 0, 8)) + + declare a: A; +>a : Symbol(T.a, Decl(c.ts, 0, 12)) +>A : Symbol(A, Decl(c.ts, 0, 8)) + + declare b: any; +>b : Symbol(T.b, Decl(c.ts, 1, 17)) +} +class L extends T {} +>L : Symbol(L, Decl(c.ts, 3, 1)) +>RT : Symbol(RT, Decl(c.ts, 4, 8)) +>a : Symbol(a, Decl(c.ts, 4, 20)) +>b : Symbol(b, Decl(c.ts, 4, 34)) +>T : Symbol(T, Decl(c.ts, 0, 0)) +>RT : Symbol(RT, Decl(c.ts, 4, 8)) +>RT : Symbol(RT, Decl(c.ts, 4, 8)) + +export class X extends L { +>X : Symbol(X, Decl(c.ts, 4, 70)) +>L : Symbol(L, Decl(c.ts, 3, 1)) +>X : Symbol(X, Decl(c.ts, 4, 70)) + + declare a: 'a' | 'b'; +>a : Symbol(X.a, Decl(c.ts, 5, 29)) + + declare b: number; +>b : Symbol(X.b, Decl(c.ts, 6, 25)) + + m() { +>m : Symbol(X.m, Decl(c.ts, 7, 22)) + + this.a; +>this.a : Symbol(X.a, Decl(c.ts, 5, 29)) +>this : Symbol(X, Decl(c.ts, 4, 70)) +>a : Symbol(X.a, Decl(c.ts, 5, 29)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=default).types new file mode 100644 index 0000000000000..8c9592f59bc30 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=default).types @@ -0,0 +1,64 @@ +//// [tests/cases/compiler/checkOrderStableInstantiationErrors.ts] //// + +=== lib.ts === +export type Dec = +>Dec : Dec + + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; +export type Recur = +>Recur : Recur + + N extends 0 ? S : Recur, `${S}_${S}`>; + +=== a.ts === +import { Recur } from "./lib"; +>Recur : any + +export let a: Recur<5, "a">; +>a : any + +=== b.ts === +import { Recur } from "./lib"; +>Recur : any + +export let b: Recur<5, "a">; +>b : any + +=== c.ts === +class T { +>T : T + + declare a: A; +>a : A + + declare b: any; +>b : any +} +class L extends T {} +>L : L +>a : "a" | "b" +>b : any +>T : T + +export class X extends L { +>X : X +>L : L + + declare a: 'a' | 'b'; +>a : "a" | "b" + + declare b: number; +>b : number + + m() { +>m : () => void + + this.a; +>this.a : "a" | "b" +>this : this +>a : "a" | "b" + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=reverse).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=reverse).errors.txt new file mode 100644 index 0000000000000..6e370b78d30f9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=reverse).errors.txt @@ -0,0 +1,35 @@ +b.ts(2,15): error TS2589: Type instantiation is excessively deep and possibly infinite. + + +==== lib.ts (0 errors) ==== + export type Dec = + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; + export type Recur = + N extends 0 ? S : Recur, `${S}_${S}`>; + +==== a.ts (0 errors) ==== + import { Recur } from "./lib"; + export let a: Recur<5, "a">; + +==== b.ts (1 errors) ==== + import { Recur } from "./lib"; + export let b: Recur<5, "a">; + ~~~~~~~~~~~~~ +!!! error TS2589: Type instantiation is excessively deep and possibly infinite. + +==== c.ts (0 errors) ==== + class T { + declare a: A; + declare b: any; + } + class L extends T {} + export class X extends L { + declare a: 'a' | 'b'; + declare b: number; + m() { + this.a; + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=reverse).js b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=reverse).js new file mode 100644 index 0000000000000..854a59f625301 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=reverse).js @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/checkOrderStableInstantiationErrors.ts] //// + +//// [lib.ts] +export type Dec = + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; +export type Recur = + N extends 0 ? S : Recur, `${S}_${S}`>; + +//// [a.ts] +import { Recur } from "./lib"; +export let a: Recur<5, "a">; + +//// [b.ts] +import { Recur } from "./lib"; +export let b: Recur<5, "a">; + +//// [c.ts] +class T { + declare a: A; + declare b: any; +} +class L extends T {} +export class X extends L { + declare a: 'a' | 'b'; + declare b: number; + m() { + this.a; + } +} + + +//// [lib.js] +export {}; +//// [a.js] +export let a; +//// [b.js] +export let b; +//// [c.js] +class T { +} +class L extends T { +} +export class X extends L { + m() { + this.a; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=reverse).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=reverse).symbols new file mode 100644 index 0000000000000..c98e5279b2d56 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=reverse).symbols @@ -0,0 +1,90 @@ +//// [tests/cases/compiler/checkOrderStableInstantiationErrors.ts] //// + +=== lib.ts === +export type Dec = +>Dec : Symbol(Dec, Decl(lib.ts, 0, 0)) +>N : Symbol(N, Decl(lib.ts, 0, 16)) + + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : +>N : Symbol(N, Decl(lib.ts, 0, 16)) +>N : Symbol(N, Decl(lib.ts, 0, 16)) +>N : Symbol(N, Decl(lib.ts, 0, 16)) + + N extends 2 ? any : +>N : Symbol(N, Decl(lib.ts, 0, 16)) + + N extends 1 ? 0 : 0; +>N : Symbol(N, Decl(lib.ts, 0, 16)) + +export type Recur = +>Recur : Symbol(Recur, Decl(lib.ts, 3, 24)) +>N : Symbol(N, Decl(lib.ts, 4, 18)) +>S : Symbol(S, Decl(lib.ts, 4, 35)) + + N extends 0 ? S : Recur, `${S}_${S}`>; +>N : Symbol(N, Decl(lib.ts, 4, 18)) +>S : Symbol(S, Decl(lib.ts, 4, 35)) +>Recur : Symbol(Recur, Decl(lib.ts, 3, 24)) +>Dec : Symbol(Dec, Decl(lib.ts, 0, 0)) +>N : Symbol(N, Decl(lib.ts, 4, 18)) +>S : Symbol(S, Decl(lib.ts, 4, 35)) +>S : Symbol(S, Decl(lib.ts, 4, 35)) + +=== a.ts === +import { Recur } from "./lib"; +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) + +export let a: Recur<5, "a">; +>a : Symbol(a, Decl(a.ts, 1, 10)) +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) + +=== b.ts === +import { Recur } from "./lib"; +>Recur : Symbol(Recur, Decl(b.ts, 0, 8)) + +export let b: Recur<5, "a">; +>b : Symbol(b, Decl(b.ts, 1, 10)) +>Recur : Symbol(Recur, Decl(b.ts, 0, 8)) + +=== c.ts === +class T { +>T : Symbol(T, Decl(c.ts, 0, 0)) +>A : Symbol(A, Decl(c.ts, 0, 8)) + + declare a: A; +>a : Symbol(T.a, Decl(c.ts, 0, 12)) +>A : Symbol(A, Decl(c.ts, 0, 8)) + + declare b: any; +>b : Symbol(T.b, Decl(c.ts, 1, 17)) +} +class L extends T {} +>L : Symbol(L, Decl(c.ts, 3, 1)) +>RT : Symbol(RT, Decl(c.ts, 4, 8)) +>a : Symbol(a, Decl(c.ts, 4, 20)) +>b : Symbol(b, Decl(c.ts, 4, 34)) +>T : Symbol(T, Decl(c.ts, 0, 0)) +>RT : Symbol(RT, Decl(c.ts, 4, 8)) +>RT : Symbol(RT, Decl(c.ts, 4, 8)) + +export class X extends L { +>X : Symbol(X, Decl(c.ts, 4, 70)) +>L : Symbol(L, Decl(c.ts, 3, 1)) +>X : Symbol(X, Decl(c.ts, 4, 70)) + + declare a: 'a' | 'b'; +>a : Symbol(X.a, Decl(c.ts, 5, 29)) + + declare b: number; +>b : Symbol(X.b, Decl(c.ts, 6, 25)) + + m() { +>m : Symbol(X.m, Decl(c.ts, 7, 22)) + + this.a; +>this.a : Symbol(X.a, Decl(c.ts, 5, 29)) +>this : Symbol(X, Decl(c.ts, 4, 70)) +>a : Symbol(X.a, Decl(c.ts, 5, 29)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=reverse).types b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=reverse).types new file mode 100644 index 0000000000000..8c9592f59bc30 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=reverse).types @@ -0,0 +1,64 @@ +//// [tests/cases/compiler/checkOrderStableInstantiationErrors.ts] //// + +=== lib.ts === +export type Dec = +>Dec : Dec + + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; +export type Recur = +>Recur : Recur + + N extends 0 ? S : Recur, `${S}_${S}`>; + +=== a.ts === +import { Recur } from "./lib"; +>Recur : any + +export let a: Recur<5, "a">; +>a : any + +=== b.ts === +import { Recur } from "./lib"; +>Recur : any + +export let b: Recur<5, "a">; +>b : any + +=== c.ts === +class T { +>T : T + + declare a: A; +>a : A + + declare b: any; +>b : any +} +class L extends T {} +>L : L +>a : "a" | "b" +>b : any +>T : T + +export class X extends L { +>X : X +>L : L + + declare a: 'a' | 'b'; +>a : "a" | "b" + + declare b: number; +>b : number + + m() { +>m : () => void + + this.a; +>this.a : "a" | "b" +>this : this +>a : "a" | "b" + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..9b99a0b62969b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=typesfirst).errors.txt @@ -0,0 +1,34 @@ +error TS2589: Type instantiation is excessively deep and possibly infinite. + + +!!! error TS2589: Type instantiation is excessively deep and possibly infinite. +==== lib.ts (0 errors) ==== + export type Dec = + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; + export type Recur = + N extends 0 ? S : Recur, `${S}_${S}`>; + +==== a.ts (0 errors) ==== + import { Recur } from "./lib"; + export let a: Recur<5, "a">; + +==== b.ts (0 errors) ==== + import { Recur } from "./lib"; + export let b: Recur<5, "a">; + +==== c.ts (0 errors) ==== + class T { + declare a: A; + declare b: any; + } + class L extends T {} + export class X extends L { + declare a: 'a' | 'b'; + declare b: number; + m() { + this.a; + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=typesfirst).js new file mode 100644 index 0000000000000..854a59f625301 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=typesfirst).js @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/checkOrderStableInstantiationErrors.ts] //// + +//// [lib.ts] +export type Dec = + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; +export type Recur = + N extends 0 ? S : Recur, `${S}_${S}`>; + +//// [a.ts] +import { Recur } from "./lib"; +export let a: Recur<5, "a">; + +//// [b.ts] +import { Recur } from "./lib"; +export let b: Recur<5, "a">; + +//// [c.ts] +class T { + declare a: A; + declare b: any; +} +class L extends T {} +export class X extends L { + declare a: 'a' | 'b'; + declare b: number; + m() { + this.a; + } +} + + +//// [lib.js] +export {}; +//// [a.js] +export let a; +//// [b.js] +export let b; +//// [c.js] +class T { +} +class L extends T { +} +export class X extends L { + m() { + this.a; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..c98e5279b2d56 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=typesfirst).symbols @@ -0,0 +1,90 @@ +//// [tests/cases/compiler/checkOrderStableInstantiationErrors.ts] //// + +=== lib.ts === +export type Dec = +>Dec : Symbol(Dec, Decl(lib.ts, 0, 0)) +>N : Symbol(N, Decl(lib.ts, 0, 16)) + + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : +>N : Symbol(N, Decl(lib.ts, 0, 16)) +>N : Symbol(N, Decl(lib.ts, 0, 16)) +>N : Symbol(N, Decl(lib.ts, 0, 16)) + + N extends 2 ? any : +>N : Symbol(N, Decl(lib.ts, 0, 16)) + + N extends 1 ? 0 : 0; +>N : Symbol(N, Decl(lib.ts, 0, 16)) + +export type Recur = +>Recur : Symbol(Recur, Decl(lib.ts, 3, 24)) +>N : Symbol(N, Decl(lib.ts, 4, 18)) +>S : Symbol(S, Decl(lib.ts, 4, 35)) + + N extends 0 ? S : Recur, `${S}_${S}`>; +>N : Symbol(N, Decl(lib.ts, 4, 18)) +>S : Symbol(S, Decl(lib.ts, 4, 35)) +>Recur : Symbol(Recur, Decl(lib.ts, 3, 24)) +>Dec : Symbol(Dec, Decl(lib.ts, 0, 0)) +>N : Symbol(N, Decl(lib.ts, 4, 18)) +>S : Symbol(S, Decl(lib.ts, 4, 35)) +>S : Symbol(S, Decl(lib.ts, 4, 35)) + +=== a.ts === +import { Recur } from "./lib"; +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) + +export let a: Recur<5, "a">; +>a : Symbol(a, Decl(a.ts, 1, 10)) +>Recur : Symbol(Recur, Decl(a.ts, 0, 8)) + +=== b.ts === +import { Recur } from "./lib"; +>Recur : Symbol(Recur, Decl(b.ts, 0, 8)) + +export let b: Recur<5, "a">; +>b : Symbol(b, Decl(b.ts, 1, 10)) +>Recur : Symbol(Recur, Decl(b.ts, 0, 8)) + +=== c.ts === +class T { +>T : Symbol(T, Decl(c.ts, 0, 0)) +>A : Symbol(A, Decl(c.ts, 0, 8)) + + declare a: A; +>a : Symbol(T.a, Decl(c.ts, 0, 12)) +>A : Symbol(A, Decl(c.ts, 0, 8)) + + declare b: any; +>b : Symbol(T.b, Decl(c.ts, 1, 17)) +} +class L extends T {} +>L : Symbol(L, Decl(c.ts, 3, 1)) +>RT : Symbol(RT, Decl(c.ts, 4, 8)) +>a : Symbol(a, Decl(c.ts, 4, 20)) +>b : Symbol(b, Decl(c.ts, 4, 34)) +>T : Symbol(T, Decl(c.ts, 0, 0)) +>RT : Symbol(RT, Decl(c.ts, 4, 8)) +>RT : Symbol(RT, Decl(c.ts, 4, 8)) + +export class X extends L { +>X : Symbol(X, Decl(c.ts, 4, 70)) +>L : Symbol(L, Decl(c.ts, 3, 1)) +>X : Symbol(X, Decl(c.ts, 4, 70)) + + declare a: 'a' | 'b'; +>a : Symbol(X.a, Decl(c.ts, 5, 29)) + + declare b: number; +>b : Symbol(X.b, Decl(c.ts, 6, 25)) + + m() { +>m : Symbol(X.m, Decl(c.ts, 7, 22)) + + this.a; +>this.a : Symbol(X.a, Decl(c.ts, 5, 29)) +>this : Symbol(X, Decl(c.ts, 4, 70)) +>a : Symbol(X.a, Decl(c.ts, 5, 29)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=typesfirst).types new file mode 100644 index 0000000000000..8c9592f59bc30 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/checkOrderStableInstantiationErrors(checkorder=typesfirst).types @@ -0,0 +1,64 @@ +//// [tests/cases/compiler/checkOrderStableInstantiationErrors.ts] //// + +=== lib.ts === +export type Dec = +>Dec : Dec + + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; +export type Recur = +>Recur : Recur + + N extends 0 ? S : Recur, `${S}_${S}`>; + +=== a.ts === +import { Recur } from "./lib"; +>Recur : any + +export let a: Recur<5, "a">; +>a : any + +=== b.ts === +import { Recur } from "./lib"; +>Recur : any + +export let b: Recur<5, "a">; +>b : any + +=== c.ts === +class T { +>T : T + + declare a: A; +>a : A + + declare b: any; +>b : any +} +class L extends T {} +>L : L +>a : "a" | "b" +>b : any +>T : T + +export class X extends L { +>X : X +>L : L + + declare a: 'a' | 'b'; +>a : "a" | "b" + + declare b: number; +>b : number + + m() { +>m : () => void + + this.a; +>this.a : "a" | "b" +>this : this +>a : "a" | "b" + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=default).errors.txt new file mode 100644 index 0000000000000..9254be443a6c1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=default).errors.txt @@ -0,0 +1,41 @@ +circularAccessorAnnotations.ts(2,9): error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. +circularAccessorAnnotations.ts(6,9): error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. +circularAccessorAnnotations.ts(15,9): error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. +circularAccessorAnnotations.ts(19,9): error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. + + +==== circularAccessorAnnotations.ts (4 errors) ==== + declare const c1: { + get foo(): typeof c1.foo; + ~~~ +!!! error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. + } + + declare const c2: { + set foo(value: typeof c2.foo); + ~~~ +!!! error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. + } + + declare const c3: { + get foo(): string; + set foo(value: typeof c3.foo); + } + + type T1 = { + get foo(): T1["foo"]; + ~~~ +!!! error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. + } + + type T2 = { + set foo(value: T2["foo"]); + ~~~ +!!! error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. + } + + type T3 = { + get foo(): string; + set foo(value: T3["foo"]); + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=default).js new file mode 100644 index 0000000000000..5f976ec06b212 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=default).js @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/circularAccessorAnnotations.ts] //// + +//// [circularAccessorAnnotations.ts] +declare const c1: { + get foo(): typeof c1.foo; +} + +declare const c2: { + set foo(value: typeof c2.foo); +} + +declare const c3: { + get foo(): string; + set foo(value: typeof c3.foo); +} + +type T1 = { + get foo(): T1["foo"]; +} + +type T2 = { + set foo(value: T2["foo"]); +} + +type T3 = { + get foo(): string; + set foo(value: T3["foo"]); +} + + +//// [circularAccessorAnnotations.js] +"use strict"; + + +//// [circularAccessorAnnotations.d.ts] +declare const c1: { + get foo(): typeof c1.foo; +}; +declare const c2: { + set foo(value: typeof c2.foo); +}; +declare const c3: { + get foo(): string; + set foo(value: typeof c3.foo); +}; +type T1 = { + get foo(): T1["foo"]; +}; +type T2 = { + set foo(value: T2["foo"]); +}; +type T3 = { + get foo(): string; + set foo(value: T3["foo"]); +}; diff --git a/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=default).symbols new file mode 100644 index 0000000000000..d95b8cec0782f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=default).symbols @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/circularAccessorAnnotations.ts] //// + +=== circularAccessorAnnotations.ts === +declare const c1: { +>c1 : Symbol(c1, Decl(circularAccessorAnnotations.ts, 0, 13)) + + get foo(): typeof c1.foo; +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 0, 19)) +>c1.foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 0, 19)) +>c1 : Symbol(c1, Decl(circularAccessorAnnotations.ts, 0, 13)) +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 0, 19)) +} + +declare const c2: { +>c2 : Symbol(c2, Decl(circularAccessorAnnotations.ts, 4, 13)) + + set foo(value: typeof c2.foo); +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 4, 19)) +>value : Symbol(value, Decl(circularAccessorAnnotations.ts, 5, 12)) +>c2.foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 4, 19)) +>c2 : Symbol(c2, Decl(circularAccessorAnnotations.ts, 4, 13)) +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 4, 19)) +} + +declare const c3: { +>c3 : Symbol(c3, Decl(circularAccessorAnnotations.ts, 8, 13)) + + get foo(): string; +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 8, 19), Decl(circularAccessorAnnotations.ts, 9, 22)) + + set foo(value: typeof c3.foo); +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 8, 19), Decl(circularAccessorAnnotations.ts, 9, 22)) +>value : Symbol(value, Decl(circularAccessorAnnotations.ts, 10, 12)) +>c3.foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 8, 19), Decl(circularAccessorAnnotations.ts, 9, 22)) +>c3 : Symbol(c3, Decl(circularAccessorAnnotations.ts, 8, 13)) +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 8, 19), Decl(circularAccessorAnnotations.ts, 9, 22)) +} + +type T1 = { +>T1 : Symbol(T1, Decl(circularAccessorAnnotations.ts, 11, 1)) + + get foo(): T1["foo"]; +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 13, 11)) +>T1 : Symbol(T1, Decl(circularAccessorAnnotations.ts, 11, 1)) +} + +type T2 = { +>T2 : Symbol(T2, Decl(circularAccessorAnnotations.ts, 15, 1)) + + set foo(value: T2["foo"]); +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 17, 11)) +>value : Symbol(value, Decl(circularAccessorAnnotations.ts, 18, 12)) +>T2 : Symbol(T2, Decl(circularAccessorAnnotations.ts, 15, 1)) +} + +type T3 = { +>T3 : Symbol(T3, Decl(circularAccessorAnnotations.ts, 19, 1)) + + get foo(): string; +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 21, 11), Decl(circularAccessorAnnotations.ts, 22, 22)) + + set foo(value: T3["foo"]); +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 21, 11), Decl(circularAccessorAnnotations.ts, 22, 22)) +>value : Symbol(value, Decl(circularAccessorAnnotations.ts, 23, 12)) +>T3 : Symbol(T3, Decl(circularAccessorAnnotations.ts, 19, 1)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=default).types new file mode 100644 index 0000000000000..2b01358a33dca --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=default).types @@ -0,0 +1,64 @@ +//// [tests/cases/compiler/circularAccessorAnnotations.ts] //// + +=== circularAccessorAnnotations.ts === +declare const c1: { +>c1 : { readonly foo: typeof c1.foo; } + + get foo(): typeof c1.foo; +>foo : any +>c1.foo : any +>c1 : { readonly foo: typeof c1.foo; } +>foo : any +} + +declare const c2: { +>c2 : { foo: typeof c2.foo; } + + set foo(value: typeof c2.foo); +>foo : any +>value : any +>c2.foo : any +>c2 : { foo: typeof c2.foo; } +>foo : any +} + +declare const c3: { +>c3 : { foo: string; } + + get foo(): string; +>foo : string + + set foo(value: typeof c3.foo); +>foo : string +>value : string +>c3.foo : string +>c3 : { foo: string; } +>foo : string +} + +type T1 = { +>T1 : T1 + + get foo(): T1["foo"]; +>foo : any +} + +type T2 = { +>T2 : T2 + + set foo(value: T2["foo"]); +>foo : any +>value : any +} + +type T3 = { +>T3 : T3 + + get foo(): string; +>foo : string + + set foo(value: T3["foo"]); +>foo : string +>value : string +} + diff --git a/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..9254be443a6c1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=typesfirst).errors.txt @@ -0,0 +1,41 @@ +circularAccessorAnnotations.ts(2,9): error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. +circularAccessorAnnotations.ts(6,9): error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. +circularAccessorAnnotations.ts(15,9): error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. +circularAccessorAnnotations.ts(19,9): error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. + + +==== circularAccessorAnnotations.ts (4 errors) ==== + declare const c1: { + get foo(): typeof c1.foo; + ~~~ +!!! error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. + } + + declare const c2: { + set foo(value: typeof c2.foo); + ~~~ +!!! error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. + } + + declare const c3: { + get foo(): string; + set foo(value: typeof c3.foo); + } + + type T1 = { + get foo(): T1["foo"]; + ~~~ +!!! error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. + } + + type T2 = { + set foo(value: T2["foo"]); + ~~~ +!!! error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. + } + + type T3 = { + get foo(): string; + set foo(value: T3["foo"]); + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=typesfirst).js new file mode 100644 index 0000000000000..5f976ec06b212 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=typesfirst).js @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/circularAccessorAnnotations.ts] //// + +//// [circularAccessorAnnotations.ts] +declare const c1: { + get foo(): typeof c1.foo; +} + +declare const c2: { + set foo(value: typeof c2.foo); +} + +declare const c3: { + get foo(): string; + set foo(value: typeof c3.foo); +} + +type T1 = { + get foo(): T1["foo"]; +} + +type T2 = { + set foo(value: T2["foo"]); +} + +type T3 = { + get foo(): string; + set foo(value: T3["foo"]); +} + + +//// [circularAccessorAnnotations.js] +"use strict"; + + +//// [circularAccessorAnnotations.d.ts] +declare const c1: { + get foo(): typeof c1.foo; +}; +declare const c2: { + set foo(value: typeof c2.foo); +}; +declare const c3: { + get foo(): string; + set foo(value: typeof c3.foo); +}; +type T1 = { + get foo(): T1["foo"]; +}; +type T2 = { + set foo(value: T2["foo"]); +}; +type T3 = { + get foo(): string; + set foo(value: T3["foo"]); +}; diff --git a/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..d95b8cec0782f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=typesfirst).symbols @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/circularAccessorAnnotations.ts] //// + +=== circularAccessorAnnotations.ts === +declare const c1: { +>c1 : Symbol(c1, Decl(circularAccessorAnnotations.ts, 0, 13)) + + get foo(): typeof c1.foo; +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 0, 19)) +>c1.foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 0, 19)) +>c1 : Symbol(c1, Decl(circularAccessorAnnotations.ts, 0, 13)) +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 0, 19)) +} + +declare const c2: { +>c2 : Symbol(c2, Decl(circularAccessorAnnotations.ts, 4, 13)) + + set foo(value: typeof c2.foo); +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 4, 19)) +>value : Symbol(value, Decl(circularAccessorAnnotations.ts, 5, 12)) +>c2.foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 4, 19)) +>c2 : Symbol(c2, Decl(circularAccessorAnnotations.ts, 4, 13)) +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 4, 19)) +} + +declare const c3: { +>c3 : Symbol(c3, Decl(circularAccessorAnnotations.ts, 8, 13)) + + get foo(): string; +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 8, 19), Decl(circularAccessorAnnotations.ts, 9, 22)) + + set foo(value: typeof c3.foo); +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 8, 19), Decl(circularAccessorAnnotations.ts, 9, 22)) +>value : Symbol(value, Decl(circularAccessorAnnotations.ts, 10, 12)) +>c3.foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 8, 19), Decl(circularAccessorAnnotations.ts, 9, 22)) +>c3 : Symbol(c3, Decl(circularAccessorAnnotations.ts, 8, 13)) +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 8, 19), Decl(circularAccessorAnnotations.ts, 9, 22)) +} + +type T1 = { +>T1 : Symbol(T1, Decl(circularAccessorAnnotations.ts, 11, 1)) + + get foo(): T1["foo"]; +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 13, 11)) +>T1 : Symbol(T1, Decl(circularAccessorAnnotations.ts, 11, 1)) +} + +type T2 = { +>T2 : Symbol(T2, Decl(circularAccessorAnnotations.ts, 15, 1)) + + set foo(value: T2["foo"]); +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 17, 11)) +>value : Symbol(value, Decl(circularAccessorAnnotations.ts, 18, 12)) +>T2 : Symbol(T2, Decl(circularAccessorAnnotations.ts, 15, 1)) +} + +type T3 = { +>T3 : Symbol(T3, Decl(circularAccessorAnnotations.ts, 19, 1)) + + get foo(): string; +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 21, 11), Decl(circularAccessorAnnotations.ts, 22, 22)) + + set foo(value: T3["foo"]); +>foo : Symbol(foo, Decl(circularAccessorAnnotations.ts, 21, 11), Decl(circularAccessorAnnotations.ts, 22, 22)) +>value : Symbol(value, Decl(circularAccessorAnnotations.ts, 23, 12)) +>T3 : Symbol(T3, Decl(circularAccessorAnnotations.ts, 19, 1)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=typesfirst).types new file mode 100644 index 0000000000000..e6b4d1fca90ca --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularAccessorAnnotations(checkorder=typesfirst).types @@ -0,0 +1,64 @@ +//// [tests/cases/compiler/circularAccessorAnnotations.ts] //// + +=== circularAccessorAnnotations.ts === +declare const c1: { +>c1 : { readonly foo: any; } + + get foo(): typeof c1.foo; +>foo : any +>c1.foo : any +>c1 : { readonly foo: any; } +>foo : any +} + +declare const c2: { +>c2 : { foo: any; } + + set foo(value: typeof c2.foo); +>foo : any +>value : any +>c2.foo : any +>c2 : { foo: any; } +>foo : any +} + +declare const c3: { +>c3 : { foo: string; } + + get foo(): string; +>foo : string + + set foo(value: typeof c3.foo); +>foo : string +>value : string +>c3.foo : string +>c3 : { foo: string; } +>foo : string +} + +type T1 = { +>T1 : T1 + + get foo(): T1["foo"]; +>foo : any +} + +type T2 = { +>T2 : T2 + + set foo(value: T2["foo"]); +>foo : any +>value : any +} + +type T3 = { +>T3 : T3 + + get foo(): string; +>foo : string + + set foo(value: T3["foo"]); +>foo : string +>value : string +} + diff --git a/tsc/testdata/baselines/reference/compiler/circularIndexedPropertyInstantiation.errors.txt b/tsc/testdata/baselines/reference/compiler/circularIndexedPropertyInstantiation.errors.txt new file mode 100644 index 0000000000000..3322a7ea25b66 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularIndexedPropertyInstantiation.errors.txt @@ -0,0 +1,14 @@ +circularIndexedPropertyInstantiation.ts(4,9): error TS5114: Instantiations of type 'Foo' appear infinitely circular. +circularIndexedPropertyInstantiation.ts(5,13): error TS2344: Type '"false"' does not satisfy the constraint '"true"'. + + +==== circularIndexedPropertyInstantiation.ts (2 errors) ==== + // Repro from #14837 + + type Foo = { "true": Foo> }[T]; + let f1: Foo<"true", {}>; + ~~~~~~~~~~~~~~~ +!!! error TS5114: Instantiations of type 'Foo' appear infinitely circular. + let f2: Foo<"false", {}>; + ~~~~~~~ +!!! error TS2344: Type '"false"' does not satisfy the constraint '"true"'. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/circularIndexedPropertyInstantiation.js b/tsc/testdata/baselines/reference/compiler/circularIndexedPropertyInstantiation.js new file mode 100644 index 0000000000000..ac6aa726ab7a4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularIndexedPropertyInstantiation.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/circularIndexedPropertyInstantiation.ts] //// + +//// [circularIndexedPropertyInstantiation.ts] +// Repro from #14837 + +type Foo = { "true": Foo> }[T]; +let f1: Foo<"true", {}>; +let f2: Foo<"false", {}>; + +//// [circularIndexedPropertyInstantiation.js] +"use strict"; +// Repro from #14837 +let f1; +let f2; diff --git a/tsc/testdata/baselines/reference/compiler/circularIndexedPropertyInstantiation.symbols b/tsc/testdata/baselines/reference/compiler/circularIndexedPropertyInstantiation.symbols new file mode 100644 index 0000000000000..5473bd4665786 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularIndexedPropertyInstantiation.symbols @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/circularIndexedPropertyInstantiation.ts] //// + +=== circularIndexedPropertyInstantiation.ts === +// Repro from #14837 + +type Foo = { "true": Foo> }[T]; +>Foo : Symbol(Foo, Decl(circularIndexedPropertyInstantiation.ts, 0, 0)) +>T : Symbol(T, Decl(circularIndexedPropertyInstantiation.ts, 2, 9)) +>B : Symbol(B, Decl(circularIndexedPropertyInstantiation.ts, 2, 26)) +>"true" : Symbol("true", Decl(circularIndexedPropertyInstantiation.ts, 2, 33)) +>Foo : Symbol(Foo, Decl(circularIndexedPropertyInstantiation.ts, 0, 0)) +>T : Symbol(T, Decl(circularIndexedPropertyInstantiation.ts, 2, 9)) +>Foo : Symbol(Foo, Decl(circularIndexedPropertyInstantiation.ts, 0, 0)) +>T : Symbol(T, Decl(circularIndexedPropertyInstantiation.ts, 2, 9)) +>B : Symbol(B, Decl(circularIndexedPropertyInstantiation.ts, 2, 26)) +>T : Symbol(T, Decl(circularIndexedPropertyInstantiation.ts, 2, 9)) + +let f1: Foo<"true", {}>; +>f1 : Symbol(f1, Decl(circularIndexedPropertyInstantiation.ts, 3, 3)) +>Foo : Symbol(Foo, Decl(circularIndexedPropertyInstantiation.ts, 0, 0)) + +let f2: Foo<"false", {}>; +>f2 : Symbol(f2, Decl(circularIndexedPropertyInstantiation.ts, 4, 3)) +>Foo : Symbol(Foo, Decl(circularIndexedPropertyInstantiation.ts, 0, 0)) + diff --git a/tsc/testdata/baselines/reference/compiler/circularIndexedPropertyInstantiation.types b/tsc/testdata/baselines/reference/compiler/circularIndexedPropertyInstantiation.types new file mode 100644 index 0000000000000..789407f9e698b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularIndexedPropertyInstantiation.types @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/circularIndexedPropertyInstantiation.ts] //// + +=== circularIndexedPropertyInstantiation.ts === +// Repro from #14837 + +type Foo = { "true": Foo> }[T]; +>Foo : Foo +>"true" : Foo> + +let f1: Foo<"true", {}>; +>f1 : any + +let f2: Foo<"false", {}>; +>f2 : unknown + diff --git a/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=false).errors.txt b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=false).errors.txt new file mode 100644 index 0000000000000..0accf5ec5ec5d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=false).errors.txt @@ -0,0 +1,40 @@ +circularInitializerInference.ts(6,14): error TS2695: Left side of comma operator is unused and has no side effects. +circularInitializerInference.ts(9,20): error TS2695: Left side of comma operator is unused and has no side effects. +circularInitializerInference.ts(9,20): error TS2695: Left side of comma operator is unused and has no side effects. + + +==== circularInitializerInference.ts (3 errors) ==== + export {}; + + type IsAny = 0 extends (1 & Type) ? true : false; + type Assert = Condition; + + var comma = (comma, 3); + ~~~~~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + type CommaInference = Assert>; + + var nestedComma = (comma, nestedComma, comma); + ~~~~~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + ~~~~~~~~~~~~~~~~~~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + type NestedCommaInference = Assert>; + + var assignment = (assignment = 2); + type AssignmentInference = Assert>; + + var nestedAssignment = (nestedAssignment = nestedAssignment = 2); + type NestedAssignmentInference = Assert>; + + var conditional = conditional ? 0 : 1; + type ConditionalInference = Assert>; + + var logicalAnd = logicalAnd && ""; + type LogicalAndInference = Assert>; + + var propertyAccess = { member: propertyAccess.member }; + type PropertyAccessInference = Assert>; + + const nonCircular: number = 3; + type NonCircularInference = Assert extends false ? true : false>; \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=false).js b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=false).js new file mode 100644 index 0000000000000..6b1e6c702f422 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=false).js @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/circularInitializerInference.ts] //// + +//// [circularInitializerInference.ts] +export {}; + +type IsAny = 0 extends (1 & Type) ? true : false; +type Assert = Condition; + +var comma = (comma, 3); +type CommaInference = Assert>; + +var nestedComma = (comma, nestedComma, comma); +type NestedCommaInference = Assert>; + +var assignment = (assignment = 2); +type AssignmentInference = Assert>; + +var nestedAssignment = (nestedAssignment = nestedAssignment = 2); +type NestedAssignmentInference = Assert>; + +var conditional = conditional ? 0 : 1; +type ConditionalInference = Assert>; + +var logicalAnd = logicalAnd && ""; +type LogicalAndInference = Assert>; + +var propertyAccess = { member: propertyAccess.member }; +type PropertyAccessInference = Assert>; + +const nonCircular: number = 3; +type NonCircularInference = Assert extends false ? true : false>; + +//// [circularInitializerInference.js] +var comma = (comma, 3); +var nestedComma = (comma, nestedComma, comma); +var assignment = (assignment = 2); +var nestedAssignment = (nestedAssignment = nestedAssignment = 2); +var conditional = conditional ? 0 : 1; +var logicalAnd = logicalAnd && ""; +var propertyAccess = { member: propertyAccess.member }; +const nonCircular = 3; +export {}; diff --git a/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=false).symbols b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=false).symbols new file mode 100644 index 0000000000000..7146dd252c8ef --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=false).symbols @@ -0,0 +1,98 @@ +//// [tests/cases/compiler/circularInitializerInference.ts] //// + +=== circularInitializerInference.ts === +export {}; + +type IsAny = 0 extends (1 & Type) ? true : false; +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>Type : Symbol(Type, Decl(circularInitializerInference.ts, 2, 11)) +>Type : Symbol(Type, Decl(circularInitializerInference.ts, 2, 11)) + +type Assert = Condition; +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>Condition : Symbol(Condition, Decl(circularInitializerInference.ts, 3, 12)) +>Condition : Symbol(Condition, Decl(circularInitializerInference.ts, 3, 12)) + +var comma = (comma, 3); +>comma : Symbol(comma, Decl(circularInitializerInference.ts, 5, 3)) +>comma : Symbol(comma, Decl(circularInitializerInference.ts, 5, 3)) + +type CommaInference = Assert>; +>CommaInference : Symbol(CommaInference, Decl(circularInitializerInference.ts, 5, 23)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>comma : Symbol(comma, Decl(circularInitializerInference.ts, 5, 3)) + +var nestedComma = (comma, nestedComma, comma); +>nestedComma : Symbol(nestedComma, Decl(circularInitializerInference.ts, 8, 3)) +>comma : Symbol(comma, Decl(circularInitializerInference.ts, 5, 3)) +>nestedComma : Symbol(nestedComma, Decl(circularInitializerInference.ts, 8, 3)) +>comma : Symbol(comma, Decl(circularInitializerInference.ts, 5, 3)) + +type NestedCommaInference = Assert>; +>NestedCommaInference : Symbol(NestedCommaInference, Decl(circularInitializerInference.ts, 8, 46)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>nestedComma : Symbol(nestedComma, Decl(circularInitializerInference.ts, 8, 3)) + +var assignment = (assignment = 2); +>assignment : Symbol(assignment, Decl(circularInitializerInference.ts, 11, 3)) +>assignment : Symbol(assignment, Decl(circularInitializerInference.ts, 11, 3)) + +type AssignmentInference = Assert>; +>AssignmentInference : Symbol(AssignmentInference, Decl(circularInitializerInference.ts, 11, 34)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>assignment : Symbol(assignment, Decl(circularInitializerInference.ts, 11, 3)) + +var nestedAssignment = (nestedAssignment = nestedAssignment = 2); +>nestedAssignment : Symbol(nestedAssignment, Decl(circularInitializerInference.ts, 14, 3)) +>nestedAssignment : Symbol(nestedAssignment, Decl(circularInitializerInference.ts, 14, 3)) +>nestedAssignment : Symbol(nestedAssignment, Decl(circularInitializerInference.ts, 14, 3)) + +type NestedAssignmentInference = Assert>; +>NestedAssignmentInference : Symbol(NestedAssignmentInference, Decl(circularInitializerInference.ts, 14, 65)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>nestedAssignment : Symbol(nestedAssignment, Decl(circularInitializerInference.ts, 14, 3)) + +var conditional = conditional ? 0 : 1; +>conditional : Symbol(conditional, Decl(circularInitializerInference.ts, 17, 3)) +>conditional : Symbol(conditional, Decl(circularInitializerInference.ts, 17, 3)) + +type ConditionalInference = Assert>; +>ConditionalInference : Symbol(ConditionalInference, Decl(circularInitializerInference.ts, 17, 38)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>conditional : Symbol(conditional, Decl(circularInitializerInference.ts, 17, 3)) + +var logicalAnd = logicalAnd && ""; +>logicalAnd : Symbol(logicalAnd, Decl(circularInitializerInference.ts, 20, 3)) +>logicalAnd : Symbol(logicalAnd, Decl(circularInitializerInference.ts, 20, 3)) + +type LogicalAndInference = Assert>; +>LogicalAndInference : Symbol(LogicalAndInference, Decl(circularInitializerInference.ts, 20, 34)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>logicalAnd : Symbol(logicalAnd, Decl(circularInitializerInference.ts, 20, 3)) + +var propertyAccess = { member: propertyAccess.member }; +>propertyAccess : Symbol(propertyAccess, Decl(circularInitializerInference.ts, 23, 3)) +>member : Symbol(member, Decl(circularInitializerInference.ts, 23, 22)) +>propertyAccess : Symbol(propertyAccess, Decl(circularInitializerInference.ts, 23, 3)) + +type PropertyAccessInference = Assert>; +>PropertyAccessInference : Symbol(PropertyAccessInference, Decl(circularInitializerInference.ts, 23, 55)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>propertyAccess : Symbol(propertyAccess, Decl(circularInitializerInference.ts, 23, 3)) + +const nonCircular: number = 3; +>nonCircular : Symbol(nonCircular, Decl(circularInitializerInference.ts, 26, 5)) + +type NonCircularInference = Assert extends false ? true : false>; +>NonCircularInference : Symbol(NonCircularInference, Decl(circularInitializerInference.ts, 26, 30)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>nonCircular : Symbol(nonCircular, Decl(circularInitializerInference.ts, 26, 5)) + diff --git a/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=false).types b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=false).types new file mode 100644 index 0000000000000..c9d5c077f18ad --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=false).types @@ -0,0 +1,106 @@ +//// [tests/cases/compiler/circularInitializerInference.ts] //// + +=== circularInitializerInference.ts === +export {}; + +type IsAny = 0 extends (1 & Type) ? true : false; +>IsAny : IsAny +>true : true +>false : false + +type Assert = Condition; +>Assert : Condition +>true : true + +var comma = (comma, 3); +>comma : any +>(comma, 3) : 3 +>comma, 3 : 3 +>comma : any +>3 : 3 + +type CommaInference = Assert>; +>CommaInference : true +>comma : any + +var nestedComma = (comma, nestedComma, comma); +>nestedComma : any +>(comma, nestedComma, comma) : any +>comma, nestedComma, comma : any +>comma, nestedComma : any +>comma : any +>nestedComma : any +>comma : any + +type NestedCommaInference = Assert>; +>NestedCommaInference : true +>nestedComma : any + +var assignment = (assignment = 2); +>assignment : any +>(assignment = 2) : 2 +>assignment = 2 : 2 +>assignment : any +>2 : 2 + +type AssignmentInference = Assert>; +>AssignmentInference : true +>assignment : any + +var nestedAssignment = (nestedAssignment = nestedAssignment = 2); +>nestedAssignment : any +>(nestedAssignment = nestedAssignment = 2) : 2 +>nestedAssignment = nestedAssignment = 2 : 2 +>nestedAssignment : any +>nestedAssignment = 2 : 2 +>nestedAssignment : any +>2 : 2 + +type NestedAssignmentInference = Assert>; +>NestedAssignmentInference : true +>nestedAssignment : any + +var conditional = conditional ? 0 : 1; +>conditional : any +>conditional ? 0 : 1 : 0 | 1 +>conditional : any +>0 : 0 +>1 : 1 + +type ConditionalInference = Assert>; +>ConditionalInference : true +>conditional : any + +var logicalAnd = logicalAnd && ""; +>logicalAnd : any +>logicalAnd && "" : "" +>logicalAnd : any +>"" : "" + +type LogicalAndInference = Assert>; +>LogicalAndInference : true +>logicalAnd : any + +var propertyAccess = { member: propertyAccess.member }; +>propertyAccess : any +>{ member: propertyAccess.member } : { member: any; } +>member : any +>propertyAccess.member : any +>propertyAccess : any +>member : any + +type PropertyAccessInference = Assert>; +>PropertyAccessInference : true +>propertyAccess : any + +const nonCircular: number = 3; +>nonCircular : number +>3 : 3 + +type NonCircularInference = Assert extends false ? true : false>; +>NonCircularInference : true +>nonCircular : number +>false : false +>true : true +>false : false + diff --git a/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=true).errors.txt b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=true).errors.txt new file mode 100644 index 0000000000000..f7f94d4a4b3bc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=true).errors.txt @@ -0,0 +1,61 @@ +circularInitializerInference.ts(6,5): error TS7022: 'comma' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +circularInitializerInference.ts(6,14): error TS2695: Left side of comma operator is unused and has no side effects. +circularInitializerInference.ts(9,5): error TS7022: 'nestedComma' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +circularInitializerInference.ts(9,20): error TS2695: Left side of comma operator is unused and has no side effects. +circularInitializerInference.ts(9,20): error TS2695: Left side of comma operator is unused and has no side effects. +circularInitializerInference.ts(12,5): error TS7022: 'assignment' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +circularInitializerInference.ts(15,5): error TS7022: 'nestedAssignment' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +circularInitializerInference.ts(18,5): error TS7022: 'conditional' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +circularInitializerInference.ts(21,5): error TS7022: 'logicalAnd' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +circularInitializerInference.ts(24,5): error TS7022: 'propertyAccess' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + + +==== circularInitializerInference.ts (10 errors) ==== + export {}; + + type IsAny = 0 extends (1 & Type) ? true : false; + type Assert = Condition; + + var comma = (comma, 3); + ~~~~~ +!!! error TS7022: 'comma' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + ~~~~~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + type CommaInference = Assert>; + + var nestedComma = (comma, nestedComma, comma); + ~~~~~~~~~~~ +!!! error TS7022: 'nestedComma' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + ~~~~~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + ~~~~~~~~~~~~~~~~~~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + type NestedCommaInference = Assert>; + + var assignment = (assignment = 2); + ~~~~~~~~~~ +!!! error TS7022: 'assignment' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + type AssignmentInference = Assert>; + + var nestedAssignment = (nestedAssignment = nestedAssignment = 2); + ~~~~~~~~~~~~~~~~ +!!! error TS7022: 'nestedAssignment' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + type NestedAssignmentInference = Assert>; + + var conditional = conditional ? 0 : 1; + ~~~~~~~~~~~ +!!! error TS7022: 'conditional' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + type ConditionalInference = Assert>; + + var logicalAnd = logicalAnd && ""; + ~~~~~~~~~~ +!!! error TS7022: 'logicalAnd' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + type LogicalAndInference = Assert>; + + var propertyAccess = { member: propertyAccess.member }; + ~~~~~~~~~~~~~~ +!!! error TS7022: 'propertyAccess' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + type PropertyAccessInference = Assert>; + + const nonCircular: number = 3; + type NonCircularInference = Assert extends false ? true : false>; \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=true).js b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=true).js new file mode 100644 index 0000000000000..6b1e6c702f422 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=true).js @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/circularInitializerInference.ts] //// + +//// [circularInitializerInference.ts] +export {}; + +type IsAny = 0 extends (1 & Type) ? true : false; +type Assert = Condition; + +var comma = (comma, 3); +type CommaInference = Assert>; + +var nestedComma = (comma, nestedComma, comma); +type NestedCommaInference = Assert>; + +var assignment = (assignment = 2); +type AssignmentInference = Assert>; + +var nestedAssignment = (nestedAssignment = nestedAssignment = 2); +type NestedAssignmentInference = Assert>; + +var conditional = conditional ? 0 : 1; +type ConditionalInference = Assert>; + +var logicalAnd = logicalAnd && ""; +type LogicalAndInference = Assert>; + +var propertyAccess = { member: propertyAccess.member }; +type PropertyAccessInference = Assert>; + +const nonCircular: number = 3; +type NonCircularInference = Assert extends false ? true : false>; + +//// [circularInitializerInference.js] +var comma = (comma, 3); +var nestedComma = (comma, nestedComma, comma); +var assignment = (assignment = 2); +var nestedAssignment = (nestedAssignment = nestedAssignment = 2); +var conditional = conditional ? 0 : 1; +var logicalAnd = logicalAnd && ""; +var propertyAccess = { member: propertyAccess.member }; +const nonCircular = 3; +export {}; diff --git a/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=true).symbols b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=true).symbols new file mode 100644 index 0000000000000..7146dd252c8ef --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=true).symbols @@ -0,0 +1,98 @@ +//// [tests/cases/compiler/circularInitializerInference.ts] //// + +=== circularInitializerInference.ts === +export {}; + +type IsAny = 0 extends (1 & Type) ? true : false; +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>Type : Symbol(Type, Decl(circularInitializerInference.ts, 2, 11)) +>Type : Symbol(Type, Decl(circularInitializerInference.ts, 2, 11)) + +type Assert = Condition; +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>Condition : Symbol(Condition, Decl(circularInitializerInference.ts, 3, 12)) +>Condition : Symbol(Condition, Decl(circularInitializerInference.ts, 3, 12)) + +var comma = (comma, 3); +>comma : Symbol(comma, Decl(circularInitializerInference.ts, 5, 3)) +>comma : Symbol(comma, Decl(circularInitializerInference.ts, 5, 3)) + +type CommaInference = Assert>; +>CommaInference : Symbol(CommaInference, Decl(circularInitializerInference.ts, 5, 23)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>comma : Symbol(comma, Decl(circularInitializerInference.ts, 5, 3)) + +var nestedComma = (comma, nestedComma, comma); +>nestedComma : Symbol(nestedComma, Decl(circularInitializerInference.ts, 8, 3)) +>comma : Symbol(comma, Decl(circularInitializerInference.ts, 5, 3)) +>nestedComma : Symbol(nestedComma, Decl(circularInitializerInference.ts, 8, 3)) +>comma : Symbol(comma, Decl(circularInitializerInference.ts, 5, 3)) + +type NestedCommaInference = Assert>; +>NestedCommaInference : Symbol(NestedCommaInference, Decl(circularInitializerInference.ts, 8, 46)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>nestedComma : Symbol(nestedComma, Decl(circularInitializerInference.ts, 8, 3)) + +var assignment = (assignment = 2); +>assignment : Symbol(assignment, Decl(circularInitializerInference.ts, 11, 3)) +>assignment : Symbol(assignment, Decl(circularInitializerInference.ts, 11, 3)) + +type AssignmentInference = Assert>; +>AssignmentInference : Symbol(AssignmentInference, Decl(circularInitializerInference.ts, 11, 34)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>assignment : Symbol(assignment, Decl(circularInitializerInference.ts, 11, 3)) + +var nestedAssignment = (nestedAssignment = nestedAssignment = 2); +>nestedAssignment : Symbol(nestedAssignment, Decl(circularInitializerInference.ts, 14, 3)) +>nestedAssignment : Symbol(nestedAssignment, Decl(circularInitializerInference.ts, 14, 3)) +>nestedAssignment : Symbol(nestedAssignment, Decl(circularInitializerInference.ts, 14, 3)) + +type NestedAssignmentInference = Assert>; +>NestedAssignmentInference : Symbol(NestedAssignmentInference, Decl(circularInitializerInference.ts, 14, 65)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>nestedAssignment : Symbol(nestedAssignment, Decl(circularInitializerInference.ts, 14, 3)) + +var conditional = conditional ? 0 : 1; +>conditional : Symbol(conditional, Decl(circularInitializerInference.ts, 17, 3)) +>conditional : Symbol(conditional, Decl(circularInitializerInference.ts, 17, 3)) + +type ConditionalInference = Assert>; +>ConditionalInference : Symbol(ConditionalInference, Decl(circularInitializerInference.ts, 17, 38)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>conditional : Symbol(conditional, Decl(circularInitializerInference.ts, 17, 3)) + +var logicalAnd = logicalAnd && ""; +>logicalAnd : Symbol(logicalAnd, Decl(circularInitializerInference.ts, 20, 3)) +>logicalAnd : Symbol(logicalAnd, Decl(circularInitializerInference.ts, 20, 3)) + +type LogicalAndInference = Assert>; +>LogicalAndInference : Symbol(LogicalAndInference, Decl(circularInitializerInference.ts, 20, 34)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>logicalAnd : Symbol(logicalAnd, Decl(circularInitializerInference.ts, 20, 3)) + +var propertyAccess = { member: propertyAccess.member }; +>propertyAccess : Symbol(propertyAccess, Decl(circularInitializerInference.ts, 23, 3)) +>member : Symbol(member, Decl(circularInitializerInference.ts, 23, 22)) +>propertyAccess : Symbol(propertyAccess, Decl(circularInitializerInference.ts, 23, 3)) + +type PropertyAccessInference = Assert>; +>PropertyAccessInference : Symbol(PropertyAccessInference, Decl(circularInitializerInference.ts, 23, 55)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>propertyAccess : Symbol(propertyAccess, Decl(circularInitializerInference.ts, 23, 3)) + +const nonCircular: number = 3; +>nonCircular : Symbol(nonCircular, Decl(circularInitializerInference.ts, 26, 5)) + +type NonCircularInference = Assert extends false ? true : false>; +>NonCircularInference : Symbol(NonCircularInference, Decl(circularInitializerInference.ts, 26, 30)) +>Assert : Symbol(Assert, Decl(circularInitializerInference.ts, 2, 55)) +>IsAny : Symbol(IsAny, Decl(circularInitializerInference.ts, 0, 10)) +>nonCircular : Symbol(nonCircular, Decl(circularInitializerInference.ts, 26, 5)) + diff --git a/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=true).types b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=true).types new file mode 100644 index 0000000000000..93d72c091cab5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInitializerInference(strict=true).types @@ -0,0 +1,106 @@ +//// [tests/cases/compiler/circularInitializerInference.ts] //// + +=== circularInitializerInference.ts === +export {}; + +type IsAny = 0 extends (1 & Type) ? true : false; +>IsAny : IsAny +>true : true +>false : false + +type Assert = Condition; +>Assert : Condition +>true : true + +var comma = (comma, 3); +>comma : any +>(comma, 3) : 3 +>comma, 3 : 3 +>comma : any +>3 : 3 + +type CommaInference = Assert>; +>CommaInference : true +>comma : any + +var nestedComma = (comma, nestedComma, comma); +>nestedComma : any +>(comma, nestedComma, comma) : any +>comma, nestedComma, comma : any +>comma, nestedComma : any +>comma : any +>nestedComma : any +>comma : any + +type NestedCommaInference = Assert>; +>NestedCommaInference : true +>nestedComma : any + +var assignment = (assignment = 2); +>assignment : any +>(assignment = 2) : 2 +>assignment = 2 : 2 +>assignment : any +>2 : 2 + +type AssignmentInference = Assert>; +>AssignmentInference : true +>assignment : any + +var nestedAssignment = (nestedAssignment = nestedAssignment = 2); +>nestedAssignment : any +>(nestedAssignment = nestedAssignment = 2) : 2 +>nestedAssignment = nestedAssignment = 2 : 2 +>nestedAssignment : any +>nestedAssignment = 2 : 2 +>nestedAssignment : any +>2 : 2 + +type NestedAssignmentInference = Assert>; +>NestedAssignmentInference : true +>nestedAssignment : any + +var conditional = conditional ? 0 : 1; +>conditional : any +>conditional ? 0 : 1 : 0 | 1 +>conditional : any +>0 : 0 +>1 : 1 + +type ConditionalInference = Assert>; +>ConditionalInference : true +>conditional : any + +var logicalAnd = logicalAnd && ""; +>logicalAnd : any +>logicalAnd && "" : any +>logicalAnd : any +>"" : "" + +type LogicalAndInference = Assert>; +>LogicalAndInference : true +>logicalAnd : any + +var propertyAccess = { member: propertyAccess.member }; +>propertyAccess : any +>{ member: propertyAccess.member } : { member: any; } +>member : any +>propertyAccess.member : any +>propertyAccess : any +>member : any + +type PropertyAccessInference = Assert>; +>PropertyAccessInference : true +>propertyAccess : any + +const nonCircular: number = 3; +>nonCircular : number +>3 : 3 + +type NonCircularInference = Assert extends false ? true : false>; +>NonCircularInference : true +>nonCircular : number +>false : false +>true : true +>false : false + diff --git a/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=default).errors.txt new file mode 100644 index 0000000000000..8d568d19a5373 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=default).errors.txt @@ -0,0 +1,20 @@ +circularInlineMappedGenericTupleTypeNoCrash.ts(11,12): error TS2589: Type instantiation is excessively deep and possibly infinite. + + +==== circularInlineMappedGenericTupleTypeNoCrash.ts (1 errors) ==== + class Foo { + public readonly elements: { [P in keyof Elements]: { bar: Elements[P] } }; + + public constructor( + ...elements: { [P in keyof Elements]: { bar: Elements[P] } } + ) { + this.elements = elements; + } + + public add(): Foo<[...Elements, "abc"]> { + return new Foo<[...Elements, "abc"]>(...this.elements, { bar: "abc" }); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2589: Type instantiation is excessively deep and possibly infinite. + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=default).symbols new file mode 100644 index 0000000000000..c5a706f25c93c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=default).symbols @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/circularInlineMappedGenericTupleTypeNoCrash.ts] //// + +=== circularInlineMappedGenericTupleTypeNoCrash.ts === +class Foo { +>Foo : Symbol(Foo, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 0)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) + + public readonly elements: { [P in keyof Elements]: { bar: Elements[P] } }; +>elements : Symbol(Foo.elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 48)) +>P : Symbol(P, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 1, 31)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) +>bar : Symbol(bar, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 1, 54)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) +>P : Symbol(P, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 1, 31)) + + public constructor( + ...elements: { [P in keyof Elements]: { bar: Elements[P] } } +>elements : Symbol(elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 3, 21)) +>P : Symbol(P, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 4, 20)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) +>bar : Symbol(bar, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 4, 43)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) +>P : Symbol(P, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 4, 20)) + + ) { + this.elements = elements; +>this.elements : Symbol(Foo.elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 48)) +>this : Symbol(Foo, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 0)) +>elements : Symbol(Foo.elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 48)) +>elements : Symbol(elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 3, 21)) + } + + public add(): Foo<[...Elements, "abc"]> { +>add : Symbol(Foo.add, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 7, 3)) +>Foo : Symbol(Foo, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 0)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) + + return new Foo<[...Elements, "abc"]>(...this.elements, { bar: "abc" }); +>Foo : Symbol(Foo, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 0)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) +>this.elements : Symbol(Foo.elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 48)) +>this : Symbol(Foo, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 0)) +>elements : Symbol(Foo.elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 48)) +>bar : Symbol(bar, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 10, 60)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=default).types new file mode 100644 index 0000000000000..660b3ff1bac7e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=default).types @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/circularInlineMappedGenericTupleTypeNoCrash.ts] //// + +=== circularInlineMappedGenericTupleTypeNoCrash.ts === +class Foo { +>Foo : Foo + + public readonly elements: { [P in keyof Elements]: { bar: Elements[P] } }; +>elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>bar : Elements[P] + + public constructor( + ...elements: { [P in keyof Elements]: { bar: Elements[P] } } +>elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>bar : Elements[P] + + ) { + this.elements = elements; +>this.elements = elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>this.elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>this : this +>elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>elements : { [P in keyof Elements]: { bar: Elements[P]; }; } + } + + public add(): Foo<[...Elements, "abc"]> { +>add : () => Foo<[...Elements, "abc"]> + + return new Foo<[...Elements, "abc"]>(...this.elements, { bar: "abc" }); +>new Foo<[...Elements, "abc"]>(...this.elements, { bar: "abc" }) : Foo<[...Elements, "abc"]> +>Foo : typeof Foo +>...this.elements : { bar: unknown; } +>this.elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>this : this +>elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>{ bar: "abc" } : { bar: string; } +>bar : string +>"abc" : "abc" + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..e78f397fc931f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=typesfirst).errors.txt @@ -0,0 +1,19 @@ +error TS2589: Type instantiation is excessively deep and possibly infinite. + + +!!! error TS2589: Type instantiation is excessively deep and possibly infinite. +==== circularInlineMappedGenericTupleTypeNoCrash.ts (0 errors) ==== + class Foo { + public readonly elements: { [P in keyof Elements]: { bar: Elements[P] } }; + + public constructor( + ...elements: { [P in keyof Elements]: { bar: Elements[P] } } + ) { + this.elements = elements; + } + + public add(): Foo<[...Elements, "abc"]> { + return new Foo<[...Elements, "abc"]>(...this.elements, { bar: "abc" }); + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..c5a706f25c93c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=typesfirst).symbols @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/circularInlineMappedGenericTupleTypeNoCrash.ts] //// + +=== circularInlineMappedGenericTupleTypeNoCrash.ts === +class Foo { +>Foo : Symbol(Foo, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 0)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) + + public readonly elements: { [P in keyof Elements]: { bar: Elements[P] } }; +>elements : Symbol(Foo.elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 48)) +>P : Symbol(P, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 1, 31)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) +>bar : Symbol(bar, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 1, 54)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) +>P : Symbol(P, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 1, 31)) + + public constructor( + ...elements: { [P in keyof Elements]: { bar: Elements[P] } } +>elements : Symbol(elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 3, 21)) +>P : Symbol(P, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 4, 20)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) +>bar : Symbol(bar, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 4, 43)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) +>P : Symbol(P, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 4, 20)) + + ) { + this.elements = elements; +>this.elements : Symbol(Foo.elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 48)) +>this : Symbol(Foo, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 0)) +>elements : Symbol(Foo.elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 48)) +>elements : Symbol(elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 3, 21)) + } + + public add(): Foo<[...Elements, "abc"]> { +>add : Symbol(Foo.add, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 7, 3)) +>Foo : Symbol(Foo, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 0)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) + + return new Foo<[...Elements, "abc"]>(...this.elements, { bar: "abc" }); +>Foo : Symbol(Foo, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 0)) +>Elements : Symbol(Elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 10)) +>this.elements : Symbol(Foo.elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 48)) +>this : Symbol(Foo, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 0)) +>elements : Symbol(Foo.elements, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 0, 48)) +>bar : Symbol(bar, Decl(circularInlineMappedGenericTupleTypeNoCrash.ts, 10, 60)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=typesfirst).types new file mode 100644 index 0000000000000..660b3ff1bac7e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularInlineMappedGenericTupleTypeNoCrash(checkorder=typesfirst).types @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/circularInlineMappedGenericTupleTypeNoCrash.ts] //// + +=== circularInlineMappedGenericTupleTypeNoCrash.ts === +class Foo { +>Foo : Foo + + public readonly elements: { [P in keyof Elements]: { bar: Elements[P] } }; +>elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>bar : Elements[P] + + public constructor( + ...elements: { [P in keyof Elements]: { bar: Elements[P] } } +>elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>bar : Elements[P] + + ) { + this.elements = elements; +>this.elements = elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>this.elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>this : this +>elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>elements : { [P in keyof Elements]: { bar: Elements[P]; }; } + } + + public add(): Foo<[...Elements, "abc"]> { +>add : () => Foo<[...Elements, "abc"]> + + return new Foo<[...Elements, "abc"]>(...this.elements, { bar: "abc" }); +>new Foo<[...Elements, "abc"]>(...this.elements, { bar: "abc" }) : Foo<[...Elements, "abc"]> +>Foo : typeof Foo +>...this.elements : { bar: unknown; } +>this.elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>this : this +>elements : { [P in keyof Elements]: { bar: Elements[P]; }; } +>{ bar: "abc" } : { bar: string; } +>bar : string +>"abc" : "abc" + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeSubtypeReductionOrder.errors.txt b/tsc/testdata/baselines/reference/compiler/circularReturnTypeSubtypeReductionOrder.errors.txt new file mode 100644 index 0000000000000..f0b2f978c0228 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeSubtypeReductionOrder.errors.txt @@ -0,0 +1,50 @@ +expression.ts(10,7): error TS2322: Type 'typeof A' is not assignable to type 'new () => A'. + Type 'A' is not assignable to type 'A'. Two different types with this name exist, but they are unrelated. + Types of property 'c' are incompatible. + Type '() => () => A | A' is not assignable to type 'A'. + + +==== expression.ts (1 errors) ==== + // Subtype reduction of rebuild's return type relates the class to A, + // which needs b's return type, which needs rebuild's: a cycle. Both + // members report it, whichever return type is requested first, as if + // rebuild's, declared first, were requested first. + interface A { + b(): A; + c: A; + } + declare const flag: boolean; + const A: new () => A = class { + ~ +!!! error TS2322: Type 'typeof A' is not assignable to type 'new () => A'. +!!! error TS2322: Type 'A' is not assignable to type 'A'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: Types of property 'c' are incompatible. +!!! error TS2322: Type '() => () => A | A' is not assignable to type 'A'. + rebuild() { + return flag ? this : new A(); + } + b() { + return this.rebuild(); + } + c() { + return this.rebuild; + } + }; + export {}; + +==== declaration.ts (0 errors) ==== + interface B { + b(): B; + } + declare const flag: boolean; + class K { + rebuild() { + return flag ? this : new B(); + } + b() { + return this.rebuild(); + } + } + const B: new () => B = K; + export {}; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeSubtypeReductionOrder.symbols b/tsc/testdata/baselines/reference/compiler/circularReturnTypeSubtypeReductionOrder.symbols new file mode 100644 index 0000000000000..5706cdcb8e401 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeSubtypeReductionOrder.symbols @@ -0,0 +1,90 @@ +//// [tests/cases/compiler/circularReturnTypeSubtypeReductionOrder.ts] //// + +=== expression.ts === +// Subtype reduction of rebuild's return type relates the class to A, +// which needs b's return type, which needs rebuild's: a cycle. Both +// members report it, whichever return type is requested first, as if +// rebuild's, declared first, were requested first. +interface A { +>A : Symbol(A, Decl(expression.ts, 0, 0), Decl(expression.ts, 9, 5)) + + b(): A; +>b : Symbol(A.b, Decl(expression.ts, 4, 13)) +>A : Symbol(A, Decl(expression.ts, 0, 0), Decl(expression.ts, 9, 5)) + + c: A; +>c : Symbol(A.c, Decl(expression.ts, 5, 11)) +>A : Symbol(A, Decl(expression.ts, 0, 0), Decl(expression.ts, 9, 5)) +} +declare const flag: boolean; +>flag : Symbol(flag, Decl(expression.ts, 8, 13)) + +const A: new () => A = class { +>A : Symbol(A, Decl(expression.ts, 0, 0), Decl(expression.ts, 9, 5)) +>A : Symbol(A, Decl(expression.ts, 0, 0), Decl(expression.ts, 9, 5)) + + rebuild() { +>rebuild : Symbol(A.rebuild, Decl(expression.ts, 9, 30)) + + return flag ? this : new A(); +>flag : Symbol(flag, Decl(expression.ts, 8, 13)) +>this : Symbol(A, Decl(expression.ts, 9, 22)) +>A : Symbol(A, Decl(expression.ts, 0, 0), Decl(expression.ts, 9, 5)) + } + b() { +>b : Symbol(A.b, Decl(expression.ts, 12, 5)) + + return this.rebuild(); +>this.rebuild : Symbol(A.rebuild, Decl(expression.ts, 9, 30)) +>this : Symbol(A, Decl(expression.ts, 9, 22)) +>rebuild : Symbol(A.rebuild, Decl(expression.ts, 9, 30)) + } + c() { +>c : Symbol(A.c, Decl(expression.ts, 15, 5)) + + return this.rebuild; +>this.rebuild : Symbol(A.rebuild, Decl(expression.ts, 9, 30)) +>this : Symbol(A, Decl(expression.ts, 9, 22)) +>rebuild : Symbol(A.rebuild, Decl(expression.ts, 9, 30)) + } +}; +export {}; + +=== declaration.ts === +interface B { +>B : Symbol(B, Decl(declaration.ts, 0, 0), Decl(declaration.ts, 12, 5)) + + b(): B; +>b : Symbol(B.b, Decl(declaration.ts, 0, 13)) +>B : Symbol(B, Decl(declaration.ts, 0, 0), Decl(declaration.ts, 12, 5)) +} +declare const flag: boolean; +>flag : Symbol(flag, Decl(declaration.ts, 3, 13)) + +class K { +>K : Symbol(K, Decl(declaration.ts, 3, 28)) + + rebuild() { +>rebuild : Symbol(K.rebuild, Decl(declaration.ts, 4, 9)) + + return flag ? this : new B(); +>flag : Symbol(flag, Decl(declaration.ts, 3, 13)) +>this : Symbol(K, Decl(declaration.ts, 3, 28)) +>B : Symbol(B, Decl(declaration.ts, 0, 0), Decl(declaration.ts, 12, 5)) + } + b() { +>b : Symbol(K.b, Decl(declaration.ts, 7, 5)) + + return this.rebuild(); +>this.rebuild : Symbol(K.rebuild, Decl(declaration.ts, 4, 9)) +>this : Symbol(K, Decl(declaration.ts, 3, 28)) +>rebuild : Symbol(K.rebuild, Decl(declaration.ts, 4, 9)) + } +} +const B: new () => B = K; +>B : Symbol(B, Decl(declaration.ts, 0, 0), Decl(declaration.ts, 12, 5)) +>B : Symbol(B, Decl(declaration.ts, 0, 0), Decl(declaration.ts, 12, 5)) +>K : Symbol(K, Decl(declaration.ts, 3, 28)) + +export {}; + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeSubtypeReductionOrder.types b/tsc/testdata/baselines/reference/compiler/circularReturnTypeSubtypeReductionOrder.types new file mode 100644 index 0000000000000..9088517456379 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeSubtypeReductionOrder.types @@ -0,0 +1,88 @@ +//// [tests/cases/compiler/circularReturnTypeSubtypeReductionOrder.ts] //// + +=== expression.ts === +// Subtype reduction of rebuild's return type relates the class to A, +// which needs b's return type, which needs rebuild's: a cycle. Both +// members report it, whichever return type is requested first, as if +// rebuild's, declared first, were requested first. +interface A { + b(): A; +>b : () => A + + c: A; +>c : A +} +declare const flag: boolean; +>flag : boolean + +const A: new () => A = class { +>A : new () => A +>class { rebuild() { return flag ? this : new A(); } b() { return this.rebuild(); } c() { return this.rebuild; }} : typeof A + + rebuild() { +>rebuild : () => this | A + + return flag ? this : new A(); +>flag ? this : new A() : this | A +>flag : boolean +>this : this +>new A() : A +>A : new () => A + } + b() { +>b : () => this | A + + return this.rebuild(); +>this.rebuild() : this | A +>this.rebuild : () => this | A +>this : this +>rebuild : () => this | A + } + c() { +>c : () => () => this | A + + return this.rebuild; +>this.rebuild : () => this | A +>this : this +>rebuild : () => this | A + } +}; +export {}; + +=== declaration.ts === +interface B { + b(): B; +>b : () => B +} +declare const flag: boolean; +>flag : boolean + +class K { +>K : K + + rebuild() { +>rebuild : () => this | B + + return flag ? this : new B(); +>flag ? this : new B() : this | B +>flag : boolean +>this : this +>new B() : B +>B : new () => B + } + b() { +>b : () => this | B + + return this.rebuild(); +>this.rebuild() : this | B +>this.rebuild : () => this | B +>this : this +>rebuild : () => this | B + } +} +const B: new () => B = K; +>B : new () => B +>K : typeof K + +export {}; + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallArgumentRelation(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallArgumentRelation(checkorder=default).symbols new file mode 100644 index 0000000000000..c320ee58e23b7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallArgumentRelation(checkorder=default).symbols @@ -0,0 +1,106 @@ +//// [tests/cases/compiler/circularReturnTypeThroughCallArgumentRelation.ts] //// + +=== circularReturnTypeThroughCallArgumentRelation.ts === +// Inferring a method's return type resolves a call whose argument check +// relates the method's own class to an interface containing that method, so +// the relation compares the method while its return type is in progress. +// TypeScript reads the in-progress return type as `any` there without failing +// it, and call resolution hides the resolutions below it, so no TS7023 is +// reported in any check order and the method gets the call's return type. +// (Reduced from meta/lexical HeadingNode.$config and effect SchemaAST getParser.) + +// Through a callback returning an instance (lexical). +interface Base { m(): unknown } +>Base : Symbol(Base, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 0, 0)) +>m : Symbol(Base.m, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 9, 16)) + +declare function config(config: { f?: () => Base }): void; +>config : Symbol(config, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 9, 31)) +>config : Symbol(config, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 10, 24)) +>f : Symbol(f, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 10, 33)) +>Base : Symbol(Base, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 0, 0)) + +declare const h: Heading; +>h : Symbol(h, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 12, 13)) +>Heading : Symbol(Heading, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 13, 18)) + +const b: Base = h; +>b : Symbol(b, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 13, 5)) +>Base : Symbol(Base, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 0, 0)) +>h : Symbol(h, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 12, 13)) + +class Heading { +>Heading : Symbol(Heading, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 13, 18)) + + m() { +>m : Symbol(Heading.m, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 15, 15)) + + return config({ f: () => create() }); +>config : Symbol(config, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 9, 31)) +>f : Symbol(f, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 17, 23)) +>create : Symbol(create, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 19, 1)) + } +} + +declare function create(): Heading; +>create : Symbol(create, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 19, 1)) +>Heading : Symbol(Heading, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 13, 18)) + +const r: void = new Heading().m(); +>r : Symbol(r, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 23, 5)) +>new Heading().m : Symbol(Heading.m, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 15, 15)) +>Heading : Symbol(Heading, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 13, 18)) +>m : Symbol(Heading.m, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 15, 15)) + +// Passing `this` directly (effect). +type Parser = (input: unknown) => unknown; +>Parser : Symbol(Parser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 23, 34)) +>input : Symbol(input, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 26, 15)) + +interface NullNode { readonly _tag: "Null"; getParser(): Parser } +>NullNode : Symbol(NullNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 26, 42), Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 5)) +>_tag : Symbol(NullNode._tag, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 27, 20)) +>getParser : Symbol(NullNode.getParser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 27, 43)) +>Parser : Symbol(Parser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 23, 34)) + +interface UndefinedNode { readonly _tag: "Undefined"; getParser(): Parser } +>UndefinedNode : Symbol(UndefinedNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 27, 65)) +>_tag : Symbol(UndefinedNode._tag, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 28, 25)) +>getParser : Symbol(UndefinedNode.getParser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 28, 53)) +>Parser : Symbol(Parser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 23, 34)) + +type AST = NullNode | UndefinedNode; +>AST : Symbol(AST, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 28, 75)) +>NullNode : Symbol(NullNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 26, 42), Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 5)) +>UndefinedNode : Symbol(UndefinedNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 27, 65)) + +declare function fromConst(ast: AST, value: unknown): Parser; +>fromConst : Symbol(fromConst, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 29, 36)) +>ast : Symbol(ast, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 30, 27)) +>AST : Symbol(AST, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 28, 75)) +>value : Symbol(value, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 30, 36)) +>Parser : Symbol(Parser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 23, 34)) + +const NullNode: new () => NullNode = class { +>NullNode : Symbol(NullNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 26, 42), Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 5)) +>NullNode : Symbol(NullNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 26, 42), Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 5)) + + readonly _tag = "Null"; +>_tag : Symbol(NullNode._tag, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 44)) + + getParser() { +>getParser : Symbol(NullNode.getParser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 33, 27)) + + return fromConst(this, null); +>fromConst : Symbol(fromConst, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 29, 36)) +>this : Symbol(NullNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 36)) + } +}; + +const p: Parser = new NullNode().getParser(); +>p : Symbol(p, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 39, 5)) +>Parser : Symbol(Parser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 23, 34)) +>new NullNode().getParser : Symbol(NullNode.getParser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 27, 43)) +>NullNode : Symbol(NullNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 26, 42), Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 5)) +>getParser : Symbol(NullNode.getParser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 27, 43)) + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallArgumentRelation(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallArgumentRelation(checkorder=default).types new file mode 100644 index 0000000000000..21a3ba0434560 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallArgumentRelation(checkorder=default).types @@ -0,0 +1,102 @@ +//// [tests/cases/compiler/circularReturnTypeThroughCallArgumentRelation.ts] //// + +=== circularReturnTypeThroughCallArgumentRelation.ts === +// Inferring a method's return type resolves a call whose argument check +// relates the method's own class to an interface containing that method, so +// the relation compares the method while its return type is in progress. +// TypeScript reads the in-progress return type as `any` there without failing +// it, and call resolution hides the resolutions below it, so no TS7023 is +// reported in any check order and the method gets the call's return type. +// (Reduced from meta/lexical HeadingNode.$config and effect SchemaAST getParser.) + +// Through a callback returning an instance (lexical). +interface Base { m(): unknown } +>m : () => unknown + +declare function config(config: { f?: () => Base }): void; +>config : (config: { f?: () => Base; }) => void +>config : { f?: () => Base; } +>f : (() => Base) | undefined + +declare const h: Heading; +>h : Heading + +const b: Base = h; +>b : Base +>h : Heading + +class Heading { +>Heading : Heading + + m() { +>m : () => void + + return config({ f: () => create() }); +>config({ f: () => create() }) : void +>config : (config: { f?: () => Base; }) => void +>{ f: () => create() } : { f: () => Heading; } +>f : () => Heading +>() => create() : () => Heading +>create() : Heading +>create : () => Heading + } +} + +declare function create(): Heading; +>create : () => Heading + +const r: void = new Heading().m(); +>r : void +>new Heading().m() : void +>new Heading().m : () => void +>new Heading() : Heading +>Heading : typeof Heading +>m : () => void + +// Passing `this` directly (effect). +type Parser = (input: unknown) => unknown; +>Parser : Parser +>input : unknown + +interface NullNode { readonly _tag: "Null"; getParser(): Parser } +>_tag : "Null" +>getParser : () => Parser + +interface UndefinedNode { readonly _tag: "Undefined"; getParser(): Parser } +>_tag : "Undefined" +>getParser : () => Parser + +type AST = NullNode | UndefinedNode; +>AST : AST + +declare function fromConst(ast: AST, value: unknown): Parser; +>fromConst : (ast: AST, value: unknown) => Parser +>ast : AST +>value : unknown + +const NullNode: new () => NullNode = class { +>NullNode : new () => NullNode +>class { readonly _tag = "Null"; getParser() { return fromConst(this, null); }} : typeof NullNode + + readonly _tag = "Null"; +>_tag : "Null" +>"Null" : "Null" + + getParser() { +>getParser : () => Parser + + return fromConst(this, null); +>fromConst(this, null) : Parser +>fromConst : (ast: AST, value: unknown) => Parser +>this : this + } +}; + +const p: Parser = new NullNode().getParser(); +>p : Parser +>new NullNode().getParser() : Parser +>new NullNode().getParser : () => Parser +>new NullNode() : NullNode +>NullNode : new () => NullNode +>getParser : () => Parser + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallArgumentRelation(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallArgumentRelation(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..c320ee58e23b7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallArgumentRelation(checkorder=typesfirst).symbols @@ -0,0 +1,106 @@ +//// [tests/cases/compiler/circularReturnTypeThroughCallArgumentRelation.ts] //// + +=== circularReturnTypeThroughCallArgumentRelation.ts === +// Inferring a method's return type resolves a call whose argument check +// relates the method's own class to an interface containing that method, so +// the relation compares the method while its return type is in progress. +// TypeScript reads the in-progress return type as `any` there without failing +// it, and call resolution hides the resolutions below it, so no TS7023 is +// reported in any check order and the method gets the call's return type. +// (Reduced from meta/lexical HeadingNode.$config and effect SchemaAST getParser.) + +// Through a callback returning an instance (lexical). +interface Base { m(): unknown } +>Base : Symbol(Base, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 0, 0)) +>m : Symbol(Base.m, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 9, 16)) + +declare function config(config: { f?: () => Base }): void; +>config : Symbol(config, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 9, 31)) +>config : Symbol(config, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 10, 24)) +>f : Symbol(f, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 10, 33)) +>Base : Symbol(Base, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 0, 0)) + +declare const h: Heading; +>h : Symbol(h, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 12, 13)) +>Heading : Symbol(Heading, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 13, 18)) + +const b: Base = h; +>b : Symbol(b, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 13, 5)) +>Base : Symbol(Base, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 0, 0)) +>h : Symbol(h, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 12, 13)) + +class Heading { +>Heading : Symbol(Heading, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 13, 18)) + + m() { +>m : Symbol(Heading.m, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 15, 15)) + + return config({ f: () => create() }); +>config : Symbol(config, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 9, 31)) +>f : Symbol(f, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 17, 23)) +>create : Symbol(create, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 19, 1)) + } +} + +declare function create(): Heading; +>create : Symbol(create, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 19, 1)) +>Heading : Symbol(Heading, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 13, 18)) + +const r: void = new Heading().m(); +>r : Symbol(r, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 23, 5)) +>new Heading().m : Symbol(Heading.m, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 15, 15)) +>Heading : Symbol(Heading, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 13, 18)) +>m : Symbol(Heading.m, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 15, 15)) + +// Passing `this` directly (effect). +type Parser = (input: unknown) => unknown; +>Parser : Symbol(Parser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 23, 34)) +>input : Symbol(input, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 26, 15)) + +interface NullNode { readonly _tag: "Null"; getParser(): Parser } +>NullNode : Symbol(NullNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 26, 42), Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 5)) +>_tag : Symbol(NullNode._tag, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 27, 20)) +>getParser : Symbol(NullNode.getParser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 27, 43)) +>Parser : Symbol(Parser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 23, 34)) + +interface UndefinedNode { readonly _tag: "Undefined"; getParser(): Parser } +>UndefinedNode : Symbol(UndefinedNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 27, 65)) +>_tag : Symbol(UndefinedNode._tag, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 28, 25)) +>getParser : Symbol(UndefinedNode.getParser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 28, 53)) +>Parser : Symbol(Parser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 23, 34)) + +type AST = NullNode | UndefinedNode; +>AST : Symbol(AST, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 28, 75)) +>NullNode : Symbol(NullNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 26, 42), Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 5)) +>UndefinedNode : Symbol(UndefinedNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 27, 65)) + +declare function fromConst(ast: AST, value: unknown): Parser; +>fromConst : Symbol(fromConst, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 29, 36)) +>ast : Symbol(ast, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 30, 27)) +>AST : Symbol(AST, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 28, 75)) +>value : Symbol(value, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 30, 36)) +>Parser : Symbol(Parser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 23, 34)) + +const NullNode: new () => NullNode = class { +>NullNode : Symbol(NullNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 26, 42), Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 5)) +>NullNode : Symbol(NullNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 26, 42), Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 5)) + + readonly _tag = "Null"; +>_tag : Symbol(NullNode._tag, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 44)) + + getParser() { +>getParser : Symbol(NullNode.getParser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 33, 27)) + + return fromConst(this, null); +>fromConst : Symbol(fromConst, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 29, 36)) +>this : Symbol(NullNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 36)) + } +}; + +const p: Parser = new NullNode().getParser(); +>p : Symbol(p, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 39, 5)) +>Parser : Symbol(Parser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 23, 34)) +>new NullNode().getParser : Symbol(NullNode.getParser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 27, 43)) +>NullNode : Symbol(NullNode, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 26, 42), Decl(circularReturnTypeThroughCallArgumentRelation.ts, 32, 5)) +>getParser : Symbol(NullNode.getParser, Decl(circularReturnTypeThroughCallArgumentRelation.ts, 27, 43)) + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallArgumentRelation(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallArgumentRelation(checkorder=typesfirst).types new file mode 100644 index 0000000000000..21a3ba0434560 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallArgumentRelation(checkorder=typesfirst).types @@ -0,0 +1,102 @@ +//// [tests/cases/compiler/circularReturnTypeThroughCallArgumentRelation.ts] //// + +=== circularReturnTypeThroughCallArgumentRelation.ts === +// Inferring a method's return type resolves a call whose argument check +// relates the method's own class to an interface containing that method, so +// the relation compares the method while its return type is in progress. +// TypeScript reads the in-progress return type as `any` there without failing +// it, and call resolution hides the resolutions below it, so no TS7023 is +// reported in any check order and the method gets the call's return type. +// (Reduced from meta/lexical HeadingNode.$config and effect SchemaAST getParser.) + +// Through a callback returning an instance (lexical). +interface Base { m(): unknown } +>m : () => unknown + +declare function config(config: { f?: () => Base }): void; +>config : (config: { f?: () => Base; }) => void +>config : { f?: () => Base; } +>f : (() => Base) | undefined + +declare const h: Heading; +>h : Heading + +const b: Base = h; +>b : Base +>h : Heading + +class Heading { +>Heading : Heading + + m() { +>m : () => void + + return config({ f: () => create() }); +>config({ f: () => create() }) : void +>config : (config: { f?: () => Base; }) => void +>{ f: () => create() } : { f: () => Heading; } +>f : () => Heading +>() => create() : () => Heading +>create() : Heading +>create : () => Heading + } +} + +declare function create(): Heading; +>create : () => Heading + +const r: void = new Heading().m(); +>r : void +>new Heading().m() : void +>new Heading().m : () => void +>new Heading() : Heading +>Heading : typeof Heading +>m : () => void + +// Passing `this` directly (effect). +type Parser = (input: unknown) => unknown; +>Parser : Parser +>input : unknown + +interface NullNode { readonly _tag: "Null"; getParser(): Parser } +>_tag : "Null" +>getParser : () => Parser + +interface UndefinedNode { readonly _tag: "Undefined"; getParser(): Parser } +>_tag : "Undefined" +>getParser : () => Parser + +type AST = NullNode | UndefinedNode; +>AST : AST + +declare function fromConst(ast: AST, value: unknown): Parser; +>fromConst : (ast: AST, value: unknown) => Parser +>ast : AST +>value : unknown + +const NullNode: new () => NullNode = class { +>NullNode : new () => NullNode +>class { readonly _tag = "Null"; getParser() { return fromConst(this, null); }} : typeof NullNode + + readonly _tag = "Null"; +>_tag : "Null" +>"Null" : "Null" + + getParser() { +>getParser : () => Parser + + return fromConst(this, null); +>fromConst(this, null) : Parser +>fromConst : (ast: AST, value: unknown) => Parser +>this : this + } +}; + +const p: Parser = new NullNode().getParser(); +>p : Parser +>new NullNode().getParser() : Parser +>new NullNode().getParser : () => Parser +>new NullNode() : NullNode +>NullNode : new () => NullNode +>getParser : () => Parser + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=false).symbols b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=false).symbols new file mode 100644 index 0000000000000..6db3b443be191 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=false).symbols @@ -0,0 +1,77 @@ +//// [tests/cases/compiler/circularReturnTypeThroughCallbackArgument.ts] //// + +=== circularReturnTypeThroughCallbackArgument.ts === +declare function fan(g: () => number): number; +>fan : Symbol(fan, Decl(circularReturnTypeThroughCallbackArgument.ts, 0, 0)) +>g : Symbol(g, Decl(circularReturnTypeThroughCallbackArgument.ts, 0, 21)) + +export function a(n: number) { +>a : Symbol(a, Decl(circularReturnTypeThroughCallbackArgument.ts, 0, 46)) +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 2, 18)) + + return fan(() => a(n)); +>fan : Symbol(fan, Decl(circularReturnTypeThroughCallbackArgument.ts, 0, 0)) +>a : Symbol(a, Decl(circularReturnTypeThroughCallbackArgument.ts, 0, 46)) +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 2, 18)) +} + +declare function fanAll(g: () => Promise<{ ok: boolean }>): Promise<{ ok: boolean }>; +>fanAll : Symbol(fanAll, Decl(circularReturnTypeThroughCallbackArgument.ts, 4, 1)) +>g : Symbol(g, Decl(circularReturnTypeThroughCallbackArgument.ts, 6, 24)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>ok : Symbol(ok, Decl(circularReturnTypeThroughCallbackArgument.ts, 6, 42)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>ok : Symbol(ok, Decl(circularReturnTypeThroughCallbackArgument.ts, 6, 69)) + +export async function b(n: number) { +>b : Symbol(b, Decl(circularReturnTypeThroughCallbackArgument.ts, 6, 85)) +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 8, 24)) + + if (n > 0) { +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 8, 24)) + + return fanAll(() => b(n - 1)); +>fanAll : Symbol(fanAll, Decl(circularReturnTypeThroughCallbackArgument.ts, 4, 1)) +>b : Symbol(b, Decl(circularReturnTypeThroughCallbackArgument.ts, 6, 85)) +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 8, 24)) + } + return { ok: true }; +>ok : Symbol(ok, Decl(circularReturnTypeThroughCallbackArgument.ts, 12, 12)) +} + +type Result = { success: boolean; [key: string]: unknown }; +>Result : Symbol(Result, Decl(circularReturnTypeThroughCallbackArgument.ts, 13, 1)) +>success : Symbol(success, Decl(circularReturnTypeThroughCallbackArgument.ts, 15, 15)) +>key : Symbol(key, Decl(circularReturnTypeThroughCallbackArgument.ts, 15, 35)) + +interface Other { success: boolean; url: string } +>Other : Symbol(Other, Decl(circularReturnTypeThroughCallbackArgument.ts, 15, 59)) +>success : Symbol(Other.success, Decl(circularReturnTypeThroughCallbackArgument.ts, 16, 17)) +>url : Symbol(Other.url, Decl(circularReturnTypeThroughCallbackArgument.ts, 16, 35)) + +declare function fanOut(generateOne: () => Promise): Promise; +>fanOut : Symbol(fanOut, Decl(circularReturnTypeThroughCallbackArgument.ts, 16, 49)) +>generateOne : Symbol(generateOne, Decl(circularReturnTypeThroughCallbackArgument.ts, 17, 24)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Result : Symbol(Result, Decl(circularReturnTypeThroughCallbackArgument.ts, 13, 1)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Result : Symbol(Result, Decl(circularReturnTypeThroughCallbackArgument.ts, 13, 1)) + +declare const other: Other; +>other : Symbol(other, Decl(circularReturnTypeThroughCallbackArgument.ts, 18, 13)) +>Other : Symbol(Other, Decl(circularReturnTypeThroughCallbackArgument.ts, 15, 59)) + +export async function c(n: number) { +>c : Symbol(c, Decl(circularReturnTypeThroughCallbackArgument.ts, 18, 27)) +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 20, 24)) + + if (n) return other; +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 20, 24)) +>other : Symbol(other, Decl(circularReturnTypeThroughCallbackArgument.ts, 18, 13)) + + return fanOut(() => c(n - 1)); +>fanOut : Symbol(fanOut, Decl(circularReturnTypeThroughCallbackArgument.ts, 16, 49)) +>c : Symbol(c, Decl(circularReturnTypeThroughCallbackArgument.ts, 18, 27)) +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 20, 24)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=false).types b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=false).types new file mode 100644 index 0000000000000..fb9e85bf2b1d7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=false).types @@ -0,0 +1,86 @@ +//// [tests/cases/compiler/circularReturnTypeThroughCallbackArgument.ts] //// + +=== circularReturnTypeThroughCallbackArgument.ts === +declare function fan(g: () => number): number; +>fan : (g: () => number) => number +>g : () => number + +export function a(n: number) { +>a : (n: number) => any +>n : number + + return fan(() => a(n)); +>fan(() => a(n)) : number +>fan : (g: () => number) => number +>() => a(n) : () => any +>a(n) : any +>a : (n: number) => any +>n : number +} + +declare function fanAll(g: () => Promise<{ ok: boolean }>): Promise<{ ok: boolean }>; +>fanAll : (g: () => Promise<{ ok: boolean; }>) => Promise<{ ok: boolean; }> +>g : () => Promise<{ ok: boolean; }> +>ok : boolean +>ok : boolean + +export async function b(n: number) { +>b : (n: number) => any +>n : number + + if (n > 0) { +>n > 0 : boolean +>n : number +>0 : 0 + + return fanAll(() => b(n - 1)); +>fanAll(() => b(n - 1)) : Promise<{ ok: boolean; }> +>fanAll : (g: () => Promise<{ ok: boolean; }>) => Promise<{ ok: boolean; }> +>() => b(n - 1) : () => any +>b(n - 1) : any +>b : (n: number) => any +>n - 1 : number +>n : number +>1 : 1 + } + return { ok: true }; +>{ ok: true } : { ok: boolean; } +>ok : boolean +>true : true +} + +type Result = { success: boolean; [key: string]: unknown }; +>Result : Result +>success : boolean +>key : string + +interface Other { success: boolean; url: string } +>success : boolean +>url : string + +declare function fanOut(generateOne: () => Promise): Promise; +>fanOut : (generateOne: () => Promise) => Promise +>generateOne : () => Promise + +declare const other: Other; +>other : Other + +export async function c(n: number) { +>c : (n: number) => any +>n : number + + if (n) return other; +>n : number +>other : Other + + return fanOut(() => c(n - 1)); +>fanOut(() => c(n - 1)) : Promise +>fanOut : (generateOne: () => Promise) => Promise +>() => c(n - 1) : () => any +>c(n - 1) : any +>c : (n: number) => any +>n - 1 : number +>n : number +>1 : 1 +} + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=true).errors.txt b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=true).errors.txt new file mode 100644 index 0000000000000..a10fc6bcbe59c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=true).errors.txt @@ -0,0 +1,46 @@ +circularReturnTypeThroughCallbackArgument.ts(3,17): error TS7023: 'a' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +circularReturnTypeThroughCallbackArgument.ts(4,16): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +circularReturnTypeThroughCallbackArgument.ts(9,23): error TS7023: 'b' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +circularReturnTypeThroughCallbackArgument.ts(11,23): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +circularReturnTypeThroughCallbackArgument.ts(21,23): error TS7023: 'c' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +circularReturnTypeThroughCallbackArgument.ts(23,19): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. + + +==== circularReturnTypeThroughCallbackArgument.ts (6 errors) ==== + declare function fan(g: () => number): number; + + export function a(n: number) { + ~ +!!! error TS7023: 'a' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. + return fan(() => a(n)); + ~~~~~~~~~~ +!!! error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. + } + + declare function fanAll(g: () => Promise<{ ok: boolean }>): Promise<{ ok: boolean }>; + + export async function b(n: number) { + ~ +!!! error TS7023: 'b' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. + if (n > 0) { + return fanAll(() => b(n - 1)); + ~~~~~~~~~~~~~~ +!!! error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. + } + return { ok: true }; + } + + type Result = { success: boolean; [key: string]: unknown }; + interface Other { success: boolean; url: string } + declare function fanOut(generateOne: () => Promise): Promise; + declare const other: Other; + + export async function c(n: number) { + ~ +!!! error TS7023: 'c' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. + if (n) return other; + return fanOut(() => c(n - 1)); + ~~~~~~~~~~~~~~ +!!! error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=true).symbols b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=true).symbols new file mode 100644 index 0000000000000..6db3b443be191 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=true).symbols @@ -0,0 +1,77 @@ +//// [tests/cases/compiler/circularReturnTypeThroughCallbackArgument.ts] //// + +=== circularReturnTypeThroughCallbackArgument.ts === +declare function fan(g: () => number): number; +>fan : Symbol(fan, Decl(circularReturnTypeThroughCallbackArgument.ts, 0, 0)) +>g : Symbol(g, Decl(circularReturnTypeThroughCallbackArgument.ts, 0, 21)) + +export function a(n: number) { +>a : Symbol(a, Decl(circularReturnTypeThroughCallbackArgument.ts, 0, 46)) +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 2, 18)) + + return fan(() => a(n)); +>fan : Symbol(fan, Decl(circularReturnTypeThroughCallbackArgument.ts, 0, 0)) +>a : Symbol(a, Decl(circularReturnTypeThroughCallbackArgument.ts, 0, 46)) +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 2, 18)) +} + +declare function fanAll(g: () => Promise<{ ok: boolean }>): Promise<{ ok: boolean }>; +>fanAll : Symbol(fanAll, Decl(circularReturnTypeThroughCallbackArgument.ts, 4, 1)) +>g : Symbol(g, Decl(circularReturnTypeThroughCallbackArgument.ts, 6, 24)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>ok : Symbol(ok, Decl(circularReturnTypeThroughCallbackArgument.ts, 6, 42)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>ok : Symbol(ok, Decl(circularReturnTypeThroughCallbackArgument.ts, 6, 69)) + +export async function b(n: number) { +>b : Symbol(b, Decl(circularReturnTypeThroughCallbackArgument.ts, 6, 85)) +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 8, 24)) + + if (n > 0) { +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 8, 24)) + + return fanAll(() => b(n - 1)); +>fanAll : Symbol(fanAll, Decl(circularReturnTypeThroughCallbackArgument.ts, 4, 1)) +>b : Symbol(b, Decl(circularReturnTypeThroughCallbackArgument.ts, 6, 85)) +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 8, 24)) + } + return { ok: true }; +>ok : Symbol(ok, Decl(circularReturnTypeThroughCallbackArgument.ts, 12, 12)) +} + +type Result = { success: boolean; [key: string]: unknown }; +>Result : Symbol(Result, Decl(circularReturnTypeThroughCallbackArgument.ts, 13, 1)) +>success : Symbol(success, Decl(circularReturnTypeThroughCallbackArgument.ts, 15, 15)) +>key : Symbol(key, Decl(circularReturnTypeThroughCallbackArgument.ts, 15, 35)) + +interface Other { success: boolean; url: string } +>Other : Symbol(Other, Decl(circularReturnTypeThroughCallbackArgument.ts, 15, 59)) +>success : Symbol(Other.success, Decl(circularReturnTypeThroughCallbackArgument.ts, 16, 17)) +>url : Symbol(Other.url, Decl(circularReturnTypeThroughCallbackArgument.ts, 16, 35)) + +declare function fanOut(generateOne: () => Promise): Promise; +>fanOut : Symbol(fanOut, Decl(circularReturnTypeThroughCallbackArgument.ts, 16, 49)) +>generateOne : Symbol(generateOne, Decl(circularReturnTypeThroughCallbackArgument.ts, 17, 24)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Result : Symbol(Result, Decl(circularReturnTypeThroughCallbackArgument.ts, 13, 1)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Result : Symbol(Result, Decl(circularReturnTypeThroughCallbackArgument.ts, 13, 1)) + +declare const other: Other; +>other : Symbol(other, Decl(circularReturnTypeThroughCallbackArgument.ts, 18, 13)) +>Other : Symbol(Other, Decl(circularReturnTypeThroughCallbackArgument.ts, 15, 59)) + +export async function c(n: number) { +>c : Symbol(c, Decl(circularReturnTypeThroughCallbackArgument.ts, 18, 27)) +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 20, 24)) + + if (n) return other; +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 20, 24)) +>other : Symbol(other, Decl(circularReturnTypeThroughCallbackArgument.ts, 18, 13)) + + return fanOut(() => c(n - 1)); +>fanOut : Symbol(fanOut, Decl(circularReturnTypeThroughCallbackArgument.ts, 16, 49)) +>c : Symbol(c, Decl(circularReturnTypeThroughCallbackArgument.ts, 18, 27)) +>n : Symbol(n, Decl(circularReturnTypeThroughCallbackArgument.ts, 20, 24)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=true).types b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=true).types new file mode 100644 index 0000000000000..fb9e85bf2b1d7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughCallbackArgument(strict=true).types @@ -0,0 +1,86 @@ +//// [tests/cases/compiler/circularReturnTypeThroughCallbackArgument.ts] //// + +=== circularReturnTypeThroughCallbackArgument.ts === +declare function fan(g: () => number): number; +>fan : (g: () => number) => number +>g : () => number + +export function a(n: number) { +>a : (n: number) => any +>n : number + + return fan(() => a(n)); +>fan(() => a(n)) : number +>fan : (g: () => number) => number +>() => a(n) : () => any +>a(n) : any +>a : (n: number) => any +>n : number +} + +declare function fanAll(g: () => Promise<{ ok: boolean }>): Promise<{ ok: boolean }>; +>fanAll : (g: () => Promise<{ ok: boolean; }>) => Promise<{ ok: boolean; }> +>g : () => Promise<{ ok: boolean; }> +>ok : boolean +>ok : boolean + +export async function b(n: number) { +>b : (n: number) => any +>n : number + + if (n > 0) { +>n > 0 : boolean +>n : number +>0 : 0 + + return fanAll(() => b(n - 1)); +>fanAll(() => b(n - 1)) : Promise<{ ok: boolean; }> +>fanAll : (g: () => Promise<{ ok: boolean; }>) => Promise<{ ok: boolean; }> +>() => b(n - 1) : () => any +>b(n - 1) : any +>b : (n: number) => any +>n - 1 : number +>n : number +>1 : 1 + } + return { ok: true }; +>{ ok: true } : { ok: boolean; } +>ok : boolean +>true : true +} + +type Result = { success: boolean; [key: string]: unknown }; +>Result : Result +>success : boolean +>key : string + +interface Other { success: boolean; url: string } +>success : boolean +>url : string + +declare function fanOut(generateOne: () => Promise): Promise; +>fanOut : (generateOne: () => Promise) => Promise +>generateOne : () => Promise + +declare const other: Other; +>other : Other + +export async function c(n: number) { +>c : (n: number) => any +>n : number + + if (n) return other; +>n : number +>other : Other + + return fanOut(() => c(n - 1)); +>fanOut(() => c(n - 1)) : Promise +>fanOut : (generateOne: () => Promise) => Promise +>() => c(n - 1) : () => any +>c(n - 1) : any +>c : (n: number) => any +>n - 1 : number +>n : number +>1 : 1 +} + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughUncontextualCallbackArgument(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughUncontextualCallbackArgument(checkorder=default).symbols new file mode 100644 index 0000000000000..f53077d24860e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughUncontextualCallbackArgument(checkorder=default).symbols @@ -0,0 +1,38 @@ +//// [tests/cases/compiler/circularReturnTypeThroughUncontextualCallbackArgument.ts] //// + +=== circularReturnTypeThroughUncontextualCallbackArgument.ts === +// `getCreds`'s return type depends on resolving `materialize({ next })`, whose +// argument check needs the return type of the (non-contextually typed) arrow +// `next`, which calls `getCreds` again. TypeScript never reports this cycle in +// any order: call resolution hides the resolutions below it, and the relation +// reads an in-progress return type as `any` without failing it. So no TS7023, +// and `getCreds` returns `number`. (Reduced from OmniRoute auth.ts +// getProviderCredentials/selectNextLeaseCandidate.) + +const x = getCreds(); +>x : Symbol(x, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 8, 5)) +>getCreds : Symbol(getCreds, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 80)) + +declare function materialize(extra: { next?: (id: string) => unknown }): number; +>materialize : Symbol(materialize, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 8, 21)) +>extra : Symbol(extra, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 29)) +>next : Symbol(next, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 37)) +>id : Symbol(id, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 46)) + +function getCreds() { +>getCreds : Symbol(getCreds, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 80)) + + const next = (id: string) => getCreds(); +>next : Symbol(next, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 13, 9)) +>id : Symbol(id, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 13, 18)) +>getCreds : Symbol(getCreds, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 80)) + + return materialize({ next }); +>materialize : Symbol(materialize, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 8, 21)) +>next : Symbol(next, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 14, 24)) +} + +const n: number = getCreds(); +>n : Symbol(n, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 17, 5)) +>getCreds : Symbol(getCreds, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 80)) + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughUncontextualCallbackArgument(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughUncontextualCallbackArgument(checkorder=default).types new file mode 100644 index 0000000000000..5cf5a07fe7c0a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughUncontextualCallbackArgument(checkorder=default).types @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/circularReturnTypeThroughUncontextualCallbackArgument.ts] //// + +=== circularReturnTypeThroughUncontextualCallbackArgument.ts === +// `getCreds`'s return type depends on resolving `materialize({ next })`, whose +// argument check needs the return type of the (non-contextually typed) arrow +// `next`, which calls `getCreds` again. TypeScript never reports this cycle in +// any order: call resolution hides the resolutions below it, and the relation +// reads an in-progress return type as `any` without failing it. So no TS7023, +// and `getCreds` returns `number`. (Reduced from OmniRoute auth.ts +// getProviderCredentials/selectNextLeaseCandidate.) + +const x = getCreds(); +>x : number +>getCreds() : number +>getCreds : () => number + +declare function materialize(extra: { next?: (id: string) => unknown }): number; +>materialize : (extra: { next?: (id: string) => unknown; }) => number +>extra : { next?: (id: string) => unknown; } +>next : ((id: string) => unknown) | undefined +>id : string + +function getCreds() { +>getCreds : () => number + + const next = (id: string) => getCreds(); +>next : (id: string) => number +>(id: string) => getCreds() : (id: string) => number +>id : string +>getCreds() : number +>getCreds : () => number + + return materialize({ next }); +>materialize({ next }) : number +>materialize : (extra: { next?: (id: string) => unknown; }) => number +>{ next } : { next: (id: string) => number; } +>next : (id: string) => number +} + +const n: number = getCreds(); +>n : number +>getCreds() : number +>getCreds : () => number + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughUncontextualCallbackArgument(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughUncontextualCallbackArgument(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..f53077d24860e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughUncontextualCallbackArgument(checkorder=typesfirst).symbols @@ -0,0 +1,38 @@ +//// [tests/cases/compiler/circularReturnTypeThroughUncontextualCallbackArgument.ts] //// + +=== circularReturnTypeThroughUncontextualCallbackArgument.ts === +// `getCreds`'s return type depends on resolving `materialize({ next })`, whose +// argument check needs the return type of the (non-contextually typed) arrow +// `next`, which calls `getCreds` again. TypeScript never reports this cycle in +// any order: call resolution hides the resolutions below it, and the relation +// reads an in-progress return type as `any` without failing it. So no TS7023, +// and `getCreds` returns `number`. (Reduced from OmniRoute auth.ts +// getProviderCredentials/selectNextLeaseCandidate.) + +const x = getCreds(); +>x : Symbol(x, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 8, 5)) +>getCreds : Symbol(getCreds, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 80)) + +declare function materialize(extra: { next?: (id: string) => unknown }): number; +>materialize : Symbol(materialize, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 8, 21)) +>extra : Symbol(extra, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 29)) +>next : Symbol(next, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 37)) +>id : Symbol(id, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 46)) + +function getCreds() { +>getCreds : Symbol(getCreds, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 80)) + + const next = (id: string) => getCreds(); +>next : Symbol(next, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 13, 9)) +>id : Symbol(id, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 13, 18)) +>getCreds : Symbol(getCreds, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 80)) + + return materialize({ next }); +>materialize : Symbol(materialize, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 8, 21)) +>next : Symbol(next, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 14, 24)) +} + +const n: number = getCreds(); +>n : Symbol(n, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 17, 5)) +>getCreds : Symbol(getCreds, Decl(circularReturnTypeThroughUncontextualCallbackArgument.ts, 10, 80)) + diff --git a/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughUncontextualCallbackArgument(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughUncontextualCallbackArgument(checkorder=typesfirst).types new file mode 100644 index 0000000000000..5cf5a07fe7c0a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularReturnTypeThroughUncontextualCallbackArgument(checkorder=typesfirst).types @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/circularReturnTypeThroughUncontextualCallbackArgument.ts] //// + +=== circularReturnTypeThroughUncontextualCallbackArgument.ts === +// `getCreds`'s return type depends on resolving `materialize({ next })`, whose +// argument check needs the return type of the (non-contextually typed) arrow +// `next`, which calls `getCreds` again. TypeScript never reports this cycle in +// any order: call resolution hides the resolutions below it, and the relation +// reads an in-progress return type as `any` without failing it. So no TS7023, +// and `getCreds` returns `number`. (Reduced from OmniRoute auth.ts +// getProviderCredentials/selectNextLeaseCandidate.) + +const x = getCreds(); +>x : number +>getCreds() : number +>getCreds : () => number + +declare function materialize(extra: { next?: (id: string) => unknown }): number; +>materialize : (extra: { next?: (id: string) => unknown; }) => number +>extra : { next?: (id: string) => unknown; } +>next : ((id: string) => unknown) | undefined +>id : string + +function getCreds() { +>getCreds : () => number + + const next = (id: string) => getCreds(); +>next : (id: string) => number +>(id: string) => getCreds() : (id: string) => number +>id : string +>getCreds() : number +>getCreds : () => number + + return materialize({ next }); +>materialize({ next }) : number +>materialize : (extra: { next?: (id: string) => unknown; }) => number +>{ next } : { next: (id: string) => number; } +>next : (id: string) => number +} + +const n: number = getCreds(); +>n : number +>getCreds() : number +>getCreds : () => number + diff --git a/tsc/testdata/baselines/reference/compiler/circularScopeThunkReverseMapped(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/circularScopeThunkReverseMapped(checkorder=default).symbols new file mode 100644 index 0000000000000..cefed83354abf --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularScopeThunkReverseMapped(checkorder=default).symbols @@ -0,0 +1,121 @@ +//// [tests/cases/compiler/circularScopeThunkReverseMapped.ts] //// + +=== circularScopeThunkReverseMapped.ts === +type Resolve = T extends () => infer R ? R : T; +>Resolve : Symbol(Resolve, Decl(circularScopeThunkReverseMapped.ts, 0, 0)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 0, 13)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 0, 13)) +>R : Symbol(R, Decl(circularScopeThunkReverseMapped.ts, 0, 39)) +>R : Symbol(R, Decl(circularScopeThunkReverseMapped.ts, 0, 39)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 0, 13)) + +type Validate = { [K in keyof def]: def[K] extends () => infer R ? () => R : def[K] }; +>Validate : Symbol(Validate, Decl(circularScopeThunkReverseMapped.ts, 0, 50)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 1, 14)) +>K : Symbol(K, Decl(circularScopeThunkReverseMapped.ts, 1, 24)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 1, 14)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 1, 14)) +>K : Symbol(K, Decl(circularScopeThunkReverseMapped.ts, 1, 24)) +>R : Symbol(R, Decl(circularScopeThunkReverseMapped.ts, 1, 67)) +>R : Symbol(R, Decl(circularScopeThunkReverseMapped.ts, 1, 67)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 1, 14)) +>K : Symbol(K, Decl(circularScopeThunkReverseMapped.ts, 1, 24)) + +interface Scope { +>Scope : Symbol(Scope, Decl(circularScopeThunkReverseMapped.ts, 1, 91)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 2, 16)) + + type(k: k): Resolve; +>type : Symbol(Scope.type, Decl(circularScopeThunkReverseMapped.ts, 2, 22)) +>k : Symbol(k, Decl(circularScopeThunkReverseMapped.ts, 3, 9), Decl(circularScopeThunkReverseMapped.ts, 3, 30)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 2, 16)) +>k : Symbol(k, Decl(circularScopeThunkReverseMapped.ts, 3, 9), Decl(circularScopeThunkReverseMapped.ts, 3, 30)) +>k : Symbol(k, Decl(circularScopeThunkReverseMapped.ts, 3, 9), Decl(circularScopeThunkReverseMapped.ts, 3, 30)) +>Resolve : Symbol(Resolve, Decl(circularScopeThunkReverseMapped.ts, 0, 0)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 2, 16)) +>k : Symbol(k, Decl(circularScopeThunkReverseMapped.ts, 3, 9), Decl(circularScopeThunkReverseMapped.ts, 3, 30)) +} +interface Type { +>Type : Symbol(Type, Decl(circularScopeThunkReverseMapped.ts, 4, 1)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 5, 15)) + + pipe(f: (x: T) => U): Type; +>pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>U : Symbol(U, Decl(circularScopeThunkReverseMapped.ts, 6, 9)) +>f : Symbol(f, Decl(circularScopeThunkReverseMapped.ts, 6, 12)) +>x : Symbol(x, Decl(circularScopeThunkReverseMapped.ts, 6, 16)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 5, 15)) +>U : Symbol(U, Decl(circularScopeThunkReverseMapped.ts, 6, 9)) +>Type : Symbol(Type, Decl(circularScopeThunkReverseMapped.ts, 4, 1)) +>U : Symbol(U, Decl(circularScopeThunkReverseMapped.ts, 6, 9)) +} +declare function scope(def: Validate): Scope; +>scope : Symbol(scope, Decl(circularScopeThunkReverseMapped.ts, 7, 1)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 8, 23), Decl(circularScopeThunkReverseMapped.ts, 8, 34)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 8, 23), Decl(circularScopeThunkReverseMapped.ts, 8, 34)) +>Validate : Symbol(Validate, Decl(circularScopeThunkReverseMapped.ts, 0, 50)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 8, 23), Decl(circularScopeThunkReverseMapped.ts, 8, 34)) +>Scope : Symbol(Scope, Decl(circularScopeThunkReverseMapped.ts, 1, 91)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 8, 23), Decl(circularScopeThunkReverseMapped.ts, 8, 34)) + +declare function type(x: T): Type; +>type : Symbol(type, Decl(circularScopeThunkReverseMapped.ts, 8, 66)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 9, 22)) +>x : Symbol(x, Decl(circularScopeThunkReverseMapped.ts, 9, 25)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 9, 22)) +>Type : Symbol(Type, Decl(circularScopeThunkReverseMapped.ts, 4, 1)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 9, 22)) + +export const $ = scope({ +>$ : Symbol($, Decl(circularScopeThunkReverseMapped.ts, 11, 12)) +>scope : Symbol(scope, Decl(circularScopeThunkReverseMapped.ts, 7, 1)) + + a: type("string").pipe(function (s) { return s.length; }), +>a : Symbol(a, Decl(circularScopeThunkReverseMapped.ts, 11, 24)) +>type("string").pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>type : Symbol(type, Decl(circularScopeThunkReverseMapped.ts, 8, 66)) +>pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>s : Symbol(s, Decl(circularScopeThunkReverseMapped.ts, 12, 37)) +>s.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(circularScopeThunkReverseMapped.ts, 12, 37)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + b: () => $.type("a").pipe(function (n) { return n === 0; }), +>b : Symbol(b, Decl(circularScopeThunkReverseMapped.ts, 12, 62)) +>$.type("a").pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>$.type : Symbol(Scope.type, Decl(circularScopeThunkReverseMapped.ts, 2, 22)) +>$ : Symbol($, Decl(circularScopeThunkReverseMapped.ts, 11, 12)) +>type : Symbol(Scope.type, Decl(circularScopeThunkReverseMapped.ts, 2, 22)) +>pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>n : Symbol(n, Decl(circularScopeThunkReverseMapped.ts, 13, 40)) +>n : Symbol(n, Decl(circularScopeThunkReverseMapped.ts, 13, 40)) + +}); + +// Entered from the function in the first property when queried in reverse +export const $2 = scope({ +>$2 : Symbol($2, Decl(circularScopeThunkReverseMapped.ts, 17, 12)) +>scope : Symbol(scope, Decl(circularScopeThunkReverseMapped.ts, 7, 1)) + + a: type("string").pipe(function (s) { return s.length; }), +>a : Symbol(a, Decl(circularScopeThunkReverseMapped.ts, 17, 25)) +>type("string").pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>type : Symbol(type, Decl(circularScopeThunkReverseMapped.ts, 8, 66)) +>pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>s : Symbol(s, Decl(circularScopeThunkReverseMapped.ts, 18, 37)) +>s.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(circularScopeThunkReverseMapped.ts, 18, 37)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + b: () => $2.type("a").pipe((n: number) => n === 0), +>b : Symbol(b, Decl(circularScopeThunkReverseMapped.ts, 18, 62)) +>$2.type("a").pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>$2.type : Symbol(Scope.type, Decl(circularScopeThunkReverseMapped.ts, 2, 22)) +>$2 : Symbol($2, Decl(circularScopeThunkReverseMapped.ts, 17, 12)) +>type : Symbol(Scope.type, Decl(circularScopeThunkReverseMapped.ts, 2, 22)) +>pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>n : Symbol(n, Decl(circularScopeThunkReverseMapped.ts, 19, 32)) +>n : Symbol(n, Decl(circularScopeThunkReverseMapped.ts, 19, 32)) + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/circularScopeThunkReverseMapped(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/circularScopeThunkReverseMapped(checkorder=default).types new file mode 100644 index 0000000000000..41f30b7dbe3f2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularScopeThunkReverseMapped(checkorder=default).types @@ -0,0 +1,107 @@ +//// [tests/cases/compiler/circularScopeThunkReverseMapped.ts] //// + +=== circularScopeThunkReverseMapped.ts === +type Resolve = T extends () => infer R ? R : T; +>Resolve : Resolve + +type Validate = { [K in keyof def]: def[K] extends () => infer R ? () => R : def[K] }; +>Validate : Validate + +interface Scope { + type(k: k): Resolve; +>type : (k: k) => Resolve +>k : k +} +interface Type { + pipe(f: (x: T) => U): Type; +>pipe : (f: (x: T) => U) => Type +>f : (x: T) => U +>x : T +} +declare function scope(def: Validate): Scope; +>scope : (def: Validate) => Scope +>def : Validate + +declare function type(x: T): Type; +>type : (x: T) => Type +>x : T + +export const $ = scope({ +>$ : Scope<{ a: Type; b: unknown; }> +>scope({ a: type("string").pipe(function (s) { return s.length; }), b: () => $.type("a").pipe(function (n) { return n === 0; }),}) : Scope<{ a: Type; b: unknown; }> +>scope : (def: Validate) => Scope +>{ a: type("string").pipe(function (s) { return s.length; }), b: () => $.type("a").pipe(function (n) { return n === 0; }),} : { a: Type; b: () => Type; } + + a: type("string").pipe(function (s) { return s.length; }), +>a : Type +>type("string").pipe(function (s) { return s.length; }) : Type +>type("string").pipe : (f: (x: string) => U) => Type +>type("string") : Type +>type : (x: T) => Type +>"string" : "string" +>pipe : (f: (x: string) => U) => Type +>function (s) { return s.length; } : (s: string) => number +>s : string +>s.length : number +>s : string +>length : number + + b: () => $.type("a").pipe(function (n) { return n === 0; }), +>b : () => Type +>() => $.type("a").pipe(function (n) { return n === 0; }) : () => Type +>$.type("a").pipe(function (n) { return n === 0; }) : Type +>$.type("a").pipe : (f: (x: number) => U) => Type +>$.type("a") : Type +>$.type : (k: k_1) => Resolve<{ a: Type; b: unknown; }[k_1]> +>$ : Scope<{ a: Type; b: unknown; }> +>type : (k: k_1) => Resolve<{ a: Type; b: unknown; }[k_1]> +>"a" : "a" +>pipe : (f: (x: number) => U) => Type +>function (n) { return n === 0; } : (n: number) => n is 0 +>n : number +>n === 0 : boolean +>n : number +>0 : 0 + +}); + +// Entered from the function in the first property when queried in reverse +export const $2 = scope({ +>$2 : Scope<{ a: Type; b: unknown; }> +>scope({ a: type("string").pipe(function (s) { return s.length; }), b: () => $2.type("a").pipe((n: number) => n === 0),}) : Scope<{ a: Type; b: unknown; }> +>scope : (def: Validate) => Scope +>{ a: type("string").pipe(function (s) { return s.length; }), b: () => $2.type("a").pipe((n: number) => n === 0),} : { a: Type; b: () => Type; } + + a: type("string").pipe(function (s) { return s.length; }), +>a : Type +>type("string").pipe(function (s) { return s.length; }) : Type +>type("string").pipe : (f: (x: string) => U) => Type +>type("string") : Type +>type : (x: T) => Type +>"string" : "string" +>pipe : (f: (x: string) => U) => Type +>function (s) { return s.length; } : (s: string) => number +>s : string +>s.length : number +>s : string +>length : number + + b: () => $2.type("a").pipe((n: number) => n === 0), +>b : () => Type +>() => $2.type("a").pipe((n: number) => n === 0) : () => Type +>$2.type("a").pipe((n: number) => n === 0) : Type +>$2.type("a").pipe : (f: (x: number) => U) => Type +>$2.type("a") : Type +>$2.type : (k: k_1) => Resolve<{ a: Type; b: unknown; }[k_1]> +>$2 : Scope<{ a: Type; b: unknown; }> +>type : (k: k_1) => Resolve<{ a: Type; b: unknown; }[k_1]> +>"a" : "a" +>pipe : (f: (x: number) => U) => Type +>(n: number) => n === 0 : (n: number) => n is 0 +>n : number +>n === 0 : boolean +>n : number +>0 : 0 + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/circularScopeThunkReverseMapped(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/circularScopeThunkReverseMapped(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..cefed83354abf --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularScopeThunkReverseMapped(checkorder=typesfirst).symbols @@ -0,0 +1,121 @@ +//// [tests/cases/compiler/circularScopeThunkReverseMapped.ts] //// + +=== circularScopeThunkReverseMapped.ts === +type Resolve = T extends () => infer R ? R : T; +>Resolve : Symbol(Resolve, Decl(circularScopeThunkReverseMapped.ts, 0, 0)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 0, 13)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 0, 13)) +>R : Symbol(R, Decl(circularScopeThunkReverseMapped.ts, 0, 39)) +>R : Symbol(R, Decl(circularScopeThunkReverseMapped.ts, 0, 39)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 0, 13)) + +type Validate = { [K in keyof def]: def[K] extends () => infer R ? () => R : def[K] }; +>Validate : Symbol(Validate, Decl(circularScopeThunkReverseMapped.ts, 0, 50)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 1, 14)) +>K : Symbol(K, Decl(circularScopeThunkReverseMapped.ts, 1, 24)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 1, 14)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 1, 14)) +>K : Symbol(K, Decl(circularScopeThunkReverseMapped.ts, 1, 24)) +>R : Symbol(R, Decl(circularScopeThunkReverseMapped.ts, 1, 67)) +>R : Symbol(R, Decl(circularScopeThunkReverseMapped.ts, 1, 67)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 1, 14)) +>K : Symbol(K, Decl(circularScopeThunkReverseMapped.ts, 1, 24)) + +interface Scope { +>Scope : Symbol(Scope, Decl(circularScopeThunkReverseMapped.ts, 1, 91)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 2, 16)) + + type(k: k): Resolve; +>type : Symbol(Scope.type, Decl(circularScopeThunkReverseMapped.ts, 2, 22)) +>k : Symbol(k, Decl(circularScopeThunkReverseMapped.ts, 3, 9), Decl(circularScopeThunkReverseMapped.ts, 3, 30)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 2, 16)) +>k : Symbol(k, Decl(circularScopeThunkReverseMapped.ts, 3, 9), Decl(circularScopeThunkReverseMapped.ts, 3, 30)) +>k : Symbol(k, Decl(circularScopeThunkReverseMapped.ts, 3, 9), Decl(circularScopeThunkReverseMapped.ts, 3, 30)) +>Resolve : Symbol(Resolve, Decl(circularScopeThunkReverseMapped.ts, 0, 0)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 2, 16)) +>k : Symbol(k, Decl(circularScopeThunkReverseMapped.ts, 3, 9), Decl(circularScopeThunkReverseMapped.ts, 3, 30)) +} +interface Type { +>Type : Symbol(Type, Decl(circularScopeThunkReverseMapped.ts, 4, 1)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 5, 15)) + + pipe(f: (x: T) => U): Type; +>pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>U : Symbol(U, Decl(circularScopeThunkReverseMapped.ts, 6, 9)) +>f : Symbol(f, Decl(circularScopeThunkReverseMapped.ts, 6, 12)) +>x : Symbol(x, Decl(circularScopeThunkReverseMapped.ts, 6, 16)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 5, 15)) +>U : Symbol(U, Decl(circularScopeThunkReverseMapped.ts, 6, 9)) +>Type : Symbol(Type, Decl(circularScopeThunkReverseMapped.ts, 4, 1)) +>U : Symbol(U, Decl(circularScopeThunkReverseMapped.ts, 6, 9)) +} +declare function scope(def: Validate): Scope; +>scope : Symbol(scope, Decl(circularScopeThunkReverseMapped.ts, 7, 1)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 8, 23), Decl(circularScopeThunkReverseMapped.ts, 8, 34)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 8, 23), Decl(circularScopeThunkReverseMapped.ts, 8, 34)) +>Validate : Symbol(Validate, Decl(circularScopeThunkReverseMapped.ts, 0, 50)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 8, 23), Decl(circularScopeThunkReverseMapped.ts, 8, 34)) +>Scope : Symbol(Scope, Decl(circularScopeThunkReverseMapped.ts, 1, 91)) +>def : Symbol(def, Decl(circularScopeThunkReverseMapped.ts, 8, 23), Decl(circularScopeThunkReverseMapped.ts, 8, 34)) + +declare function type(x: T): Type; +>type : Symbol(type, Decl(circularScopeThunkReverseMapped.ts, 8, 66)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 9, 22)) +>x : Symbol(x, Decl(circularScopeThunkReverseMapped.ts, 9, 25)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 9, 22)) +>Type : Symbol(Type, Decl(circularScopeThunkReverseMapped.ts, 4, 1)) +>T : Symbol(T, Decl(circularScopeThunkReverseMapped.ts, 9, 22)) + +export const $ = scope({ +>$ : Symbol($, Decl(circularScopeThunkReverseMapped.ts, 11, 12)) +>scope : Symbol(scope, Decl(circularScopeThunkReverseMapped.ts, 7, 1)) + + a: type("string").pipe(function (s) { return s.length; }), +>a : Symbol(a, Decl(circularScopeThunkReverseMapped.ts, 11, 24)) +>type("string").pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>type : Symbol(type, Decl(circularScopeThunkReverseMapped.ts, 8, 66)) +>pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>s : Symbol(s, Decl(circularScopeThunkReverseMapped.ts, 12, 37)) +>s.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(circularScopeThunkReverseMapped.ts, 12, 37)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + b: () => $.type("a").pipe(function (n) { return n === 0; }), +>b : Symbol(b, Decl(circularScopeThunkReverseMapped.ts, 12, 62)) +>$.type("a").pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>$.type : Symbol(Scope.type, Decl(circularScopeThunkReverseMapped.ts, 2, 22)) +>$ : Symbol($, Decl(circularScopeThunkReverseMapped.ts, 11, 12)) +>type : Symbol(Scope.type, Decl(circularScopeThunkReverseMapped.ts, 2, 22)) +>pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>n : Symbol(n, Decl(circularScopeThunkReverseMapped.ts, 13, 40)) +>n : Symbol(n, Decl(circularScopeThunkReverseMapped.ts, 13, 40)) + +}); + +// Entered from the function in the first property when queried in reverse +export const $2 = scope({ +>$2 : Symbol($2, Decl(circularScopeThunkReverseMapped.ts, 17, 12)) +>scope : Symbol(scope, Decl(circularScopeThunkReverseMapped.ts, 7, 1)) + + a: type("string").pipe(function (s) { return s.length; }), +>a : Symbol(a, Decl(circularScopeThunkReverseMapped.ts, 17, 25)) +>type("string").pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>type : Symbol(type, Decl(circularScopeThunkReverseMapped.ts, 8, 66)) +>pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>s : Symbol(s, Decl(circularScopeThunkReverseMapped.ts, 18, 37)) +>s.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(circularScopeThunkReverseMapped.ts, 18, 37)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + b: () => $2.type("a").pipe((n: number) => n === 0), +>b : Symbol(b, Decl(circularScopeThunkReverseMapped.ts, 18, 62)) +>$2.type("a").pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>$2.type : Symbol(Scope.type, Decl(circularScopeThunkReverseMapped.ts, 2, 22)) +>$2 : Symbol($2, Decl(circularScopeThunkReverseMapped.ts, 17, 12)) +>type : Symbol(Scope.type, Decl(circularScopeThunkReverseMapped.ts, 2, 22)) +>pipe : Symbol(Type.pipe, Decl(circularScopeThunkReverseMapped.ts, 5, 19)) +>n : Symbol(n, Decl(circularScopeThunkReverseMapped.ts, 19, 32)) +>n : Symbol(n, Decl(circularScopeThunkReverseMapped.ts, 19, 32)) + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/circularScopeThunkReverseMapped(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/circularScopeThunkReverseMapped(checkorder=typesfirst).types new file mode 100644 index 0000000000000..41f30b7dbe3f2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/circularScopeThunkReverseMapped(checkorder=typesfirst).types @@ -0,0 +1,107 @@ +//// [tests/cases/compiler/circularScopeThunkReverseMapped.ts] //// + +=== circularScopeThunkReverseMapped.ts === +type Resolve = T extends () => infer R ? R : T; +>Resolve : Resolve + +type Validate = { [K in keyof def]: def[K] extends () => infer R ? () => R : def[K] }; +>Validate : Validate + +interface Scope { + type(k: k): Resolve; +>type : (k: k) => Resolve +>k : k +} +interface Type { + pipe(f: (x: T) => U): Type; +>pipe : (f: (x: T) => U) => Type +>f : (x: T) => U +>x : T +} +declare function scope(def: Validate): Scope; +>scope : (def: Validate) => Scope +>def : Validate + +declare function type(x: T): Type; +>type : (x: T) => Type +>x : T + +export const $ = scope({ +>$ : Scope<{ a: Type; b: unknown; }> +>scope({ a: type("string").pipe(function (s) { return s.length; }), b: () => $.type("a").pipe(function (n) { return n === 0; }),}) : Scope<{ a: Type; b: unknown; }> +>scope : (def: Validate) => Scope +>{ a: type("string").pipe(function (s) { return s.length; }), b: () => $.type("a").pipe(function (n) { return n === 0; }),} : { a: Type; b: () => Type; } + + a: type("string").pipe(function (s) { return s.length; }), +>a : Type +>type("string").pipe(function (s) { return s.length; }) : Type +>type("string").pipe : (f: (x: string) => U) => Type +>type("string") : Type +>type : (x: T) => Type +>"string" : "string" +>pipe : (f: (x: string) => U) => Type +>function (s) { return s.length; } : (s: string) => number +>s : string +>s.length : number +>s : string +>length : number + + b: () => $.type("a").pipe(function (n) { return n === 0; }), +>b : () => Type +>() => $.type("a").pipe(function (n) { return n === 0; }) : () => Type +>$.type("a").pipe(function (n) { return n === 0; }) : Type +>$.type("a").pipe : (f: (x: number) => U) => Type +>$.type("a") : Type +>$.type : (k: k_1) => Resolve<{ a: Type; b: unknown; }[k_1]> +>$ : Scope<{ a: Type; b: unknown; }> +>type : (k: k_1) => Resolve<{ a: Type; b: unknown; }[k_1]> +>"a" : "a" +>pipe : (f: (x: number) => U) => Type +>function (n) { return n === 0; } : (n: number) => n is 0 +>n : number +>n === 0 : boolean +>n : number +>0 : 0 + +}); + +// Entered from the function in the first property when queried in reverse +export const $2 = scope({ +>$2 : Scope<{ a: Type; b: unknown; }> +>scope({ a: type("string").pipe(function (s) { return s.length; }), b: () => $2.type("a").pipe((n: number) => n === 0),}) : Scope<{ a: Type; b: unknown; }> +>scope : (def: Validate) => Scope +>{ a: type("string").pipe(function (s) { return s.length; }), b: () => $2.type("a").pipe((n: number) => n === 0),} : { a: Type; b: () => Type; } + + a: type("string").pipe(function (s) { return s.length; }), +>a : Type +>type("string").pipe(function (s) { return s.length; }) : Type +>type("string").pipe : (f: (x: string) => U) => Type +>type("string") : Type +>type : (x: T) => Type +>"string" : "string" +>pipe : (f: (x: string) => U) => Type +>function (s) { return s.length; } : (s: string) => number +>s : string +>s.length : number +>s : string +>length : number + + b: () => $2.type("a").pipe((n: number) => n === 0), +>b : () => Type +>() => $2.type("a").pipe((n: number) => n === 0) : () => Type +>$2.type("a").pipe((n: number) => n === 0) : Type +>$2.type("a").pipe : (f: (x: number) => U) => Type +>$2.type("a") : Type +>$2.type : (k: k_1) => Resolve<{ a: Type; b: unknown; }[k_1]> +>$2 : Scope<{ a: Type; b: unknown; }> +>type : (k: k_1) => Resolve<{ a: Type; b: unknown; }[k_1]> +>"a" : "a" +>pipe : (f: (x: number) => U) => Type +>(n: number) => n === 0 : (n: number) => n is 0 +>n : number +>n === 0 : boolean +>n : number +>0 : 0 + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=false).errors.txt b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=false).errors.txt new file mode 100644 index 0000000000000..e6a85a2793754 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=false).errors.txt @@ -0,0 +1,80 @@ +classCircularityDiagnostics.ts(1,7): error TS2506: 'Direct' is referenced directly or indirectly in its own base expression. +classCircularityDiagnostics.ts(9,7): error TS2506: 'First' is referenced directly or indirectly in its own base expression. +classCircularityDiagnostics.ts(9,21): error TS2449: Class 'Second' used before its declaration. +classCircularityDiagnostics.ts(10,7): error TS2506: 'Second' is referenced directly or indirectly in its own base expression. +classCircularityDiagnostics.ts(12,26): error TS2506: 'Named' is referenced directly or indirectly in its own base expression. +classCircularityDiagnostics.ts(23,16): error TS2448: Block-scoped variable 'SelfReferencingBase' used before its declaration. +classCircularityDiagnostics.ts(41,44): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +classCircularityDiagnostics.ts(42,58): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +classCircularityDiagnostics.ts(45,34): error TS2507: Type 'number' is not a constructor function type. +classCircularityDiagnostics.ts(45,50): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + + +==== classCircularityDiagnostics.ts (10 errors) ==== + class Direct extends Direct { + ~~~~~~ +!!! error TS2506: 'Direct' is referenced directly or indirectly in its own base expression. + static value = 1; + value = 2; + } + + const staticValue = Direct.value; + const instanceValue = new Direct().value; + + class First extends Second {} + ~~~~~ +!!! error TS2506: 'First' is referenced directly or indirectly in its own base expression. + ~~~~~~ +!!! error TS2449: Class 'Second' used before its declaration. +!!! related TS2728 classCircularityDiagnostics.ts:10:7: 'Second' is declared here. + class Second extends First {} + ~~~~~~ +!!! error TS2506: 'Second' is referenced directly or indirectly in its own base expression. + + const Expression = class Named extends Named {}; + ~~~~~ +!!! error TS2506: 'Named' is referenced directly or indirectly in its own base expression. + + class NestedBase extends (class { + static value = 1; + value = 2; + }) {} + + const nestedStaticValue: number = NestedBase.value; + const nestedInstanceValue: number = new NestedBase().value; + + const SelfReferencingBase = class extends (class { + static self = SelfReferencingBase; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2448: Block-scoped variable 'SelfReferencingBase' used before its declaration. +!!! related TS2728 classCircularityDiagnostics.ts:22:7: 'SelfReferencingBase' is declared here. + }) {}; + + const selfConstructor = SelfReferencingBase.self; + + function mixin {}>(base: Base) { + return class extends base { + static value = 1; + value = 2; + }; + } + + class Mixed extends mixin(NestedBase) {} + + const mixedStaticValue: number = Mixed.value; + const mixedInstanceValue: number = new Mixed().value; + + declare function makeBase(value: number): typeof NestedBase; + class InvalidBaseArgument extends makeBase("invalid") {} + ~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + const InvalidExpressionArgument = class extends makeBase("invalid") {}; + ~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + + declare function makeInvalidBase(value: number): number; + class InvalidConstructor extends makeInvalidBase("invalid") {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2507: Type 'number' is not a constructor function type. + ~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=false).js b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=false).js new file mode 100644 index 0000000000000..2ff93ac2eb65b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=false).js @@ -0,0 +1,91 @@ +//// [tests/cases/compiler/classCircularityDiagnostics.ts] //// + +//// [classCircularityDiagnostics.ts] +class Direct extends Direct { + static value = 1; + value = 2; +} + +const staticValue = Direct.value; +const instanceValue = new Direct().value; + +class First extends Second {} +class Second extends First {} + +const Expression = class Named extends Named {}; + +class NestedBase extends (class { + static value = 1; + value = 2; +}) {} + +const nestedStaticValue: number = NestedBase.value; +const nestedInstanceValue: number = new NestedBase().value; + +const SelfReferencingBase = class extends (class { + static self = SelfReferencingBase; +}) {}; + +const selfConstructor = SelfReferencingBase.self; + +function mixin {}>(base: Base) { + return class extends base { + static value = 1; + value = 2; + }; +} + +class Mixed extends mixin(NestedBase) {} + +const mixedStaticValue: number = Mixed.value; +const mixedInstanceValue: number = new Mixed().value; + +declare function makeBase(value: number): typeof NestedBase; +class InvalidBaseArgument extends makeBase("invalid") {} +const InvalidExpressionArgument = class extends makeBase("invalid") {}; + +declare function makeInvalidBase(value: number): number; +class InvalidConstructor extends makeInvalidBase("invalid") {} + +//// [classCircularityDiagnostics.js] +"use strict"; +class Direct extends Direct { + static value = 1; + value = 2; +} +const staticValue = Direct.value; +const instanceValue = new Direct().value; +class First extends Second { +} +class Second extends First { +} +const Expression = class Named extends Named { +}; +class NestedBase extends (class { + static value = 1; + value = 2; +}) { +} +const nestedStaticValue = NestedBase.value; +const nestedInstanceValue = new NestedBase().value; +const SelfReferencingBase = class extends (class { + static self = SelfReferencingBase; +}) { +}; +const selfConstructor = SelfReferencingBase.self; +function mixin(base) { + return class extends base { + static value = 1; + value = 2; + }; +} +class Mixed extends mixin(NestedBase) { +} +const mixedStaticValue = Mixed.value; +const mixedInstanceValue = new Mixed().value; +class InvalidBaseArgument extends makeBase("invalid") { +} +const InvalidExpressionArgument = class extends makeBase("invalid") { +}; +class InvalidConstructor extends makeInvalidBase("invalid") { +} diff --git a/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=false).symbols b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=false).symbols new file mode 100644 index 0000000000000..9e892a1edd0ab --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=false).symbols @@ -0,0 +1,134 @@ +//// [tests/cases/compiler/classCircularityDiagnostics.ts] //// + +=== classCircularityDiagnostics.ts === +class Direct extends Direct { +>Direct : Symbol(Direct, Decl(classCircularityDiagnostics.ts, 0, 0)) +>Direct : Symbol(Direct, Decl(classCircularityDiagnostics.ts, 0, 0)) + + static value = 1; +>value : Symbol(Direct.value, Decl(classCircularityDiagnostics.ts, 0, 29)) + + value = 2; +>value : Symbol(Direct.value, Decl(classCircularityDiagnostics.ts, 1, 18)) +} + +const staticValue = Direct.value; +>staticValue : Symbol(staticValue, Decl(classCircularityDiagnostics.ts, 5, 5)) +>Direct.value : Symbol(Direct.value, Decl(classCircularityDiagnostics.ts, 0, 29)) +>Direct : Symbol(Direct, Decl(classCircularityDiagnostics.ts, 0, 0)) +>value : Symbol(Direct.value, Decl(classCircularityDiagnostics.ts, 0, 29)) + +const instanceValue = new Direct().value; +>instanceValue : Symbol(instanceValue, Decl(classCircularityDiagnostics.ts, 6, 5)) +>new Direct().value : Symbol(Direct.value, Decl(classCircularityDiagnostics.ts, 1, 18)) +>Direct : Symbol(Direct, Decl(classCircularityDiagnostics.ts, 0, 0)) +>value : Symbol(Direct.value, Decl(classCircularityDiagnostics.ts, 1, 18)) + +class First extends Second {} +>First : Symbol(First, Decl(classCircularityDiagnostics.ts, 6, 41)) +>Second : Symbol(Second, Decl(classCircularityDiagnostics.ts, 8, 29)) + +class Second extends First {} +>Second : Symbol(Second, Decl(classCircularityDiagnostics.ts, 8, 29)) +>First : Symbol(First, Decl(classCircularityDiagnostics.ts, 6, 41)) + +const Expression = class Named extends Named {}; +>Expression : Symbol(Expression, Decl(classCircularityDiagnostics.ts, 11, 5)) +>Named : Symbol(Named, Decl(classCircularityDiagnostics.ts, 11, 18)) +>Named : Symbol(Named, Decl(classCircularityDiagnostics.ts, 11, 18)) + +class NestedBase extends (class { +>NestedBase : Symbol(NestedBase, Decl(classCircularityDiagnostics.ts, 11, 48)) + + static value = 1; +>value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 13, 33)) + + value = 2; +>value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 14, 18)) + +}) {} + +const nestedStaticValue: number = NestedBase.value; +>nestedStaticValue : Symbol(nestedStaticValue, Decl(classCircularityDiagnostics.ts, 18, 5)) +>NestedBase.value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 13, 33)) +>NestedBase : Symbol(NestedBase, Decl(classCircularityDiagnostics.ts, 11, 48)) +>value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 13, 33)) + +const nestedInstanceValue: number = new NestedBase().value; +>nestedInstanceValue : Symbol(nestedInstanceValue, Decl(classCircularityDiagnostics.ts, 19, 5)) +>new NestedBase().value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 14, 18)) +>NestedBase : Symbol(NestedBase, Decl(classCircularityDiagnostics.ts, 11, 48)) +>value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 14, 18)) + +const SelfReferencingBase = class extends (class { +>SelfReferencingBase : Symbol(SelfReferencingBase, Decl(classCircularityDiagnostics.ts, 21, 5)) + + static self = SelfReferencingBase; +>self : Symbol((Anonymous class).self, Decl(classCircularityDiagnostics.ts, 21, 50)) +>SelfReferencingBase : Symbol(SelfReferencingBase, Decl(classCircularityDiagnostics.ts, 21, 5)) + +}) {}; + +const selfConstructor = SelfReferencingBase.self; +>selfConstructor : Symbol(selfConstructor, Decl(classCircularityDiagnostics.ts, 25, 5)) +>SelfReferencingBase.self : Symbol((Anonymous class).self, Decl(classCircularityDiagnostics.ts, 21, 50)) +>SelfReferencingBase : Symbol(SelfReferencingBase, Decl(classCircularityDiagnostics.ts, 21, 5)) +>self : Symbol((Anonymous class).self, Decl(classCircularityDiagnostics.ts, 21, 50)) + +function mixin {}>(base: Base) { +>mixin : Symbol(mixin, Decl(classCircularityDiagnostics.ts, 25, 49)) +>Base : Symbol(Base, Decl(classCircularityDiagnostics.ts, 27, 15)) +>args : Symbol(args, Decl(classCircularityDiagnostics.ts, 27, 33)) +>base : Symbol(base, Decl(classCircularityDiagnostics.ts, 27, 56)) +>Base : Symbol(Base, Decl(classCircularityDiagnostics.ts, 27, 15)) + + return class extends base { +>base : Symbol(base, Decl(classCircularityDiagnostics.ts, 27, 56)) + + static value = 1; +>value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 28, 28)) + + value = 2; +>value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 29, 19)) + + }; +} + +class Mixed extends mixin(NestedBase) {} +>Mixed : Symbol(Mixed, Decl(classCircularityDiagnostics.ts, 32, 1)) +>mixin : Symbol(mixin, Decl(classCircularityDiagnostics.ts, 25, 49)) +>NestedBase : Symbol(NestedBase, Decl(classCircularityDiagnostics.ts, 11, 48)) + +const mixedStaticValue: number = Mixed.value; +>mixedStaticValue : Symbol(mixedStaticValue, Decl(classCircularityDiagnostics.ts, 36, 5)) +>Mixed.value : Symbol(value, Decl(classCircularityDiagnostics.ts, 28, 28), Decl(classCircularityDiagnostics.ts, 13, 33)) +>Mixed : Symbol(Mixed, Decl(classCircularityDiagnostics.ts, 32, 1)) +>value : Symbol(value, Decl(classCircularityDiagnostics.ts, 28, 28), Decl(classCircularityDiagnostics.ts, 13, 33)) + +const mixedInstanceValue: number = new Mixed().value; +>mixedInstanceValue : Symbol(mixedInstanceValue, Decl(classCircularityDiagnostics.ts, 37, 5)) +>new Mixed().value : Symbol(value, Decl(classCircularityDiagnostics.ts, 29, 19), Decl(classCircularityDiagnostics.ts, 14, 18)) +>Mixed : Symbol(Mixed, Decl(classCircularityDiagnostics.ts, 32, 1)) +>value : Symbol(value, Decl(classCircularityDiagnostics.ts, 29, 19), Decl(classCircularityDiagnostics.ts, 14, 18)) + +declare function makeBase(value: number): typeof NestedBase; +>makeBase : Symbol(makeBase, Decl(classCircularityDiagnostics.ts, 37, 53)) +>value : Symbol(value, Decl(classCircularityDiagnostics.ts, 39, 26)) +>NestedBase : Symbol(NestedBase, Decl(classCircularityDiagnostics.ts, 11, 48)) + +class InvalidBaseArgument extends makeBase("invalid") {} +>InvalidBaseArgument : Symbol(InvalidBaseArgument, Decl(classCircularityDiagnostics.ts, 39, 60)) +>makeBase : Symbol(makeBase, Decl(classCircularityDiagnostics.ts, 37, 53)) + +const InvalidExpressionArgument = class extends makeBase("invalid") {}; +>InvalidExpressionArgument : Symbol(InvalidExpressionArgument, Decl(classCircularityDiagnostics.ts, 41, 5)) +>makeBase : Symbol(makeBase, Decl(classCircularityDiagnostics.ts, 37, 53)) + +declare function makeInvalidBase(value: number): number; +>makeInvalidBase : Symbol(makeInvalidBase, Decl(classCircularityDiagnostics.ts, 41, 71)) +>value : Symbol(value, Decl(classCircularityDiagnostics.ts, 43, 33)) + +class InvalidConstructor extends makeInvalidBase("invalid") {} +>InvalidConstructor : Symbol(InvalidConstructor, Decl(classCircularityDiagnostics.ts, 43, 56)) +>makeInvalidBase : Symbol(makeInvalidBase, Decl(classCircularityDiagnostics.ts, 41, 71)) + diff --git a/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=false).types b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=false).types new file mode 100644 index 0000000000000..0b46eec400402 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=false).types @@ -0,0 +1,156 @@ +//// [tests/cases/compiler/classCircularityDiagnostics.ts] //// + +=== classCircularityDiagnostics.ts === +class Direct extends Direct { +>Direct : Direct +>Direct : typeof Direct + + static value = 1; +>value : number +>1 : 1 + + value = 2; +>value : number +>2 : 2 +} + +const staticValue = Direct.value; +>staticValue : number +>Direct.value : number +>Direct : typeof Direct +>value : number + +const instanceValue = new Direct().value; +>instanceValue : number +>new Direct().value : number +>new Direct() : Direct +>Direct : typeof Direct +>value : number + +class First extends Second {} +>First : First +>Second : typeof Second + +class Second extends First {} +>Second : Second +>First : typeof First + +const Expression = class Named extends Named {}; +>Expression : typeof Named +>class Named extends Named {} : typeof Named +>Named : typeof Named +>Named : typeof Named + +class NestedBase extends (class { +>NestedBase : NestedBase +>(class { static value = 1; value = 2;}) : (Anonymous class) +>class { static value = 1; value = 2;} : typeof (Anonymous class) + + static value = 1; +>value : number +>1 : 1 + + value = 2; +>value : number +>2 : 2 + +}) {} + +const nestedStaticValue: number = NestedBase.value; +>nestedStaticValue : number +>NestedBase.value : number +>NestedBase : typeof NestedBase +>value : number + +const nestedInstanceValue: number = new NestedBase().value; +>nestedInstanceValue : number +>new NestedBase().value : number +>new NestedBase() : NestedBase +>NestedBase : typeof NestedBase +>value : number + +const SelfReferencingBase = class extends (class { +>SelfReferencingBase : typeof SelfReferencingBase +>class extends (class { static self = SelfReferencingBase;}) {} : typeof SelfReferencingBase +>(class { static self = SelfReferencingBase;}) : (Anonymous class) +>class { static self = SelfReferencingBase;} : typeof (Anonymous class) + + static self = SelfReferencingBase; +>self : typeof SelfReferencingBase +>SelfReferencingBase : typeof SelfReferencingBase + +}) {}; + +const selfConstructor = SelfReferencingBase.self; +>selfConstructor : typeof SelfReferencingBase +>SelfReferencingBase.self : typeof SelfReferencingBase +>SelfReferencingBase : typeof SelfReferencingBase +>self : typeof SelfReferencingBase + +function mixin {}>(base: Base) { +>mixin : {}>(base: Base) => { new (...args: any[]): (Anonymous class); value: number; prototype: mixin.(Anonymous class); } & Base +>args : any[] +>base : Base + + return class extends base { +>class extends base { static value = 1; value = 2; } : { new (...args: any[]): (Anonymous class); value: number; prototype: mixin.(Anonymous class); } & Base +>base : {} + + static value = 1; +>value : number +>1 : 1 + + value = 2; +>value : number +>2 : 2 + + }; +} + +class Mixed extends mixin(NestedBase) {} +>Mixed : Mixed +>mixin(NestedBase) : mixin.(Anonymous class) & NestedBase +>mixin : {}>(base: Base) => { new (...args: any[]): (Anonymous class); value: number; prototype: mixin.(Anonymous class); } & Base +>NestedBase : typeof NestedBase + +const mixedStaticValue: number = Mixed.value; +>mixedStaticValue : number +>Mixed.value : number +>Mixed : typeof Mixed +>value : number + +const mixedInstanceValue: number = new Mixed().value; +>mixedInstanceValue : number +>new Mixed().value : number +>new Mixed() : Mixed +>Mixed : typeof Mixed +>value : number + +declare function makeBase(value: number): typeof NestedBase; +>makeBase : (value: number) => typeof NestedBase +>value : number +>NestedBase : typeof NestedBase + +class InvalidBaseArgument extends makeBase("invalid") {} +>InvalidBaseArgument : InvalidBaseArgument +>makeBase("invalid") : NestedBase +>makeBase : (value: number) => typeof NestedBase +>"invalid" : "invalid" + +const InvalidExpressionArgument = class extends makeBase("invalid") {}; +>InvalidExpressionArgument : typeof InvalidExpressionArgument +>class extends makeBase("invalid") {} : typeof InvalidExpressionArgument +>makeBase("invalid") : NestedBase +>makeBase : (value: number) => typeof NestedBase +>"invalid" : "invalid" + +declare function makeInvalidBase(value: number): number; +>makeInvalidBase : (value: number) => number +>value : number + +class InvalidConstructor extends makeInvalidBase("invalid") {} +>InvalidConstructor : InvalidConstructor +>makeInvalidBase("invalid") : number +>makeInvalidBase : (value: number) => number +>"invalid" : "invalid" + diff --git a/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=true).errors.txt b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=true).errors.txt new file mode 100644 index 0000000000000..e6a85a2793754 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=true).errors.txt @@ -0,0 +1,80 @@ +classCircularityDiagnostics.ts(1,7): error TS2506: 'Direct' is referenced directly or indirectly in its own base expression. +classCircularityDiagnostics.ts(9,7): error TS2506: 'First' is referenced directly or indirectly in its own base expression. +classCircularityDiagnostics.ts(9,21): error TS2449: Class 'Second' used before its declaration. +classCircularityDiagnostics.ts(10,7): error TS2506: 'Second' is referenced directly or indirectly in its own base expression. +classCircularityDiagnostics.ts(12,26): error TS2506: 'Named' is referenced directly or indirectly in its own base expression. +classCircularityDiagnostics.ts(23,16): error TS2448: Block-scoped variable 'SelfReferencingBase' used before its declaration. +classCircularityDiagnostics.ts(41,44): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +classCircularityDiagnostics.ts(42,58): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +classCircularityDiagnostics.ts(45,34): error TS2507: Type 'number' is not a constructor function type. +classCircularityDiagnostics.ts(45,50): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + + +==== classCircularityDiagnostics.ts (10 errors) ==== + class Direct extends Direct { + ~~~~~~ +!!! error TS2506: 'Direct' is referenced directly or indirectly in its own base expression. + static value = 1; + value = 2; + } + + const staticValue = Direct.value; + const instanceValue = new Direct().value; + + class First extends Second {} + ~~~~~ +!!! error TS2506: 'First' is referenced directly or indirectly in its own base expression. + ~~~~~~ +!!! error TS2449: Class 'Second' used before its declaration. +!!! related TS2728 classCircularityDiagnostics.ts:10:7: 'Second' is declared here. + class Second extends First {} + ~~~~~~ +!!! error TS2506: 'Second' is referenced directly or indirectly in its own base expression. + + const Expression = class Named extends Named {}; + ~~~~~ +!!! error TS2506: 'Named' is referenced directly or indirectly in its own base expression. + + class NestedBase extends (class { + static value = 1; + value = 2; + }) {} + + const nestedStaticValue: number = NestedBase.value; + const nestedInstanceValue: number = new NestedBase().value; + + const SelfReferencingBase = class extends (class { + static self = SelfReferencingBase; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2448: Block-scoped variable 'SelfReferencingBase' used before its declaration. +!!! related TS2728 classCircularityDiagnostics.ts:22:7: 'SelfReferencingBase' is declared here. + }) {}; + + const selfConstructor = SelfReferencingBase.self; + + function mixin {}>(base: Base) { + return class extends base { + static value = 1; + value = 2; + }; + } + + class Mixed extends mixin(NestedBase) {} + + const mixedStaticValue: number = Mixed.value; + const mixedInstanceValue: number = new Mixed().value; + + declare function makeBase(value: number): typeof NestedBase; + class InvalidBaseArgument extends makeBase("invalid") {} + ~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + const InvalidExpressionArgument = class extends makeBase("invalid") {}; + ~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + + declare function makeInvalidBase(value: number): number; + class InvalidConstructor extends makeInvalidBase("invalid") {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2507: Type 'number' is not a constructor function type. + ~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=true).js b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=true).js new file mode 100644 index 0000000000000..2ff93ac2eb65b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=true).js @@ -0,0 +1,91 @@ +//// [tests/cases/compiler/classCircularityDiagnostics.ts] //// + +//// [classCircularityDiagnostics.ts] +class Direct extends Direct { + static value = 1; + value = 2; +} + +const staticValue = Direct.value; +const instanceValue = new Direct().value; + +class First extends Second {} +class Second extends First {} + +const Expression = class Named extends Named {}; + +class NestedBase extends (class { + static value = 1; + value = 2; +}) {} + +const nestedStaticValue: number = NestedBase.value; +const nestedInstanceValue: number = new NestedBase().value; + +const SelfReferencingBase = class extends (class { + static self = SelfReferencingBase; +}) {}; + +const selfConstructor = SelfReferencingBase.self; + +function mixin {}>(base: Base) { + return class extends base { + static value = 1; + value = 2; + }; +} + +class Mixed extends mixin(NestedBase) {} + +const mixedStaticValue: number = Mixed.value; +const mixedInstanceValue: number = new Mixed().value; + +declare function makeBase(value: number): typeof NestedBase; +class InvalidBaseArgument extends makeBase("invalid") {} +const InvalidExpressionArgument = class extends makeBase("invalid") {}; + +declare function makeInvalidBase(value: number): number; +class InvalidConstructor extends makeInvalidBase("invalid") {} + +//// [classCircularityDiagnostics.js] +"use strict"; +class Direct extends Direct { + static value = 1; + value = 2; +} +const staticValue = Direct.value; +const instanceValue = new Direct().value; +class First extends Second { +} +class Second extends First { +} +const Expression = class Named extends Named { +}; +class NestedBase extends (class { + static value = 1; + value = 2; +}) { +} +const nestedStaticValue = NestedBase.value; +const nestedInstanceValue = new NestedBase().value; +const SelfReferencingBase = class extends (class { + static self = SelfReferencingBase; +}) { +}; +const selfConstructor = SelfReferencingBase.self; +function mixin(base) { + return class extends base { + static value = 1; + value = 2; + }; +} +class Mixed extends mixin(NestedBase) { +} +const mixedStaticValue = Mixed.value; +const mixedInstanceValue = new Mixed().value; +class InvalidBaseArgument extends makeBase("invalid") { +} +const InvalidExpressionArgument = class extends makeBase("invalid") { +}; +class InvalidConstructor extends makeInvalidBase("invalid") { +} diff --git a/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=true).symbols b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=true).symbols new file mode 100644 index 0000000000000..9e892a1edd0ab --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=true).symbols @@ -0,0 +1,134 @@ +//// [tests/cases/compiler/classCircularityDiagnostics.ts] //// + +=== classCircularityDiagnostics.ts === +class Direct extends Direct { +>Direct : Symbol(Direct, Decl(classCircularityDiagnostics.ts, 0, 0)) +>Direct : Symbol(Direct, Decl(classCircularityDiagnostics.ts, 0, 0)) + + static value = 1; +>value : Symbol(Direct.value, Decl(classCircularityDiagnostics.ts, 0, 29)) + + value = 2; +>value : Symbol(Direct.value, Decl(classCircularityDiagnostics.ts, 1, 18)) +} + +const staticValue = Direct.value; +>staticValue : Symbol(staticValue, Decl(classCircularityDiagnostics.ts, 5, 5)) +>Direct.value : Symbol(Direct.value, Decl(classCircularityDiagnostics.ts, 0, 29)) +>Direct : Symbol(Direct, Decl(classCircularityDiagnostics.ts, 0, 0)) +>value : Symbol(Direct.value, Decl(classCircularityDiagnostics.ts, 0, 29)) + +const instanceValue = new Direct().value; +>instanceValue : Symbol(instanceValue, Decl(classCircularityDiagnostics.ts, 6, 5)) +>new Direct().value : Symbol(Direct.value, Decl(classCircularityDiagnostics.ts, 1, 18)) +>Direct : Symbol(Direct, Decl(classCircularityDiagnostics.ts, 0, 0)) +>value : Symbol(Direct.value, Decl(classCircularityDiagnostics.ts, 1, 18)) + +class First extends Second {} +>First : Symbol(First, Decl(classCircularityDiagnostics.ts, 6, 41)) +>Second : Symbol(Second, Decl(classCircularityDiagnostics.ts, 8, 29)) + +class Second extends First {} +>Second : Symbol(Second, Decl(classCircularityDiagnostics.ts, 8, 29)) +>First : Symbol(First, Decl(classCircularityDiagnostics.ts, 6, 41)) + +const Expression = class Named extends Named {}; +>Expression : Symbol(Expression, Decl(classCircularityDiagnostics.ts, 11, 5)) +>Named : Symbol(Named, Decl(classCircularityDiagnostics.ts, 11, 18)) +>Named : Symbol(Named, Decl(classCircularityDiagnostics.ts, 11, 18)) + +class NestedBase extends (class { +>NestedBase : Symbol(NestedBase, Decl(classCircularityDiagnostics.ts, 11, 48)) + + static value = 1; +>value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 13, 33)) + + value = 2; +>value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 14, 18)) + +}) {} + +const nestedStaticValue: number = NestedBase.value; +>nestedStaticValue : Symbol(nestedStaticValue, Decl(classCircularityDiagnostics.ts, 18, 5)) +>NestedBase.value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 13, 33)) +>NestedBase : Symbol(NestedBase, Decl(classCircularityDiagnostics.ts, 11, 48)) +>value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 13, 33)) + +const nestedInstanceValue: number = new NestedBase().value; +>nestedInstanceValue : Symbol(nestedInstanceValue, Decl(classCircularityDiagnostics.ts, 19, 5)) +>new NestedBase().value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 14, 18)) +>NestedBase : Symbol(NestedBase, Decl(classCircularityDiagnostics.ts, 11, 48)) +>value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 14, 18)) + +const SelfReferencingBase = class extends (class { +>SelfReferencingBase : Symbol(SelfReferencingBase, Decl(classCircularityDiagnostics.ts, 21, 5)) + + static self = SelfReferencingBase; +>self : Symbol((Anonymous class).self, Decl(classCircularityDiagnostics.ts, 21, 50)) +>SelfReferencingBase : Symbol(SelfReferencingBase, Decl(classCircularityDiagnostics.ts, 21, 5)) + +}) {}; + +const selfConstructor = SelfReferencingBase.self; +>selfConstructor : Symbol(selfConstructor, Decl(classCircularityDiagnostics.ts, 25, 5)) +>SelfReferencingBase.self : Symbol((Anonymous class).self, Decl(classCircularityDiagnostics.ts, 21, 50)) +>SelfReferencingBase : Symbol(SelfReferencingBase, Decl(classCircularityDiagnostics.ts, 21, 5)) +>self : Symbol((Anonymous class).self, Decl(classCircularityDiagnostics.ts, 21, 50)) + +function mixin {}>(base: Base) { +>mixin : Symbol(mixin, Decl(classCircularityDiagnostics.ts, 25, 49)) +>Base : Symbol(Base, Decl(classCircularityDiagnostics.ts, 27, 15)) +>args : Symbol(args, Decl(classCircularityDiagnostics.ts, 27, 33)) +>base : Symbol(base, Decl(classCircularityDiagnostics.ts, 27, 56)) +>Base : Symbol(Base, Decl(classCircularityDiagnostics.ts, 27, 15)) + + return class extends base { +>base : Symbol(base, Decl(classCircularityDiagnostics.ts, 27, 56)) + + static value = 1; +>value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 28, 28)) + + value = 2; +>value : Symbol((Anonymous class).value, Decl(classCircularityDiagnostics.ts, 29, 19)) + + }; +} + +class Mixed extends mixin(NestedBase) {} +>Mixed : Symbol(Mixed, Decl(classCircularityDiagnostics.ts, 32, 1)) +>mixin : Symbol(mixin, Decl(classCircularityDiagnostics.ts, 25, 49)) +>NestedBase : Symbol(NestedBase, Decl(classCircularityDiagnostics.ts, 11, 48)) + +const mixedStaticValue: number = Mixed.value; +>mixedStaticValue : Symbol(mixedStaticValue, Decl(classCircularityDiagnostics.ts, 36, 5)) +>Mixed.value : Symbol(value, Decl(classCircularityDiagnostics.ts, 28, 28), Decl(classCircularityDiagnostics.ts, 13, 33)) +>Mixed : Symbol(Mixed, Decl(classCircularityDiagnostics.ts, 32, 1)) +>value : Symbol(value, Decl(classCircularityDiagnostics.ts, 28, 28), Decl(classCircularityDiagnostics.ts, 13, 33)) + +const mixedInstanceValue: number = new Mixed().value; +>mixedInstanceValue : Symbol(mixedInstanceValue, Decl(classCircularityDiagnostics.ts, 37, 5)) +>new Mixed().value : Symbol(value, Decl(classCircularityDiagnostics.ts, 29, 19), Decl(classCircularityDiagnostics.ts, 14, 18)) +>Mixed : Symbol(Mixed, Decl(classCircularityDiagnostics.ts, 32, 1)) +>value : Symbol(value, Decl(classCircularityDiagnostics.ts, 29, 19), Decl(classCircularityDiagnostics.ts, 14, 18)) + +declare function makeBase(value: number): typeof NestedBase; +>makeBase : Symbol(makeBase, Decl(classCircularityDiagnostics.ts, 37, 53)) +>value : Symbol(value, Decl(classCircularityDiagnostics.ts, 39, 26)) +>NestedBase : Symbol(NestedBase, Decl(classCircularityDiagnostics.ts, 11, 48)) + +class InvalidBaseArgument extends makeBase("invalid") {} +>InvalidBaseArgument : Symbol(InvalidBaseArgument, Decl(classCircularityDiagnostics.ts, 39, 60)) +>makeBase : Symbol(makeBase, Decl(classCircularityDiagnostics.ts, 37, 53)) + +const InvalidExpressionArgument = class extends makeBase("invalid") {}; +>InvalidExpressionArgument : Symbol(InvalidExpressionArgument, Decl(classCircularityDiagnostics.ts, 41, 5)) +>makeBase : Symbol(makeBase, Decl(classCircularityDiagnostics.ts, 37, 53)) + +declare function makeInvalidBase(value: number): number; +>makeInvalidBase : Symbol(makeInvalidBase, Decl(classCircularityDiagnostics.ts, 41, 71)) +>value : Symbol(value, Decl(classCircularityDiagnostics.ts, 43, 33)) + +class InvalidConstructor extends makeInvalidBase("invalid") {} +>InvalidConstructor : Symbol(InvalidConstructor, Decl(classCircularityDiagnostics.ts, 43, 56)) +>makeInvalidBase : Symbol(makeInvalidBase, Decl(classCircularityDiagnostics.ts, 41, 71)) + diff --git a/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=true).types b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=true).types new file mode 100644 index 0000000000000..0b46eec400402 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/classCircularityDiagnostics(noimplicitany=true).types @@ -0,0 +1,156 @@ +//// [tests/cases/compiler/classCircularityDiagnostics.ts] //// + +=== classCircularityDiagnostics.ts === +class Direct extends Direct { +>Direct : Direct +>Direct : typeof Direct + + static value = 1; +>value : number +>1 : 1 + + value = 2; +>value : number +>2 : 2 +} + +const staticValue = Direct.value; +>staticValue : number +>Direct.value : number +>Direct : typeof Direct +>value : number + +const instanceValue = new Direct().value; +>instanceValue : number +>new Direct().value : number +>new Direct() : Direct +>Direct : typeof Direct +>value : number + +class First extends Second {} +>First : First +>Second : typeof Second + +class Second extends First {} +>Second : Second +>First : typeof First + +const Expression = class Named extends Named {}; +>Expression : typeof Named +>class Named extends Named {} : typeof Named +>Named : typeof Named +>Named : typeof Named + +class NestedBase extends (class { +>NestedBase : NestedBase +>(class { static value = 1; value = 2;}) : (Anonymous class) +>class { static value = 1; value = 2;} : typeof (Anonymous class) + + static value = 1; +>value : number +>1 : 1 + + value = 2; +>value : number +>2 : 2 + +}) {} + +const nestedStaticValue: number = NestedBase.value; +>nestedStaticValue : number +>NestedBase.value : number +>NestedBase : typeof NestedBase +>value : number + +const nestedInstanceValue: number = new NestedBase().value; +>nestedInstanceValue : number +>new NestedBase().value : number +>new NestedBase() : NestedBase +>NestedBase : typeof NestedBase +>value : number + +const SelfReferencingBase = class extends (class { +>SelfReferencingBase : typeof SelfReferencingBase +>class extends (class { static self = SelfReferencingBase;}) {} : typeof SelfReferencingBase +>(class { static self = SelfReferencingBase;}) : (Anonymous class) +>class { static self = SelfReferencingBase;} : typeof (Anonymous class) + + static self = SelfReferencingBase; +>self : typeof SelfReferencingBase +>SelfReferencingBase : typeof SelfReferencingBase + +}) {}; + +const selfConstructor = SelfReferencingBase.self; +>selfConstructor : typeof SelfReferencingBase +>SelfReferencingBase.self : typeof SelfReferencingBase +>SelfReferencingBase : typeof SelfReferencingBase +>self : typeof SelfReferencingBase + +function mixin {}>(base: Base) { +>mixin : {}>(base: Base) => { new (...args: any[]): (Anonymous class); value: number; prototype: mixin.(Anonymous class); } & Base +>args : any[] +>base : Base + + return class extends base { +>class extends base { static value = 1; value = 2; } : { new (...args: any[]): (Anonymous class); value: number; prototype: mixin.(Anonymous class); } & Base +>base : {} + + static value = 1; +>value : number +>1 : 1 + + value = 2; +>value : number +>2 : 2 + + }; +} + +class Mixed extends mixin(NestedBase) {} +>Mixed : Mixed +>mixin(NestedBase) : mixin.(Anonymous class) & NestedBase +>mixin : {}>(base: Base) => { new (...args: any[]): (Anonymous class); value: number; prototype: mixin.(Anonymous class); } & Base +>NestedBase : typeof NestedBase + +const mixedStaticValue: number = Mixed.value; +>mixedStaticValue : number +>Mixed.value : number +>Mixed : typeof Mixed +>value : number + +const mixedInstanceValue: number = new Mixed().value; +>mixedInstanceValue : number +>new Mixed().value : number +>new Mixed() : Mixed +>Mixed : typeof Mixed +>value : number + +declare function makeBase(value: number): typeof NestedBase; +>makeBase : (value: number) => typeof NestedBase +>value : number +>NestedBase : typeof NestedBase + +class InvalidBaseArgument extends makeBase("invalid") {} +>InvalidBaseArgument : InvalidBaseArgument +>makeBase("invalid") : NestedBase +>makeBase : (value: number) => typeof NestedBase +>"invalid" : "invalid" + +const InvalidExpressionArgument = class extends makeBase("invalid") {}; +>InvalidExpressionArgument : typeof InvalidExpressionArgument +>class extends makeBase("invalid") {} : typeof InvalidExpressionArgument +>makeBase("invalid") : NestedBase +>makeBase : (value: number) => typeof NestedBase +>"invalid" : "invalid" + +declare function makeInvalidBase(value: number): number; +>makeInvalidBase : (value: number) => number +>value : number + +class InvalidConstructor extends makeInvalidBase("invalid") {} +>InvalidConstructor : InvalidConstructor +>makeInvalidBase("invalid") : number +>makeInvalidBase : (value: number) => number +>"invalid" : "invalid" + diff --git a/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=default).symbols new file mode 100644 index 0000000000000..a61c1f0f60680 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=default).symbols @@ -0,0 +1,66 @@ +//// [tests/cases/compiler/clonedTypeParameterUnionOrder.ts] //// + +=== a.ts === +interface Pair { a: A; b: B } +>Pair : Symbol(Pair, Decl(a.ts, 0, 0)) +>A : Symbol(A, Decl(a.ts, 0, 15)) +>B : Symbol(B, Decl(a.ts, 0, 17)) +>a : Symbol(Pair.a, Decl(a.ts, 0, 22)) +>A : Symbol(A, Decl(a.ts, 0, 15)) +>b : Symbol(Pair.b, Decl(a.ts, 0, 28)) +>B : Symbol(B, Decl(a.ts, 0, 17)) + +interface Box { m(x: T): Pair } +>Box : Symbol(Box, Decl(a.ts, 0, 35)) +>U : Symbol(U, Decl(a.ts, 1, 14)) +>m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>T : Symbol(T, Decl(a.ts, 1, 21)) +>x : Symbol(x, Decl(a.ts, 1, 24)) +>T : Symbol(T, Decl(a.ts, 1, 21)) +>Pair : Symbol(Pair, Decl(a.ts, 0, 0)) +>T : Symbol(T, Decl(a.ts, 1, 21)) +>U : Symbol(U, Decl(a.ts, 1, 14)) + +declare function call(f: (x: A) => R): (x: A) => R; +>call : Symbol(call, Decl(a.ts, 1, 43)) +>A : Symbol(A, Decl(a.ts, 2, 22)) +>R : Symbol(R, Decl(a.ts, 2, 24)) +>f : Symbol(f, Decl(a.ts, 2, 28)) +>x : Symbol(x, Decl(a.ts, 2, 32)) +>A : Symbol(A, Decl(a.ts, 2, 22)) +>R : Symbol(R, Decl(a.ts, 2, 24)) +>x : Symbol(x, Decl(a.ts, 2, 46)) +>A : Symbol(A, Decl(a.ts, 2, 22)) +>R : Symbol(R, Decl(a.ts, 2, 24)) + +declare const bs: Box; +>bs : Symbol(bs, Decl(a.ts, 3, 13)) +>Box : Symbol(Box, Decl(a.ts, 0, 35)) + +declare const bn: Box; +>bn : Symbol(bn, Decl(a.ts, 4, 13)) +>Box : Symbol(Box, Decl(a.ts, 0, 35)) + +const n = call(bn.m); +>n : Symbol(n, Decl(a.ts, 5, 5)) +>call : Symbol(call, Decl(a.ts, 1, 43)) +>bn.m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>bn : Symbol(bn, Decl(a.ts, 4, 13)) +>m : Symbol(Box.m, Decl(a.ts, 1, 18)) + +=== b.ts === +declare const c: boolean; +>c : Symbol(c, Decl(b.ts, 0, 13)) + +const r = c ? call(bs.m) : call(bn.m); +>r : Symbol(r, Decl(b.ts, 1, 5)) +>c : Symbol(c, Decl(b.ts, 0, 13)) +>call : Symbol(call, Decl(a.ts, 1, 43)) +>bs.m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>bs : Symbol(bs, Decl(a.ts, 3, 13)) +>m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>call : Symbol(call, Decl(a.ts, 1, 43)) +>bn.m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>bn : Symbol(bn, Decl(a.ts, 4, 13)) +>m : Symbol(Box.m, Decl(a.ts, 1, 18)) + diff --git a/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=default).types new file mode 100644 index 0000000000000..487cdba50bc87 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=default).types @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/clonedTypeParameterUnionOrder.ts] //// + +=== a.ts === +interface Pair { a: A; b: B } +>a : A +>b : B + +interface Box { m(x: T): Pair } +>m : (x: T) => Pair +>x : T + +declare function call(f: (x: A) => R): (x: A) => R; +>call : (f: (x: A) => R) => (x: A) => R +>f : (x: A) => R +>x : A +>x : A + +declare const bs: Box; +>bs : Box + +declare const bn: Box; +>bn : Box + +const n = call(bn.m); +>n : (x: T) => Pair +>call(bn.m) : (x: T) => Pair +>call : (f: (x: A) => R) => (x: A) => R +>bn.m : (x: T) => Pair +>bn : Box +>m : (x: T) => Pair + +=== b.ts === +declare const c: boolean; +>c : boolean + +const r = c ? call(bs.m) : call(bn.m); +>r : ((x: T) => Pair) | ((x: T) => Pair) +>c ? call(bs.m) : call(bn.m) : ((x: T) => Pair) | ((x: T) => Pair) +>c : boolean +>call(bs.m) : (x: T) => Pair +>call : (f: (x: A) => R) => (x: A) => R +>bs.m : (x: T) => Pair +>bs : Box +>m : (x: T) => Pair +>call(bn.m) : (x: T) => Pair +>call : (f: (x: A) => R) => (x: A) => R +>bn.m : (x: T) => Pair +>bn : Box +>m : (x: T) => Pair + diff --git a/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=reverse).symbols b/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=reverse).symbols new file mode 100644 index 0000000000000..a61c1f0f60680 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=reverse).symbols @@ -0,0 +1,66 @@ +//// [tests/cases/compiler/clonedTypeParameterUnionOrder.ts] //// + +=== a.ts === +interface Pair { a: A; b: B } +>Pair : Symbol(Pair, Decl(a.ts, 0, 0)) +>A : Symbol(A, Decl(a.ts, 0, 15)) +>B : Symbol(B, Decl(a.ts, 0, 17)) +>a : Symbol(Pair.a, Decl(a.ts, 0, 22)) +>A : Symbol(A, Decl(a.ts, 0, 15)) +>b : Symbol(Pair.b, Decl(a.ts, 0, 28)) +>B : Symbol(B, Decl(a.ts, 0, 17)) + +interface Box { m(x: T): Pair } +>Box : Symbol(Box, Decl(a.ts, 0, 35)) +>U : Symbol(U, Decl(a.ts, 1, 14)) +>m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>T : Symbol(T, Decl(a.ts, 1, 21)) +>x : Symbol(x, Decl(a.ts, 1, 24)) +>T : Symbol(T, Decl(a.ts, 1, 21)) +>Pair : Symbol(Pair, Decl(a.ts, 0, 0)) +>T : Symbol(T, Decl(a.ts, 1, 21)) +>U : Symbol(U, Decl(a.ts, 1, 14)) + +declare function call(f: (x: A) => R): (x: A) => R; +>call : Symbol(call, Decl(a.ts, 1, 43)) +>A : Symbol(A, Decl(a.ts, 2, 22)) +>R : Symbol(R, Decl(a.ts, 2, 24)) +>f : Symbol(f, Decl(a.ts, 2, 28)) +>x : Symbol(x, Decl(a.ts, 2, 32)) +>A : Symbol(A, Decl(a.ts, 2, 22)) +>R : Symbol(R, Decl(a.ts, 2, 24)) +>x : Symbol(x, Decl(a.ts, 2, 46)) +>A : Symbol(A, Decl(a.ts, 2, 22)) +>R : Symbol(R, Decl(a.ts, 2, 24)) + +declare const bs: Box; +>bs : Symbol(bs, Decl(a.ts, 3, 13)) +>Box : Symbol(Box, Decl(a.ts, 0, 35)) + +declare const bn: Box; +>bn : Symbol(bn, Decl(a.ts, 4, 13)) +>Box : Symbol(Box, Decl(a.ts, 0, 35)) + +const n = call(bn.m); +>n : Symbol(n, Decl(a.ts, 5, 5)) +>call : Symbol(call, Decl(a.ts, 1, 43)) +>bn.m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>bn : Symbol(bn, Decl(a.ts, 4, 13)) +>m : Symbol(Box.m, Decl(a.ts, 1, 18)) + +=== b.ts === +declare const c: boolean; +>c : Symbol(c, Decl(b.ts, 0, 13)) + +const r = c ? call(bs.m) : call(bn.m); +>r : Symbol(r, Decl(b.ts, 1, 5)) +>c : Symbol(c, Decl(b.ts, 0, 13)) +>call : Symbol(call, Decl(a.ts, 1, 43)) +>bs.m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>bs : Symbol(bs, Decl(a.ts, 3, 13)) +>m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>call : Symbol(call, Decl(a.ts, 1, 43)) +>bn.m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>bn : Symbol(bn, Decl(a.ts, 4, 13)) +>m : Symbol(Box.m, Decl(a.ts, 1, 18)) + diff --git a/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=reverse).types b/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=reverse).types new file mode 100644 index 0000000000000..8b93c5f3f8987 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=reverse).types @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/clonedTypeParameterUnionOrder.ts] //// + +=== a.ts === +interface Pair { a: A; b: B } +>a : A +>b : B + +interface Box { m(x: T): Pair } +>m : (x: T) => Pair +>x : T + +declare function call(f: (x: A) => R): (x: A) => R; +>call : (f: (x: A) => R) => (x: A) => R +>f : (x: A) => R +>x : A +>x : A + +declare const bs: Box; +>bs : Box + +declare const bn: Box; +>bn : Box + +const n = call(bn.m); +>n : (x: T) => Pair +>call(bn.m) : (x: T) => Pair +>call : (f: (x: A) => R) => (x: A) => R +>bn.m : (x: T) => Pair +>bn : Box +>m : (x: T) => Pair + +=== b.ts === +declare const c: boolean; +>c : boolean + +const r = c ? call(bs.m) : call(bn.m); +>r : ((x: T) => Pair) | ((x: T) => Pair) +>c ? call(bs.m) : call(bn.m) : ((x: T) => Pair) | ((x: T) => Pair) +>c : boolean +>call(bs.m) : (x: T) => Pair +>call : (f: (x: A) => R) => (x: A) => R +>bs.m : (x: T) => Pair +>bs : Box +>m : (x: T) => Pair +>call(bn.m) : (x: T) => Pair +>call : (f: (x: A) => R) => (x: A) => R +>bn.m : (x: T) => Pair +>bn : Box +>m : (x: T) => Pair + diff --git a/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..a61c1f0f60680 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=typesfirst).symbols @@ -0,0 +1,66 @@ +//// [tests/cases/compiler/clonedTypeParameterUnionOrder.ts] //// + +=== a.ts === +interface Pair { a: A; b: B } +>Pair : Symbol(Pair, Decl(a.ts, 0, 0)) +>A : Symbol(A, Decl(a.ts, 0, 15)) +>B : Symbol(B, Decl(a.ts, 0, 17)) +>a : Symbol(Pair.a, Decl(a.ts, 0, 22)) +>A : Symbol(A, Decl(a.ts, 0, 15)) +>b : Symbol(Pair.b, Decl(a.ts, 0, 28)) +>B : Symbol(B, Decl(a.ts, 0, 17)) + +interface Box { m(x: T): Pair } +>Box : Symbol(Box, Decl(a.ts, 0, 35)) +>U : Symbol(U, Decl(a.ts, 1, 14)) +>m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>T : Symbol(T, Decl(a.ts, 1, 21)) +>x : Symbol(x, Decl(a.ts, 1, 24)) +>T : Symbol(T, Decl(a.ts, 1, 21)) +>Pair : Symbol(Pair, Decl(a.ts, 0, 0)) +>T : Symbol(T, Decl(a.ts, 1, 21)) +>U : Symbol(U, Decl(a.ts, 1, 14)) + +declare function call(f: (x: A) => R): (x: A) => R; +>call : Symbol(call, Decl(a.ts, 1, 43)) +>A : Symbol(A, Decl(a.ts, 2, 22)) +>R : Symbol(R, Decl(a.ts, 2, 24)) +>f : Symbol(f, Decl(a.ts, 2, 28)) +>x : Symbol(x, Decl(a.ts, 2, 32)) +>A : Symbol(A, Decl(a.ts, 2, 22)) +>R : Symbol(R, Decl(a.ts, 2, 24)) +>x : Symbol(x, Decl(a.ts, 2, 46)) +>A : Symbol(A, Decl(a.ts, 2, 22)) +>R : Symbol(R, Decl(a.ts, 2, 24)) + +declare const bs: Box; +>bs : Symbol(bs, Decl(a.ts, 3, 13)) +>Box : Symbol(Box, Decl(a.ts, 0, 35)) + +declare const bn: Box; +>bn : Symbol(bn, Decl(a.ts, 4, 13)) +>Box : Symbol(Box, Decl(a.ts, 0, 35)) + +const n = call(bn.m); +>n : Symbol(n, Decl(a.ts, 5, 5)) +>call : Symbol(call, Decl(a.ts, 1, 43)) +>bn.m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>bn : Symbol(bn, Decl(a.ts, 4, 13)) +>m : Symbol(Box.m, Decl(a.ts, 1, 18)) + +=== b.ts === +declare const c: boolean; +>c : Symbol(c, Decl(b.ts, 0, 13)) + +const r = c ? call(bs.m) : call(bn.m); +>r : Symbol(r, Decl(b.ts, 1, 5)) +>c : Symbol(c, Decl(b.ts, 0, 13)) +>call : Symbol(call, Decl(a.ts, 1, 43)) +>bs.m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>bs : Symbol(bs, Decl(a.ts, 3, 13)) +>m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>call : Symbol(call, Decl(a.ts, 1, 43)) +>bn.m : Symbol(Box.m, Decl(a.ts, 1, 18)) +>bn : Symbol(bn, Decl(a.ts, 4, 13)) +>m : Symbol(Box.m, Decl(a.ts, 1, 18)) + diff --git a/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=typesfirst).types new file mode 100644 index 0000000000000..487cdba50bc87 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/clonedTypeParameterUnionOrder(checkorder=typesfirst).types @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/clonedTypeParameterUnionOrder.ts] //// + +=== a.ts === +interface Pair { a: A; b: B } +>a : A +>b : B + +interface Box { m(x: T): Pair } +>m : (x: T) => Pair +>x : T + +declare function call(f: (x: A) => R): (x: A) => R; +>call : (f: (x: A) => R) => (x: A) => R +>f : (x: A) => R +>x : A +>x : A + +declare const bs: Box; +>bs : Box + +declare const bn: Box; +>bn : Box + +const n = call(bn.m); +>n : (x: T) => Pair +>call(bn.m) : (x: T) => Pair +>call : (f: (x: A) => R) => (x: A) => R +>bn.m : (x: T) => Pair +>bn : Box +>m : (x: T) => Pair + +=== b.ts === +declare const c: boolean; +>c : boolean + +const r = c ? call(bs.m) : call(bn.m); +>r : ((x: T) => Pair) | ((x: T) => Pair) +>c ? call(bs.m) : call(bn.m) : ((x: T) => Pair) | ((x: T) => Pair) +>c : boolean +>call(bs.m) : (x: T) => Pair +>call : (f: (x: A) => R) => (x: A) => R +>bs.m : (x: T) => Pair +>bs : Box +>m : (x: T) => Pair +>call(bn.m) : (x: T) => Pair +>call : (f: (x: A) => R) => (x: A) => R +>bn.m : (x: T) => Pair +>bn : Box +>m : (x: T) => Pair + diff --git a/tsc/testdata/baselines/reference/compiler/constAssertionBindingPatternQueryOrder(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/constAssertionBindingPatternQueryOrder(checkorder=default).symbols new file mode 100644 index 0000000000000..cbd22ad10c410 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/constAssertionBindingPatternQueryOrder(checkorder=default).symbols @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/constAssertionBindingPatternQueryOrder.ts] //// + +=== constAssertionBindingPatternQueryOrder.ts === +declare function settle(fn: () => T): Promise<{ [K in keyof T]: [Awaited] }>; +>settle : Symbol(settle, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 0)) +>T : Symbol(T, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 24)) +>fn : Symbol(fn, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 54)) +>T : Symbol(T, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 24)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>K : Symbol(K, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 79)) +>T : Symbol(T, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 24)) +>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 24)) +>K : Symbol(K, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 79)) + +async function f() { +>f : Symbol(f, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 113)) + + const [[a], b] = await settle(() => [Promise.resolve(0), Promise.reject(1)] as const); +>a : Symbol(a, Decl(constAssertionBindingPatternQueryOrder.ts, 3, 10)) +>b : Symbol(b, Decl(constAssertionBindingPatternQueryOrder.ts, 3, 13)) +>settle : Symbol(settle, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 0)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --)) +>const : Symbol(const) +} + diff --git a/tsc/testdata/baselines/reference/compiler/constAssertionBindingPatternQueryOrder(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/constAssertionBindingPatternQueryOrder(checkorder=default).types new file mode 100644 index 0000000000000..d263c604b0052 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/constAssertionBindingPatternQueryOrder(checkorder=default).types @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/constAssertionBindingPatternQueryOrder.ts] //// + +=== constAssertionBindingPatternQueryOrder.ts === +declare function settle(fn: () => T): Promise<{ [K in keyof T]: [Awaited] }>; +>settle : (fn: () => T) => Promise<{ [K in keyof T]: [Awaited]; }> +>fn : () => T + +async function f() { +>f : () => Promise + + const [[a], b] = await settle(() => [Promise.resolve(0), Promise.reject(1)] as const); +>a : number +>b : [never] +>await settle(() => [Promise.resolve(0), Promise.reject(1)] as const) : [[number], [never]] +>settle(() => [Promise.resolve(0), Promise.reject(1)] as const) : Promise<[[number], [never]]> +>settle : (fn: () => T) => Promise<{ [K in keyof T]: [Awaited]; }> +>() => [Promise.resolve(0), Promise.reject(1)] as const : () => [Promise, Promise] +>[Promise.resolve(0), Promise.reject(1)] as const : [Promise, Promise] +>[Promise.resolve(0), Promise.reject(1)] : [Promise, Promise] +>Promise.resolve(0) : Promise +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } +>0 : 0 +>Promise.reject(1) : Promise +>Promise.reject : (reason?: any) => Promise +>Promise : PromiseConstructor +>reject : (reason?: any) => Promise +>1 : 1 +} + diff --git a/tsc/testdata/baselines/reference/compiler/constAssertionBindingPatternQueryOrder(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/constAssertionBindingPatternQueryOrder(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..cbd22ad10c410 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/constAssertionBindingPatternQueryOrder(checkorder=typesfirst).symbols @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/constAssertionBindingPatternQueryOrder.ts] //// + +=== constAssertionBindingPatternQueryOrder.ts === +declare function settle(fn: () => T): Promise<{ [K in keyof T]: [Awaited] }>; +>settle : Symbol(settle, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 0)) +>T : Symbol(T, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 24)) +>fn : Symbol(fn, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 54)) +>T : Symbol(T, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 24)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>K : Symbol(K, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 79)) +>T : Symbol(T, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 24)) +>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 24)) +>K : Symbol(K, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 79)) + +async function f() { +>f : Symbol(f, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 113)) + + const [[a], b] = await settle(() => [Promise.resolve(0), Promise.reject(1)] as const); +>a : Symbol(a, Decl(constAssertionBindingPatternQueryOrder.ts, 3, 10)) +>b : Symbol(b, Decl(constAssertionBindingPatternQueryOrder.ts, 3, 13)) +>settle : Symbol(settle, Decl(constAssertionBindingPatternQueryOrder.ts, 0, 0)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --)) +>const : Symbol(const) +} + diff --git a/tsc/testdata/baselines/reference/compiler/constAssertionBindingPatternQueryOrder(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/constAssertionBindingPatternQueryOrder(checkorder=typesfirst).types new file mode 100644 index 0000000000000..d263c604b0052 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/constAssertionBindingPatternQueryOrder(checkorder=typesfirst).types @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/constAssertionBindingPatternQueryOrder.ts] //// + +=== constAssertionBindingPatternQueryOrder.ts === +declare function settle(fn: () => T): Promise<{ [K in keyof T]: [Awaited] }>; +>settle : (fn: () => T) => Promise<{ [K in keyof T]: [Awaited]; }> +>fn : () => T + +async function f() { +>f : () => Promise + + const [[a], b] = await settle(() => [Promise.resolve(0), Promise.reject(1)] as const); +>a : number +>b : [never] +>await settle(() => [Promise.resolve(0), Promise.reject(1)] as const) : [[number], [never]] +>settle(() => [Promise.resolve(0), Promise.reject(1)] as const) : Promise<[[number], [never]]> +>settle : (fn: () => T) => Promise<{ [K in keyof T]: [Awaited]; }> +>() => [Promise.resolve(0), Promise.reject(1)] as const : () => [Promise, Promise] +>[Promise.resolve(0), Promise.reject(1)] as const : [Promise, Promise] +>[Promise.resolve(0), Promise.reject(1)] : [Promise, Promise] +>Promise.resolve(0) : Promise +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } +>0 : 0 +>Promise.reject(1) : Promise +>Promise.reject : (reason?: any) => Promise +>Promise : PromiseConstructor +>reject : (reason?: any) => Promise +>1 : 1 +} + diff --git a/tsc/testdata/baselines/reference/compiler/contextualCheckReentryFromOuterTypeParameters.symbols b/tsc/testdata/baselines/reference/compiler/contextualCheckReentryFromOuterTypeParameters.symbols new file mode 100644 index 0000000000000..88f761461324a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualCheckReentryFromOuterTypeParameters.symbols @@ -0,0 +1,81 @@ +//// [tests/cases/compiler/contextualCheckReentryFromOuterTypeParameters.ts] //// + +=== contextualCheckReentryFromOuterTypeParameters.ts === +interface Argv { +>Argv : Symbol(Argv, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 0, 0)) +>T : Symbol(T, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 0, 15)) + + command(builder: (args: Argv) => Argv, handler: (args: Arguments) => void): Argv; +>command : Symbol(Argv.command, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 0, 24)) +>U : Symbol(U, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 1, 12)) +>builder : Symbol(builder, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 1, 15)) +>args : Symbol(args, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 1, 25)) +>Argv : Symbol(Argv, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 0, 0)) +>T : Symbol(T, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 0, 15)) +>Argv : Symbol(Argv, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 0, 0)) +>U : Symbol(U, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 1, 12)) +>handler : Symbol(handler, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 1, 51)) +>args : Symbol(args, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 1, 62)) +>Arguments : Symbol(Arguments, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 3, 1)) +>U : Symbol(U, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 1, 12)) +>Argv : Symbol(Argv, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 0, 0)) +>T : Symbol(T, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 0, 15)) + + option(key: K, options: O): Argv<{ [key in K]: O } & Check>; +>option : Symbol(Argv.option, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 1, 100)) +>K : Symbol(K, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 2, 11)) +>O : Symbol(O, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 2, 28)) +>key : Symbol(key, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 2, 32)) +>K : Symbol(K, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 2, 11)) +>options : Symbol(options, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 2, 39)) +>O : Symbol(O, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 2, 28)) +>Argv : Symbol(Argv, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 0, 0)) +>key : Symbol(key, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 2, 61)) +>K : Symbol(K, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 2, 11)) +>O : Symbol(O, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 2, 28)) +>Check : Symbol(Check, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 4, 78)) +>O : Symbol(O, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 2, 28)) +} +type Arguments = { [key in keyof T]: T[key] } & { [key: string]: unknown }; +>Arguments : Symbol(Arguments, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 3, 1)) +>T : Symbol(T, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 4, 15)) +>key : Symbol(key, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 4, 23)) +>T : Symbol(T, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 4, 15)) +>T : Symbol(T, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 4, 15)) +>key : Symbol(key, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 4, 23)) +>key : Symbol(key, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 4, 54)) + +type Check = O extends {} ? {} : {}; +>Check : Symbol(Check, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 4, 78)) +>O : Symbol(O, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 5, 11)) +>O : Symbol(O, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 5, 11)) + +declare const yargs: Argv; +>yargs : Symbol(yargs, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 6, 13)) +>Argv : Symbol(Argv, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 0, 0)) + +yargs.command( +>yargs.command : Symbol(Argv.command, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 0, 24)) +>yargs : Symbol(yargs, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 6, 13)) +>command : Symbol(Argv.command, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 0, 24)) + + (yargs) => yargs.option("a", { type: "string" }), +>yargs : Symbol(yargs, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 9, 5)) +>yargs.option : Symbol(Argv.option, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 1, 100)) +>yargs : Symbol(yargs, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 9, 5)) +>option : Symbol(Argv.option, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 1, 100)) +>type : Symbol(type, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 9, 34)) + + (argv) => { +>argv : Symbol(argv, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 10, 5)) + + const a: { type: string } = argv.a; +>a : Symbol(a, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 11, 13)) +>type : Symbol(type, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 11, 18)) +>argv.a : Symbol(a) +>argv : Symbol(argv, Decl(contextualCheckReentryFromOuterTypeParameters.ts, 10, 5)) +>a : Symbol(a) + + }, +); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualCheckReentryFromOuterTypeParameters.types b/tsc/testdata/baselines/reference/compiler/contextualCheckReentryFromOuterTypeParameters.types new file mode 100644 index 0000000000000..bd12f97face3b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualCheckReentryFromOuterTypeParameters.types @@ -0,0 +1,58 @@ +//// [tests/cases/compiler/contextualCheckReentryFromOuterTypeParameters.ts] //// + +=== contextualCheckReentryFromOuterTypeParameters.ts === +interface Argv { + command(builder: (args: Argv) => Argv, handler: (args: Arguments) => void): Argv; +>command : (builder: (args: Argv) => Argv, handler: (args: Arguments) => void) => Argv +>builder : (args: Argv) => Argv +>args : Argv +>handler : (args: Arguments) => void +>args : Arguments + + option(key: K, options: O): Argv<{ [key in K]: O } & Check>; +>option : (key: K, options: O) => Argv<{ [key in K]: O; } & Check> +>key : K +>options : O +} +type Arguments = { [key in keyof T]: T[key] } & { [key: string]: unknown }; +>Arguments : Arguments +>key : string + +type Check = O extends {} ? {} : {}; +>Check : Check + +declare const yargs: Argv; +>yargs : Argv<{}> + +yargs.command( +>yargs.command( (yargs) => yargs.option("a", { type: "string" }), (argv) => { const a: { type: string } = argv.a; },) : Argv<{}> +>yargs.command : (builder: (args: Argv<{}>) => Argv, handler: (args: Arguments) => void) => Argv<{}> +>yargs : Argv<{}> +>command : (builder: (args: Argv<{}>) => Argv, handler: (args: Arguments) => void) => Argv<{}> + + (yargs) => yargs.option("a", { type: "string" }), +>(yargs) => yargs.option("a", { type: "string" }) : (yargs: Argv<{}>) => Argv<{ a: { type: string; }; }> +>yargs : Argv<{}> +>yargs.option("a", { type: "string" }) : Argv<{ a: { type: string; }; }> +>yargs.option : (key: K, options: O) => Argv<{ [key in K]: O; } & Check> +>yargs : Argv<{}> +>option : (key: K, options: O) => Argv<{ [key in K]: O; } & Check> +>"a" : "a" +>{ type: "string" } : { type: string; } +>type : string +>"string" : "string" + + (argv) => { +>(argv) => { const a: { type: string } = argv.a; } : (argv: Arguments<{ a: { type: string; }; }>) => void +>argv : Arguments<{ a: { type: string; }; }> + + const a: { type: string } = argv.a; +>a : { type: string; } +>type : string +>argv.a : { type: string; } +>argv : Arguments<{ a: { type: string; }; }> +>a : { type: string; } + + }, +); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualOuterTypeParameters(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/contextualOuterTypeParameters(checkorder=default).symbols new file mode 100644 index 0000000000000..3fe6805b944a0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualOuterTypeParameters(checkorder=default).symbols @@ -0,0 +1,106 @@ +//// [tests/cases/compiler/contextualOuterTypeParameters.ts] //// + +=== contextualOuterTypeParameters.ts === +// https://github.com/microsoft/TypeScript/issues/59450 + +declare function f(fun: (t: T) => void): void +>f : Symbol(f, Decl(contextualOuterTypeParameters.ts, 0, 0)) +>fun : Symbol(fun, Decl(contextualOuterTypeParameters.ts, 2, 19)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 2, 25)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 2, 28)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 2, 25)) + +f(t => { +>f : Symbol(f, Decl(contextualOuterTypeParameters.ts, 0, 0)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 4, 2)) + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : Symbol(isArray, Decl(contextualOuterTypeParameters.ts, 4, 8)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 4, 2)) + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : Symbol(IsObject, Decl(contextualOuterTypeParameters.ts, 5, 64)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 6, 21)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 4, 2)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 6, 45)) + +}); + +const fn1: (x: T) => void = t => { +>fn1 : Symbol(fn1, Decl(contextualOuterTypeParameters.ts, 9, 5)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 9, 12)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 9, 15)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 9, 12)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 9, 30)) + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : Symbol(isArray, Decl(contextualOuterTypeParameters.ts, 9, 37)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 9, 30)) + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : Symbol(IsObject, Decl(contextualOuterTypeParameters.ts, 10, 64)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 11, 21)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 9, 30)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 11, 45)) + +}; + +const fn2: (x: T) => void = function test(t) { +>fn2 : Symbol(fn2, Decl(contextualOuterTypeParameters.ts, 14, 5)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 14, 12)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 14, 15)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 14, 12)) +>test : Symbol(test, Decl(contextualOuterTypeParameters.ts, 14, 30)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 14, 45)) + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : Symbol(isArray, Decl(contextualOuterTypeParameters.ts, 14, 49)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 14, 45)) + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : Symbol(IsObject, Decl(contextualOuterTypeParameters.ts, 15, 64)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 16, 21)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 14, 45)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 16, 45)) + +}; + +const obj: { f: (x: T) => void } = { +>obj : Symbol(obj, Decl(contextualOuterTypeParameters.ts, 19, 5)) +>f : Symbol(f, Decl(contextualOuterTypeParameters.ts, 19, 12)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 19, 17)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 19, 20)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 19, 17)) + + f(t) { +>f : Symbol(f, Decl(contextualOuterTypeParameters.ts, 19, 39)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 20, 6)) + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : Symbol(isArray, Decl(contextualOuterTypeParameters.ts, 20, 10)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 20, 6)) + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : Symbol(IsObject, Decl(contextualOuterTypeParameters.ts, 21, 68)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 22, 25)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 20, 6)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 22, 49)) + } +}; + +f(function self(t) { +>f : Symbol(f, Decl(contextualOuterTypeParameters.ts, 0, 0)) +>self : Symbol(self, Decl(contextualOuterTypeParameters.ts, 26, 2)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 26, 16)) + + const s = self; +>s : Symbol(s, Decl(contextualOuterTypeParameters.ts, 27, 9)) +>self : Symbol(self, Decl(contextualOuterTypeParameters.ts, 26, 2)) + + type P = Parameters; +>P : Symbol(P, Decl(contextualOuterTypeParameters.ts, 27, 19)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(contextualOuterTypeParameters.ts, 27, 9)) + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualOuterTypeParameters(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/contextualOuterTypeParameters(checkorder=default).types new file mode 100644 index 0000000000000..3be38bfec4e31 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualOuterTypeParameters(checkorder=default).types @@ -0,0 +1,120 @@ +//// [tests/cases/compiler/contextualOuterTypeParameters.ts] //// + +=== contextualOuterTypeParameters.ts === +// https://github.com/microsoft/TypeScript/issues/59450 + +declare function f(fun: (t: T) => void): void +>f : (fun: (t: T) => void) => void +>fun : (t: T) => void +>t : T + +f(t => { +>f(t => { type isArray = (typeof t)[] extends string[] ? true : false; type IsObject = { x: typeof t } extends { x: string } ? true : false;}) : void +>f : (fun: (t: T) => void) => void +>t => { type isArray = (typeof t)[] extends string[] ? true : false; type IsObject = { x: typeof t } extends { x: string } ? true : false;} : (t: T) => void +>t : T + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : T[] extends string[] ? true : false +>t : T +>true : true +>false : false + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : { x: typeof t; } extends { x: string; } ? true : false +>x : T +>t : T +>x : string +>true : true +>false : false + +}); + +const fn1: (x: T) => void = t => { +>fn1 : (x: T) => void +>x : T +>t => { type isArray = (typeof t)[] extends string[] ? true : false; type IsObject = { x: typeof t } extends { x: string } ? true : false;} : (t: T) => void +>t : T + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : T[] extends string[] ? true : false +>t : T +>true : true +>false : false + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : { x: typeof t; } extends { x: string; } ? true : false +>x : T +>t : T +>x : string +>true : true +>false : false + +}; + +const fn2: (x: T) => void = function test(t) { +>fn2 : (x: T) => void +>x : T +>function test(t) { type isArray = (typeof t)[] extends string[] ? true : false; type IsObject = { x: typeof t } extends { x: string } ? true : false;} : (t: T) => void +>test : (t: T) => void +>t : T + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : T[] extends string[] ? true : false +>t : T +>true : true +>false : false + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : { x: typeof t; } extends { x: string; } ? true : false +>x : T +>t : T +>x : string +>true : true +>false : false + +}; + +const obj: { f: (x: T) => void } = { +>obj : { f: (x: T) => void; } +>f : (x: T) => void +>x : T +>{ f(t) { type isArray = (typeof t)[] extends string[] ? true : false; type IsObject = { x: typeof t } extends { x: string } ? true : false; }} : { f(t: T): void; } + + f(t) { +>f : (t: T) => void +>t : T + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : T[] extends string[] ? true : false +>t : T +>true : true +>false : false + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : { x: typeof t; } extends { x: string; } ? true : false +>x : T +>t : T +>x : string +>true : true +>false : false + } +}; + +f(function self(t) { +>f(function self(t) { const s = self; type P = Parameters;}) : void +>f : (fun: (t: T) => void) => void +>function self(t) { const s = self; type P = Parameters;} : (t: T) => void +>self : (t: T) => void +>t : T + + const s = self; +>s : (t: T) => void +>self : (t: T) => void + + type P = Parameters; +>P : [t: unknown] +>s : (t: T) => void + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualOuterTypeParameters(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/contextualOuterTypeParameters(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..3fe6805b944a0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualOuterTypeParameters(checkorder=typesfirst).symbols @@ -0,0 +1,106 @@ +//// [tests/cases/compiler/contextualOuterTypeParameters.ts] //// + +=== contextualOuterTypeParameters.ts === +// https://github.com/microsoft/TypeScript/issues/59450 + +declare function f(fun: (t: T) => void): void +>f : Symbol(f, Decl(contextualOuterTypeParameters.ts, 0, 0)) +>fun : Symbol(fun, Decl(contextualOuterTypeParameters.ts, 2, 19)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 2, 25)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 2, 28)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 2, 25)) + +f(t => { +>f : Symbol(f, Decl(contextualOuterTypeParameters.ts, 0, 0)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 4, 2)) + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : Symbol(isArray, Decl(contextualOuterTypeParameters.ts, 4, 8)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 4, 2)) + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : Symbol(IsObject, Decl(contextualOuterTypeParameters.ts, 5, 64)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 6, 21)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 4, 2)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 6, 45)) + +}); + +const fn1: (x: T) => void = t => { +>fn1 : Symbol(fn1, Decl(contextualOuterTypeParameters.ts, 9, 5)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 9, 12)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 9, 15)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 9, 12)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 9, 30)) + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : Symbol(isArray, Decl(contextualOuterTypeParameters.ts, 9, 37)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 9, 30)) + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : Symbol(IsObject, Decl(contextualOuterTypeParameters.ts, 10, 64)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 11, 21)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 9, 30)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 11, 45)) + +}; + +const fn2: (x: T) => void = function test(t) { +>fn2 : Symbol(fn2, Decl(contextualOuterTypeParameters.ts, 14, 5)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 14, 12)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 14, 15)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 14, 12)) +>test : Symbol(test, Decl(contextualOuterTypeParameters.ts, 14, 30)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 14, 45)) + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : Symbol(isArray, Decl(contextualOuterTypeParameters.ts, 14, 49)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 14, 45)) + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : Symbol(IsObject, Decl(contextualOuterTypeParameters.ts, 15, 64)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 16, 21)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 14, 45)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 16, 45)) + +}; + +const obj: { f: (x: T) => void } = { +>obj : Symbol(obj, Decl(contextualOuterTypeParameters.ts, 19, 5)) +>f : Symbol(f, Decl(contextualOuterTypeParameters.ts, 19, 12)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 19, 17)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 19, 20)) +>T : Symbol(T, Decl(contextualOuterTypeParameters.ts, 19, 17)) + + f(t) { +>f : Symbol(f, Decl(contextualOuterTypeParameters.ts, 19, 39)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 20, 6)) + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : Symbol(isArray, Decl(contextualOuterTypeParameters.ts, 20, 10)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 20, 6)) + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : Symbol(IsObject, Decl(contextualOuterTypeParameters.ts, 21, 68)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 22, 25)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 20, 6)) +>x : Symbol(x, Decl(contextualOuterTypeParameters.ts, 22, 49)) + } +}; + +f(function self(t) { +>f : Symbol(f, Decl(contextualOuterTypeParameters.ts, 0, 0)) +>self : Symbol(self, Decl(contextualOuterTypeParameters.ts, 26, 2)) +>t : Symbol(t, Decl(contextualOuterTypeParameters.ts, 26, 16)) + + const s = self; +>s : Symbol(s, Decl(contextualOuterTypeParameters.ts, 27, 9)) +>self : Symbol(self, Decl(contextualOuterTypeParameters.ts, 26, 2)) + + type P = Parameters; +>P : Symbol(P, Decl(contextualOuterTypeParameters.ts, 27, 19)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(contextualOuterTypeParameters.ts, 27, 9)) + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualOuterTypeParameters(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/contextualOuterTypeParameters(checkorder=typesfirst).types new file mode 100644 index 0000000000000..280e75fb600cf --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualOuterTypeParameters(checkorder=typesfirst).types @@ -0,0 +1,120 @@ +//// [tests/cases/compiler/contextualOuterTypeParameters.ts] //// + +=== contextualOuterTypeParameters.ts === +// https://github.com/microsoft/TypeScript/issues/59450 + +declare function f(fun: (t: T) => void): void +>f : (fun: (t: T) => void) => void +>fun : (t: T) => void +>t : T + +f(t => { +>f(t => { type isArray = (typeof t)[] extends string[] ? true : false; type IsObject = { x: typeof t } extends { x: string } ? true : false;}) : void +>f : (fun: (t: T) => void) => void +>t => { type isArray = (typeof t)[] extends string[] ? true : false; type IsObject = { x: typeof t } extends { x: string } ? true : false;} : (t: T) => void +>t : T + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : T[] extends string[] ? true : false +>t : T +>true : true +>false : false + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : { x: typeof t; } extends { x: string; } ? true : false +>x : T +>t : T +>x : string +>true : true +>false : false + +}); + +const fn1: (x: T) => void = t => { +>fn1 : (x: T) => void +>x : T +>t => { type isArray = (typeof t)[] extends string[] ? true : false; type IsObject = { x: typeof t } extends { x: string } ? true : false;} : (t: T) => void +>t : T + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : false +>t : T +>true : true +>false : false + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : false +>x : T +>t : T +>x : string +>true : true +>false : false + +}; + +const fn2: (x: T) => void = function test(t) { +>fn2 : (x: T) => void +>x : T +>function test(t) { type isArray = (typeof t)[] extends string[] ? true : false; type IsObject = { x: typeof t } extends { x: string } ? true : false;} : (t: T) => void +>test : (t: T) => void +>t : T + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : false +>t : T +>true : true +>false : false + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : false +>x : T +>t : T +>x : string +>true : true +>false : false + +}; + +const obj: { f: (x: T) => void } = { +>obj : { f: (x: T) => void; } +>f : (x: T) => void +>x : T +>{ f(t) { type isArray = (typeof t)[] extends string[] ? true : false; type IsObject = { x: typeof t } extends { x: string } ? true : false; }} : { f(t: T): void; } + + f(t) { +>f : (t: T) => void +>t : T + + type isArray = (typeof t)[] extends string[] ? true : false; +>isArray : false +>t : T +>true : true +>false : false + + type IsObject = { x: typeof t } extends { x: string } ? true : false; +>IsObject : false +>x : T +>t : T +>x : string +>true : true +>false : false + } +}; + +f(function self(t) { +>f(function self(t) { const s = self; type P = Parameters;}) : void +>f : (fun: (t: T) => void) => void +>function self(t) { const s = self; type P = Parameters;} : (t: T) => void +>self : (t: T) => void +>t : T + + const s = self; +>s : (t: T) => void +>self : (t: T) => void + + type P = Parameters; +>P : [t: unknown] +>s : (t: T) => void + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualParameterInCircularVariableInitializer(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/contextualParameterInCircularVariableInitializer(checkorder=default).symbols new file mode 100644 index 0000000000000..c4969f0ef5812 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualParameterInCircularVariableInitializer(checkorder=default).symbols @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/contextualParameterInCircularVariableInitializer.ts] //// + +=== contextualParameterInCircularVariableInitializer.ts === +// The initializer of `store` refers to `store` from a callback, so resolving +// the type of `store` re-enters itself. `y` must still get its contextual +// type `string` from `Store` (zustand `create()(...)` pattern), with no +// TS7006, as in main and TS 6.0. + +declare function create(init: () => T): T; +>create : Symbol(create, Decl(contextualParameterInCircularVariableInitializer.ts, 0, 0)) +>T : Symbol(T, Decl(contextualParameterInCircularVariableInitializer.ts, 5, 24)) +>init : Symbol(init, Decl(contextualParameterInCircularVariableInitializer.ts, 5, 27)) +>T : Symbol(T, Decl(contextualParameterInCircularVariableInitializer.ts, 5, 24)) +>T : Symbol(T, Decl(contextualParameterInCircularVariableInitializer.ts, 5, 24)) + +interface Store { +>Store : Symbol(Store, Decl(contextualParameterInCircularVariableInitializer.ts, 5, 45)) + + a: (x: boolean) => void; +>a : Symbol(Store.a, Decl(contextualParameterInCircularVariableInitializer.ts, 7, 17)) +>x : Symbol(x, Decl(contextualParameterInCircularVariableInitializer.ts, 8, 8)) + + b: (y: string) => void; +>b : Symbol(Store.b, Decl(contextualParameterInCircularVariableInitializer.ts, 8, 28)) +>y : Symbol(y, Decl(contextualParameterInCircularVariableInitializer.ts, 9, 8)) +} + +const store = create(() => ({ +>store : Symbol(store, Decl(contextualParameterInCircularVariableInitializer.ts, 12, 5)) +>create : Symbol(create, Decl(contextualParameterInCircularVariableInitializer.ts, 0, 0)) +>Store : Symbol(Store, Decl(contextualParameterInCircularVariableInitializer.ts, 5, 45)) + + a: (x) => store.b(""), +>a : Symbol(a, Decl(contextualParameterInCircularVariableInitializer.ts, 12, 36)) +>x : Symbol(x, Decl(contextualParameterInCircularVariableInitializer.ts, 13, 8)) +>store.b : Symbol(Store.b, Decl(contextualParameterInCircularVariableInitializer.ts, 8, 28)) +>store : Symbol(store, Decl(contextualParameterInCircularVariableInitializer.ts, 12, 5)) +>b : Symbol(Store.b, Decl(contextualParameterInCircularVariableInitializer.ts, 8, 28)) + + b: (y) => {}, +>b : Symbol(b, Decl(contextualParameterInCircularVariableInitializer.ts, 13, 26)) +>y : Symbol(y, Decl(contextualParameterInCircularVariableInitializer.ts, 14, 8)) + +})); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualParameterInCircularVariableInitializer(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/contextualParameterInCircularVariableInitializer(checkorder=default).types new file mode 100644 index 0000000000000..95dd171a5925d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualParameterInCircularVariableInitializer(checkorder=default).types @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/contextualParameterInCircularVariableInitializer.ts] //// + +=== contextualParameterInCircularVariableInitializer.ts === +// The initializer of `store` refers to `store` from a callback, so resolving +// the type of `store` re-enters itself. `y` must still get its contextual +// type `string` from `Store` (zustand `create()(...)` pattern), with no +// TS7006, as in main and TS 6.0. + +declare function create(init: () => T): T; +>create : (init: () => T) => T +>init : () => T + +interface Store { + a: (x: boolean) => void; +>a : (x: boolean) => void +>x : boolean + + b: (y: string) => void; +>b : (y: string) => void +>y : string +} + +const store = create(() => ({ +>store : Store +>create(() => ({ a: (x) => store.b(""), b: (y) => {},})) : Store +>create : (init: () => T) => T +>() => ({ a: (x) => store.b(""), b: (y) => {},}) : () => { a: (x: boolean) => void; b: (y: string) => void; } +>({ a: (x) => store.b(""), b: (y) => {},}) : { a: (x: boolean) => void; b: (y: string) => void; } +>{ a: (x) => store.b(""), b: (y) => {},} : { a: (x: boolean) => void; b: (y: string) => void; } + + a: (x) => store.b(""), +>a : (x: boolean) => void +>(x) => store.b("") : (x: boolean) => void +>x : boolean +>store.b("") : void +>store.b : (y: string) => void +>store : Store +>b : (y: string) => void +>"" : "" + + b: (y) => {}, +>b : (y: string) => void +>(y) => {} : (y: string) => void +>y : string + +})); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualParameterInCircularVariableInitializer(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/contextualParameterInCircularVariableInitializer(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..c4969f0ef5812 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualParameterInCircularVariableInitializer(checkorder=typesfirst).symbols @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/contextualParameterInCircularVariableInitializer.ts] //// + +=== contextualParameterInCircularVariableInitializer.ts === +// The initializer of `store` refers to `store` from a callback, so resolving +// the type of `store` re-enters itself. `y` must still get its contextual +// type `string` from `Store` (zustand `create()(...)` pattern), with no +// TS7006, as in main and TS 6.0. + +declare function create(init: () => T): T; +>create : Symbol(create, Decl(contextualParameterInCircularVariableInitializer.ts, 0, 0)) +>T : Symbol(T, Decl(contextualParameterInCircularVariableInitializer.ts, 5, 24)) +>init : Symbol(init, Decl(contextualParameterInCircularVariableInitializer.ts, 5, 27)) +>T : Symbol(T, Decl(contextualParameterInCircularVariableInitializer.ts, 5, 24)) +>T : Symbol(T, Decl(contextualParameterInCircularVariableInitializer.ts, 5, 24)) + +interface Store { +>Store : Symbol(Store, Decl(contextualParameterInCircularVariableInitializer.ts, 5, 45)) + + a: (x: boolean) => void; +>a : Symbol(Store.a, Decl(contextualParameterInCircularVariableInitializer.ts, 7, 17)) +>x : Symbol(x, Decl(contextualParameterInCircularVariableInitializer.ts, 8, 8)) + + b: (y: string) => void; +>b : Symbol(Store.b, Decl(contextualParameterInCircularVariableInitializer.ts, 8, 28)) +>y : Symbol(y, Decl(contextualParameterInCircularVariableInitializer.ts, 9, 8)) +} + +const store = create(() => ({ +>store : Symbol(store, Decl(contextualParameterInCircularVariableInitializer.ts, 12, 5)) +>create : Symbol(create, Decl(contextualParameterInCircularVariableInitializer.ts, 0, 0)) +>Store : Symbol(Store, Decl(contextualParameterInCircularVariableInitializer.ts, 5, 45)) + + a: (x) => store.b(""), +>a : Symbol(a, Decl(contextualParameterInCircularVariableInitializer.ts, 12, 36)) +>x : Symbol(x, Decl(contextualParameterInCircularVariableInitializer.ts, 13, 8)) +>store.b : Symbol(Store.b, Decl(contextualParameterInCircularVariableInitializer.ts, 8, 28)) +>store : Symbol(store, Decl(contextualParameterInCircularVariableInitializer.ts, 12, 5)) +>b : Symbol(Store.b, Decl(contextualParameterInCircularVariableInitializer.ts, 8, 28)) + + b: (y) => {}, +>b : Symbol(b, Decl(contextualParameterInCircularVariableInitializer.ts, 13, 26)) +>y : Symbol(y, Decl(contextualParameterInCircularVariableInitializer.ts, 14, 8)) + +})); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualParameterInCircularVariableInitializer(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/contextualParameterInCircularVariableInitializer(checkorder=typesfirst).types new file mode 100644 index 0000000000000..95dd171a5925d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualParameterInCircularVariableInitializer(checkorder=typesfirst).types @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/contextualParameterInCircularVariableInitializer.ts] //// + +=== contextualParameterInCircularVariableInitializer.ts === +// The initializer of `store` refers to `store` from a callback, so resolving +// the type of `store` re-enters itself. `y` must still get its contextual +// type `string` from `Store` (zustand `create()(...)` pattern), with no +// TS7006, as in main and TS 6.0. + +declare function create(init: () => T): T; +>create : (init: () => T) => T +>init : () => T + +interface Store { + a: (x: boolean) => void; +>a : (x: boolean) => void +>x : boolean + + b: (y: string) => void; +>b : (y: string) => void +>y : string +} + +const store = create(() => ({ +>store : Store +>create(() => ({ a: (x) => store.b(""), b: (y) => {},})) : Store +>create : (init: () => T) => T +>() => ({ a: (x) => store.b(""), b: (y) => {},}) : () => { a: (x: boolean) => void; b: (y: string) => void; } +>({ a: (x) => store.b(""), b: (y) => {},}) : { a: (x: boolean) => void; b: (y: string) => void; } +>{ a: (x) => store.b(""), b: (y) => {},} : { a: (x: boolean) => void; b: (y: string) => void; } + + a: (x) => store.b(""), +>a : (x: boolean) => void +>(x) => store.b("") : (x: boolean) => void +>x : boolean +>store.b("") : void +>store.b : (y: string) => void +>store : Store +>b : (y: string) => void +>"" : "" + + b: (y) => {}, +>b : (y: string) => void +>(y) => {} : (y: string) => void +>y : string + +})); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualParameterInReturnTypeCycleOfGenericCall(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/contextualParameterInReturnTypeCycleOfGenericCall(checkorder=default).symbols new file mode 100644 index 0000000000000..e51b75113df82 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualParameterInReturnTypeCycleOfGenericCall(checkorder=default).symbols @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/contextualParameterInReturnTypeCycleOfGenericCall.ts] //// + +=== contextualParameterInReturnTypeCycleOfGenericCall.ts === +// Inferring `T` for `g` needs the return type of the arrow, whose body is a +// call to `f` that is contextually typed by that same return type, a cycle. +// `state` must still get the contextual type `number` (S inferred from +// `initialState`), as in main and TS 6.0 (redux-toolkit `createSlice` inside +// vitest `expect(() => ...)` pattern). + +declare function f S>>(options: { +>f : Symbol(f, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 0, 0)) +>S : Symbol(S, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 19)) +>CR : Symbol(CR, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 21)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>state : Symbol(state, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 49)) +>S : Symbol(S, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 19)) +>S : Symbol(S, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 19)) +>options : Symbol(options, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 66)) + + initialState: S; +>initialState : Symbol(initialState, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 76)) +>S : Symbol(S, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 19)) + + reducers: CR; +>reducers : Symbol(reducers, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 7, 20)) +>CR : Symbol(CR, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 21)) + +}): CR; +>CR : Symbol(CR, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 21)) + +declare function g(a: T): void; +>g : Symbol(g, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 9, 7)) +>T : Symbol(T, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 10, 19)) +>a : Symbol(a, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 10, 22)) +>T : Symbol(T, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 10, 19)) + +g(() => f({ reducers: { a: (state) => state + 1 }, initialState: 0 })); +>g : Symbol(g, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 9, 7)) +>f : Symbol(f, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 0, 0)) +>reducers : Symbol(reducers, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 12, 11)) +>a : Symbol(a, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 12, 23)) +>state : Symbol(state, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 12, 28)) +>state : Symbol(state, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 12, 28)) +>initialState : Symbol(initialState, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 12, 50)) + diff --git a/tsc/testdata/baselines/reference/compiler/contextualParameterInReturnTypeCycleOfGenericCall(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/contextualParameterInReturnTypeCycleOfGenericCall(checkorder=default).types new file mode 100644 index 0000000000000..4d0000d7f411b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualParameterInReturnTypeCycleOfGenericCall(checkorder=default).types @@ -0,0 +1,43 @@ +//// [tests/cases/compiler/contextualParameterInReturnTypeCycleOfGenericCall.ts] //// + +=== contextualParameterInReturnTypeCycleOfGenericCall.ts === +// Inferring `T` for `g` needs the return type of the arrow, whose body is a +// call to `f` that is contextually typed by that same return type, a cycle. +// `state` must still get the contextual type `number` (S inferred from +// `initialState`), as in main and TS 6.0 (redux-toolkit `createSlice` inside +// vitest `expect(() => ...)` pattern). + +declare function f S>>(options: { +>f : S>>(options: { initialState: S; reducers: CR; }) => CR +>state : S +>options : { initialState: S; reducers: CR; } + + initialState: S; +>initialState : S + + reducers: CR; +>reducers : CR + +}): CR; +declare function g(a: T): void; +>g : (a: T) => void +>a : T + +g(() => f({ reducers: { a: (state) => state + 1 }, initialState: 0 })); +>g(() => f({ reducers: { a: (state) => state + 1 }, initialState: 0 })) : void +>g : (a: T) => void +>() => f({ reducers: { a: (state) => state + 1 }, initialState: 0 }) : () => { a: (state: number) => number; } +>f({ reducers: { a: (state) => state + 1 }, initialState: 0 }) : { a: (state: number) => number; } +>f : S>>(options: { initialState: S; reducers: CR; }) => CR +>{ reducers: { a: (state) => state + 1 }, initialState: 0 } : { reducers: { a: (state: number) => number; }; initialState: number; } +>reducers : { a: (state: number) => number; } +>{ a: (state) => state + 1 } : { a: (state: number) => number; } +>a : (state: number) => number +>(state) => state + 1 : (state: number) => number +>state : number +>state + 1 : number +>state : number +>1 : 1 +>initialState : number +>0 : 0 + diff --git a/tsc/testdata/baselines/reference/compiler/contextualParameterInReturnTypeCycleOfGenericCall(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/contextualParameterInReturnTypeCycleOfGenericCall(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..e51b75113df82 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualParameterInReturnTypeCycleOfGenericCall(checkorder=typesfirst).symbols @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/contextualParameterInReturnTypeCycleOfGenericCall.ts] //// + +=== contextualParameterInReturnTypeCycleOfGenericCall.ts === +// Inferring `T` for `g` needs the return type of the arrow, whose body is a +// call to `f` that is contextually typed by that same return type, a cycle. +// `state` must still get the contextual type `number` (S inferred from +// `initialState`), as in main and TS 6.0 (redux-toolkit `createSlice` inside +// vitest `expect(() => ...)` pattern). + +declare function f S>>(options: { +>f : Symbol(f, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 0, 0)) +>S : Symbol(S, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 19)) +>CR : Symbol(CR, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 21)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>state : Symbol(state, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 49)) +>S : Symbol(S, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 19)) +>S : Symbol(S, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 19)) +>options : Symbol(options, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 66)) + + initialState: S; +>initialState : Symbol(initialState, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 76)) +>S : Symbol(S, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 19)) + + reducers: CR; +>reducers : Symbol(reducers, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 7, 20)) +>CR : Symbol(CR, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 21)) + +}): CR; +>CR : Symbol(CR, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 6, 21)) + +declare function g(a: T): void; +>g : Symbol(g, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 9, 7)) +>T : Symbol(T, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 10, 19)) +>a : Symbol(a, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 10, 22)) +>T : Symbol(T, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 10, 19)) + +g(() => f({ reducers: { a: (state) => state + 1 }, initialState: 0 })); +>g : Symbol(g, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 9, 7)) +>f : Symbol(f, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 0, 0)) +>reducers : Symbol(reducers, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 12, 11)) +>a : Symbol(a, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 12, 23)) +>state : Symbol(state, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 12, 28)) +>state : Symbol(state, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 12, 28)) +>initialState : Symbol(initialState, Decl(contextualParameterInReturnTypeCycleOfGenericCall.ts, 12, 50)) + diff --git a/tsc/testdata/baselines/reference/compiler/contextualParameterInReturnTypeCycleOfGenericCall(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/contextualParameterInReturnTypeCycleOfGenericCall(checkorder=typesfirst).types new file mode 100644 index 0000000000000..4d0000d7f411b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualParameterInReturnTypeCycleOfGenericCall(checkorder=typesfirst).types @@ -0,0 +1,43 @@ +//// [tests/cases/compiler/contextualParameterInReturnTypeCycleOfGenericCall.ts] //// + +=== contextualParameterInReturnTypeCycleOfGenericCall.ts === +// Inferring `T` for `g` needs the return type of the arrow, whose body is a +// call to `f` that is contextually typed by that same return type, a cycle. +// `state` must still get the contextual type `number` (S inferred from +// `initialState`), as in main and TS 6.0 (redux-toolkit `createSlice` inside +// vitest `expect(() => ...)` pattern). + +declare function f S>>(options: { +>f : S>>(options: { initialState: S; reducers: CR; }) => CR +>state : S +>options : { initialState: S; reducers: CR; } + + initialState: S; +>initialState : S + + reducers: CR; +>reducers : CR + +}): CR; +declare function g(a: T): void; +>g : (a: T) => void +>a : T + +g(() => f({ reducers: { a: (state) => state + 1 }, initialState: 0 })); +>g(() => f({ reducers: { a: (state) => state + 1 }, initialState: 0 })) : void +>g : (a: T) => void +>() => f({ reducers: { a: (state) => state + 1 }, initialState: 0 }) : () => { a: (state: number) => number; } +>f({ reducers: { a: (state) => state + 1 }, initialState: 0 }) : { a: (state: number) => number; } +>f : S>>(options: { initialState: S; reducers: CR; }) => CR +>{ reducers: { a: (state) => state + 1 }, initialState: 0 } : { reducers: { a: (state: number) => number; }; initialState: number; } +>reducers : { a: (state: number) => number; } +>{ a: (state) => state + 1 } : { a: (state: number) => number; } +>a : (state: number) => number +>(state) => state + 1 : (state: number) => number +>state : number +>state + 1 : number +>state : number +>1 : 1 +>initialState : number +>0 : 0 + diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=default).js new file mode 100644 index 0000000000000..6772baec879f7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=default).js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/contextualReturnArrayPatternCallback.ts] //// + +//// [contextualReturnArrayPatternCallback.ts] +interface Matcher { + matcher(): { match(value: Input): boolean; value?: Value }; +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +type ArrayElement = Input extends readonly (infer Value)[] ? Value : unknown; +declare function array>>(value: Value): Matcher; +declare function when unknown>(callback: Callback): Matcher; +declare function accept>(value: Value): void; + +accept({ + list: array({ + prop: when(value => { + const text: string = value; + return true; + }), + }), +}); + + +//// [contextualReturnArrayPatternCallback.js] +"use strict"; +accept({ + list: array({ + prop: when(value => { + const text = value; + return true; + }), + }), +}); diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=default).symbols new file mode 100644 index 0000000000000..2e6faa18727fd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=default).symbols @@ -0,0 +1,89 @@ +//// [tests/cases/compiler/contextualReturnArrayPatternCallback.ts] //// + +=== contextualReturnArrayPatternCallback.ts === +interface Matcher { +>Matcher : Symbol(Matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 0, 18)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 0, 24)) + + matcher(): { match(value: Input): boolean; value?: Value }; +>matcher : Symbol(Matcher.matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 43)) +>match : Symbol(match, Decl(contextualReturnArrayPatternCallback.ts, 1, 16)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 1, 23)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 0, 18)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 1, 46)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 0, 24)) +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +>Pattern : Symbol(Pattern, Decl(contextualReturnArrayPatternCallback.ts, 2, 1)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Matcher : Symbol(Matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Key : Symbol(Key, Decl(contextualReturnArrayPatternCallback.ts, 3, 50)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Pattern : Symbol(Pattern, Decl(contextualReturnArrayPatternCallback.ts, 2, 1)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Key : Symbol(Key, Decl(contextualReturnArrayPatternCallback.ts, 3, 50)) + +type ArrayElement = Input extends readonly (infer Value)[] ? Value : unknown; +>ArrayElement : Symbol(ArrayElement, Decl(contextualReturnArrayPatternCallback.ts, 3, 94)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 4, 18)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 4, 18)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 4, 56)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 4, 56)) + +declare function array>>(value: Value): Matcher; +>array : Symbol(array, Decl(contextualReturnArrayPatternCallback.ts, 4, 84)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 5, 23)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 5, 29)) +>Pattern : Symbol(Pattern, Decl(contextualReturnArrayPatternCallback.ts, 2, 1)) +>ArrayElement : Symbol(ArrayElement, Decl(contextualReturnArrayPatternCallback.ts, 3, 94)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 5, 23)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 5, 74)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 5, 29)) +>Matcher : Symbol(Matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 5, 23)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 5, 29)) + +declare function when unknown>(callback: Callback): Matcher; +>when : Symbol(when, Decl(contextualReturnArrayPatternCallback.ts, 5, 111)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 6, 22)) +>Callback : Symbol(Callback, Decl(contextualReturnArrayPatternCallback.ts, 6, 28)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 6, 47)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 6, 22)) +>callback : Symbol(callback, Decl(contextualReturnArrayPatternCallback.ts, 6, 73)) +>Callback : Symbol(Callback, Decl(contextualReturnArrayPatternCallback.ts, 6, 28)) +>Matcher : Symbol(Matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 6, 22)) + +declare function accept>(value: Value): void; +>accept : Symbol(accept, Decl(contextualReturnArrayPatternCallback.ts, 6, 109)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 7, 24)) +>Pattern : Symbol(Pattern, Decl(contextualReturnArrayPatternCallback.ts, 2, 1)) +>list : Symbol(list, Decl(contextualReturnArrayPatternCallback.ts, 7, 47)) +>prop : Symbol(prop, Decl(contextualReturnArrayPatternCallback.ts, 7, 55)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 7, 77)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 7, 24)) + +accept({ +>accept : Symbol(accept, Decl(contextualReturnArrayPatternCallback.ts, 6, 109)) + + list: array({ +>list : Symbol(list, Decl(contextualReturnArrayPatternCallback.ts, 9, 8)) +>array : Symbol(array, Decl(contextualReturnArrayPatternCallback.ts, 4, 84)) + + prop: when(value => { +>prop : Symbol(prop, Decl(contextualReturnArrayPatternCallback.ts, 10, 17)) +>when : Symbol(when, Decl(contextualReturnArrayPatternCallback.ts, 5, 111)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 11, 19)) + + const text: string = value; +>text : Symbol(text, Decl(contextualReturnArrayPatternCallback.ts, 12, 17)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 11, 19)) + + return true; + }), + }), +}); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=default).types new file mode 100644 index 0000000000000..8ae0e4c69acc3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=default).types @@ -0,0 +1,60 @@ +//// [tests/cases/compiler/contextualReturnArrayPatternCallback.ts] //// + +=== contextualReturnArrayPatternCallback.ts === +interface Matcher { + matcher(): { match(value: Input): boolean; value?: Value }; +>matcher : () => { match(value: Input): boolean; value?: Value; } +>match : (value: Input) => boolean +>value : Input +>value : Value | undefined +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +>Pattern : Pattern + +type ArrayElement = Input extends readonly (infer Value)[] ? Value : unknown; +>ArrayElement : ArrayElement + +declare function array>>(value: Value): Matcher; +>array : >>(value: Value) => Matcher +>value : Value + +declare function when unknown>(callback: Callback): Matcher; +>when : unknown>(callback: Callback) => Matcher +>value : Input +>callback : Callback + +declare function accept>(value: Value): void; +>accept : >(value: Value) => void +>list : { prop: string; }[] +>prop : string +>value : Value + +accept({ +>accept({ list: array({ prop: when(value => { const text: string = value; return true; }), }),}) : void +>accept : >(value: Value) => void +>{ list: array({ prop: when(value => { const text: string = value; return true; }), }),} : { list: Matcher<{ prop: string; }[], { prop: Matcher; }>; } + + list: array({ +>list : Matcher<{ prop: string; }[], { prop: Matcher; }> +>array({ prop: when(value => { const text: string = value; return true; }), }) : Matcher<{ prop: string; }[], { prop: Matcher; }> +>array : >>(value: Value) => Matcher +>{ prop: when(value => { const text: string = value; return true; }), } : { prop: Matcher; } + + prop: when(value => { +>prop : Matcher +>when(value => { const text: string = value; return true; }) : Matcher +>when : unknown>(callback: Callback) => Matcher +>value => { const text: string = value; return true; } : (value: string) => boolean +>value : string + + const text: string = value; +>text : string +>value : string + + return true; +>true : true + + }), + }), +}); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..0976f43f81f01 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=typesfirst).errors.txt @@ -0,0 +1,24 @@ +contextualReturnArrayPatternCallback.ts(13,19): error TS2322: Type 'unknown' is not assignable to type 'string'. + + +==== contextualReturnArrayPatternCallback.ts (1 errors) ==== + interface Matcher { + matcher(): { match(value: Input): boolean; value?: Value }; + } + type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; + type ArrayElement = Input extends readonly (infer Value)[] ? Value : unknown; + declare function array>>(value: Value): Matcher; + declare function when unknown>(callback: Callback): Matcher; + declare function accept>(value: Value): void; + + accept({ + list: array({ + prop: when(value => { + const text: string = value; + ~~~~ +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. + return true; + }), + }), + }); + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=typesfirst).js new file mode 100644 index 0000000000000..6772baec879f7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=typesfirst).js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/contextualReturnArrayPatternCallback.ts] //// + +//// [contextualReturnArrayPatternCallback.ts] +interface Matcher { + matcher(): { match(value: Input): boolean; value?: Value }; +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +type ArrayElement = Input extends readonly (infer Value)[] ? Value : unknown; +declare function array>>(value: Value): Matcher; +declare function when unknown>(callback: Callback): Matcher; +declare function accept>(value: Value): void; + +accept({ + list: array({ + prop: when(value => { + const text: string = value; + return true; + }), + }), +}); + + +//// [contextualReturnArrayPatternCallback.js] +"use strict"; +accept({ + list: array({ + prop: when(value => { + const text = value; + return true; + }), + }), +}); diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..2e6faa18727fd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=typesfirst).symbols @@ -0,0 +1,89 @@ +//// [tests/cases/compiler/contextualReturnArrayPatternCallback.ts] //// + +=== contextualReturnArrayPatternCallback.ts === +interface Matcher { +>Matcher : Symbol(Matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 0, 18)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 0, 24)) + + matcher(): { match(value: Input): boolean; value?: Value }; +>matcher : Symbol(Matcher.matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 43)) +>match : Symbol(match, Decl(contextualReturnArrayPatternCallback.ts, 1, 16)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 1, 23)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 0, 18)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 1, 46)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 0, 24)) +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +>Pattern : Symbol(Pattern, Decl(contextualReturnArrayPatternCallback.ts, 2, 1)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Matcher : Symbol(Matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Key : Symbol(Key, Decl(contextualReturnArrayPatternCallback.ts, 3, 50)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Pattern : Symbol(Pattern, Decl(contextualReturnArrayPatternCallback.ts, 2, 1)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Key : Symbol(Key, Decl(contextualReturnArrayPatternCallback.ts, 3, 50)) + +type ArrayElement = Input extends readonly (infer Value)[] ? Value : unknown; +>ArrayElement : Symbol(ArrayElement, Decl(contextualReturnArrayPatternCallback.ts, 3, 94)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 4, 18)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 4, 18)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 4, 56)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 4, 56)) + +declare function array>>(value: Value): Matcher; +>array : Symbol(array, Decl(contextualReturnArrayPatternCallback.ts, 4, 84)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 5, 23)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 5, 29)) +>Pattern : Symbol(Pattern, Decl(contextualReturnArrayPatternCallback.ts, 2, 1)) +>ArrayElement : Symbol(ArrayElement, Decl(contextualReturnArrayPatternCallback.ts, 3, 94)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 5, 23)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 5, 74)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 5, 29)) +>Matcher : Symbol(Matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 5, 23)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 5, 29)) + +declare function when unknown>(callback: Callback): Matcher; +>when : Symbol(when, Decl(contextualReturnArrayPatternCallback.ts, 5, 111)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 6, 22)) +>Callback : Symbol(Callback, Decl(contextualReturnArrayPatternCallback.ts, 6, 28)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 6, 47)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 6, 22)) +>callback : Symbol(callback, Decl(contextualReturnArrayPatternCallback.ts, 6, 73)) +>Callback : Symbol(Callback, Decl(contextualReturnArrayPatternCallback.ts, 6, 28)) +>Matcher : Symbol(Matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 6, 22)) + +declare function accept>(value: Value): void; +>accept : Symbol(accept, Decl(contextualReturnArrayPatternCallback.ts, 6, 109)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 7, 24)) +>Pattern : Symbol(Pattern, Decl(contextualReturnArrayPatternCallback.ts, 2, 1)) +>list : Symbol(list, Decl(contextualReturnArrayPatternCallback.ts, 7, 47)) +>prop : Symbol(prop, Decl(contextualReturnArrayPatternCallback.ts, 7, 55)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 7, 77)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 7, 24)) + +accept({ +>accept : Symbol(accept, Decl(contextualReturnArrayPatternCallback.ts, 6, 109)) + + list: array({ +>list : Symbol(list, Decl(contextualReturnArrayPatternCallback.ts, 9, 8)) +>array : Symbol(array, Decl(contextualReturnArrayPatternCallback.ts, 4, 84)) + + prop: when(value => { +>prop : Symbol(prop, Decl(contextualReturnArrayPatternCallback.ts, 10, 17)) +>when : Symbol(when, Decl(contextualReturnArrayPatternCallback.ts, 5, 111)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 11, 19)) + + const text: string = value; +>text : Symbol(text, Decl(contextualReturnArrayPatternCallback.ts, 12, 17)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 11, 19)) + + return true; + }), + }), +}); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=typesfirst).types new file mode 100644 index 0000000000000..68eb717e1e135 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback(checkorder=typesfirst).types @@ -0,0 +1,60 @@ +//// [tests/cases/compiler/contextualReturnArrayPatternCallback.ts] //// + +=== contextualReturnArrayPatternCallback.ts === +interface Matcher { + matcher(): { match(value: Input): boolean; value?: Value }; +>matcher : () => { match(value: Input): boolean; value?: Value; } +>match : (value: Input) => boolean +>value : Input +>value : Value | undefined +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +>Pattern : Pattern + +type ArrayElement = Input extends readonly (infer Value)[] ? Value : unknown; +>ArrayElement : ArrayElement + +declare function array>>(value: Value): Matcher; +>array : >>(value: Value) => Matcher +>value : Value + +declare function when unknown>(callback: Callback): Matcher; +>when : unknown>(callback: Callback) => Matcher +>value : Input +>callback : Callback + +declare function accept>(value: Value): void; +>accept : >(value: Value) => void +>list : { prop: string; }[] +>prop : string +>value : Value + +accept({ +>accept({ list: array({ prop: when(value => { const text: string = value; return true; }), }),}) : void +>accept : >(value: Value) => void +>{ list: array({ prop: when(value => { const text: string = value; return true; }), }),} : { list: Matcher<{ prop: string; }[], { prop: Matcher; }>; } + + list: array({ +>list : Matcher<{ prop: string; }[], { prop: Matcher; }> +>array({ prop: when(value => { const text: string = value; return true; }), }) : Matcher<{ prop: string; }[], { prop: Matcher; }> +>array : >>(value: Value) => Matcher +>{ prop: when(value => { const text: string = value; return true; }), } : { prop: Matcher; } + + prop: when(value => { +>prop : Matcher +>when(value => { const text: string = value; return true; }) : Matcher +>when : unknown>(callback: Callback) => Matcher +>value => { const text: string = value; return true; } : (value: unknown) => boolean +>value : unknown + + const text: string = value; +>text : string +>value : unknown + + return true; +>true : true + + }), + }), +}); + diff --git a/tsc/testdata/baselines/reference/compiler/deferredTypeReferenceCycleRollback.errors.txt b/tsc/testdata/baselines/reference/compiler/deferredTypeReferenceCycleRollback.errors.txt new file mode 100644 index 0000000000000..88bdce38b167c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deferredTypeReferenceCycleRollback.errors.txt @@ -0,0 +1,24 @@ +deferredTypeReferenceCycleRollback.ts(17,31): error TS2304: Cannot find name 'Missing'. + + +==== deferredTypeReferenceCycleRollback.ts (1 errors) ==== + // A cycle rollback used to reset the type of the Array> + // node while the deferred reference identified by that node survived, + // which crashed a later instantiation of it. + + declare function declare(): void; + + interface PluginObj { + visitor: Visit; + } + type Visit = VisitFn | VisitObj; + type VisitFn = (path: NodePath

) => void; + interface VisitObj {} + declare class NodePath { + parentPath: NodePath>; + get: Get; + } + type Get = T extends Array ? Array> : never; + ~~~~~~~ +!!! error TS2304: Cannot find name 'Missing'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/deferredTypeReferenceCycleRollback.symbols b/tsc/testdata/baselines/reference/compiler/deferredTypeReferenceCycleRollback.symbols new file mode 100644 index 0000000000000..285889376a2ba --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deferredTypeReferenceCycleRollback.symbols @@ -0,0 +1,70 @@ +//// [tests/cases/compiler/deferredTypeReferenceCycleRollback.ts] //// + +=== deferredTypeReferenceCycleRollback.ts === +// A cycle rollback used to reset the type of the Array> +// node while the deferred reference identified by that node survived, +// which crashed a later instantiation of it. + +declare function declare(): void; +>declare : Symbol(declare, Decl(deferredTypeReferenceCycleRollback.ts, 0, 0)) +>T : Symbol(T, Decl(deferredTypeReferenceCycleRollback.ts, 4, 25)) +>PluginObj : Symbol(PluginObj, Decl(deferredTypeReferenceCycleRollback.ts, 4, 66)) +>PluginObj : Symbol(PluginObj, Decl(deferredTypeReferenceCycleRollback.ts, 4, 66)) + +interface PluginObj { +>PluginObj : Symbol(PluginObj, Decl(deferredTypeReferenceCycleRollback.ts, 4, 66)) +>S : Symbol(S, Decl(deferredTypeReferenceCycleRollback.ts, 6, 20)) + + visitor: Visit; +>visitor : Symbol(PluginObj.visitor, Decl(deferredTypeReferenceCycleRollback.ts, 6, 34)) +>Visit : Symbol(Visit, Decl(deferredTypeReferenceCycleRollback.ts, 8, 1)) +>S : Symbol(S, Decl(deferredTypeReferenceCycleRollback.ts, 6, 20)) +} +type Visit = VisitFn | VisitObj; +>Visit : Symbol(Visit, Decl(deferredTypeReferenceCycleRollback.ts, 8, 1)) +>S : Symbol(S, Decl(deferredTypeReferenceCycleRollback.ts, 9, 11)) +>P : Symbol(P, Decl(deferredTypeReferenceCycleRollback.ts, 9, 13)) +>VisitFn : Symbol(VisitFn, Decl(deferredTypeReferenceCycleRollback.ts, 9, 50)) +>S : Symbol(S, Decl(deferredTypeReferenceCycleRollback.ts, 9, 11)) +>P : Symbol(P, Decl(deferredTypeReferenceCycleRollback.ts, 9, 13)) +>VisitObj : Symbol(VisitObj, Decl(deferredTypeReferenceCycleRollback.ts, 10, 49)) +>S : Symbol(S, Decl(deferredTypeReferenceCycleRollback.ts, 9, 11)) +>P : Symbol(P, Decl(deferredTypeReferenceCycleRollback.ts, 9, 13)) + +type VisitFn = (path: NodePath

) => void; +>VisitFn : Symbol(VisitFn, Decl(deferredTypeReferenceCycleRollback.ts, 9, 50)) +>S : Symbol(S, Decl(deferredTypeReferenceCycleRollback.ts, 10, 13)) +>P : Symbol(P, Decl(deferredTypeReferenceCycleRollback.ts, 10, 15)) +>path : Symbol(path, Decl(deferredTypeReferenceCycleRollback.ts, 10, 22)) +>NodePath : Symbol(NodePath, Decl(deferredTypeReferenceCycleRollback.ts, 11, 27)) +>P : Symbol(P, Decl(deferredTypeReferenceCycleRollback.ts, 10, 15)) + +interface VisitObj {} +>VisitObj : Symbol(VisitObj, Decl(deferredTypeReferenceCycleRollback.ts, 10, 49)) +>S : Symbol(S, Decl(deferredTypeReferenceCycleRollback.ts, 11, 19)) +>P : Symbol(P, Decl(deferredTypeReferenceCycleRollback.ts, 11, 21)) + +declare class NodePath { +>NodePath : Symbol(NodePath, Decl(deferredTypeReferenceCycleRollback.ts, 11, 27)) +>T : Symbol(T, Decl(deferredTypeReferenceCycleRollback.ts, 12, 23)) + + parentPath: NodePath>; +>parentPath : Symbol(NodePath.parentPath, Decl(deferredTypeReferenceCycleRollback.ts, 12, 27)) +>NodePath : Symbol(NodePath, Decl(deferredTypeReferenceCycleRollback.ts, 11, 27)) +>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(deferredTypeReferenceCycleRollback.ts, 12, 23)) + + get: Get; +>get : Symbol(NodePath.get, Decl(deferredTypeReferenceCycleRollback.ts, 13, 43)) +>Get : Symbol(Get, Decl(deferredTypeReferenceCycleRollback.ts, 15, 1)) +>T : Symbol(T, Decl(deferredTypeReferenceCycleRollback.ts, 12, 23)) +} +type Get = T extends Array ? Array> : never; +>Get : Symbol(Get, Decl(deferredTypeReferenceCycleRollback.ts, 15, 1)) +>T : Symbol(T, Decl(deferredTypeReferenceCycleRollback.ts, 16, 9)) +>T : Symbol(T, Decl(deferredTypeReferenceCycleRollback.ts, 16, 9)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>Missing : Symbol(Missing) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>NodePath : Symbol(NodePath, Decl(deferredTypeReferenceCycleRollback.ts, 11, 27)) + diff --git a/tsc/testdata/baselines/reference/compiler/deferredTypeReferenceCycleRollback.types b/tsc/testdata/baselines/reference/compiler/deferredTypeReferenceCycleRollback.types new file mode 100644 index 0000000000000..7db259991a1ca --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deferredTypeReferenceCycleRollback.types @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/deferredTypeReferenceCycleRollback.ts] //// + +=== deferredTypeReferenceCycleRollback.ts === +// A cycle rollback used to reset the type of the Array> +// node while the deferred reference identified by that node survived, +// which crashed a later instantiation of it. + +declare function declare(): void; +>declare : >() => void + +interface PluginObj { + visitor: Visit; +>visitor : Visit +} +type Visit = VisitFn | VisitObj; +>Visit : Visit + +type VisitFn = (path: NodePath

) => void; +>VisitFn : VisitFn +>path : NodePath

= P | ((props: P) => void); + interface Ref { + value: T; + } + interface Rep, Nested, Runtime, Extra> extends Readonly<{ + root: Ref>; + }> {} + type Preloaded = T extends Record> ? { [K in keyof T]: Unwrap> } : never; + interface Props extends Readonly<{ + nested: Preloaded; + queries: Queries; + }> {} + type EntryPointComponent, Nested, Runtime, Extra = {}> = Component>; + type Unwrap = C extends EntryPointComponent ? Readonly<{}> : {}; + type EntryPoint = Rep ? Q : never, never, never, never>; + type GetComponent = T extends EntryPoint ? C : never; + + declare const c: EntryPointComponent<{ q: { readonly variables: { slug: string } } }, {}, { onClick: () => void }>; + declare const e: EntryPoint; + const whole: EntryPoint = e; + const root: EntryPoint["root"] = e.root; + ~~~~ +!!! error TS2322: Type 'Ref>' is not assignable to type 'Ref, never, never, {}>>'. +!!! error TS2322: Type 'EntryPointComponent<{ q: { readonly variables: { slug: string; }; }; }, never, never, {}>' is not assignable to type 'EntryPointComponent, never, never, {}>'. +!!! error TS2322: Type '(props: Props<{ q: { readonly variables: { slug: string; }; }; }, never, never, {}>) => void' is not assignable to type 'EntryPointComponent, never, never, {}>'. +!!! error TS2322: Type '(props: Props<{ q: { readonly variables: { slug: string; }; }; }, never, never, {}>) => void' is not assignable to type '(props: Props, never, never, {}>) => void'. +!!! error TS2322: Types of parameters 'props' and 'props' are incompatible. +!!! error TS2322: Type 'Props, never, never, {}>' is not assignable to type 'Props<{ q: { readonly variables: { slug: string; }; }; }, never, never, {}>'. +!!! error TS2322: Types of property 'queries' are incompatible. +!!! error TS2322: Property 'q' is missing in type 'Record' but required in type '{ q: { readonly variables: { slug: string; }; }; }'. +!!! related TS2728 varianceCircularConsistency.ts:23:40: 'q' is declared here. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/varianceCircularConsistency.symbols b/tsc/testdata/baselines/reference/compiler/varianceCircularConsistency.symbols new file mode 100644 index 0000000000000..648c66a010864 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCircularConsistency.symbols @@ -0,0 +1,146 @@ +//// [tests/cases/compiler/varianceCircularConsistency.ts] //// + +=== varianceCircularConsistency.ts === +// Variances of these mutually recursive generics must not depend on values +// measured mid-cycle. Assigning `e` to `EntryPoint` must agree with +// assigning `e.root` to `EntryPoint["root"]`. + +interface Query {} +>Query : Symbol(Query, Decl(varianceCircularConsistency.ts, 0, 0)) + +type Component

= P | ((props: P) => void); +>Component : Symbol(Component, Decl(varianceCircularConsistency.ts, 4, 18)) +>P : Symbol(P, Decl(varianceCircularConsistency.ts, 5, 15)) +>P : Symbol(P, Decl(varianceCircularConsistency.ts, 5, 15)) +>props : Symbol(props, Decl(varianceCircularConsistency.ts, 5, 26)) +>P : Symbol(P, Decl(varianceCircularConsistency.ts, 5, 15)) + +interface Ref { +>Ref : Symbol(Ref, Decl(varianceCircularConsistency.ts, 5, 45)) +>T : Symbol(T, Decl(varianceCircularConsistency.ts, 6, 14)) + + value: T; +>value : Symbol(Ref.value, Decl(varianceCircularConsistency.ts, 6, 18)) +>T : Symbol(T, Decl(varianceCircularConsistency.ts, 6, 14)) +} +interface Rep, Nested, Runtime, Extra> extends Readonly<{ +>Rep : Symbol(Rep, Decl(varianceCircularConsistency.ts, 8, 1)) +>Params : Symbol(Params, Decl(varianceCircularConsistency.ts, 9, 14)) +>Queries : Symbol(Queries, Decl(varianceCircularConsistency.ts, 9, 21)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>Query : Symbol(Query, Decl(varianceCircularConsistency.ts, 0, 0)) +>Nested : Symbol(Nested, Decl(varianceCircularConsistency.ts, 9, 60)) +>Runtime : Symbol(Runtime, Decl(varianceCircularConsistency.ts, 9, 68)) +>Extra : Symbol(Extra, Decl(varianceCircularConsistency.ts, 9, 77)) +>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --)) + + root: Ref>; +>root : Symbol(root, Decl(varianceCircularConsistency.ts, 9, 103)) +>Ref : Symbol(Ref, Decl(varianceCircularConsistency.ts, 5, 45)) +>EntryPointComponent : Symbol(EntryPointComponent, Decl(varianceCircularConsistency.ts, 16, 5)) +>Queries : Symbol(Queries, Decl(varianceCircularConsistency.ts, 9, 21)) +>Nested : Symbol(Nested, Decl(varianceCircularConsistency.ts, 9, 60)) +>Runtime : Symbol(Runtime, Decl(varianceCircularConsistency.ts, 9, 68)) + +}> {} +type Preloaded = T extends Record> ? { [K in keyof T]: Unwrap> } : never; +>Preloaded : Symbol(Preloaded, Decl(varianceCircularConsistency.ts, 11, 5)) +>T : Symbol(T, Decl(varianceCircularConsistency.ts, 12, 15)) +>T : Symbol(T, Decl(varianceCircularConsistency.ts, 12, 15)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>Rep : Symbol(Rep, Decl(varianceCircularConsistency.ts, 8, 1)) +>K : Symbol(K, Decl(varianceCircularConsistency.ts, 12, 80)) +>T : Symbol(T, Decl(varianceCircularConsistency.ts, 12, 15)) +>Unwrap : Symbol(Unwrap, Decl(varianceCircularConsistency.ts, 17, 145)) +>GetComponent : Symbol(GetComponent, Decl(varianceCircularConsistency.ts, 19, 124)) +>T : Symbol(T, Decl(varianceCircularConsistency.ts, 12, 15)) + +interface Props extends Readonly<{ +>Props : Symbol(Props, Decl(varianceCircularConsistency.ts, 12, 129)) +>Queries : Symbol(Queries, Decl(varianceCircularConsistency.ts, 13, 16)) +>Nested : Symbol(Nested, Decl(varianceCircularConsistency.ts, 13, 24)) +>Runtime : Symbol(Runtime, Decl(varianceCircularConsistency.ts, 13, 32)) +>Extra : Symbol(Extra, Decl(varianceCircularConsistency.ts, 13, 41)) +>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --)) + + nested: Preloaded; +>nested : Symbol(nested, Decl(varianceCircularConsistency.ts, 13, 67)) +>Preloaded : Symbol(Preloaded, Decl(varianceCircularConsistency.ts, 11, 5)) +>Nested : Symbol(Nested, Decl(varianceCircularConsistency.ts, 13, 24)) + + queries: Queries; +>queries : Symbol(queries, Decl(varianceCircularConsistency.ts, 14, 30)) +>Queries : Symbol(Queries, Decl(varianceCircularConsistency.ts, 13, 16)) + +}> {} +type EntryPointComponent, Nested, Runtime, Extra = {}> = Component>; +>EntryPointComponent : Symbol(EntryPointComponent, Decl(varianceCircularConsistency.ts, 16, 5)) +>Queries : Symbol(Queries, Decl(varianceCircularConsistency.ts, 17, 25)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>Query : Symbol(Query, Decl(varianceCircularConsistency.ts, 0, 0)) +>Nested : Symbol(Nested, Decl(varianceCircularConsistency.ts, 17, 63)) +>Runtime : Symbol(Runtime, Decl(varianceCircularConsistency.ts, 17, 71)) +>Extra : Symbol(Extra, Decl(varianceCircularConsistency.ts, 17, 80)) +>Component : Symbol(Component, Decl(varianceCircularConsistency.ts, 4, 18)) +>Props : Symbol(Props, Decl(varianceCircularConsistency.ts, 12, 129)) +>Queries : Symbol(Queries, Decl(varianceCircularConsistency.ts, 17, 25)) +>Nested : Symbol(Nested, Decl(varianceCircularConsistency.ts, 17, 63)) +>Runtime : Symbol(Runtime, Decl(varianceCircularConsistency.ts, 17, 71)) +>Extra : Symbol(Extra, Decl(varianceCircularConsistency.ts, 17, 80)) + +type Unwrap = C extends EntryPointComponent ? Readonly<{}> : {}; +>Unwrap : Symbol(Unwrap, Decl(varianceCircularConsistency.ts, 17, 145)) +>C : Symbol(C, Decl(varianceCircularConsistency.ts, 18, 12)) +>C : Symbol(C, Decl(varianceCircularConsistency.ts, 18, 12)) +>EntryPointComponent : Symbol(EntryPointComponent, Decl(varianceCircularConsistency.ts, 16, 5)) +>Q : Symbol(Q, Decl(varianceCircularConsistency.ts, 18, 52)) +>N : Symbol(N, Decl(varianceCircularConsistency.ts, 18, 61)) +>R : Symbol(R, Decl(varianceCircularConsistency.ts, 18, 70)) +>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --)) + +type EntryPoint = Rep ? Q : never, never, never, never>; +>EntryPoint : Symbol(EntryPoint, Decl(varianceCircularConsistency.ts, 18, 94)) +>C : Symbol(C, Decl(varianceCircularConsistency.ts, 19, 16)) +>Params : Symbol(Params, Decl(varianceCircularConsistency.ts, 19, 18)) +>Rep : Symbol(Rep, Decl(varianceCircularConsistency.ts, 8, 1)) +>Params : Symbol(Params, Decl(varianceCircularConsistency.ts, 19, 18)) +>C : Symbol(C, Decl(varianceCircularConsistency.ts, 19, 16)) +>EntryPointComponent : Symbol(EntryPointComponent, Decl(varianceCircularConsistency.ts, 16, 5)) +>Q : Symbol(Q, Decl(varianceCircularConsistency.ts, 19, 76)) +>Q : Symbol(Q, Decl(varianceCircularConsistency.ts, 19, 76)) + +type GetComponent = T extends EntryPoint ? C : never; +>GetComponent : Symbol(GetComponent, Decl(varianceCircularConsistency.ts, 19, 124)) +>T : Symbol(T, Decl(varianceCircularConsistency.ts, 20, 18)) +>T : Symbol(T, Decl(varianceCircularConsistency.ts, 20, 18)) +>EntryPoint : Symbol(EntryPoint, Decl(varianceCircularConsistency.ts, 18, 94)) +>C : Symbol(C, Decl(varianceCircularConsistency.ts, 20, 49)) +>P : Symbol(P, Decl(varianceCircularConsistency.ts, 20, 58)) +>C : Symbol(C, Decl(varianceCircularConsistency.ts, 20, 49)) + +declare const c: EntryPointComponent<{ q: { readonly variables: { slug: string } } }, {}, { onClick: () => void }>; +>c : Symbol(c, Decl(varianceCircularConsistency.ts, 22, 13)) +>EntryPointComponent : Symbol(EntryPointComponent, Decl(varianceCircularConsistency.ts, 16, 5)) +>q : Symbol(q, Decl(varianceCircularConsistency.ts, 22, 38)) +>variables : Symbol(variables, Decl(varianceCircularConsistency.ts, 22, 43)) +>slug : Symbol(slug, Decl(varianceCircularConsistency.ts, 22, 65)) +>onClick : Symbol(onClick, Decl(varianceCircularConsistency.ts, 22, 91)) + +declare const e: EntryPoint; +>e : Symbol(e, Decl(varianceCircularConsistency.ts, 23, 13)) +>EntryPoint : Symbol(EntryPoint, Decl(varianceCircularConsistency.ts, 18, 94)) +>c : Symbol(c, Decl(varianceCircularConsistency.ts, 22, 13)) +>slug : Symbol(slug, Decl(varianceCircularConsistency.ts, 23, 39)) + +const whole: EntryPoint = e; +>whole : Symbol(whole, Decl(varianceCircularConsistency.ts, 24, 5)) +>EntryPoint : Symbol(EntryPoint, Decl(varianceCircularConsistency.ts, 18, 94)) +>e : Symbol(e, Decl(varianceCircularConsistency.ts, 23, 13)) + +const root: EntryPoint["root"] = e.root; +>root : Symbol(root, Decl(varianceCircularConsistency.ts, 25, 5)) +>EntryPoint : Symbol(EntryPoint, Decl(varianceCircularConsistency.ts, 18, 94)) +>e.root : Symbol(root, Decl(varianceCircularConsistency.ts, 9, 103)) +>e : Symbol(e, Decl(varianceCircularConsistency.ts, 23, 13)) +>root : Symbol(root, Decl(varianceCircularConsistency.ts, 9, 103)) + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCircularConsistency.types b/tsc/testdata/baselines/reference/compiler/varianceCircularConsistency.types new file mode 100644 index 0000000000000..28c105bfea8f1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCircularConsistency.types @@ -0,0 +1,66 @@ +//// [tests/cases/compiler/varianceCircularConsistency.ts] //// + +=== varianceCircularConsistency.ts === +// Variances of these mutually recursive generics must not depend on values +// measured mid-cycle. Assigning `e` to `EntryPoint` must agree with +// assigning `e.root` to `EntryPoint["root"]`. + +interface Query {} +type Component

= P | ((props: P) => void); +>Component : Component

+>props : P + +interface Ref { + value: T; +>value : T +} +interface Rep, Nested, Runtime, Extra> extends Readonly<{ + root: Ref>; +>root : Ref> + +}> {} +type Preloaded = T extends Record> ? { [K in keyof T]: Unwrap> } : never; +>Preloaded : Preloaded + +interface Props extends Readonly<{ + nested: Preloaded; +>nested : Preloaded + + queries: Queries; +>queries : Queries + +}> {} +type EntryPointComponent, Nested, Runtime, Extra = {}> = Component>; +>EntryPointComponent : EntryPointComponent + +type Unwrap = C extends EntryPointComponent ? Readonly<{}> : {}; +>Unwrap : Unwrap + +type EntryPoint = Rep ? Q : never, never, never, never>; +>EntryPoint : EntryPoint + +type GetComponent = T extends EntryPoint ? C : never; +>GetComponent : GetComponent + +declare const c: EntryPointComponent<{ q: { readonly variables: { slug: string } } }, {}, { onClick: () => void }>; +>c : EntryPointComponent<{ q: { readonly variables: { slug: string; }; }; }, {}, { onClick: () => void; }, {}> +>q : { readonly variables: { slug: string; }; } +>variables : { slug: string; } +>slug : string +>onClick : () => void + +declare const e: EntryPoint; +>e : EntryPoint void; }, {}>, { slug: string; }> +>c : EntryPointComponent<{ q: { readonly variables: { slug: string; }; }; }, {}, { onClick: () => void; }, {}> +>slug : string + +const whole: EntryPoint = e; +>whole : EntryPoint +>e : EntryPoint void; }, {}>, { slug: string; }> + +const root: EntryPoint["root"] = e.root; +>root : Ref, never, never, {}>> +>e.root : Ref> +>e : EntryPoint void; }, {}>, { slug: string; }> +>root : Ref> + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCircularityChartjsPlugin(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/varianceCircularityChartjsPlugin(checkorder=default).symbols new file mode 100644 index 0000000000000..0006921f84935 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCircularityChartjsPlugin(checkorder=default).symbols @@ -0,0 +1,279 @@ +//// [tests/cases/compiler/varianceCircularityChartjsPlugin.ts] //// + +=== varianceCircularityChartjsPlugin.ts === +// Reduced from chart.js typings (PeerTube, Unleash). Chart, TooltipModel and +// ScriptableContext form a variance circularity. ScriptableContext is in +// fact invariant: ScriptableContext<"bar" | "line"> is not assignable to +// ScriptableContext<"bar"> ('dataset.data' differs), so Chart<"bar"> is not +// assignable to Chart and the assignment below must be an error. +// Measuring variances from the circularity's entry, main recorded +// ScriptableContext/TooltipModel as bivariant (measured mid-cycle) and +// accepted it; main reports this error too when ScriptableContext's variance +// is measured first (e.g. after checking a ScriptableContext assignment). + +declare class Element { options: O } +>Element : Symbol(Element, Decl(varianceCircularityChartjsPlugin.ts, 0, 0)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 10, 22)) +>O : Symbol(O, Decl(varianceCircularityChartjsPlugin.ts, 10, 24)) +>options : Symbol(Element.options, Decl(varianceCircularityChartjsPlugin.ts, 10, 29)) +>O : Symbol(O, Decl(varianceCircularityChartjsPlugin.ts, 10, 24)) + +type DeepPartial = T extends Function ? T : T extends object ? _DeepPartialObject : undefined +>DeepPartial : Symbol(DeepPartial, Decl(varianceCircularityChartjsPlugin.ts, 10, 42)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 11, 17)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 11, 17)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 11, 17)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 11, 17)) +>_DeepPartialObject : Symbol(_DeepPartialObject, Decl(varianceCircularityChartjsPlugin.ts, 11, 99)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 11, 17)) + +type _DeepPartialObject = { [P in keyof T]?: DeepPartial } +>_DeepPartialObject : Symbol(_DeepPartialObject, Decl(varianceCircularityChartjsPlugin.ts, 11, 99)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 12, 24)) +>P : Symbol(P, Decl(varianceCircularityChartjsPlugin.ts, 12, 32)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 12, 24)) +>DeepPartial : Symbol(DeepPartial, Decl(varianceCircularityChartjsPlugin.ts, 10, 42)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 12, 24)) +>P : Symbol(P, Decl(varianceCircularityChartjsPlugin.ts, 12, 32)) + +type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never +>UnionToIntersection : Symbol(UnionToIntersection, Decl(varianceCircularityChartjsPlugin.ts, 12, 67)) +>U : Symbol(U, Decl(varianceCircularityChartjsPlugin.ts, 13, 25)) +>U : Symbol(U, Decl(varianceCircularityChartjsPlugin.ts, 13, 25)) +>k : Symbol(k, Decl(varianceCircularityChartjsPlugin.ts, 13, 52)) +>U : Symbol(U, Decl(varianceCircularityChartjsPlugin.ts, 13, 25)) +>k : Symbol(k, Decl(varianceCircularityChartjsPlugin.ts, 13, 84)) +>I : Symbol(I, Decl(varianceCircularityChartjsPlugin.ts, 13, 92)) +>I : Symbol(I, Decl(varianceCircularityChartjsPlugin.ts, 13, 92)) + +type AnyObject = Record +>AnyObject : Symbol(AnyObject, Decl(varianceCircularityChartjsPlugin.ts, 13, 115)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + +interface ScriptableContext { +>ScriptableContext : Symbol(ScriptableContext, Decl(varianceCircularityChartjsPlugin.ts, 14, 36)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 15, 28)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + dataset: UnionToIntersection> +>dataset : Symbol(ScriptableContext.dataset, Decl(varianceCircularityChartjsPlugin.ts, 15, 54)) +>UnionToIntersection : Symbol(UnionToIntersection, Decl(varianceCircularityChartjsPlugin.ts, 12, 67)) +>ChartDataset : Symbol(ChartDataset, Decl(varianceCircularityChartjsPlugin.ts, 56, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 15, 28)) +} +type Scriptable = (ctx: TContext) => T +>Scriptable : Symbol(Scriptable, Decl(varianceCircularityChartjsPlugin.ts, 17, 1)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 18, 16)) +>TContext : Symbol(TContext, Decl(varianceCircularityChartjsPlugin.ts, 18, 18)) +>ctx : Symbol(ctx, Decl(varianceCircularityChartjsPlugin.ts, 18, 32)) +>TContext : Symbol(TContext, Decl(varianceCircularityChartjsPlugin.ts, 18, 18)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 18, 16)) + +declare class Chart { +>Chart : Symbol(Chart, Decl(varianceCircularityChartjsPlugin.ts, 18, 51)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 19, 20)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>TData : Symbol(TData, Decl(varianceCircularityChartjsPlugin.ts, 19, 56)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 19, 20)) + + config: ChartConfigurationCustomTypesPerDataset +>config : Symbol(Chart.config, Decl(varianceCircularityChartjsPlugin.ts, 19, 73)) +>ChartConfigurationCustomTypesPerDataset : Symbol(ChartConfigurationCustomTypesPerDataset, Decl(varianceCircularityChartjsPlugin.ts, 62, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 19, 20)) +} +interface Plugin { +>Plugin : Symbol(Plugin, Decl(varianceCircularityChartjsPlugin.ts, 21, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 22, 17)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + id: string; +>id : Symbol(Plugin.id, Decl(varianceCircularityChartjsPlugin.ts, 22, 43)) + + beforeDraw(chart: Chart): void +>beforeDraw : Symbol(Plugin.beforeDraw, Decl(varianceCircularityChartjsPlugin.ts, 23, 15)) +>chart : Symbol(chart, Decl(varianceCircularityChartjsPlugin.ts, 24, 15)) +>Chart : Symbol(Chart, Decl(varianceCircularityChartjsPlugin.ts, 18, 51)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 22, 17)) +} +interface CoreChartOptions { +>CoreChartOptions : Symbol(CoreChartOptions, Decl(varianceCircularityChartjsPlugin.ts, 25, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 26, 27)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + backgroundColor: Scriptable> +>backgroundColor : Symbol(CoreChartOptions.backgroundColor, Decl(varianceCircularityChartjsPlugin.ts, 26, 53)) +>Scriptable : Symbol(Scriptable, Decl(varianceCircularityChartjsPlugin.ts, 17, 1)) +>ScriptableContext : Symbol(ScriptableContext, Decl(varianceCircularityChartjsPlugin.ts, 14, 36)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 26, 27)) +} +interface AnimationSpec { +>AnimationSpec : Symbol(AnimationSpec, Decl(varianceCircularityChartjsPlugin.ts, 28, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 29, 24)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + delay: Scriptable> +>delay : Symbol(AnimationSpec.delay, Decl(varianceCircularityChartjsPlugin.ts, 29, 50)) +>Scriptable : Symbol(Scriptable, Decl(varianceCircularityChartjsPlugin.ts, 17, 1)) +>ScriptableContext : Symbol(ScriptableContext, Decl(varianceCircularityChartjsPlugin.ts, 14, 36)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 29, 24)) +} +interface TooltipModel extends Element> { +>TooltipModel : Symbol(TooltipModel, Decl(varianceCircularityChartjsPlugin.ts, 31, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 32, 23)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>Element : Symbol(Element, Decl(varianceCircularityChartjsPlugin.ts, 0, 0)) +>AnyObject : Symbol(AnyObject, Decl(varianceCircularityChartjsPlugin.ts, 13, 115)) +>TooltipOptions : Symbol(TooltipOptions, Decl(varianceCircularityChartjsPlugin.ts, 37, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 32, 23)) + + chart: Chart +>chart : Symbol(TooltipModel.chart, Decl(varianceCircularityChartjsPlugin.ts, 32, 99)) +>Chart : Symbol(Chart, Decl(varianceCircularityChartjsPlugin.ts, 18, 51)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 32, 23)) +} +interface TooltipDatasetCallbacks> { +>TooltipDatasetCallbacks : Symbol(TooltipDatasetCallbacks, Decl(varianceCircularityChartjsPlugin.ts, 34, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 35, 34)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>Model : Symbol(Model, Decl(varianceCircularityChartjsPlugin.ts, 35, 58)) +>TooltipModel : Symbol(TooltipModel, Decl(varianceCircularityChartjsPlugin.ts, 31, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 35, 34)) + + (this: Model): void +>this : Symbol(this, Decl(varianceCircularityChartjsPlugin.ts, 36, 5)) +>Model : Symbol(Model, Decl(varianceCircularityChartjsPlugin.ts, 35, 58)) +} +interface TooltipOptions { +>TooltipOptions : Symbol(TooltipOptions, Decl(varianceCircularityChartjsPlugin.ts, 37, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 38, 25)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + animation: AnimationSpec +>animation : Symbol(TooltipOptions.animation, Decl(varianceCircularityChartjsPlugin.ts, 38, 51)) +>AnimationSpec : Symbol(AnimationSpec, Decl(varianceCircularityChartjsPlugin.ts, 28, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 38, 25)) +} +interface TooltipDatasetOptions { +>TooltipDatasetOptions : Symbol(TooltipDatasetOptions, Decl(varianceCircularityChartjsPlugin.ts, 40, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 41, 32)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + callbacks: TooltipDatasetCallbacks +>callbacks : Symbol(TooltipDatasetOptions.callbacks, Decl(varianceCircularityChartjsPlugin.ts, 41, 58)) +>TooltipDatasetCallbacks : Symbol(TooltipDatasetCallbacks, Decl(varianceCircularityChartjsPlugin.ts, 34, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 41, 32)) +} +interface PluginDatasetOptionsByType { +>PluginDatasetOptionsByType : Symbol(PluginDatasetOptionsByType, Decl(varianceCircularityChartjsPlugin.ts, 43, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 44, 37)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + tooltip: TooltipDatasetOptions +>tooltip : Symbol(PluginDatasetOptionsByType.tooltip, Decl(varianceCircularityChartjsPlugin.ts, 44, 63)) +>TooltipDatasetOptions : Symbol(TooltipDatasetOptions, Decl(varianceCircularityChartjsPlugin.ts, 40, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 44, 37)) +} +interface ChartTypeRegistry { +>ChartTypeRegistry : Symbol(ChartTypeRegistry, Decl(varianceCircularityChartjsPlugin.ts, 46, 1)) + + bar: { defaultDataPoint: [] } +>bar : Symbol(ChartTypeRegistry.bar, Decl(varianceCircularityChartjsPlugin.ts, 47, 29)) +>defaultDataPoint : Symbol(defaultDataPoint, Decl(varianceCircularityChartjsPlugin.ts, 48, 10)) + + line: { defaultDataPoint: null } +>line : Symbol(ChartTypeRegistry.line, Decl(varianceCircularityChartjsPlugin.ts, 48, 33)) +>defaultDataPoint : Symbol(defaultDataPoint, Decl(varianceCircularityChartjsPlugin.ts, 49, 11)) +} +type ChartType = keyof ChartTypeRegistry +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>ChartTypeRegistry : Symbol(ChartTypeRegistry, Decl(varianceCircularityChartjsPlugin.ts, 46, 1)) + +type DatasetChartOptions = { [key in TType]: {} } +>DatasetChartOptions : Symbol(DatasetChartOptions, Decl(varianceCircularityChartjsPlugin.ts, 51, 40)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 52, 25)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>key : Symbol(key, Decl(varianceCircularityChartjsPlugin.ts, 52, 55)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 52, 25)) + +type ChartOptions = Exclude & DatasetChartOptions & TType>, undefined> +>ChartOptions : Symbol(ChartOptions, Decl(varianceCircularityChartjsPlugin.ts, 52, 74)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 53, 18)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) +>DeepPartial : Symbol(DeepPartial, Decl(varianceCircularityChartjsPlugin.ts, 10, 42)) +>CoreChartOptions : Symbol(CoreChartOptions, Decl(varianceCircularityChartjsPlugin.ts, 25, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 53, 18)) +>DatasetChartOptions : Symbol(DatasetChartOptions, Decl(varianceCircularityChartjsPlugin.ts, 51, 40)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 53, 18)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 53, 18)) + +interface ChartDatasetProperties { +>ChartDatasetProperties : Symbol(ChartDatasetProperties, Decl(varianceCircularityChartjsPlugin.ts, 53, 138)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 54, 33)) +>TData : Symbol(TData, Decl(varianceCircularityChartjsPlugin.ts, 54, 39)) + + data: TData +>data : Symbol(ChartDatasetProperties.data, Decl(varianceCircularityChartjsPlugin.ts, 54, 48)) +>TData : Symbol(TData, Decl(varianceCircularityChartjsPlugin.ts, 54, 39)) +} +type ChartDataset = +>ChartDataset : Symbol(ChartDataset, Decl(varianceCircularityChartjsPlugin.ts, 56, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 57, 18)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>TData : Symbol(TData, Decl(varianceCircularityChartjsPlugin.ts, 57, 42)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 57, 18)) + + DeepPartial> & ChartDatasetProperties +>DeepPartial : Symbol(DeepPartial, Decl(varianceCircularityChartjsPlugin.ts, 10, 42)) +>ChartTypeRegistry : Symbol(ChartTypeRegistry, Decl(varianceCircularityChartjsPlugin.ts, 46, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 57, 18)) +>PluginDatasetOptionsByType : Symbol(PluginDatasetOptionsByType, Decl(varianceCircularityChartjsPlugin.ts, 43, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 57, 18)) +>ChartDatasetProperties : Symbol(ChartDatasetProperties, Decl(varianceCircularityChartjsPlugin.ts, 53, 138)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 57, 18)) +>TData : Symbol(TData, Decl(varianceCircularityChartjsPlugin.ts, 57, 42)) + +type ChartDatasetCustomTypesPerDataset = DeepPartial> +>ChartDatasetCustomTypesPerDataset : Symbol(ChartDatasetCustomTypesPerDataset, Decl(varianceCircularityChartjsPlugin.ts, 58, 116)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 59, 39)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>DeepPartial : Symbol(DeepPartial, Decl(varianceCircularityChartjsPlugin.ts, 10, 42)) +>PluginDatasetOptionsByType : Symbol(PluginDatasetOptionsByType, Decl(varianceCircularityChartjsPlugin.ts, 43, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 59, 39)) + +interface ChartDataCustomTypesPerDataset { +>ChartDataCustomTypesPerDataset : Symbol(ChartDataCustomTypesPerDataset, Decl(varianceCircularityChartjsPlugin.ts, 59, 112)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 60, 41)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + datasets: ChartDatasetCustomTypesPerDataset +>datasets : Symbol(ChartDataCustomTypesPerDataset.datasets, Decl(varianceCircularityChartjsPlugin.ts, 60, 67)) +>ChartDatasetCustomTypesPerDataset : Symbol(ChartDatasetCustomTypesPerDataset, Decl(varianceCircularityChartjsPlugin.ts, 58, 116)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 60, 41)) +} +export interface ChartConfigurationCustomTypesPerDataset { +>ChartConfigurationCustomTypesPerDataset : Symbol(ChartConfigurationCustomTypesPerDataset, Decl(varianceCircularityChartjsPlugin.ts, 62, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 63, 57)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + data: ChartDataCustomTypesPerDataset +>data : Symbol(ChartConfigurationCustomTypesPerDataset.data, Decl(varianceCircularityChartjsPlugin.ts, 63, 83)) +>ChartDataCustomTypesPerDataset : Symbol(ChartDataCustomTypesPerDataset, Decl(varianceCircularityChartjsPlugin.ts, 59, 112)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 63, 57)) + + options: ChartOptions +>options : Symbol(ChartConfigurationCustomTypesPerDataset.options, Decl(varianceCircularityChartjsPlugin.ts, 64, 47)) +>ChartOptions : Symbol(ChartOptions, Decl(varianceCircularityChartjsPlugin.ts, 52, 74)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 63, 57)) +} + +const p: Plugin<"bar"> = { id: "x", beforeDraw: (chart: Chart) => {} }; +>p : Symbol(p, Decl(varianceCircularityChartjsPlugin.ts, 68, 5)) +>Plugin : Symbol(Plugin, Decl(varianceCircularityChartjsPlugin.ts, 21, 1)) +>id : Symbol(id, Decl(varianceCircularityChartjsPlugin.ts, 68, 26)) +>beforeDraw : Symbol(beforeDraw, Decl(varianceCircularityChartjsPlugin.ts, 68, 35)) +>chart : Symbol(chart, Decl(varianceCircularityChartjsPlugin.ts, 68, 49)) +>Chart : Symbol(Chart, Decl(varianceCircularityChartjsPlugin.ts, 18, 51)) + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCircularityChartjsPlugin(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/varianceCircularityChartjsPlugin(checkorder=default).types new file mode 100644 index 0000000000000..2f50b33ca6485 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCircularityChartjsPlugin(checkorder=default).types @@ -0,0 +1,131 @@ +//// [tests/cases/compiler/varianceCircularityChartjsPlugin.ts] //// + +=== varianceCircularityChartjsPlugin.ts === +// Reduced from chart.js typings (PeerTube, Unleash). Chart, TooltipModel and +// ScriptableContext form a variance circularity. ScriptableContext is in +// fact invariant: ScriptableContext<"bar" | "line"> is not assignable to +// ScriptableContext<"bar"> ('dataset.data' differs), so Chart<"bar"> is not +// assignable to Chart and the assignment below must be an error. +// Measuring variances from the circularity's entry, main recorded +// ScriptableContext/TooltipModel as bivariant (measured mid-cycle) and +// accepted it; main reports this error too when ScriptableContext's variance +// is measured first (e.g. after checking a ScriptableContext assignment). + +declare class Element { options: O } +>Element : Element +>options : O + +type DeepPartial = T extends Function ? T : T extends object ? _DeepPartialObject : undefined +>DeepPartial : DeepPartial + +type _DeepPartialObject = { [P in keyof T]?: DeepPartial } +>_DeepPartialObject : _DeepPartialObject + +type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never +>UnionToIntersection : UnionToIntersection +>k : U +>k : I + +type AnyObject = Record +>AnyObject : AnyObject + +interface ScriptableContext { + dataset: UnionToIntersection> +>dataset : UnionToIntersection> +} +type Scriptable = (ctx: TContext) => T +>Scriptable : Scriptable +>ctx : TContext + +declare class Chart { +>Chart : Chart + + config: ChartConfigurationCustomTypesPerDataset +>config : ChartConfigurationCustomTypesPerDataset +} +interface Plugin { + id: string; +>id : string + + beforeDraw(chart: Chart): void +>beforeDraw : (chart: Chart) => void +>chart : Chart +} +interface CoreChartOptions { + backgroundColor: Scriptable> +>backgroundColor : Scriptable> +} +interface AnimationSpec { + delay: Scriptable> +>delay : Scriptable> +} +interface TooltipModel extends Element> { + chart: Chart +>chart : Chart +} +interface TooltipDatasetCallbacks> { + (this: Model): void +>this : Model +} +interface TooltipOptions { + animation: AnimationSpec +>animation : AnimationSpec +} +interface TooltipDatasetOptions { + callbacks: TooltipDatasetCallbacks +>callbacks : TooltipDatasetCallbacks> +} +interface PluginDatasetOptionsByType { + tooltip: TooltipDatasetOptions +>tooltip : TooltipDatasetOptions +} +interface ChartTypeRegistry { + bar: { defaultDataPoint: [] } +>bar : { defaultDataPoint: []; } +>defaultDataPoint : [] + + line: { defaultDataPoint: null } +>line : { defaultDataPoint: null; } +>defaultDataPoint : null +} +type ChartType = keyof ChartTypeRegistry +>ChartType : keyof ChartTypeRegistry + +type DatasetChartOptions = { [key in TType]: {} } +>DatasetChartOptions : DatasetChartOptions + +type ChartOptions = Exclude & DatasetChartOptions & TType>, undefined> +>ChartOptions : ChartOptions + +interface ChartDatasetProperties { + data: TData +>data : TData +} +type ChartDataset = +>ChartDataset : ChartDataset + + DeepPartial> & ChartDatasetProperties +type ChartDatasetCustomTypesPerDataset = DeepPartial> +>ChartDatasetCustomTypesPerDataset : _DeepPartialObject> + +interface ChartDataCustomTypesPerDataset { + datasets: ChartDatasetCustomTypesPerDataset +>datasets : _DeepPartialObject> +} +export interface ChartConfigurationCustomTypesPerDataset { + data: ChartDataCustomTypesPerDataset +>data : ChartDataCustomTypesPerDataset + + options: ChartOptions +>options : Exclude & DatasetChartOptions & TType>, undefined> +} + +const p: Plugin<"bar"> = { id: "x", beforeDraw: (chart: Chart) => {} }; +>p : Plugin<"bar"> +>{ id: "x", beforeDraw: (chart: Chart) => {} } : { id: string; beforeDraw: (chart: Chart) => void; } +>id : string +>"x" : "x" +>beforeDraw : (chart: Chart) => void +>(chart: Chart) => {} : (chart: Chart) => void +>chart : Chart + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCircularityChartjsPlugin(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/varianceCircularityChartjsPlugin(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..0006921f84935 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCircularityChartjsPlugin(checkorder=typesfirst).symbols @@ -0,0 +1,279 @@ +//// [tests/cases/compiler/varianceCircularityChartjsPlugin.ts] //// + +=== varianceCircularityChartjsPlugin.ts === +// Reduced from chart.js typings (PeerTube, Unleash). Chart, TooltipModel and +// ScriptableContext form a variance circularity. ScriptableContext is in +// fact invariant: ScriptableContext<"bar" | "line"> is not assignable to +// ScriptableContext<"bar"> ('dataset.data' differs), so Chart<"bar"> is not +// assignable to Chart and the assignment below must be an error. +// Measuring variances from the circularity's entry, main recorded +// ScriptableContext/TooltipModel as bivariant (measured mid-cycle) and +// accepted it; main reports this error too when ScriptableContext's variance +// is measured first (e.g. after checking a ScriptableContext assignment). + +declare class Element { options: O } +>Element : Symbol(Element, Decl(varianceCircularityChartjsPlugin.ts, 0, 0)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 10, 22)) +>O : Symbol(O, Decl(varianceCircularityChartjsPlugin.ts, 10, 24)) +>options : Symbol(Element.options, Decl(varianceCircularityChartjsPlugin.ts, 10, 29)) +>O : Symbol(O, Decl(varianceCircularityChartjsPlugin.ts, 10, 24)) + +type DeepPartial = T extends Function ? T : T extends object ? _DeepPartialObject : undefined +>DeepPartial : Symbol(DeepPartial, Decl(varianceCircularityChartjsPlugin.ts, 10, 42)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 11, 17)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 11, 17)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 11, 17)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 11, 17)) +>_DeepPartialObject : Symbol(_DeepPartialObject, Decl(varianceCircularityChartjsPlugin.ts, 11, 99)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 11, 17)) + +type _DeepPartialObject = { [P in keyof T]?: DeepPartial } +>_DeepPartialObject : Symbol(_DeepPartialObject, Decl(varianceCircularityChartjsPlugin.ts, 11, 99)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 12, 24)) +>P : Symbol(P, Decl(varianceCircularityChartjsPlugin.ts, 12, 32)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 12, 24)) +>DeepPartial : Symbol(DeepPartial, Decl(varianceCircularityChartjsPlugin.ts, 10, 42)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 12, 24)) +>P : Symbol(P, Decl(varianceCircularityChartjsPlugin.ts, 12, 32)) + +type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never +>UnionToIntersection : Symbol(UnionToIntersection, Decl(varianceCircularityChartjsPlugin.ts, 12, 67)) +>U : Symbol(U, Decl(varianceCircularityChartjsPlugin.ts, 13, 25)) +>U : Symbol(U, Decl(varianceCircularityChartjsPlugin.ts, 13, 25)) +>k : Symbol(k, Decl(varianceCircularityChartjsPlugin.ts, 13, 52)) +>U : Symbol(U, Decl(varianceCircularityChartjsPlugin.ts, 13, 25)) +>k : Symbol(k, Decl(varianceCircularityChartjsPlugin.ts, 13, 84)) +>I : Symbol(I, Decl(varianceCircularityChartjsPlugin.ts, 13, 92)) +>I : Symbol(I, Decl(varianceCircularityChartjsPlugin.ts, 13, 92)) + +type AnyObject = Record +>AnyObject : Symbol(AnyObject, Decl(varianceCircularityChartjsPlugin.ts, 13, 115)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + +interface ScriptableContext { +>ScriptableContext : Symbol(ScriptableContext, Decl(varianceCircularityChartjsPlugin.ts, 14, 36)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 15, 28)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + dataset: UnionToIntersection> +>dataset : Symbol(ScriptableContext.dataset, Decl(varianceCircularityChartjsPlugin.ts, 15, 54)) +>UnionToIntersection : Symbol(UnionToIntersection, Decl(varianceCircularityChartjsPlugin.ts, 12, 67)) +>ChartDataset : Symbol(ChartDataset, Decl(varianceCircularityChartjsPlugin.ts, 56, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 15, 28)) +} +type Scriptable = (ctx: TContext) => T +>Scriptable : Symbol(Scriptable, Decl(varianceCircularityChartjsPlugin.ts, 17, 1)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 18, 16)) +>TContext : Symbol(TContext, Decl(varianceCircularityChartjsPlugin.ts, 18, 18)) +>ctx : Symbol(ctx, Decl(varianceCircularityChartjsPlugin.ts, 18, 32)) +>TContext : Symbol(TContext, Decl(varianceCircularityChartjsPlugin.ts, 18, 18)) +>T : Symbol(T, Decl(varianceCircularityChartjsPlugin.ts, 18, 16)) + +declare class Chart { +>Chart : Symbol(Chart, Decl(varianceCircularityChartjsPlugin.ts, 18, 51)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 19, 20)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>TData : Symbol(TData, Decl(varianceCircularityChartjsPlugin.ts, 19, 56)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 19, 20)) + + config: ChartConfigurationCustomTypesPerDataset +>config : Symbol(Chart.config, Decl(varianceCircularityChartjsPlugin.ts, 19, 73)) +>ChartConfigurationCustomTypesPerDataset : Symbol(ChartConfigurationCustomTypesPerDataset, Decl(varianceCircularityChartjsPlugin.ts, 62, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 19, 20)) +} +interface Plugin { +>Plugin : Symbol(Plugin, Decl(varianceCircularityChartjsPlugin.ts, 21, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 22, 17)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + id: string; +>id : Symbol(Plugin.id, Decl(varianceCircularityChartjsPlugin.ts, 22, 43)) + + beforeDraw(chart: Chart): void +>beforeDraw : Symbol(Plugin.beforeDraw, Decl(varianceCircularityChartjsPlugin.ts, 23, 15)) +>chart : Symbol(chart, Decl(varianceCircularityChartjsPlugin.ts, 24, 15)) +>Chart : Symbol(Chart, Decl(varianceCircularityChartjsPlugin.ts, 18, 51)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 22, 17)) +} +interface CoreChartOptions { +>CoreChartOptions : Symbol(CoreChartOptions, Decl(varianceCircularityChartjsPlugin.ts, 25, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 26, 27)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + backgroundColor: Scriptable> +>backgroundColor : Symbol(CoreChartOptions.backgroundColor, Decl(varianceCircularityChartjsPlugin.ts, 26, 53)) +>Scriptable : Symbol(Scriptable, Decl(varianceCircularityChartjsPlugin.ts, 17, 1)) +>ScriptableContext : Symbol(ScriptableContext, Decl(varianceCircularityChartjsPlugin.ts, 14, 36)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 26, 27)) +} +interface AnimationSpec { +>AnimationSpec : Symbol(AnimationSpec, Decl(varianceCircularityChartjsPlugin.ts, 28, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 29, 24)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + delay: Scriptable> +>delay : Symbol(AnimationSpec.delay, Decl(varianceCircularityChartjsPlugin.ts, 29, 50)) +>Scriptable : Symbol(Scriptable, Decl(varianceCircularityChartjsPlugin.ts, 17, 1)) +>ScriptableContext : Symbol(ScriptableContext, Decl(varianceCircularityChartjsPlugin.ts, 14, 36)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 29, 24)) +} +interface TooltipModel extends Element> { +>TooltipModel : Symbol(TooltipModel, Decl(varianceCircularityChartjsPlugin.ts, 31, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 32, 23)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>Element : Symbol(Element, Decl(varianceCircularityChartjsPlugin.ts, 0, 0)) +>AnyObject : Symbol(AnyObject, Decl(varianceCircularityChartjsPlugin.ts, 13, 115)) +>TooltipOptions : Symbol(TooltipOptions, Decl(varianceCircularityChartjsPlugin.ts, 37, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 32, 23)) + + chart: Chart +>chart : Symbol(TooltipModel.chart, Decl(varianceCircularityChartjsPlugin.ts, 32, 99)) +>Chart : Symbol(Chart, Decl(varianceCircularityChartjsPlugin.ts, 18, 51)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 32, 23)) +} +interface TooltipDatasetCallbacks> { +>TooltipDatasetCallbacks : Symbol(TooltipDatasetCallbacks, Decl(varianceCircularityChartjsPlugin.ts, 34, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 35, 34)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>Model : Symbol(Model, Decl(varianceCircularityChartjsPlugin.ts, 35, 58)) +>TooltipModel : Symbol(TooltipModel, Decl(varianceCircularityChartjsPlugin.ts, 31, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 35, 34)) + + (this: Model): void +>this : Symbol(this, Decl(varianceCircularityChartjsPlugin.ts, 36, 5)) +>Model : Symbol(Model, Decl(varianceCircularityChartjsPlugin.ts, 35, 58)) +} +interface TooltipOptions { +>TooltipOptions : Symbol(TooltipOptions, Decl(varianceCircularityChartjsPlugin.ts, 37, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 38, 25)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + animation: AnimationSpec +>animation : Symbol(TooltipOptions.animation, Decl(varianceCircularityChartjsPlugin.ts, 38, 51)) +>AnimationSpec : Symbol(AnimationSpec, Decl(varianceCircularityChartjsPlugin.ts, 28, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 38, 25)) +} +interface TooltipDatasetOptions { +>TooltipDatasetOptions : Symbol(TooltipDatasetOptions, Decl(varianceCircularityChartjsPlugin.ts, 40, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 41, 32)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + callbacks: TooltipDatasetCallbacks +>callbacks : Symbol(TooltipDatasetOptions.callbacks, Decl(varianceCircularityChartjsPlugin.ts, 41, 58)) +>TooltipDatasetCallbacks : Symbol(TooltipDatasetCallbacks, Decl(varianceCircularityChartjsPlugin.ts, 34, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 41, 32)) +} +interface PluginDatasetOptionsByType { +>PluginDatasetOptionsByType : Symbol(PluginDatasetOptionsByType, Decl(varianceCircularityChartjsPlugin.ts, 43, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 44, 37)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + tooltip: TooltipDatasetOptions +>tooltip : Symbol(PluginDatasetOptionsByType.tooltip, Decl(varianceCircularityChartjsPlugin.ts, 44, 63)) +>TooltipDatasetOptions : Symbol(TooltipDatasetOptions, Decl(varianceCircularityChartjsPlugin.ts, 40, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 44, 37)) +} +interface ChartTypeRegistry { +>ChartTypeRegistry : Symbol(ChartTypeRegistry, Decl(varianceCircularityChartjsPlugin.ts, 46, 1)) + + bar: { defaultDataPoint: [] } +>bar : Symbol(ChartTypeRegistry.bar, Decl(varianceCircularityChartjsPlugin.ts, 47, 29)) +>defaultDataPoint : Symbol(defaultDataPoint, Decl(varianceCircularityChartjsPlugin.ts, 48, 10)) + + line: { defaultDataPoint: null } +>line : Symbol(ChartTypeRegistry.line, Decl(varianceCircularityChartjsPlugin.ts, 48, 33)) +>defaultDataPoint : Symbol(defaultDataPoint, Decl(varianceCircularityChartjsPlugin.ts, 49, 11)) +} +type ChartType = keyof ChartTypeRegistry +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>ChartTypeRegistry : Symbol(ChartTypeRegistry, Decl(varianceCircularityChartjsPlugin.ts, 46, 1)) + +type DatasetChartOptions = { [key in TType]: {} } +>DatasetChartOptions : Symbol(DatasetChartOptions, Decl(varianceCircularityChartjsPlugin.ts, 51, 40)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 52, 25)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>key : Symbol(key, Decl(varianceCircularityChartjsPlugin.ts, 52, 55)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 52, 25)) + +type ChartOptions = Exclude & DatasetChartOptions & TType>, undefined> +>ChartOptions : Symbol(ChartOptions, Decl(varianceCircularityChartjsPlugin.ts, 52, 74)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 53, 18)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) +>DeepPartial : Symbol(DeepPartial, Decl(varianceCircularityChartjsPlugin.ts, 10, 42)) +>CoreChartOptions : Symbol(CoreChartOptions, Decl(varianceCircularityChartjsPlugin.ts, 25, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 53, 18)) +>DatasetChartOptions : Symbol(DatasetChartOptions, Decl(varianceCircularityChartjsPlugin.ts, 51, 40)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 53, 18)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 53, 18)) + +interface ChartDatasetProperties { +>ChartDatasetProperties : Symbol(ChartDatasetProperties, Decl(varianceCircularityChartjsPlugin.ts, 53, 138)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 54, 33)) +>TData : Symbol(TData, Decl(varianceCircularityChartjsPlugin.ts, 54, 39)) + + data: TData +>data : Symbol(ChartDatasetProperties.data, Decl(varianceCircularityChartjsPlugin.ts, 54, 48)) +>TData : Symbol(TData, Decl(varianceCircularityChartjsPlugin.ts, 54, 39)) +} +type ChartDataset = +>ChartDataset : Symbol(ChartDataset, Decl(varianceCircularityChartjsPlugin.ts, 56, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 57, 18)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>TData : Symbol(TData, Decl(varianceCircularityChartjsPlugin.ts, 57, 42)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 57, 18)) + + DeepPartial> & ChartDatasetProperties +>DeepPartial : Symbol(DeepPartial, Decl(varianceCircularityChartjsPlugin.ts, 10, 42)) +>ChartTypeRegistry : Symbol(ChartTypeRegistry, Decl(varianceCircularityChartjsPlugin.ts, 46, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 57, 18)) +>PluginDatasetOptionsByType : Symbol(PluginDatasetOptionsByType, Decl(varianceCircularityChartjsPlugin.ts, 43, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 57, 18)) +>ChartDatasetProperties : Symbol(ChartDatasetProperties, Decl(varianceCircularityChartjsPlugin.ts, 53, 138)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 57, 18)) +>TData : Symbol(TData, Decl(varianceCircularityChartjsPlugin.ts, 57, 42)) + +type ChartDatasetCustomTypesPerDataset = DeepPartial> +>ChartDatasetCustomTypesPerDataset : Symbol(ChartDatasetCustomTypesPerDataset, Decl(varianceCircularityChartjsPlugin.ts, 58, 116)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 59, 39)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) +>DeepPartial : Symbol(DeepPartial, Decl(varianceCircularityChartjsPlugin.ts, 10, 42)) +>PluginDatasetOptionsByType : Symbol(PluginDatasetOptionsByType, Decl(varianceCircularityChartjsPlugin.ts, 43, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 59, 39)) + +interface ChartDataCustomTypesPerDataset { +>ChartDataCustomTypesPerDataset : Symbol(ChartDataCustomTypesPerDataset, Decl(varianceCircularityChartjsPlugin.ts, 59, 112)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 60, 41)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + datasets: ChartDatasetCustomTypesPerDataset +>datasets : Symbol(ChartDataCustomTypesPerDataset.datasets, Decl(varianceCircularityChartjsPlugin.ts, 60, 67)) +>ChartDatasetCustomTypesPerDataset : Symbol(ChartDatasetCustomTypesPerDataset, Decl(varianceCircularityChartjsPlugin.ts, 58, 116)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 60, 41)) +} +export interface ChartConfigurationCustomTypesPerDataset { +>ChartConfigurationCustomTypesPerDataset : Symbol(ChartConfigurationCustomTypesPerDataset, Decl(varianceCircularityChartjsPlugin.ts, 62, 1)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 63, 57)) +>ChartType : Symbol(ChartType, Decl(varianceCircularityChartjsPlugin.ts, 50, 1)) + + data: ChartDataCustomTypesPerDataset +>data : Symbol(ChartConfigurationCustomTypesPerDataset.data, Decl(varianceCircularityChartjsPlugin.ts, 63, 83)) +>ChartDataCustomTypesPerDataset : Symbol(ChartDataCustomTypesPerDataset, Decl(varianceCircularityChartjsPlugin.ts, 59, 112)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 63, 57)) + + options: ChartOptions +>options : Symbol(ChartConfigurationCustomTypesPerDataset.options, Decl(varianceCircularityChartjsPlugin.ts, 64, 47)) +>ChartOptions : Symbol(ChartOptions, Decl(varianceCircularityChartjsPlugin.ts, 52, 74)) +>TType : Symbol(TType, Decl(varianceCircularityChartjsPlugin.ts, 63, 57)) +} + +const p: Plugin<"bar"> = { id: "x", beforeDraw: (chart: Chart) => {} }; +>p : Symbol(p, Decl(varianceCircularityChartjsPlugin.ts, 68, 5)) +>Plugin : Symbol(Plugin, Decl(varianceCircularityChartjsPlugin.ts, 21, 1)) +>id : Symbol(id, Decl(varianceCircularityChartjsPlugin.ts, 68, 26)) +>beforeDraw : Symbol(beforeDraw, Decl(varianceCircularityChartjsPlugin.ts, 68, 35)) +>chart : Symbol(chart, Decl(varianceCircularityChartjsPlugin.ts, 68, 49)) +>Chart : Symbol(Chart, Decl(varianceCircularityChartjsPlugin.ts, 18, 51)) + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCircularityChartjsPlugin(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/varianceCircularityChartjsPlugin(checkorder=typesfirst).types new file mode 100644 index 0000000000000..2f50b33ca6485 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCircularityChartjsPlugin(checkorder=typesfirst).types @@ -0,0 +1,131 @@ +//// [tests/cases/compiler/varianceCircularityChartjsPlugin.ts] //// + +=== varianceCircularityChartjsPlugin.ts === +// Reduced from chart.js typings (PeerTube, Unleash). Chart, TooltipModel and +// ScriptableContext form a variance circularity. ScriptableContext is in +// fact invariant: ScriptableContext<"bar" | "line"> is not assignable to +// ScriptableContext<"bar"> ('dataset.data' differs), so Chart<"bar"> is not +// assignable to Chart and the assignment below must be an error. +// Measuring variances from the circularity's entry, main recorded +// ScriptableContext/TooltipModel as bivariant (measured mid-cycle) and +// accepted it; main reports this error too when ScriptableContext's variance +// is measured first (e.g. after checking a ScriptableContext assignment). + +declare class Element { options: O } +>Element : Element +>options : O + +type DeepPartial = T extends Function ? T : T extends object ? _DeepPartialObject : undefined +>DeepPartial : DeepPartial + +type _DeepPartialObject = { [P in keyof T]?: DeepPartial } +>_DeepPartialObject : _DeepPartialObject + +type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never +>UnionToIntersection : UnionToIntersection +>k : U +>k : I + +type AnyObject = Record +>AnyObject : AnyObject + +interface ScriptableContext { + dataset: UnionToIntersection> +>dataset : UnionToIntersection> +} +type Scriptable = (ctx: TContext) => T +>Scriptable : Scriptable +>ctx : TContext + +declare class Chart { +>Chart : Chart + + config: ChartConfigurationCustomTypesPerDataset +>config : ChartConfigurationCustomTypesPerDataset +} +interface Plugin { + id: string; +>id : string + + beforeDraw(chart: Chart): void +>beforeDraw : (chart: Chart) => void +>chart : Chart +} +interface CoreChartOptions { + backgroundColor: Scriptable> +>backgroundColor : Scriptable> +} +interface AnimationSpec { + delay: Scriptable> +>delay : Scriptable> +} +interface TooltipModel extends Element> { + chart: Chart +>chart : Chart +} +interface TooltipDatasetCallbacks> { + (this: Model): void +>this : Model +} +interface TooltipOptions { + animation: AnimationSpec +>animation : AnimationSpec +} +interface TooltipDatasetOptions { + callbacks: TooltipDatasetCallbacks +>callbacks : TooltipDatasetCallbacks> +} +interface PluginDatasetOptionsByType { + tooltip: TooltipDatasetOptions +>tooltip : TooltipDatasetOptions +} +interface ChartTypeRegistry { + bar: { defaultDataPoint: [] } +>bar : { defaultDataPoint: []; } +>defaultDataPoint : [] + + line: { defaultDataPoint: null } +>line : { defaultDataPoint: null; } +>defaultDataPoint : null +} +type ChartType = keyof ChartTypeRegistry +>ChartType : keyof ChartTypeRegistry + +type DatasetChartOptions = { [key in TType]: {} } +>DatasetChartOptions : DatasetChartOptions + +type ChartOptions = Exclude & DatasetChartOptions & TType>, undefined> +>ChartOptions : ChartOptions + +interface ChartDatasetProperties { + data: TData +>data : TData +} +type ChartDataset = +>ChartDataset : ChartDataset + + DeepPartial> & ChartDatasetProperties +type ChartDatasetCustomTypesPerDataset = DeepPartial> +>ChartDatasetCustomTypesPerDataset : _DeepPartialObject> + +interface ChartDataCustomTypesPerDataset { + datasets: ChartDatasetCustomTypesPerDataset +>datasets : _DeepPartialObject> +} +export interface ChartConfigurationCustomTypesPerDataset { + data: ChartDataCustomTypesPerDataset +>data : ChartDataCustomTypesPerDataset + + options: ChartOptions +>options : Exclude & DatasetChartOptions & TType>, undefined> +} + +const p: Plugin<"bar"> = { id: "x", beforeDraw: (chart: Chart) => {} }; +>p : Plugin<"bar"> +>{ id: "x", beforeDraw: (chart: Chart) => {} } : { id: string; beforeDraw: (chart: Chart) => void; } +>id : string +>"x" : "x" +>beforeDraw : (chart: Chart) => void +>(chart: Chart) => {} : (chart: Chart) => void +>chart : Chart + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleCachedResults.errors.txt b/tsc/testdata/baselines/reference/compiler/varianceCycleCachedResults.errors.txt new file mode 100644 index 0000000000000..fed3dca53a0ed --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleCachedResults.errors.txt @@ -0,0 +1,25 @@ +first.ts(3,1): error TS2322: Type 'Box' is not assignable to type 'Box'. + Type 'number' is not assignable to type 'string'. + + +==== first.ts (1 errors) ==== + declare let b1: Box; + declare let b2: Box; + b1 = b2; + ~~ +!!! error TS2322: Type 'Box' is not assignable to type 'Box'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + +==== box.ts (0 errors) ==== + declare let a1: Box; + declare let a2: Box; + declare const cond: boolean; + class Box { + value!: T; + m() { + if (cond) return a1; + return a2; + } + } + const r = new Box().m(); + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleCachedResults.js b/tsc/testdata/baselines/reference/compiler/varianceCycleCachedResults.js new file mode 100644 index 0000000000000..1cc3125377745 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleCachedResults.js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/varianceCycleCachedResults.ts] //// + +//// [first.ts] +declare let b1: Box; +declare let b2: Box; +b1 = b2; + +//// [box.ts] +declare let a1: Box; +declare let a2: Box; +declare const cond: boolean; +class Box { + value!: T; + m() { + if (cond) return a1; + return a2; + } +} +const r = new Box().m(); + + +//// [first.js] +"use strict"; +b1 = b2; +//// [box.js] +"use strict"; +class Box { + value; + m() { + if (cond) + return a1; + return a2; + } +} +const r = new Box().m(); diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleCachedResults.symbols b/tsc/testdata/baselines/reference/compiler/varianceCycleCachedResults.symbols new file mode 100644 index 0000000000000..84c44e9268207 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleCachedResults.symbols @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/varianceCycleCachedResults.ts] //// + +=== first.ts === +declare let b1: Box; +>b1 : Symbol(b1, Decl(first.ts, 0, 11)) +>Box : Symbol(Box, Decl(box.ts, 2, 28)) + +declare let b2: Box; +>b2 : Symbol(b2, Decl(first.ts, 1, 11)) +>Box : Symbol(Box, Decl(box.ts, 2, 28)) + +b1 = b2; +>b1 : Symbol(b1, Decl(first.ts, 0, 11)) +>b2 : Symbol(b2, Decl(first.ts, 1, 11)) + +=== box.ts === +declare let a1: Box; +>a1 : Symbol(a1, Decl(box.ts, 0, 11)) +>Box : Symbol(Box, Decl(box.ts, 2, 28)) + +declare let a2: Box; +>a2 : Symbol(a2, Decl(box.ts, 1, 11)) +>Box : Symbol(Box, Decl(box.ts, 2, 28)) + +declare const cond: boolean; +>cond : Symbol(cond, Decl(box.ts, 2, 13)) + +class Box { +>Box : Symbol(Box, Decl(box.ts, 2, 28)) +>T : Symbol(T, Decl(box.ts, 3, 10)) + + value!: T; +>value : Symbol(Box.value, Decl(box.ts, 3, 14)) +>T : Symbol(T, Decl(box.ts, 3, 10)) + + m() { +>m : Symbol(Box.m, Decl(box.ts, 4, 14)) + + if (cond) return a1; +>cond : Symbol(cond, Decl(box.ts, 2, 13)) +>a1 : Symbol(a1, Decl(box.ts, 0, 11)) + + return a2; +>a2 : Symbol(a2, Decl(box.ts, 1, 11)) + } +} +const r = new Box().m(); +>r : Symbol(r, Decl(box.ts, 10, 5)) +>new Box().m : Symbol(Box.m, Decl(box.ts, 4, 14)) +>Box : Symbol(Box, Decl(box.ts, 2, 28)) +>m : Symbol(Box.m, Decl(box.ts, 4, 14)) + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleCachedResults.types b/tsc/testdata/baselines/reference/compiler/varianceCycleCachedResults.types new file mode 100644 index 0000000000000..c5448fc75d3ab --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleCachedResults.types @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/varianceCycleCachedResults.ts] //// + +=== first.ts === +declare let b1: Box; +>b1 : Box + +declare let b2: Box; +>b2 : Box + +b1 = b2; +>b1 = b2 : Box +>b1 : Box +>b2 : Box + +=== box.ts === +declare let a1: Box; +>a1 : Box + +declare let a2: Box; +>a2 : Box + +declare const cond: boolean; +>cond : boolean + +class Box { +>Box : Box + + value!: T; +>value : T + + m() { +>m : () => Box + + if (cond) return a1; +>cond : boolean +>a1 : Box + + return a2; +>a2 : Box + } +} +const r = new Box().m(); +>r : Box +>new Box().m() : Box +>new Box().m : () => Box +>new Box() : Box +>Box : typeof Box +>m : () => Box + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleCapnwebRpcStub.errors.txt b/tsc/testdata/baselines/reference/compiler/varianceCycleCapnwebRpcStub.errors.txt new file mode 100644 index 0000000000000..b2e530d9aca01 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleCapnwebRpcStub.errors.txt @@ -0,0 +1,165 @@ +main.ts(5,3): error TS2589: Type instantiation is excessively deep and possibly infinite. +main.ts(6,18): error TS7006: Parameter 's' implicitly has an 'any' type. + + +==== capnweb.d.ts (0 errors) ==== + // Copyright (c) 2025 Cloudflare, Inc. + // Licensed under the MIT license found in the LICENSE.txt file or at: + // https://opensource.org/license/mit + // This file borrows heavily from `types/defines/rpc.d.ts` in workerd. + // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s. + // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`. + // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to + // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape) + declare const __RPC_STUB_BRAND: '__RPC_STUB_BRAND'; + declare const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND'; + // Distinguishes mapper placeholders from regular values so param unwrapping can accept them. + declare const __RPC_MAP_VALUE_BRAND: unique symbol; + interface RpcTargetBranded { + [__RPC_TARGET_BRAND]: never; + } + // Types that can be used through `Stub`s + // `never[]` preserves compatibility with strongly-typed function signatures without introducing + // `any` into inference. + type Stubable = RpcTargetBranded | ((...args: never[]) => unknown); + // Note: also true for `any` (call sites that care check `IsAny` first). + type IsUnknown = unknown extends T ? true : false; // Types that can be passed over RPC + // The reason for using a generic type here is to build the serializable subset of RPC-compatible + // composite types. This allows types defined with the "interface" keyword to pass the + // serializable check as well. Otherwise, only types defined with the "type" keyword would pass. + type RpcCompatible = // Allow `unknown` as a leaf so records/interfaces with `unknown` fields remain compatible. + (IsUnknown extends true ? unknown : never) // RPC-compatible base values + | BaseType // RPC-compatible composites + | Map ? RpcCompatible : never, T extends Map ? RpcCompatible : never> | Set ? RpcCompatible : never> | Array ? RpcCompatible : never> | ReadonlyArray ? RpcCompatible : never> | { [K in keyof T as K extends string | number ? K : never]: RpcCompatible } | Promise ? RpcCompatible : never> // Special types + | Stub // Serialized as stubs, see `Stubify` + | Stubable; + // Base type for all RPC stubs, including common memory management methods. + // `T` is used as a marker type for unwrapping `Stub`s later. + interface StubBase extends Disposable { + [__RPC_STUB_BRAND]: T; + dup(): this; + onRpcBroken(callback: (error: any) => void): void; + } + type Stub> = T extends object ? Provider & StubBase : StubBase; + type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | BigUint64Array | BigInt64Array | Float32Array | Float64Array; // This represents all the types that can be sent as-is over an RPC boundary + type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | Blob | ReadableStream // Chunk type can be any RPC-compatible type + | WritableStream // Chunk type can be any RPC-compatible type + | URL | Request | Response | Headers; // Recursively rewrite all `Stubable` types with `Stub`s, and resolve promises. + // Arm ordering matters here: + // - `Promise` must come before `StubBase`: `RpcPromise` matches both, and must resolve + // through the Promise arm rather than pass through as-is. + // - `StubBase` must come before `Stubable`: `Stub` of a callable `T` is itself callable, so + // it matches `Stubable`. Checking `StubBase` first keeps existing stubs as-is instead of + // double-wrapping them as `Stub>`. + // prettier-ignore + type Stubify = T extends Promise ? Stubify : T extends StubBase ? T : T extends Stubable ? Stub : T extends Map ? Map, Stubify> : T extends Set ? Set> : T extends [] ? [] : T extends [infer Head, ...infer Tail] ? [Stubify, ...Stubify] : T extends readonly [] ? readonly [] : T extends readonly [infer Head, ...infer Tail] ? readonly [Stubify, ...Stubify] : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends BaseType ? T // When using "unknown" instead of "any", interfaces are not stubified. + : T extends { + [key: string | number]: any; + } ? { [K in keyof T as K extends string | number ? K : never]: Stubify } : T; + // Recursively rewrite all `Stub`s with the corresponding `T`s. + // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies: + // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`. + // prettier-ignore + type UnstubifyInner = // Preserve local RpcTarget acceptance, but avoid needless `Stub | Value` unions when the stub + // is already assignable to the value type (important for callback contextual typing). + T extends StubBase ? (T extends V ? UnstubifyInner : (T | UnstubifyInner)) : T extends Promise ? UnstubifyInner : T extends Map ? Map, Unstubify> : T extends Set ? Set> : T extends [] ? [] : T extends [infer Head, ...infer Tail] ? [Unstubify, ...Unstubify] : T extends readonly [] ? readonly [] : T extends readonly [infer Head, ...infer Tail] ? readonly [Unstubify, ...Unstubify] : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends BaseType ? T : T extends { + [key: string | number]: unknown; + } ? { [K in keyof T as K extends string | number ? K : never]: Unstubify } : T; // You can put promises anywhere in the params and they'll be resolved before delivery. + // (This also covers RpcPromise, because it's defined as being a Promise.) + // Map placeholders are also allowed so primitive map callback inputs can be forwarded directly + // into RPC params. + // + // Keep raw non-stub members so generic assignability still works when UnstubifyInner is deferred. + // Remove stub members from mixed unions so callback params don’t get both stub and unstubbed signatures. + // Marker carried by map() callback inputs. This lets primitive placeholders flow through params. + type Unstubify = NonStubMembers | UnstubifyInner | Promise> | MapValuePlaceholder>; + type UnstubifyAll = { [I in keyof A]: Unstubify }; + interface MapValuePlaceholder { + [__RPC_MAP_VALUE_BRAND]: T; + } + type NonStubMembers = Exclude>; // Utility type for adding `Disposable`s to `object` types only. + // Note `unknown & T` is equivalent to `T`. + type MaybeDisposable = T extends object ? Disposable : unknown; // The type behind the public `RpcPromise` (re-exported with its `RpcCompatible` constraint from + // index.ts). Defined here so that `Result`'s arms below resolve to the exact same alias + // instantiation: when both sides of an assignability check are the same alias applied to the + // same type arguments, the checker short-circuits on identity instead of recursing through the + // full structural comparison of these mutually-recursive types. + type RpcPromise$1 = T extends Stubable ? Promise> & Provider & StubBase : Promise & MaybeDisposable> & Provider & StubBase; + // The elision `Result` applies to a bare stub type: unwrap `Stub` back to `T` when the + // payload is `Stubable`. Such stubs await back to a stub either way, so eliding keeps a + // declared `Promise>` return interchangeable with a `Promise` return. + // Plain-interface stubs are NOT elided: `RpcPromise` only awaits to `Stub` when + // `U extends Stubable`, so eliding those would change the awaited type from a stub to a + // stubified record. The payload check is deliberately non-distributive (`[U] extends [...]`). + // `Stub` is not elided either: `[any] extends [Stubable]` is true, so without the `IsAny` + // guard an `any`-payload stub would lose its stub surface. + // Also used by the `RpcPromise` constructor signature (index.ts), which applies exactly this + // transformation so constructing from a promised stub matches the method-return type. + type ElideStub = T extends StubBase ? (IsAny extends true ? T : [U] extends [Stubable] ? U : T) : T; + // What the promise given to `new RpcPromise(...)` may resolve to: the payload itself, or — + // for stubable payloads — a stub of it. `NoInfer` keeps the stub arm out of inference, so an + // inferred `T` is always the promise's own resolution type; the arm only matters when `T` is + // explicitly annotated (`new RpcPromise(promiseOfStub)`). Stubs of non-stubable + // payloads are deliberately rejected: `ElideStub` wouldn't elide those, so accepting one would + // claim the promise awaits to a stubified record while the runtime resolves to a stub. + type PayloadOrStub = T | NoInfer>>; + // Type for method return or property on an RPC interface. + // - Stubable types are replaced by stubs. + // - RpcCompatible types are passed by value, with stubable types replaced by stubs + // and a top-level `Disposer`. + // Everything else can't be passed over RPC. + // Technically, we use custom thenables here, but they quack like `Promise`s. + // Intersecting with `(Maybe)Provider` allows pipelining. + // prettier-ignore + type Result = IsAny extends true ? RpcPromise$1 // `RpcPromise`: always safe to normalize — `Result` is idempotent — so a declared + // `RpcPromise` return produces the same type as a `Promise` return. + : R extends PromiseLike & StubBase ? Result // Bare stubs: elide per `ElideStub` above. Note there is no `RpcCompatible` re-check + // here: anything matching our `StubBase` was produced by machinery that already enforced + // the constraint, and re-evaluating `RpcCompatible` in this arm recurses through its + // `Stub` member back into `Result`, tripping TS2615 circularity errors in mapped + // types. + : R extends StubBase ? RpcPromise$1> : R extends RpcCompatible ? RpcPromise$1 : never; + type IsAny = 0 extends (1 & T) ? true : false; // Type for method or property on an RPC interface. + // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s. + // Unwrapping `Stub`s allows calling with `Stubable` arguments. + // For properties, rewrite types to be `Result`s. + // In each case, unwrap `Promise`s. + type MethodOrProperty = V extends ((...args: infer P) => infer R) ? (...args: UnstubifyAll

) => Result> : Result>; // Type for the callable part of an `Provider` if `T` is callable. + // This is intersected with methods/properties. + type MaybeCallableProvider = T extends ((...args: any[]) => any) ? MethodOrProperty : unknown; + type TupleIndexKeys> = Extract; + type MapCallbackValue = // `Omit` removes call signatures, so re-intersect callable provider behavior. + T extends unknown ? Omit, keyof Promise> & MaybeCallableProvider & MapValuePlaceholder : never; + type InvalidNativePromiseInMapResult = T extends unknown ? InvalidNativePromiseInMapResultImpl : never; + type InvalidNativePromiseInMapResultImpl = [T] extends [Seen] ? never // RpcPromise is modeled as Promise & StubBase, so allow promise-like stub values. + : T extends StubBase ? never // Native thenables cannot be represented in map recordings, even when typed as PromiseLike. + : T extends PromiseLike ? T : T extends Map ? InvalidNativePromiseInMapResult | InvalidNativePromiseInMapResult : T extends Set ? InvalidNativePromiseInMapResult : T extends readonly [] ? never : T extends readonly [infer Head, ...infer Tail] ? InvalidNativePromiseInMapResult | InvalidNativePromiseInMapResult : T extends ReadonlyArray ? InvalidNativePromiseInMapResult : T extends { + [key: string | number]: unknown; + } ? InvalidNativePromiseInMapResult], Seen | T> : never; + type MapCallbackReturn = InvalidNativePromiseInMapResult extends never ? T : never; + type ArrayProvider = { [K in number]: MethodOrProperty } & { + map(callback: (elem: MapCallbackValue) => MapCallbackReturn): Result>; + }; + type TupleProvider> = { [K in TupleIndexKeys]: MethodOrProperty } & ArrayProvider; // Base type for all other types providing RPC-like interfaces. + // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types. + // `__RPC_TARGET_BRAND` deliberately flows through the key mapping (as a `never` property) so + // stubs of branded targets stay assignable to workers-types' `Stubable`. Such stubs match our + // `Stubable` too — harmless, since all machinery checks `StubBase` before `Stubable`. + type Provider = MaybeCallableProvider & (T extends ReadonlyArray ? number extends T["length"] ? ArrayProvider : TupleProvider : { [K in Exclude>]: MethodOrProperty } & { + map(callback: (value: MapCallbackValue>) => MapCallbackReturn): Result>; + }); + export type RpcStub> = Stub; + +==== main.ts (2 errors) ==== + import type { RpcStub } from "./capnweb"; + + declare const api: RpcStub<{ sub(): Promise> }>; + export async function f() { + await api.sub(); + ~~~~~~~~~~~~~~~ +!!! error TS2589: Type instantiation is excessively deep and possibly infinite. + api.sub().then(s => s); + ~ +!!! error TS7006: Parameter 's' implicitly has an 'any' type. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleCapnwebRpcStub.symbols b/tsc/testdata/baselines/reference/compiler/varianceCycleCapnwebRpcStub.symbols new file mode 100644 index 0000000000000..ba9c1355e14cb --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleCapnwebRpcStub.symbols @@ -0,0 +1,754 @@ +//// [tests/cases/compiler/varianceCycleCapnwebRpcStub.ts] //// + +=== capnweb.d.ts === +// Copyright (c) 2025 Cloudflare, Inc. +// Licensed under the MIT license found in the LICENSE.txt file or at: +// https://opensource.org/license/mit +// This file borrows heavily from `types/defines/rpc.d.ts` in workerd. +// Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s. +// TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`. +// For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to +// accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape) +declare const __RPC_STUB_BRAND: '__RPC_STUB_BRAND'; +>__RPC_STUB_BRAND : Symbol(__RPC_STUB_BRAND, Decl(capnweb.d.ts, 8, 13)) + +declare const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND'; +>__RPC_TARGET_BRAND : Symbol(__RPC_TARGET_BRAND, Decl(capnweb.d.ts, 9, 13)) + +// Distinguishes mapper placeholders from regular values so param unwrapping can accept them. +declare const __RPC_MAP_VALUE_BRAND: unique symbol; +>__RPC_MAP_VALUE_BRAND : Symbol(__RPC_MAP_VALUE_BRAND, Decl(capnweb.d.ts, 11, 13)) + +interface RpcTargetBranded { +>RpcTargetBranded : Symbol(RpcTargetBranded, Decl(capnweb.d.ts, 11, 51)) + + [__RPC_TARGET_BRAND]: never; +>[__RPC_TARGET_BRAND] : Symbol(RpcTargetBranded[__RPC_TARGET_BRAND], Decl(capnweb.d.ts, 12, 28)) +>__RPC_TARGET_BRAND : Symbol(__RPC_TARGET_BRAND, Decl(capnweb.d.ts, 9, 13)) +} +// Types that can be used through `Stub`s +// `never[]` preserves compatibility with strongly-typed function signatures without introducing +// `any` into inference. +type Stubable = RpcTargetBranded | ((...args: never[]) => unknown); +>Stubable : Symbol(Stubable, Decl(capnweb.d.ts, 14, 1)) +>RpcTargetBranded : Symbol(RpcTargetBranded, Decl(capnweb.d.ts, 11, 51)) +>args : Symbol(args, Decl(capnweb.d.ts, 18, 37)) + +// Note: also true for `any` (call sites that care check `IsAny` first). +type IsUnknown = unknown extends T ? true : false; // Types that can be passed over RPC +>IsUnknown : Symbol(IsUnknown, Decl(capnweb.d.ts, 18, 67)) +>T : Symbol(T, Decl(capnweb.d.ts, 20, 15)) +>T : Symbol(T, Decl(capnweb.d.ts, 20, 15)) + +// The reason for using a generic type here is to build the serializable subset of RPC-compatible +// composite types. This allows types defined with the "interface" keyword to pass the +// serializable check as well. Otherwise, only types defined with the "type" keyword would pass. +type RpcCompatible = // Allow `unknown` as a leaf so records/interfaces with `unknown` fields remain compatible. +>RpcCompatible : Symbol(RpcCompatible, Decl(capnweb.d.ts, 20, 53)) +>T : Symbol(T, Decl(capnweb.d.ts, 24, 19)) + +(IsUnknown extends true ? unknown : never) // RPC-compatible base values +>IsUnknown : Symbol(IsUnknown, Decl(capnweb.d.ts, 18, 67)) +>T : Symbol(T, Decl(capnweb.d.ts, 24, 19)) + +| BaseType // RPC-compatible composites +>BaseType : Symbol(BaseType, Decl(capnweb.d.ts, 38, 178)) + +| Map ? RpcCompatible : never, T extends Map ? RpcCompatible : never> | Set ? RpcCompatible : never> | Array ? RpcCompatible : never> | ReadonlyArray ? RpcCompatible : never> | { [K in keyof T as K extends string | number ? K : never]: RpcCompatible } | Promise ? RpcCompatible : never> // Special types +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2026.collection.d.ts, --, --)) +>T : Symbol(T, Decl(capnweb.d.ts, 24, 19)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2026.collection.d.ts, --, --)) +>U : Symbol(U, Decl(capnweb.d.ts, 27, 25)) +>RpcCompatible : Symbol(RpcCompatible, Decl(capnweb.d.ts, 20, 53)) +>U : Symbol(U, Decl(capnweb.d.ts, 27, 25)) +>T : Symbol(T, Decl(capnweb.d.ts, 24, 19)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2026.collection.d.ts, --, --)) +>U : Symbol(U, Decl(capnweb.d.ts, 27, 94)) +>RpcCompatible : Symbol(RpcCompatible, Decl(capnweb.d.ts, 20, 53)) +>U : Symbol(U, Decl(capnweb.d.ts, 27, 94)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2025.collection.d.ts, --, --)) +>T : Symbol(T, Decl(capnweb.d.ts, 24, 19)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2025.collection.d.ts, --, --)) +>U : Symbol(U, Decl(capnweb.d.ts, 27, 151)) +>RpcCompatible : Symbol(RpcCompatible, Decl(capnweb.d.ts, 20, 53)) +>U : Symbol(U, Decl(capnweb.d.ts, 27, 151)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>T : Symbol(T, Decl(capnweb.d.ts, 24, 19)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>U : Symbol(U, Decl(capnweb.d.ts, 27, 212)) +>RpcCompatible : Symbol(RpcCompatible, Decl(capnweb.d.ts, 20, 53)) +>U : Symbol(U, Decl(capnweb.d.ts, 27, 212)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 3 more) +>T : Symbol(T, Decl(capnweb.d.ts, 24, 19)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 3 more) +>U : Symbol(U, Decl(capnweb.d.ts, 27, 289)) +>RpcCompatible : Symbol(RpcCompatible, Decl(capnweb.d.ts, 20, 53)) +>U : Symbol(U, Decl(capnweb.d.ts, 27, 289)) +>K : Symbol(K, Decl(capnweb.d.ts, 27, 326)) +>T : Symbol(T, Decl(capnweb.d.ts, 24, 19)) +>K : Symbol(K, Decl(capnweb.d.ts, 27, 326)) +>K : Symbol(K, Decl(capnweb.d.ts, 27, 326)) +>RpcCompatible : Symbol(RpcCompatible, Decl(capnweb.d.ts, 20, 53)) +>T : Symbol(T, Decl(capnweb.d.ts, 24, 19)) +>K : Symbol(K, Decl(capnweb.d.ts, 27, 326)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>T : Symbol(T, Decl(capnweb.d.ts, 24, 19)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>U : Symbol(U, Decl(capnweb.d.ts, 27, 437)) +>RpcCompatible : Symbol(RpcCompatible, Decl(capnweb.d.ts, 20, 53)) +>U : Symbol(U, Decl(capnweb.d.ts, 27, 437)) + +| Stub // Serialized as stubs, see `Stubify` +>Stub : Symbol(Stub, Decl(capnweb.d.ts, 36, 1)) +>Stubable : Symbol(Stubable, Decl(capnweb.d.ts, 14, 1)) + +| Stubable; +>Stubable : Symbol(Stubable, Decl(capnweb.d.ts, 14, 1)) + +// Base type for all RPC stubs, including common memory management methods. +// `T` is used as a marker type for unwrapping `Stub`s later. +interface StubBase extends Disposable { +>StubBase : Symbol(StubBase, Decl(capnweb.d.ts, 29, 11)) +>T : Symbol(T, Decl(capnweb.d.ts, 32, 19)) +>Disposable : Symbol(Disposable, Decl(lib.esnext.disposable.d.ts, --, --)) + + [__RPC_STUB_BRAND]: T; +>[__RPC_STUB_BRAND] : Symbol(StubBase[__RPC_STUB_BRAND], Decl(capnweb.d.ts, 32, 52)) +>__RPC_STUB_BRAND : Symbol(__RPC_STUB_BRAND, Decl(capnweb.d.ts, 8, 13)) +>T : Symbol(T, Decl(capnweb.d.ts, 32, 19)) + + dup(): this; +>dup : Symbol(StubBase.dup, Decl(capnweb.d.ts, 33, 24)) + + onRpcBroken(callback: (error: any) => void): void; +>onRpcBroken : Symbol(StubBase.onRpcBroken, Decl(capnweb.d.ts, 34, 14)) +>callback : Symbol(callback, Decl(capnweb.d.ts, 35, 14)) +>error : Symbol(error, Decl(capnweb.d.ts, 35, 25)) +} +type Stub> = T extends object ? Provider & StubBase : StubBase; +>Stub : Symbol(Stub, Decl(capnweb.d.ts, 36, 1)) +>T : Symbol(T, Decl(capnweb.d.ts, 37, 10)) +>RpcCompatible : Symbol(RpcCompatible, Decl(capnweb.d.ts, 20, 53)) +>T : Symbol(T, Decl(capnweb.d.ts, 37, 10)) +>T : Symbol(T, Decl(capnweb.d.ts, 37, 10)) +>Provider : Symbol(Provider, Decl(capnweb.d.ts, 137, 135)) +>T : Symbol(T, Decl(capnweb.d.ts, 37, 10)) +>StubBase : Symbol(StubBase, Decl(capnweb.d.ts, 29, 11)) +>T : Symbol(T, Decl(capnweb.d.ts, 37, 10)) +>StubBase : Symbol(StubBase, Decl(capnweb.d.ts, 29, 11)) +>T : Symbol(T, Decl(capnweb.d.ts, 37, 10)) + +type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | BigUint64Array | BigInt64Array | Float32Array | Float64Array; // This represents all the types that can be sent as-is over an RPC boundary +>TypedArray : Symbol(TypedArray, Decl(capnweb.d.ts, 37, 99)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) +>Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) +>Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) +>Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) +>Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) +>Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) +>BigUint64Array : Symbol(BigUint64Array, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2022.array.d.ts, --, --), Decl(lib.es2023.array.d.ts, --, --)) +>BigInt64Array : Symbol(BigInt64Array, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2022.array.d.ts, --, --), Decl(lib.es2023.array.d.ts, --, --)) +>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) +>Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) + +type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | Blob | ReadableStream // Chunk type can be any RPC-compatible type +>BaseType : Symbol(BaseType, Decl(capnweb.d.ts, 38, 178)) +>TypedArray : Symbol(TypedArray, Decl(capnweb.d.ts, 37, 99)) +>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2024.arraybuffer.d.ts, --, --)) +>DataView : Symbol(DataView, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2025.float16.d.ts, --, --)) +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --) ... and 1 more) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --)) +>RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.regexp.d.ts, --, --) ... and 3 more) +>Blob : Symbol(Blob, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>ReadableStream : Symbol(ReadableStream, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +| WritableStream // Chunk type can be any RPC-compatible type +>WritableStream : Symbol(WritableStream, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +| URL | Request | Response | Headers; // Recursively rewrite all `Stubable` types with `Stub`s, and resolve promises. +>URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>Request : Symbol(Request, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>Response : Symbol(Response, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>Headers : Symbol(Headers, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +// Arm ordering matters here: +// - `Promise` must come before `StubBase`: `RpcPromise` matches both, and must resolve +// through the Promise arm rather than pass through as-is. +// - `StubBase` must come before `Stubable`: `Stub` of a callable `T` is itself callable, so +// it matches `Stubable`. Checking `StubBase` first keeps existing stubs as-is instead of +// double-wrapping them as `Stub>`. +// prettier-ignore +type Stubify = T extends Promise ? Stubify : T extends StubBase ? T : T extends Stubable ? Stub : T extends Map ? Map, Stubify> : T extends Set ? Set> : T extends [] ? [] : T extends [infer Head, ...infer Tail] ? [Stubify, ...Stubify] : T extends readonly [] ? readonly [] : T extends readonly [infer Head, ...infer Tail] ? readonly [Stubify, ...Stubify] : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends BaseType ? T // When using "unknown" instead of "any", interfaces are not stubified. +>Stubify : Symbol(Stubify, Decl(capnweb.d.ts, 41, 37)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>U : Symbol(U, Decl(capnweb.d.ts, 49, 41)) +>Stubify : Symbol(Stubify, Decl(capnweb.d.ts, 41, 37)) +>U : Symbol(U, Decl(capnweb.d.ts, 49, 41)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>StubBase : Symbol(StubBase, Decl(capnweb.d.ts, 29, 11)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>Stubable : Symbol(Stubable, Decl(capnweb.d.ts, 14, 1)) +>Stub : Symbol(Stub, Decl(capnweb.d.ts, 36, 1)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2026.collection.d.ts, --, --)) +>K : Symbol(K, Decl(capnweb.d.ts, 49, 140)) +>V : Symbol(V, Decl(capnweb.d.ts, 49, 149)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2026.collection.d.ts, --, --)) +>Stubify : Symbol(Stubify, Decl(capnweb.d.ts, 41, 37)) +>K : Symbol(K, Decl(capnweb.d.ts, 49, 140)) +>Stubify : Symbol(Stubify, Decl(capnweb.d.ts, 41, 37)) +>V : Symbol(V, Decl(capnweb.d.ts, 49, 149)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2025.collection.d.ts, --, --)) +>V : Symbol(V, Decl(capnweb.d.ts, 49, 204)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2025.collection.d.ts, --, --)) +>Stubify : Symbol(Stubify, Decl(capnweb.d.ts, 41, 37)) +>V : Symbol(V, Decl(capnweb.d.ts, 49, 204)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>Head : Symbol(Head, Decl(capnweb.d.ts, 49, 264)) +>Tail : Symbol(Tail, Decl(capnweb.d.ts, 49, 279)) +>Stubify : Symbol(Stubify, Decl(capnweb.d.ts, 41, 37)) +>Head : Symbol(Head, Decl(capnweb.d.ts, 49, 264)) +>Stubify : Symbol(Stubify, Decl(capnweb.d.ts, 41, 37)) +>Tail : Symbol(Tail, Decl(capnweb.d.ts, 49, 279)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>Head : Symbol(Head, Decl(capnweb.d.ts, 49, 387)) +>Tail : Symbol(Tail, Decl(capnweb.d.ts, 49, 402)) +>Stubify : Symbol(Stubify, Decl(capnweb.d.ts, 41, 37)) +>Head : Symbol(Head, Decl(capnweb.d.ts, 49, 387)) +>Stubify : Symbol(Stubify, Decl(capnweb.d.ts, 41, 37)) +>Tail : Symbol(Tail, Decl(capnweb.d.ts, 49, 402)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>V : Symbol(V, Decl(capnweb.d.ts, 49, 477)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>Stubify : Symbol(Stubify, Decl(capnweb.d.ts, 41, 37)) +>V : Symbol(V, Decl(capnweb.d.ts, 49, 477)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 3 more) +>V : Symbol(V, Decl(capnweb.d.ts, 49, 532)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 3 more) +>Stubify : Symbol(Stubify, Decl(capnweb.d.ts, 41, 37)) +>V : Symbol(V, Decl(capnweb.d.ts, 49, 532)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>BaseType : Symbol(BaseType, Decl(capnweb.d.ts, 38, 178)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) + +: T extends { +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) + + [key: string | number]: any; +>key : Symbol(key, Decl(capnweb.d.ts, 51, 3)) + +} ? { [K in keyof T as K extends string | number ? K : never]: Stubify } : T; +>K : Symbol(K, Decl(capnweb.d.ts, 52, 7)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>K : Symbol(K, Decl(capnweb.d.ts, 52, 7)) +>K : Symbol(K, Decl(capnweb.d.ts, 52, 7)) +>Stubify : Symbol(Stubify, Decl(capnweb.d.ts, 41, 37)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) +>K : Symbol(K, Decl(capnweb.d.ts, 52, 7)) +>T : Symbol(T, Decl(capnweb.d.ts, 49, 13)) + +// Recursively rewrite all `Stub`s with the corresponding `T`s. +// Note we use `StubBase` instead of `Stub` here to avoid circular dependencies: +// `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`. +// prettier-ignore +type UnstubifyInner = // Preserve local RpcTarget acceptance, but avoid needless `Stub | Value` unions when the stub +>UnstubifyInner : Symbol(UnstubifyInner, Decl(capnweb.d.ts, 52, 83)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) + +// is already assignable to the value type (important for callback contextual typing). +T extends StubBase ? (T extends V ? UnstubifyInner : (T | UnstubifyInner)) : T extends Promise ? UnstubifyInner : T extends Map ? Map, Unstubify> : T extends Set ? Set> : T extends [] ? [] : T extends [infer Head, ...infer Tail] ? [Unstubify, ...Unstubify] : T extends readonly [] ? readonly [] : T extends readonly [infer Head, ...infer Tail] ? readonly [Unstubify, ...Unstubify] : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends BaseType ? T : T extends { +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>StubBase : Symbol(StubBase, Decl(capnweb.d.ts, 29, 11)) +>V : Symbol(V, Decl(capnweb.d.ts, 59, 24)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>V : Symbol(V, Decl(capnweb.d.ts, 59, 24)) +>UnstubifyInner : Symbol(UnstubifyInner, Decl(capnweb.d.ts, 52, 83)) +>V : Symbol(V, Decl(capnweb.d.ts, 59, 24)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>UnstubifyInner : Symbol(UnstubifyInner, Decl(capnweb.d.ts, 52, 83)) +>V : Symbol(V, Decl(capnweb.d.ts, 59, 24)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>U : Symbol(U, Decl(capnweb.d.ts, 59, 115)) +>UnstubifyInner : Symbol(UnstubifyInner, Decl(capnweb.d.ts, 52, 83)) +>U : Symbol(U, Decl(capnweb.d.ts, 59, 115)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2026.collection.d.ts, --, --)) +>K : Symbol(K, Decl(capnweb.d.ts, 59, 160)) +>V : Symbol(V, Decl(capnweb.d.ts, 59, 169)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2026.collection.d.ts, --, --)) +>Unstubify : Symbol(Unstubify, Decl(capnweb.d.ts, 61, 85)) +>K : Symbol(K, Decl(capnweb.d.ts, 59, 160)) +>Unstubify : Symbol(Unstubify, Decl(capnweb.d.ts, 61, 85)) +>V : Symbol(V, Decl(capnweb.d.ts, 59, 169)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2025.collection.d.ts, --, --)) +>V : Symbol(V, Decl(capnweb.d.ts, 59, 228)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2025.collection.d.ts, --, --)) +>Unstubify : Symbol(Unstubify, Decl(capnweb.d.ts, 61, 85)) +>V : Symbol(V, Decl(capnweb.d.ts, 59, 228)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>Head : Symbol(Head, Decl(capnweb.d.ts, 59, 290)) +>Tail : Symbol(Tail, Decl(capnweb.d.ts, 59, 305)) +>Unstubify : Symbol(Unstubify, Decl(capnweb.d.ts, 61, 85)) +>Head : Symbol(Head, Decl(capnweb.d.ts, 59, 290)) +>Unstubify : Symbol(Unstubify, Decl(capnweb.d.ts, 61, 85)) +>Tail : Symbol(Tail, Decl(capnweb.d.ts, 59, 305)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>Head : Symbol(Head, Decl(capnweb.d.ts, 59, 417)) +>Tail : Symbol(Tail, Decl(capnweb.d.ts, 59, 432)) +>Unstubify : Symbol(Unstubify, Decl(capnweb.d.ts, 61, 85)) +>Head : Symbol(Head, Decl(capnweb.d.ts, 59, 417)) +>Unstubify : Symbol(Unstubify, Decl(capnweb.d.ts, 61, 85)) +>Tail : Symbol(Tail, Decl(capnweb.d.ts, 59, 432)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>V : Symbol(V, Decl(capnweb.d.ts, 59, 511)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>Unstubify : Symbol(Unstubify, Decl(capnweb.d.ts, 61, 85)) +>V : Symbol(V, Decl(capnweb.d.ts, 59, 511)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 3 more) +>V : Symbol(V, Decl(capnweb.d.ts, 59, 568)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 3 more) +>Unstubify : Symbol(Unstubify, Decl(capnweb.d.ts, 61, 85)) +>V : Symbol(V, Decl(capnweb.d.ts, 59, 568)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>BaseType : Symbol(BaseType, Decl(capnweb.d.ts, 38, 178)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) + + [key: string | number]: unknown; +>key : Symbol(key, Decl(capnweb.d.ts, 60, 3)) + +} ? { [K in keyof T as K extends string | number ? K : never]: Unstubify } : T; // You can put promises anywhere in the params and they'll be resolved before delivery. +>K : Symbol(K, Decl(capnweb.d.ts, 61, 7)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>K : Symbol(K, Decl(capnweb.d.ts, 61, 7)) +>K : Symbol(K, Decl(capnweb.d.ts, 61, 7)) +>Unstubify : Symbol(Unstubify, Decl(capnweb.d.ts, 61, 85)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) +>K : Symbol(K, Decl(capnweb.d.ts, 61, 7)) +>T : Symbol(T, Decl(capnweb.d.ts, 57, 20)) + +// (This also covers RpcPromise, because it's defined as being a Promise.) +// Map placeholders are also allowed so primitive map callback inputs can be forwarded directly +// into RPC params. +// +// Keep raw non-stub members so generic assignability still works when UnstubifyInner is deferred. +// Remove stub members from mixed unions so callback params don’t get both stub and unstubbed signatures. +// Marker carried by map() callback inputs. This lets primitive placeholders flow through params. +type Unstubify = NonStubMembers | UnstubifyInner | Promise> | MapValuePlaceholder>; +>Unstubify : Symbol(Unstubify, Decl(capnweb.d.ts, 61, 85)) +>T : Symbol(T, Decl(capnweb.d.ts, 69, 15)) +>NonStubMembers : Symbol(NonStubMembers, Decl(capnweb.d.ts, 73, 1)) +>T : Symbol(T, Decl(capnweb.d.ts, 69, 15)) +>UnstubifyInner : Symbol(UnstubifyInner, Decl(capnweb.d.ts, 52, 83)) +>T : Symbol(T, Decl(capnweb.d.ts, 69, 15)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>UnstubifyInner : Symbol(UnstubifyInner, Decl(capnweb.d.ts, 52, 83)) +>T : Symbol(T, Decl(capnweb.d.ts, 69, 15)) +>MapValuePlaceholder : Symbol(MapValuePlaceholder, Decl(capnweb.d.ts, 70, 86)) +>UnstubifyInner : Symbol(UnstubifyInner, Decl(capnweb.d.ts, 52, 83)) +>T : Symbol(T, Decl(capnweb.d.ts, 69, 15)) + +type UnstubifyAll = { [I in keyof A]: Unstubify }; +>UnstubifyAll : Symbol(UnstubifyAll, Decl(capnweb.d.ts, 69, 128)) +>A : Symbol(A, Decl(capnweb.d.ts, 70, 18)) +>I : Symbol(I, Decl(capnweb.d.ts, 70, 53)) +>A : Symbol(A, Decl(capnweb.d.ts, 70, 18)) +>Unstubify : Symbol(Unstubify, Decl(capnweb.d.ts, 61, 85)) +>A : Symbol(A, Decl(capnweb.d.ts, 70, 18)) +>I : Symbol(I, Decl(capnweb.d.ts, 70, 53)) + +interface MapValuePlaceholder { +>MapValuePlaceholder : Symbol(MapValuePlaceholder, Decl(capnweb.d.ts, 70, 86)) +>T : Symbol(T, Decl(capnweb.d.ts, 71, 30)) + + [__RPC_MAP_VALUE_BRAND]: T; +>[__RPC_MAP_VALUE_BRAND] : Symbol(MapValuePlaceholder[__RPC_MAP_VALUE_BRAND], Decl(capnweb.d.ts, 71, 34)) +>__RPC_MAP_VALUE_BRAND : Symbol(__RPC_MAP_VALUE_BRAND, Decl(capnweb.d.ts, 11, 13)) +>T : Symbol(T, Decl(capnweb.d.ts, 71, 30)) +} +type NonStubMembers = Exclude>; // Utility type for adding `Disposable`s to `object` types only. +>NonStubMembers : Symbol(NonStubMembers, Decl(capnweb.d.ts, 73, 1)) +>T : Symbol(T, Decl(capnweb.d.ts, 74, 20)) +>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(capnweb.d.ts, 74, 20)) +>StubBase : Symbol(StubBase, Decl(capnweb.d.ts, 29, 11)) + +// Note `unknown & T` is equivalent to `T`. +type MaybeDisposable = T extends object ? Disposable : unknown; // The type behind the public `RpcPromise` (re-exported with its `RpcCompatible` constraint from +>MaybeDisposable : Symbol(MaybeDisposable, Decl(capnweb.d.ts, 74, 51)) +>T : Symbol(T, Decl(capnweb.d.ts, 76, 21)) +>T : Symbol(T, Decl(capnweb.d.ts, 76, 21)) +>Disposable : Symbol(Disposable, Decl(lib.esnext.disposable.d.ts, --, --)) + +// index.ts). Defined here so that `Result`'s arms below resolve to the exact same alias +// instantiation: when both sides of an assignability check are the same alias applied to the +// same type arguments, the checker short-circuits on identity instead of recursing through the +// full structural comparison of these mutually-recursive types. +type RpcPromise$1 = T extends Stubable ? Promise> & Provider & StubBase : Promise & MaybeDisposable> & Provider & StubBase; +>RpcPromise$1 : Symbol(RpcPromise$1, Decl(capnweb.d.ts, 76, 66)) +>T : Symbol(T, Decl(capnweb.d.ts, 81, 18)) +>T : Symbol(T, Decl(capnweb.d.ts, 81, 18)) +>Stubable : Symbol(Stubable, Decl(capnweb.d.ts, 14, 1)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Stub : Symbol(Stub, Decl(capnweb.d.ts, 36, 1)) +>T : Symbol(T, Decl(capnweb.d.ts, 81, 18)) +>Provider : Symbol(Provider, Decl(capnweb.d.ts, 137, 135)) +>T : Symbol(T, Decl(capnweb.d.ts, 81, 18)) +>StubBase : Symbol(StubBase, Decl(capnweb.d.ts, 29, 11)) +>T : Symbol(T, Decl(capnweb.d.ts, 81, 18)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Stubify : Symbol(Stubify, Decl(capnweb.d.ts, 41, 37)) +>T : Symbol(T, Decl(capnweb.d.ts, 81, 18)) +>MaybeDisposable : Symbol(MaybeDisposable, Decl(capnweb.d.ts, 74, 51)) +>T : Symbol(T, Decl(capnweb.d.ts, 81, 18)) +>Provider : Symbol(Provider, Decl(capnweb.d.ts, 137, 135)) +>T : Symbol(T, Decl(capnweb.d.ts, 81, 18)) +>StubBase : Symbol(StubBase, Decl(capnweb.d.ts, 29, 11)) +>T : Symbol(T, Decl(capnweb.d.ts, 81, 18)) + +// The elision `Result` applies to a bare stub type: unwrap `Stub` back to `T` when the +// payload is `Stubable`. Such stubs await back to a stub either way, so eliding keeps a +// declared `Promise>` return interchangeable with a `Promise` return. +// Plain-interface stubs are NOT elided: `RpcPromise` only awaits to `Stub` when +// `U extends Stubable`, so eliding those would change the awaited type from a stub to a +// stubified record. The payload check is deliberately non-distributive (`[U] extends [...]`). +// `Stub` is not elided either: `[any] extends [Stubable]` is true, so without the `IsAny` +// guard an `any`-payload stub would lose its stub surface. +// Also used by the `RpcPromise` constructor signature (index.ts), which applies exactly this +// transformation so constructing from a promised stub matches the method-return type. +type ElideStub = T extends StubBase ? (IsAny extends true ? T : [U] extends [Stubable] ? U : T) : T; +>ElideStub : Symbol(ElideStub, Decl(capnweb.d.ts, 81, 160)) +>T : Symbol(T, Decl(capnweb.d.ts, 92, 15)) +>T : Symbol(T, Decl(capnweb.d.ts, 92, 15)) +>StubBase : Symbol(StubBase, Decl(capnweb.d.ts, 29, 11)) +>U : Symbol(U, Decl(capnweb.d.ts, 92, 44)) +>IsAny : Symbol(IsAny, Decl(capnweb.d.ts, 115, 110)) +>U : Symbol(U, Decl(capnweb.d.ts, 92, 44)) +>T : Symbol(T, Decl(capnweb.d.ts, 92, 15)) +>U : Symbol(U, Decl(capnweb.d.ts, 92, 44)) +>Stubable : Symbol(Stubable, Decl(capnweb.d.ts, 14, 1)) +>U : Symbol(U, Decl(capnweb.d.ts, 92, 44)) +>T : Symbol(T, Decl(capnweb.d.ts, 92, 15)) +>T : Symbol(T, Decl(capnweb.d.ts, 92, 15)) + +// What the promise given to `new RpcPromise(...)` may resolve to: the payload itself, or — +// for stubable payloads — a stub of it. `NoInfer` keeps the stub arm out of inference, so an +// inferred `T` is always the promise's own resolution type; the arm only matters when `T` is +// explicitly annotated (`new RpcPromise(promiseOfStub)`). Stubs of non-stubable +// payloads are deliberately rejected: `ElideStub` wouldn't elide those, so accepting one would +// claim the promise awaits to a stubified record while the runtime resolves to a stub. +type PayloadOrStub = T | NoInfer>>; +>PayloadOrStub : Symbol(PayloadOrStub, Decl(capnweb.d.ts, 92, 115)) +>T : Symbol(T, Decl(capnweb.d.ts, 99, 19)) +>T : Symbol(T, Decl(capnweb.d.ts, 99, 19)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>Stub : Symbol(Stub, Decl(capnweb.d.ts, 36, 1)) +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(capnweb.d.ts, 99, 19)) +>Stubable : Symbol(Stubable, Decl(capnweb.d.ts, 14, 1)) + +// Type for method return or property on an RPC interface. +// - Stubable types are replaced by stubs. +// - RpcCompatible types are passed by value, with stubable types replaced by stubs +// and a top-level `Disposer`. +// Everything else can't be passed over RPC. +// Technically, we use custom thenables here, but they quack like `Promise`s. +// Intersecting with `(Maybe)Provider` allows pipelining. +// prettier-ignore +type Result = IsAny extends true ? RpcPromise$1 // `RpcPromise`: always safe to normalize — `Result` is idempotent — so a declared +>Result : Symbol(Result, Decl(capnweb.d.ts, 99, 64)) +>R : Symbol(R, Decl(capnweb.d.ts, 108, 12)) +>IsAny : Symbol(IsAny, Decl(capnweb.d.ts, 115, 110)) +>R : Symbol(R, Decl(capnweb.d.ts, 108, 12)) +>RpcPromise$1 : Symbol(RpcPromise$1, Decl(capnweb.d.ts, 76, 66)) + +// `RpcPromise` return produces the same type as a `Promise` return. +: R extends PromiseLike & StubBase ? Result // Bare stubs: elide per `ElideStub` above. Note there is no `RpcCompatible` re-check +>R : Symbol(R, Decl(capnweb.d.ts, 108, 12)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) +>StubBase : Symbol(StubBase, Decl(capnweb.d.ts, 29, 11)) +>U : Symbol(U, Decl(capnweb.d.ts, 110, 49)) +>Result : Symbol(Result, Decl(capnweb.d.ts, 99, 64)) +>U : Symbol(U, Decl(capnweb.d.ts, 110, 49)) + +// here: anything matching our `StubBase` was produced by machinery that already enforced +// the constraint, and re-evaluating `RpcCompatible` in this arm recurses through its +// `Stub` member back into `Result`, tripping TS2615 circularity errors in mapped +// types. +: R extends StubBase ? RpcPromise$1> : R extends RpcCompatible ? RpcPromise$1 : never; +>R : Symbol(R, Decl(capnweb.d.ts, 108, 12)) +>StubBase : Symbol(StubBase, Decl(capnweb.d.ts, 29, 11)) +>RpcPromise$1 : Symbol(RpcPromise$1, Decl(capnweb.d.ts, 76, 66)) +>ElideStub : Symbol(ElideStub, Decl(capnweb.d.ts, 81, 160)) +>R : Symbol(R, Decl(capnweb.d.ts, 108, 12)) +>R : Symbol(R, Decl(capnweb.d.ts, 108, 12)) +>RpcCompatible : Symbol(RpcCompatible, Decl(capnweb.d.ts, 20, 53)) +>R : Symbol(R, Decl(capnweb.d.ts, 108, 12)) +>RpcPromise$1 : Symbol(RpcPromise$1, Decl(capnweb.d.ts, 76, 66)) +>R : Symbol(R, Decl(capnweb.d.ts, 108, 12)) + +type IsAny = 0 extends (1 & T) ? true : false; // Type for method or property on an RPC interface. +>IsAny : Symbol(IsAny, Decl(capnweb.d.ts, 115, 110)) +>T : Symbol(T, Decl(capnweb.d.ts, 116, 11)) +>T : Symbol(T, Decl(capnweb.d.ts, 116, 11)) + +// For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s. +// Unwrapping `Stub`s allows calling with `Stubable` arguments. +// For properties, rewrite types to be `Result`s. +// In each case, unwrap `Promise`s. +type MethodOrProperty = V extends ((...args: infer P) => infer R) ? (...args: UnstubifyAll

) => Result> : Result>; // Type for the callable part of an `Provider` if `T` is callable. +>MethodOrProperty : Symbol(MethodOrProperty, Decl(capnweb.d.ts, 116, 49)) +>V : Symbol(V, Decl(capnweb.d.ts, 121, 22)) +>V : Symbol(V, Decl(capnweb.d.ts, 121, 22)) +>args : Symbol(args, Decl(capnweb.d.ts, 121, 39)) +>P : Symbol(P, Decl(capnweb.d.ts, 121, 53)) +>R : Symbol(R, Decl(capnweb.d.ts, 121, 65)) +>args : Symbol(args, Decl(capnweb.d.ts, 121, 72)) +>UnstubifyAll : Symbol(UnstubifyAll, Decl(capnweb.d.ts, 69, 128)) +>P : Symbol(P, Decl(capnweb.d.ts, 121, 53)) +>Result : Symbol(Result, Decl(capnweb.d.ts, 99, 64)) +>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --)) +>R : Symbol(R, Decl(capnweb.d.ts, 121, 65)) +>Result : Symbol(Result, Decl(capnweb.d.ts, 99, 64)) +>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --)) +>V : Symbol(V, Decl(capnweb.d.ts, 121, 22)) + +// This is intersected with methods/properties. +type MaybeCallableProvider = T extends ((...args: any[]) => any) ? MethodOrProperty : unknown; +>MaybeCallableProvider : Symbol(MaybeCallableProvider, Decl(capnweb.d.ts, 121, 141)) +>T : Symbol(T, Decl(capnweb.d.ts, 123, 27)) +>T : Symbol(T, Decl(capnweb.d.ts, 123, 27)) +>args : Symbol(args, Decl(capnweb.d.ts, 123, 44)) +>MethodOrProperty : Symbol(MethodOrProperty, Decl(capnweb.d.ts, 116, 49)) +>T : Symbol(T, Decl(capnweb.d.ts, 123, 27)) + +type TupleIndexKeys> = Extract; +>TupleIndexKeys : Symbol(TupleIndexKeys, Decl(capnweb.d.ts, 123, 100)) +>T : Symbol(T, Decl(capnweb.d.ts, 124, 20)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 3 more) +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(capnweb.d.ts, 124, 20)) + +type MapCallbackValue = // `Omit` removes call signatures, so re-intersect callable provider behavior. +>MapCallbackValue : Symbol(MapCallbackValue, Decl(capnweb.d.ts, 124, 86)) +>T : Symbol(T, Decl(capnweb.d.ts, 125, 22)) + +T extends unknown ? Omit, keyof Promise> & MaybeCallableProvider & MapValuePlaceholder : never; +>T : Symbol(T, Decl(capnweb.d.ts, 125, 22)) +>Omit : Symbol(Omit, Decl(lib.es5.d.ts, --, --)) +>Result : Symbol(Result, Decl(capnweb.d.ts, 99, 64)) +>T : Symbol(T, Decl(capnweb.d.ts, 125, 22)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>MaybeCallableProvider : Symbol(MaybeCallableProvider, Decl(capnweb.d.ts, 121, 141)) +>T : Symbol(T, Decl(capnweb.d.ts, 125, 22)) +>MapValuePlaceholder : Symbol(MapValuePlaceholder, Decl(capnweb.d.ts, 70, 86)) +>T : Symbol(T, Decl(capnweb.d.ts, 125, 22)) + +type InvalidNativePromiseInMapResult = T extends unknown ? InvalidNativePromiseInMapResultImpl : never; +>InvalidNativePromiseInMapResult : Symbol(InvalidNativePromiseInMapResult, Decl(capnweb.d.ts, 126, 120)) +>T : Symbol(T, Decl(capnweb.d.ts, 127, 37)) +>Seen : Symbol(Seen, Decl(capnweb.d.ts, 127, 39)) +>T : Symbol(T, Decl(capnweb.d.ts, 127, 37)) +>InvalidNativePromiseInMapResultImpl : Symbol(InvalidNativePromiseInMapResultImpl, Decl(capnweb.d.ts, 127, 129)) +>T : Symbol(T, Decl(capnweb.d.ts, 127, 37)) +>Seen : Symbol(Seen, Decl(capnweb.d.ts, 127, 39)) + +type InvalidNativePromiseInMapResultImpl = [T] extends [Seen] ? never // RpcPromise is modeled as Promise & StubBase, so allow promise-like stub values. +>InvalidNativePromiseInMapResultImpl : Symbol(InvalidNativePromiseInMapResultImpl, Decl(capnweb.d.ts, 127, 129)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>Seen : Symbol(Seen, Decl(capnweb.d.ts, 128, 43)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>Seen : Symbol(Seen, Decl(capnweb.d.ts, 128, 43)) + +: T extends StubBase ? never // Native thenables cannot be represented in map recordings, even when typed as PromiseLike. +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>StubBase : Symbol(StubBase, Decl(capnweb.d.ts, 29, 11)) + +: T extends PromiseLike ? T : T extends Map ? InvalidNativePromiseInMapResult | InvalidNativePromiseInMapResult : T extends Set ? InvalidNativePromiseInMapResult : T extends readonly [] ? never : T extends readonly [infer Head, ...infer Tail] ? InvalidNativePromiseInMapResult | InvalidNativePromiseInMapResult : T extends ReadonlyArray ? InvalidNativePromiseInMapResult : T extends { +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2026.collection.d.ts, --, --)) +>K : Symbol(K, Decl(capnweb.d.ts, 130, 58)) +>V : Symbol(V, Decl(capnweb.d.ts, 130, 67)) +>InvalidNativePromiseInMapResult : Symbol(InvalidNativePromiseInMapResult, Decl(capnweb.d.ts, 126, 120)) +>K : Symbol(K, Decl(capnweb.d.ts, 130, 58)) +>Seen : Symbol(Seen, Decl(capnweb.d.ts, 128, 43)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>InvalidNativePromiseInMapResult : Symbol(InvalidNativePromiseInMapResult, Decl(capnweb.d.ts, 126, 120)) +>V : Symbol(V, Decl(capnweb.d.ts, 130, 67)) +>Seen : Symbol(Seen, Decl(capnweb.d.ts, 128, 43)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2025.collection.d.ts, --, --)) +>V : Symbol(V, Decl(capnweb.d.ts, 130, 186)) +>InvalidNativePromiseInMapResult : Symbol(InvalidNativePromiseInMapResult, Decl(capnweb.d.ts, 126, 120)) +>V : Symbol(V, Decl(capnweb.d.ts, 130, 186)) +>Seen : Symbol(Seen, Decl(capnweb.d.ts, 128, 43)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>Head : Symbol(Head, Decl(capnweb.d.ts, 130, 296)) +>Tail : Symbol(Tail, Decl(capnweb.d.ts, 130, 311)) +>InvalidNativePromiseInMapResult : Symbol(InvalidNativePromiseInMapResult, Decl(capnweb.d.ts, 126, 120)) +>Head : Symbol(Head, Decl(capnweb.d.ts, 130, 296)) +>Seen : Symbol(Seen, Decl(capnweb.d.ts, 128, 43)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>InvalidNativePromiseInMapResult : Symbol(InvalidNativePromiseInMapResult, Decl(capnweb.d.ts, 126, 120)) +>Tail : Symbol(Tail, Decl(capnweb.d.ts, 130, 311)) +>Seen : Symbol(Seen, Decl(capnweb.d.ts, 128, 43)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 3 more) +>V : Symbol(V, Decl(capnweb.d.ts, 130, 457)) +>InvalidNativePromiseInMapResult : Symbol(InvalidNativePromiseInMapResult, Decl(capnweb.d.ts, 126, 120)) +>V : Symbol(V, Decl(capnweb.d.ts, 130, 457)) +>Seen : Symbol(Seen, Decl(capnweb.d.ts, 128, 43)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) + + [key: string | number]: unknown; +>key : Symbol(key, Decl(capnweb.d.ts, 131, 3)) + +} ? InvalidNativePromiseInMapResult], Seen | T> : never; +>InvalidNativePromiseInMapResult : Symbol(InvalidNativePromiseInMapResult, Decl(capnweb.d.ts, 126, 120)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) +>Seen : Symbol(Seen, Decl(capnweb.d.ts, 128, 43)) +>T : Symbol(T, Decl(capnweb.d.ts, 128, 41)) + +type MapCallbackReturn = InvalidNativePromiseInMapResult extends never ? T : never; +>MapCallbackReturn : Symbol(MapCallbackReturn, Decl(capnweb.d.ts, 132, 92)) +>T : Symbol(T, Decl(capnweb.d.ts, 133, 23)) +>InvalidNativePromiseInMapResult : Symbol(InvalidNativePromiseInMapResult, Decl(capnweb.d.ts, 126, 120)) +>T : Symbol(T, Decl(capnweb.d.ts, 133, 23)) +>T : Symbol(T, Decl(capnweb.d.ts, 133, 23)) + +type ArrayProvider = { [K in number]: MethodOrProperty } & { +>ArrayProvider : Symbol(ArrayProvider, Decl(capnweb.d.ts, 133, 89)) +>E : Symbol(E, Decl(capnweb.d.ts, 134, 19)) +>K : Symbol(K, Decl(capnweb.d.ts, 134, 27)) +>MethodOrProperty : Symbol(MethodOrProperty, Decl(capnweb.d.ts, 116, 49)) +>E : Symbol(E, Decl(capnweb.d.ts, 134, 19)) + + map(callback: (elem: MapCallbackValue) => MapCallbackReturn): Result>; +>map : Symbol(map, Decl(capnweb.d.ts, 134, 66)) +>V : Symbol(V, Decl(capnweb.d.ts, 135, 6)) +>callback : Symbol(callback, Decl(capnweb.d.ts, 135, 9)) +>elem : Symbol(elem, Decl(capnweb.d.ts, 135, 20)) +>MapCallbackValue : Symbol(MapCallbackValue, Decl(capnweb.d.ts, 124, 86)) +>E : Symbol(E, Decl(capnweb.d.ts, 134, 19)) +>MapCallbackReturn : Symbol(MapCallbackReturn, Decl(capnweb.d.ts, 132, 92)) +>V : Symbol(V, Decl(capnweb.d.ts, 135, 6)) +>Result : Symbol(Result, Decl(capnweb.d.ts, 99, 64)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>V : Symbol(V, Decl(capnweb.d.ts, 135, 6)) + +}; +type TupleProvider> = { [K in TupleIndexKeys]: MethodOrProperty } & ArrayProvider; // Base type for all other types providing RPC-like interfaces. +>TupleProvider : Symbol(TupleProvider, Decl(capnweb.d.ts, 136, 2)) +>T : Symbol(T, Decl(capnweb.d.ts, 137, 19)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 3 more) +>K : Symbol(K, Decl(capnweb.d.ts, 137, 58)) +>TupleIndexKeys : Symbol(TupleIndexKeys, Decl(capnweb.d.ts, 123, 100)) +>T : Symbol(T, Decl(capnweb.d.ts, 137, 19)) +>MethodOrProperty : Symbol(MethodOrProperty, Decl(capnweb.d.ts, 116, 49)) +>T : Symbol(T, Decl(capnweb.d.ts, 137, 19)) +>K : Symbol(K, Decl(capnweb.d.ts, 137, 58)) +>ArrayProvider : Symbol(ArrayProvider, Decl(capnweb.d.ts, 133, 89)) +>T : Symbol(T, Decl(capnweb.d.ts, 137, 19)) + +// Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types. +// `__RPC_TARGET_BRAND` deliberately flows through the key mapping (as a `never` property) so +// stubs of branded targets stay assignable to workers-types' `Stubable`. Such stubs match our +// `Stubable` too — harmless, since all machinery checks `StubBase` before `Stubable`. +type Provider = MaybeCallableProvider & (T extends ReadonlyArray ? number extends T["length"] ? ArrayProvider : TupleProvider : { [K in Exclude>]: MethodOrProperty } & { +>Provider : Symbol(Provider, Decl(capnweb.d.ts, 137, 135)) +>T : Symbol(T, Decl(capnweb.d.ts, 142, 14)) +>MaybeCallableProvider : Symbol(MaybeCallableProvider, Decl(capnweb.d.ts, 121, 141)) +>T : Symbol(T, Decl(capnweb.d.ts, 142, 14)) +>T : Symbol(T, Decl(capnweb.d.ts, 142, 14)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 3 more) +>T : Symbol(T, Decl(capnweb.d.ts, 142, 14)) +>ArrayProvider : Symbol(ArrayProvider, Decl(capnweb.d.ts, 133, 89)) +>T : Symbol(T, Decl(capnweb.d.ts, 142, 14)) +>TupleProvider : Symbol(TupleProvider, Decl(capnweb.d.ts, 136, 2)) +>T : Symbol(T, Decl(capnweb.d.ts, 142, 14)) +>K : Symbol(K, Decl(capnweb.d.ts, 142, 160)) +>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(capnweb.d.ts, 142, 14)) +>StubBase : Symbol(StubBase, Decl(capnweb.d.ts, 29, 11)) +>MethodOrProperty : Symbol(MethodOrProperty, Decl(capnweb.d.ts, 116, 49)) +>T : Symbol(T, Decl(capnweb.d.ts, 142, 14)) +>K : Symbol(K, Decl(capnweb.d.ts, 142, 160)) + + map(callback: (value: MapCallbackValue>) => MapCallbackReturn): Result>; +>map : Symbol(map, Decl(capnweb.d.ts, 142, 244)) +>V : Symbol(V, Decl(capnweb.d.ts, 143, 6)) +>callback : Symbol(callback, Decl(capnweb.d.ts, 143, 9)) +>value : Symbol(value, Decl(capnweb.d.ts, 143, 20)) +>MapCallbackValue : Symbol(MapCallbackValue, Decl(capnweb.d.ts, 124, 86)) +>NonNullable : Symbol(NonNullable, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(capnweb.d.ts, 142, 14)) +>MapCallbackReturn : Symbol(MapCallbackReturn, Decl(capnweb.d.ts, 132, 92)) +>V : Symbol(V, Decl(capnweb.d.ts, 143, 6)) +>Result : Symbol(Result, Decl(capnweb.d.ts, 99, 64)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>V : Symbol(V, Decl(capnweb.d.ts, 143, 6)) + +}); +export type RpcStub> = Stub; +>RpcStub : Symbol(RpcStub, Decl(capnweb.d.ts, 144, 3)) +>T : Symbol(T, Decl(capnweb.d.ts, 145, 20)) +>RpcCompatible : Symbol(RpcCompatible, Decl(capnweb.d.ts, 20, 53)) +>T : Symbol(T, Decl(capnweb.d.ts, 145, 20)) +>Stub : Symbol(Stub, Decl(capnweb.d.ts, 36, 1)) +>T : Symbol(T, Decl(capnweb.d.ts, 145, 20)) + +=== main.ts === +import type { RpcStub } from "./capnweb"; +>RpcStub : Symbol(RpcStub, Decl(main.ts, 0, 13)) + +declare const api: RpcStub<{ sub(): Promise> }>; +>api : Symbol(api, Decl(main.ts, 2, 13)) +>RpcStub : Symbol(RpcStub, Decl(main.ts, 0, 13)) +>sub : Symbol(sub, Decl(main.ts, 2, 28)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>RpcStub : Symbol(RpcStub, Decl(main.ts, 0, 13)) + +export async function f() { +>f : Symbol(f, Decl(main.ts, 2, 60)) + + await api.sub(); +>api.sub : Symbol(sub) +>api : Symbol(api, Decl(main.ts, 2, 13)) +>sub : Symbol(sub) + + api.sub().then(s => s); +>api.sub().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>api.sub : Symbol(sub) +>api : Symbol(api, Decl(main.ts, 2, 13)) +>sub : Symbol(sub) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(main.ts, 5, 17)) +>s : Symbol(s, Decl(main.ts, 5, 17)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleCapnwebRpcStub.types b/tsc/testdata/baselines/reference/compiler/varianceCycleCapnwebRpcStub.types new file mode 100644 index 0000000000000..c562e36ae1268 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleCapnwebRpcStub.types @@ -0,0 +1,280 @@ +//// [tests/cases/compiler/varianceCycleCapnwebRpcStub.ts] //// + +=== capnweb.d.ts === +// Copyright (c) 2025 Cloudflare, Inc. +// Licensed under the MIT license found in the LICENSE.txt file or at: +// https://opensource.org/license/mit +// This file borrows heavily from `types/defines/rpc.d.ts` in workerd. +// Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s. +// TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`. +// For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to +// accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape) +declare const __RPC_STUB_BRAND: '__RPC_STUB_BRAND'; +>__RPC_STUB_BRAND : "__RPC_STUB_BRAND" + +declare const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND'; +>__RPC_TARGET_BRAND : "__RPC_TARGET_BRAND" + +// Distinguishes mapper placeholders from regular values so param unwrapping can accept them. +declare const __RPC_MAP_VALUE_BRAND: unique symbol; +>__RPC_MAP_VALUE_BRAND : unique symbol + +interface RpcTargetBranded { + [__RPC_TARGET_BRAND]: never; +>[__RPC_TARGET_BRAND] : never +>__RPC_TARGET_BRAND : "__RPC_TARGET_BRAND" +} +// Types that can be used through `Stub`s +// `never[]` preserves compatibility with strongly-typed function signatures without introducing +// `any` into inference. +type Stubable = RpcTargetBranded | ((...args: never[]) => unknown); +>Stubable : Stubable +>args : never[] + +// Note: also true for `any` (call sites that care check `IsAny` first). +type IsUnknown = unknown extends T ? true : false; // Types that can be passed over RPC +>IsUnknown : IsUnknown +>true : true +>false : false + +// The reason for using a generic type here is to build the serializable subset of RPC-compatible +// composite types. This allows types defined with the "interface" keyword to pass the +// serializable check as well. Otherwise, only types defined with the "type" keyword would pass. +type RpcCompatible = // Allow `unknown` as a leaf so records/interfaces with `unknown` fields remain compatible. +>RpcCompatible : RpcCompatible + +(IsUnknown extends true ? unknown : never) // RPC-compatible base values +>true : true + +| BaseType // RPC-compatible composites +| Map ? RpcCompatible : never, T extends Map ? RpcCompatible : never> | Set ? RpcCompatible : never> | Array ? RpcCompatible : never> | ReadonlyArray ? RpcCompatible : never> | { [K in keyof T as K extends string | number ? K : never]: RpcCompatible } | Promise ? RpcCompatible : never> // Special types +| Stub // Serialized as stubs, see `Stubify` +| Stubable; +// Base type for all RPC stubs, including common memory management methods. +// `T` is used as a marker type for unwrapping `Stub`s later. +interface StubBase extends Disposable { + [__RPC_STUB_BRAND]: T; +>[__RPC_STUB_BRAND] : T +>__RPC_STUB_BRAND : "__RPC_STUB_BRAND" + + dup(): this; +>dup : () => this + + onRpcBroken(callback: (error: any) => void): void; +>onRpcBroken : (callback: (error: any) => void) => void +>callback : (error: any) => void +>error : any +} +type Stub> = T extends object ? Provider & StubBase : StubBase; +>Stub : Stub + +type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | BigUint64Array | BigInt64Array | Float32Array | Float64Array; // This represents all the types that can be sent as-is over an RPC boundary +>TypedArray : TypedArray + +type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | Blob | ReadableStream // Chunk type can be any RPC-compatible type +>BaseType : BaseType + +| WritableStream // Chunk type can be any RPC-compatible type +| URL | Request | Response | Headers; // Recursively rewrite all `Stubable` types with `Stub`s, and resolve promises. +// Arm ordering matters here: +// - `Promise` must come before `StubBase`: `RpcPromise` matches both, and must resolve +// through the Promise arm rather than pass through as-is. +// - `StubBase` must come before `Stubable`: `Stub` of a callable `T` is itself callable, so +// it matches `Stubable`. Checking `StubBase` first keeps existing stubs as-is instead of +// double-wrapping them as `Stub>`. +// prettier-ignore +type Stubify = T extends Promise ? Stubify : T extends StubBase ? T : T extends Stubable ? Stub : T extends Map ? Map, Stubify> : T extends Set ? Set> : T extends [] ? [] : T extends [infer Head, ...infer Tail] ? [Stubify, ...Stubify] : T extends readonly [] ? readonly [] : T extends readonly [infer Head, ...infer Tail] ? readonly [Stubify, ...Stubify] : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends BaseType ? T // When using "unknown" instead of "any", interfaces are not stubified. +>Stubify : Stubify + +: T extends { + [key: string | number]: any; +>key : string | number + +} ? { [K in keyof T as K extends string | number ? K : never]: Stubify } : T; +// Recursively rewrite all `Stub`s with the corresponding `T`s. +// Note we use `StubBase` instead of `Stub` here to avoid circular dependencies: +// `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`. +// prettier-ignore +type UnstubifyInner = // Preserve local RpcTarget acceptance, but avoid needless `Stub | Value` unions when the stub +>UnstubifyInner : UnstubifyInner + +// is already assignable to the value type (important for callback contextual typing). +T extends StubBase ? (T extends V ? UnstubifyInner : (T | UnstubifyInner)) : T extends Promise ? UnstubifyInner : T extends Map ? Map, Unstubify> : T extends Set ? Set> : T extends [] ? [] : T extends [infer Head, ...infer Tail] ? [Unstubify, ...Unstubify] : T extends readonly [] ? readonly [] : T extends readonly [infer Head, ...infer Tail] ? readonly [Unstubify, ...Unstubify] : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends BaseType ? T : T extends { + [key: string | number]: unknown; +>key : string | number + +} ? { [K in keyof T as K extends string | number ? K : never]: Unstubify } : T; // You can put promises anywhere in the params and they'll be resolved before delivery. +// (This also covers RpcPromise, because it's defined as being a Promise.) +// Map placeholders are also allowed so primitive map callback inputs can be forwarded directly +// into RPC params. +// +// Keep raw non-stub members so generic assignability still works when UnstubifyInner is deferred. +// Remove stub members from mixed unions so callback params don’t get both stub and unstubbed signatures. +// Marker carried by map() callback inputs. This lets primitive placeholders flow through params. +type Unstubify = NonStubMembers | UnstubifyInner | Promise> | MapValuePlaceholder>; +>Unstubify : Unstubify + +type UnstubifyAll = { [I in keyof A]: Unstubify }; +>UnstubifyAll : UnstubifyAll + +interface MapValuePlaceholder { + [__RPC_MAP_VALUE_BRAND]: T; +>[__RPC_MAP_VALUE_BRAND] : T +>__RPC_MAP_VALUE_BRAND : unique symbol +} +type NonStubMembers = Exclude>; // Utility type for adding `Disposable`s to `object` types only. +>NonStubMembers : NonStubMembers + +// Note `unknown & T` is equivalent to `T`. +type MaybeDisposable = T extends object ? Disposable : unknown; // The type behind the public `RpcPromise` (re-exported with its `RpcCompatible` constraint from +>MaybeDisposable : MaybeDisposable + +// index.ts). Defined here so that `Result`'s arms below resolve to the exact same alias +// instantiation: when both sides of an assignability check are the same alias applied to the +// same type arguments, the checker short-circuits on identity instead of recursing through the +// full structural comparison of these mutually-recursive types. +type RpcPromise$1 = T extends Stubable ? Promise> & Provider & StubBase : Promise & MaybeDisposable> & Provider & StubBase; +>RpcPromise$1 : RpcPromise$1 + +// The elision `Result` applies to a bare stub type: unwrap `Stub` back to `T` when the +// payload is `Stubable`. Such stubs await back to a stub either way, so eliding keeps a +// declared `Promise>` return interchangeable with a `Promise` return. +// Plain-interface stubs are NOT elided: `RpcPromise` only awaits to `Stub` when +// `U extends Stubable`, so eliding those would change the awaited type from a stub to a +// stubified record. The payload check is deliberately non-distributive (`[U] extends [...]`). +// `Stub` is not elided either: `[any] extends [Stubable]` is true, so without the `IsAny` +// guard an `any`-payload stub would lose its stub surface. +// Also used by the `RpcPromise` constructor signature (index.ts), which applies exactly this +// transformation so constructing from a promised stub matches the method-return type. +type ElideStub = T extends StubBase ? (IsAny extends true ? T : [U] extends [Stubable] ? U : T) : T; +>ElideStub : ElideStub +>true : true + +// What the promise given to `new RpcPromise(...)` may resolve to: the payload itself, or — +// for stubable payloads — a stub of it. `NoInfer` keeps the stub arm out of inference, so an +// inferred `T` is always the promise's own resolution type; the arm only matters when `T` is +// explicitly annotated (`new RpcPromise(promiseOfStub)`). Stubs of non-stubable +// payloads are deliberately rejected: `ElideStub` wouldn't elide those, so accepting one would +// claim the promise awaits to a stubified record while the runtime resolves to a stub. +type PayloadOrStub = T | NoInfer>>; +>PayloadOrStub : PayloadOrStub + +// Type for method return or property on an RPC interface. +// - Stubable types are replaced by stubs. +// - RpcCompatible types are passed by value, with stubable types replaced by stubs +// and a top-level `Disposer`. +// Everything else can't be passed over RPC. +// Technically, we use custom thenables here, but they quack like `Promise`s. +// Intersecting with `(Maybe)Provider` allows pipelining. +// prettier-ignore +type Result = IsAny extends true ? RpcPromise$1 // `RpcPromise`: always safe to normalize — `Result` is idempotent — so a declared +>Result : Result +>true : true + +// `RpcPromise` return produces the same type as a `Promise` return. +: R extends PromiseLike & StubBase ? Result // Bare stubs: elide per `ElideStub` above. Note there is no `RpcCompatible` re-check +// here: anything matching our `StubBase` was produced by machinery that already enforced +// the constraint, and re-evaluating `RpcCompatible` in this arm recurses through its +// `Stub` member back into `Result`, tripping TS2615 circularity errors in mapped +// types. +: R extends StubBase ? RpcPromise$1> : R extends RpcCompatible ? RpcPromise$1 : never; +type IsAny = 0 extends (1 & T) ? true : false; // Type for method or property on an RPC interface. +>IsAny : IsAny +>true : true +>false : false + +// For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s. +// Unwrapping `Stub`s allows calling with `Stubable` arguments. +// For properties, rewrite types to be `Result`s. +// In each case, unwrap `Promise`s. +type MethodOrProperty = V extends ((...args: infer P) => infer R) ? (...args: UnstubifyAll

) => Result> : Result>; // Type for the callable part of an `Provider` if `T` is callable. +>MethodOrProperty : MethodOrProperty +>args : P +>args : UnstubifyAll

+ +// This is intersected with methods/properties. +type MaybeCallableProvider = T extends ((...args: any[]) => any) ? MethodOrProperty : unknown; +>MaybeCallableProvider : MaybeCallableProvider +>args : any[] + +type TupleIndexKeys> = Extract; +>TupleIndexKeys : TupleIndexKeys + +type MapCallbackValue = // `Omit` removes call signatures, so re-intersect callable provider behavior. +>MapCallbackValue : MapCallbackValue + +T extends unknown ? Omit, keyof Promise> & MaybeCallableProvider & MapValuePlaceholder : never; +type InvalidNativePromiseInMapResult = T extends unknown ? InvalidNativePromiseInMapResultImpl : never; +>InvalidNativePromiseInMapResult : InvalidNativePromiseInMapResult + +type InvalidNativePromiseInMapResultImpl = [T] extends [Seen] ? never // RpcPromise is modeled as Promise & StubBase, so allow promise-like stub values. +>InvalidNativePromiseInMapResultImpl : InvalidNativePromiseInMapResultImpl + +: T extends StubBase ? never // Native thenables cannot be represented in map recordings, even when typed as PromiseLike. +: T extends PromiseLike ? T : T extends Map ? InvalidNativePromiseInMapResult | InvalidNativePromiseInMapResult : T extends Set ? InvalidNativePromiseInMapResult : T extends readonly [] ? never : T extends readonly [infer Head, ...infer Tail] ? InvalidNativePromiseInMapResult | InvalidNativePromiseInMapResult : T extends ReadonlyArray ? InvalidNativePromiseInMapResult : T extends { + [key: string | number]: unknown; +>key : string | number + +} ? InvalidNativePromiseInMapResult], Seen | T> : never; +type MapCallbackReturn = InvalidNativePromiseInMapResult extends never ? T : never; +>MapCallbackReturn : MapCallbackReturn + +type ArrayProvider = { [K in number]: MethodOrProperty } & { +>ArrayProvider : ArrayProvider + + map(callback: (elem: MapCallbackValue) => MapCallbackReturn): Result>; +>map : (callback: (elem: MapCallbackValue) => MapCallbackReturn) => Result> +>callback : (elem: MapCallbackValue) => MapCallbackReturn +>elem : MapCallbackValue + +}; +type TupleProvider> = { [K in TupleIndexKeys]: MethodOrProperty } & ArrayProvider; // Base type for all other types providing RPC-like interfaces. +>TupleProvider : TupleProvider + +// Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types. +// `__RPC_TARGET_BRAND` deliberately flows through the key mapping (as a `never` property) so +// stubs of branded targets stay assignable to workers-types' `Stubable`. Such stubs match our +// `Stubable` too — harmless, since all machinery checks `StubBase` before `Stubable`. +type Provider = MaybeCallableProvider & (T extends ReadonlyArray ? number extends T["length"] ? ArrayProvider : TupleProvider : { [K in Exclude>]: MethodOrProperty } & { +>Provider : Provider + + map(callback: (value: MapCallbackValue>) => MapCallbackReturn): Result>; +>map : (callback: (value: MapCallbackValue>) => MapCallbackReturn) => Result> +>callback : (value: MapCallbackValue>) => MapCallbackReturn +>value : MapCallbackValue> + +}); +export type RpcStub> = Stub; +>RpcStub : RpcStub + +=== main.ts === +import type { RpcStub } from "./capnweb"; +>RpcStub : RpcStub + +declare const api: RpcStub<{ sub(): Promise> }>; +>api : { sub: () => Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>; } & { map(callback: (value: Omit Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>) & {} & { map(callback: (value: Omit Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>) & {} & any & import("./capnweb").StubBase<() => Promise>>> & (() => Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>) & {} & any & import("./capnweb").StubBase<() => Promise>>, keyof Promise> & (() => Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>) & import("./capnweb").MapValuePlaceholder<() => Promise>>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & any & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & Disposable> & any & any & import("./capnweb").StubBase, keyof Promise> & import("./capnweb").MapValuePlaceholder) => import("./capnweb").MapCallbackReturn): any & any & import("./capnweb").StubBase; } & import("./capnweb").StubBase +>sub : () => Promise> + +export async function f() { +>f : () => Promise + + await api.sub(); +>await api.sub() : Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>> +>api.sub() : Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>> +>api.sub : () => Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>> +>api : { sub: () => Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>; } & { map(callback: (value: Omit Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>) & {} & { map(callback: (value: Omit Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>) & {} & any & import("./capnweb").StubBase<() => Promise>>> & (() => Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>) & {} & any & import("./capnweb").StubBase<() => Promise>>, keyof Promise> & (() => Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>) & import("./capnweb").MapValuePlaceholder<() => Promise>>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & any & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & Disposable> & any & any & import("./capnweb").StubBase, keyof Promise> & import("./capnweb").MapValuePlaceholder) => import("./capnweb").MapCallbackReturn): any & any & import("./capnweb").StubBase; } & import("./capnweb").StubBase +>sub : () => Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>> + + api.sub().then(s => s); +>api.sub().then(s => s) : any +>api.sub().then : any +>api.sub() : Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>> +>api.sub : () => Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>> +>api : { sub: () => Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>; } & { map(callback: (value: Omit Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>) & {} & { map(callback: (value: Omit Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>) & {} & any & import("./capnweb").StubBase<() => Promise>>> & (() => Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>) & {} & any & import("./capnweb").StubBase<() => Promise>>, keyof Promise> & (() => Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>>) & import("./capnweb").MapValuePlaceholder<() => Promise>>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & any & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase; } & Disposable> & any & any & import("./capnweb").StubBase, keyof Promise> & import("./capnweb").MapValuePlaceholder) => import("./capnweb").MapCallbackReturn): any & any & import("./capnweb").StubBase; } & import("./capnweb").StubBase +>sub : () => Promise<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}> & Disposable> & { map: any; } & {} & import("./capnweb").StubBase<{} & { map(callback: (value: Omit & {} & any & import("./capnweb").StubBase<{}>, keyof Promise> & import("./capnweb").MapValuePlaceholder<{}>) => import("./capnweb").MapCallbackReturn): Promise[] & Disposable> & { [x: number]: import("./capnweb").MethodOrProperty; } & { map(callback: (elem: import("./capnweb").MapCallbackValue) => import("./capnweb").MapCallbackReturn): import("./capnweb").Result>; } & import("./capnweb").StubBase; } & import("./capnweb").StubBase<{}>> +>then : any +>s => s : (s: any) => any +>s : any +>s : any +} + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleDiscardedDiagnostics.errors.txt b/tsc/testdata/baselines/reference/compiler/varianceCycleDiscardedDiagnostics.errors.txt new file mode 100644 index 0000000000000..570f693fae100 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleDiscardedDiagnostics.errors.txt @@ -0,0 +1,31 @@ +varianceCycleDiscardedDiagnostics.ts(14,5): error TS7022: 'Value' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + + +==== varianceCycleDiscardedDiagnostics.ts (1 errors) ==== + // Measuring the variances of Bar resolves the type of Value, which picks an + // overload by relating Foo to Foo while the variances of Bar are + // still being measured. Diagnostics from that attempt must not outlive it, + // and the result must not depend on whether Value or the variances of Bar + // are needed first. + + interface A { a: string } + interface B { foo: string } + declare function pick(x: Foo): A; + declare function pick(x: object): B; + + class Bar { + x!: T; + Value = pick(new Foo(this)).foo; + ~~~~~ +!!! error TS7022: 'Value' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + } + + class Foo { + bar!: Bar; + constructor(bar: Bar) { + this.bar = bar; + } + } + + const v: number = new Bar().Value; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleDiscardedDiagnostics.symbols b/tsc/testdata/baselines/reference/compiler/varianceCycleDiscardedDiagnostics.symbols new file mode 100644 index 0000000000000..437eb30b0dc81 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleDiscardedDiagnostics.symbols @@ -0,0 +1,73 @@ +//// [tests/cases/compiler/varianceCycleDiscardedDiagnostics.ts] //// + +=== varianceCycleDiscardedDiagnostics.ts === +// Measuring the variances of Bar resolves the type of Value, which picks an +// overload by relating Foo to Foo while the variances of Bar are +// still being measured. Diagnostics from that attempt must not outlive it, +// and the result must not depend on whether Value or the variances of Bar +// are needed first. + +interface A { a: string } +>A : Symbol(A, Decl(varianceCycleDiscardedDiagnostics.ts, 0, 0)) +>a : Symbol(A.a, Decl(varianceCycleDiscardedDiagnostics.ts, 6, 13)) + +interface B { foo: string } +>B : Symbol(B, Decl(varianceCycleDiscardedDiagnostics.ts, 6, 25)) +>foo : Symbol(B.foo, Decl(varianceCycleDiscardedDiagnostics.ts, 7, 13)) + +declare function pick(x: Foo): A; +>pick : Symbol(pick, Decl(varianceCycleDiscardedDiagnostics.ts, 7, 27), Decl(varianceCycleDiscardedDiagnostics.ts, 8, 41)) +>x : Symbol(x, Decl(varianceCycleDiscardedDiagnostics.ts, 8, 22)) +>Foo : Symbol(Foo, Decl(varianceCycleDiscardedDiagnostics.ts, 14, 1)) +>A : Symbol(A, Decl(varianceCycleDiscardedDiagnostics.ts, 0, 0)) + +declare function pick(x: object): B; +>pick : Symbol(pick, Decl(varianceCycleDiscardedDiagnostics.ts, 7, 27), Decl(varianceCycleDiscardedDiagnostics.ts, 8, 41)) +>x : Symbol(x, Decl(varianceCycleDiscardedDiagnostics.ts, 9, 22)) +>B : Symbol(B, Decl(varianceCycleDiscardedDiagnostics.ts, 6, 25)) + +class Bar { +>Bar : Symbol(Bar, Decl(varianceCycleDiscardedDiagnostics.ts, 9, 36)) +>T : Symbol(T, Decl(varianceCycleDiscardedDiagnostics.ts, 11, 10)) + + x!: T; +>x : Symbol(Bar.x, Decl(varianceCycleDiscardedDiagnostics.ts, 11, 14)) +>T : Symbol(T, Decl(varianceCycleDiscardedDiagnostics.ts, 11, 10)) + + Value = pick(new Foo(this)).foo; +>Value : Symbol(Bar.Value, Decl(varianceCycleDiscardedDiagnostics.ts, 12, 10)) +>pick(new Foo(this)).foo : Symbol(B.foo, Decl(varianceCycleDiscardedDiagnostics.ts, 7, 13)) +>pick : Symbol(pick, Decl(varianceCycleDiscardedDiagnostics.ts, 7, 27), Decl(varianceCycleDiscardedDiagnostics.ts, 8, 41)) +>Foo : Symbol(Foo, Decl(varianceCycleDiscardedDiagnostics.ts, 14, 1)) +>this : Symbol(Bar, Decl(varianceCycleDiscardedDiagnostics.ts, 9, 36)) +>foo : Symbol(B.foo, Decl(varianceCycleDiscardedDiagnostics.ts, 7, 13)) +} + +class Foo { +>Foo : Symbol(Foo, Decl(varianceCycleDiscardedDiagnostics.ts, 14, 1)) +>T : Symbol(T, Decl(varianceCycleDiscardedDiagnostics.ts, 16, 10)) + + bar!: Bar; +>bar : Symbol(Foo.bar, Decl(varianceCycleDiscardedDiagnostics.ts, 16, 14)) +>Bar : Symbol(Bar, Decl(varianceCycleDiscardedDiagnostics.ts, 9, 36)) +>T : Symbol(T, Decl(varianceCycleDiscardedDiagnostics.ts, 16, 10)) + + constructor(bar: Bar) { +>bar : Symbol(bar, Decl(varianceCycleDiscardedDiagnostics.ts, 18, 16)) +>Bar : Symbol(Bar, Decl(varianceCycleDiscardedDiagnostics.ts, 9, 36)) +>T : Symbol(T, Decl(varianceCycleDiscardedDiagnostics.ts, 16, 10)) + + this.bar = bar; +>this.bar : Symbol(Foo.bar, Decl(varianceCycleDiscardedDiagnostics.ts, 16, 14)) +>this : Symbol(Foo, Decl(varianceCycleDiscardedDiagnostics.ts, 14, 1)) +>bar : Symbol(Foo.bar, Decl(varianceCycleDiscardedDiagnostics.ts, 16, 14)) +>bar : Symbol(bar, Decl(varianceCycleDiscardedDiagnostics.ts, 18, 16)) + } +} + +const v: number = new Bar().Value; +>v : Symbol(v, Decl(varianceCycleDiscardedDiagnostics.ts, 23, 5)) +>new Bar().Value : Symbol(Bar.Value, Decl(varianceCycleDiscardedDiagnostics.ts, 12, 10)) +>Bar : Symbol(Bar, Decl(varianceCycleDiscardedDiagnostics.ts, 9, 36)) +>Value : Symbol(Bar.Value, Decl(varianceCycleDiscardedDiagnostics.ts, 12, 10)) + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleDiscardedDiagnostics.types b/tsc/testdata/baselines/reference/compiler/varianceCycleDiscardedDiagnostics.types new file mode 100644 index 0000000000000..6d56cf12120d4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleDiscardedDiagnostics.types @@ -0,0 +1,65 @@ +//// [tests/cases/compiler/varianceCycleDiscardedDiagnostics.ts] //// + +=== varianceCycleDiscardedDiagnostics.ts === +// Measuring the variances of Bar resolves the type of Value, which picks an +// overload by relating Foo to Foo while the variances of Bar are +// still being measured. Diagnostics from that attempt must not outlive it, +// and the result must not depend on whether Value or the variances of Bar +// are needed first. + +interface A { a: string } +>a : string + +interface B { foo: string } +>foo : string + +declare function pick(x: Foo): A; +>pick : { (x: Foo): A; (x: object): B; } +>x : Foo + +declare function pick(x: object): B; +>pick : { (x: Foo): A; (x: object): B; } +>x : object + +class Bar { +>Bar : Bar + + x!: T; +>x : T + + Value = pick(new Foo(this)).foo; +>Value : any +>pick(new Foo(this)).foo : string +>pick(new Foo(this)) : B +>pick : { (x: Foo): A; (x: object): B; } +>new Foo(this) : Foo +>Foo : typeof Foo +>this : this +>foo : string +} + +class Foo { +>Foo : Foo + + bar!: Bar; +>bar : Bar + + constructor(bar: Bar) { +>bar : Bar + + this.bar = bar; +>this.bar = bar : Bar +>this.bar : Bar +>this : this +>bar : Bar +>bar : Bar + } +} + +const v: number = new Bar().Value; +>v : number +>new Bar().Value : any +>new Bar() : Bar +>Bar : typeof Bar +>Value : any + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleEnteredAfterCanonicalEntry(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/varianceCycleEnteredAfterCanonicalEntry(checkorder=default).symbols new file mode 100644 index 0000000000000..b6711c2e9b95b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleEnteredAfterCanonicalEntry(checkorder=default).symbols @@ -0,0 +1,132 @@ +//// [tests/cases/compiler/varianceCycleEnteredAfterCanonicalEntry.ts] //// + +=== varianceCycleEnteredAfterCanonicalEntry.ts === +// Reduced from capnweb's RpcStub types (cloudflare-os). Measuring the variance +// of Stubify enters a circularity (Stubify -> Stub -> Provider -> +// MethodOrProperty -> Result -> RpcPromise -> Stubify) whose canonical entry is +// Stub, so the measurement from Stubify is discarded and the circularity +// measured again from Stub. The discarded measurement once ran to completion, +// which on the full types took long enough to exceed the instantiation limit. + +interface StubBase { +>StubBase : Symbol(StubBase, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 0, 0)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 7, 19)) + + brand: T; +>brand : Symbol(StubBase.brand, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 7, 33)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 7, 19)) +} +type Stub = T extends object ? Provider & StubBase : StubBase; +>Stub : Symbol(Stub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 9, 1)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 10)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 10)) +>Provider : Symbol(Provider, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 125)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 10)) +>StubBase : Symbol(StubBase, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 0, 0)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 10)) +>StubBase : Symbol(StubBase, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 0, 0)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 10)) + +type Stubify = T extends StubBase ? T : T extends Function ? Stub : T; +>Stubify : Symbol(Stubify, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 74)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 13)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 13)) +>StubBase : Symbol(StubBase, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 0, 0)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 13)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 13)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) +>Stub : Symbol(Stub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 9, 1)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 13)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 13)) + +type RpcPromise = Promise> & Provider & StubBase; +>RpcPromise : Symbol(RpcPromise, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 81)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 16)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Stubify : Symbol(Stubify, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 74)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 16)) +>Provider : Symbol(Provider, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 125)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 16)) +>StubBase : Symbol(StubBase, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 0, 0)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 16)) + +type Result = R extends StubBase ? Result : RpcPromise; +>Result : Symbol(Result, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 69)) +>R : Symbol(R, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 12)) +>R : Symbol(R, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 12)) +>StubBase : Symbol(StubBase, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 0, 0)) +>U : Symbol(U, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 41)) +>Result : Symbol(Result, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 69)) +>U : Symbol(U, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 41)) +>RpcPromise : Symbol(RpcPromise, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 81)) +>R : Symbol(R, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 12)) + +type MethodOrProperty = V extends (...args: infer P) => infer R ? (...args: P) => Result> : Result>; +>MethodOrProperty : Symbol(MethodOrProperty, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 73)) +>V : Symbol(V, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 22)) +>V : Symbol(V, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 22)) +>args : Symbol(args, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 38)) +>P : Symbol(P, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 52)) +>R : Symbol(R, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 64)) +>args : Symbol(args, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 70)) +>P : Symbol(P, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 52)) +>Result : Symbol(Result, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 69)) +>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --)) +>R : Symbol(R, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 64)) +>Result : Symbol(Result, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 69)) +>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --)) +>V : Symbol(V, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 22)) + +type Provider = { [K in keyof T]: MethodOrProperty }; +>Provider : Symbol(Provider, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 125)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 15, 14)) +>K : Symbol(K, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 15, 22)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 15, 14)) +>MethodOrProperty : Symbol(MethodOrProperty, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 73)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 15, 14)) +>K : Symbol(K, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 15, 22)) + +function f(x: Stubify, y: Stubify) { +>f : Symbol(f, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 15, 62)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 11)) +>x : Symbol(x, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 14)) +>Stubify : Symbol(Stubify, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 74)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 11)) +>y : Symbol(y, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 28)) +>Stubify : Symbol(Stubify, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 74)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 11)) + + y = x; +>y : Symbol(y, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 28)) +>x : Symbol(x, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 14)) + + x = y; +>x : Symbol(x, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 14)) +>y : Symbol(y, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 28)) +} + +declare const api: Stub<{ sub(): Promise> }>; +>api : Symbol(api, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 13)) +>Stub : Symbol(Stub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 9, 1)) +>sub : Symbol(sub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 25)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Stub : Symbol(Stub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 9, 1)) + +export async function g() { +>g : Symbol(g, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 54)) + + await api.sub(); +>api.sub : Symbol(sub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 25)) +>api : Symbol(api, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 13)) +>sub : Symbol(sub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 25)) + + api.sub().then(s => s); +>api.sub().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>api.sub : Symbol(sub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 25)) +>api : Symbol(api, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 13)) +>sub : Symbol(sub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 25)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 25, 17)) +>s : Symbol(s, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 25, 17)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleEnteredAfterCanonicalEntry(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/varianceCycleEnteredAfterCanonicalEntry(checkorder=default).types new file mode 100644 index 0000000000000..41efe3567475b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleEnteredAfterCanonicalEntry(checkorder=default).types @@ -0,0 +1,77 @@ +//// [tests/cases/compiler/varianceCycleEnteredAfterCanonicalEntry.ts] //// + +=== varianceCycleEnteredAfterCanonicalEntry.ts === +// Reduced from capnweb's RpcStub types (cloudflare-os). Measuring the variance +// of Stubify enters a circularity (Stubify -> Stub -> Provider -> +// MethodOrProperty -> Result -> RpcPromise -> Stubify) whose canonical entry is +// Stub, so the measurement from Stubify is discarded and the circularity +// measured again from Stub. The discarded measurement once ran to completion, +// which on the full types took long enough to exceed the instantiation limit. + +interface StubBase { + brand: T; +>brand : T +} +type Stub = T extends object ? Provider & StubBase : StubBase; +>Stub : Stub + +type Stubify = T extends StubBase ? T : T extends Function ? Stub : T; +>Stubify : Stubify + +type RpcPromise = Promise> & Provider & StubBase; +>RpcPromise : RpcPromise + +type Result = R extends StubBase ? Result : RpcPromise; +>Result : Result + +type MethodOrProperty = V extends (...args: infer P) => infer R ? (...args: P) => Result> : Result>; +>MethodOrProperty : MethodOrProperty +>args : P +>args : P + +type Provider = { [K in keyof T]: MethodOrProperty }; +>Provider : Provider + +function f(x: Stubify, y: Stubify) { +>f : (x: Stubify, y: Stubify) => void +>x : Stubify +>y : Stubify | undefined + + y = x; +>y = x : Stubify +>y : Stubify | undefined +>x : Stubify + + x = y; +>x = y : Stubify +>x : Stubify +>y : Stubify +} + +declare const api: Stub<{ sub(): Promise> }>; +>api : Provider<{ sub(): Promise>; }> & StubBase<{ sub(): Promise>; }> +>sub : () => Promise> + +export async function g() { +>g : () => Promise + + await api.sub(); +>await api.sub() : {} +>api.sub() : RpcPromise<{}> +>api.sub : () => RpcPromise<{}> +>api : Provider<{ sub(): Promise>; }> & StubBase<{ sub(): Promise>; }> +>sub : () => RpcPromise<{}> + + api.sub().then(s => s); +>api.sub().then(s => s) : Promise<{}> +>api.sub().then : (onfulfilled?: ((value: {}) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>api.sub() : RpcPromise<{}> +>api.sub : () => RpcPromise<{}> +>api : Provider<{ sub(): Promise>; }> & StubBase<{ sub(): Promise>; }> +>sub : () => RpcPromise<{}> +>then : (onfulfilled?: ((value: {}) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>s => s : (s: {}) => {} +>s : {} +>s : {} +} + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleEnteredAfterCanonicalEntry(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/varianceCycleEnteredAfterCanonicalEntry(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..b6711c2e9b95b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleEnteredAfterCanonicalEntry(checkorder=typesfirst).symbols @@ -0,0 +1,132 @@ +//// [tests/cases/compiler/varianceCycleEnteredAfterCanonicalEntry.ts] //// + +=== varianceCycleEnteredAfterCanonicalEntry.ts === +// Reduced from capnweb's RpcStub types (cloudflare-os). Measuring the variance +// of Stubify enters a circularity (Stubify -> Stub -> Provider -> +// MethodOrProperty -> Result -> RpcPromise -> Stubify) whose canonical entry is +// Stub, so the measurement from Stubify is discarded and the circularity +// measured again from Stub. The discarded measurement once ran to completion, +// which on the full types took long enough to exceed the instantiation limit. + +interface StubBase { +>StubBase : Symbol(StubBase, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 0, 0)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 7, 19)) + + brand: T; +>brand : Symbol(StubBase.brand, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 7, 33)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 7, 19)) +} +type Stub = T extends object ? Provider & StubBase : StubBase; +>Stub : Symbol(Stub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 9, 1)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 10)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 10)) +>Provider : Symbol(Provider, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 125)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 10)) +>StubBase : Symbol(StubBase, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 0, 0)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 10)) +>StubBase : Symbol(StubBase, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 0, 0)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 10)) + +type Stubify = T extends StubBase ? T : T extends Function ? Stub : T; +>Stubify : Symbol(Stubify, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 74)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 13)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 13)) +>StubBase : Symbol(StubBase, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 0, 0)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 13)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 13)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) +>Stub : Symbol(Stub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 9, 1)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 13)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 13)) + +type RpcPromise = Promise> & Provider & StubBase; +>RpcPromise : Symbol(RpcPromise, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 81)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 16)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Stubify : Symbol(Stubify, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 74)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 16)) +>Provider : Symbol(Provider, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 125)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 16)) +>StubBase : Symbol(StubBase, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 0, 0)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 16)) + +type Result = R extends StubBase ? Result : RpcPromise; +>Result : Symbol(Result, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 69)) +>R : Symbol(R, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 12)) +>R : Symbol(R, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 12)) +>StubBase : Symbol(StubBase, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 0, 0)) +>U : Symbol(U, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 41)) +>Result : Symbol(Result, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 69)) +>U : Symbol(U, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 41)) +>RpcPromise : Symbol(RpcPromise, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 11, 81)) +>R : Symbol(R, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 12)) + +type MethodOrProperty = V extends (...args: infer P) => infer R ? (...args: P) => Result> : Result>; +>MethodOrProperty : Symbol(MethodOrProperty, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 73)) +>V : Symbol(V, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 22)) +>V : Symbol(V, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 22)) +>args : Symbol(args, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 38)) +>P : Symbol(P, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 52)) +>R : Symbol(R, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 64)) +>args : Symbol(args, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 70)) +>P : Symbol(P, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 52)) +>Result : Symbol(Result, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 69)) +>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --)) +>R : Symbol(R, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 64)) +>Result : Symbol(Result, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 12, 69)) +>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --)) +>V : Symbol(V, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 22)) + +type Provider = { [K in keyof T]: MethodOrProperty }; +>Provider : Symbol(Provider, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 14, 125)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 15, 14)) +>K : Symbol(K, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 15, 22)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 15, 14)) +>MethodOrProperty : Symbol(MethodOrProperty, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 13, 73)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 15, 14)) +>K : Symbol(K, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 15, 22)) + +function f(x: Stubify, y: Stubify) { +>f : Symbol(f, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 15, 62)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 11)) +>x : Symbol(x, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 14)) +>Stubify : Symbol(Stubify, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 74)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 11)) +>y : Symbol(y, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 28)) +>Stubify : Symbol(Stubify, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 10, 74)) +>T : Symbol(T, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 11)) + + y = x; +>y : Symbol(y, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 28)) +>x : Symbol(x, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 14)) + + x = y; +>x : Symbol(x, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 14)) +>y : Symbol(y, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 17, 28)) +} + +declare const api: Stub<{ sub(): Promise> }>; +>api : Symbol(api, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 13)) +>Stub : Symbol(Stub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 9, 1)) +>sub : Symbol(sub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 25)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Stub : Symbol(Stub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 9, 1)) + +export async function g() { +>g : Symbol(g, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 54)) + + await api.sub(); +>api.sub : Symbol(sub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 25)) +>api : Symbol(api, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 13)) +>sub : Symbol(sub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 25)) + + api.sub().then(s => s); +>api.sub().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>api.sub : Symbol(sub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 25)) +>api : Symbol(api, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 13)) +>sub : Symbol(sub, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 22, 25)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 25, 17)) +>s : Symbol(s, Decl(varianceCycleEnteredAfterCanonicalEntry.ts, 25, 17)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleEnteredAfterCanonicalEntry(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/varianceCycleEnteredAfterCanonicalEntry(checkorder=typesfirst).types new file mode 100644 index 0000000000000..41efe3567475b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleEnteredAfterCanonicalEntry(checkorder=typesfirst).types @@ -0,0 +1,77 @@ +//// [tests/cases/compiler/varianceCycleEnteredAfterCanonicalEntry.ts] //// + +=== varianceCycleEnteredAfterCanonicalEntry.ts === +// Reduced from capnweb's RpcStub types (cloudflare-os). Measuring the variance +// of Stubify enters a circularity (Stubify -> Stub -> Provider -> +// MethodOrProperty -> Result -> RpcPromise -> Stubify) whose canonical entry is +// Stub, so the measurement from Stubify is discarded and the circularity +// measured again from Stub. The discarded measurement once ran to completion, +// which on the full types took long enough to exceed the instantiation limit. + +interface StubBase { + brand: T; +>brand : T +} +type Stub = T extends object ? Provider & StubBase : StubBase; +>Stub : Stub + +type Stubify = T extends StubBase ? T : T extends Function ? Stub : T; +>Stubify : Stubify + +type RpcPromise = Promise> & Provider & StubBase; +>RpcPromise : RpcPromise + +type Result = R extends StubBase ? Result : RpcPromise; +>Result : Result + +type MethodOrProperty = V extends (...args: infer P) => infer R ? (...args: P) => Result> : Result>; +>MethodOrProperty : MethodOrProperty +>args : P +>args : P + +type Provider = { [K in keyof T]: MethodOrProperty }; +>Provider : Provider + +function f(x: Stubify, y: Stubify) { +>f : (x: Stubify, y: Stubify) => void +>x : Stubify +>y : Stubify | undefined + + y = x; +>y = x : Stubify +>y : Stubify | undefined +>x : Stubify + + x = y; +>x = y : Stubify +>x : Stubify +>y : Stubify +} + +declare const api: Stub<{ sub(): Promise> }>; +>api : Provider<{ sub(): Promise>; }> & StubBase<{ sub(): Promise>; }> +>sub : () => Promise> + +export async function g() { +>g : () => Promise + + await api.sub(); +>await api.sub() : {} +>api.sub() : RpcPromise<{}> +>api.sub : () => RpcPromise<{}> +>api : Provider<{ sub(): Promise>; }> & StubBase<{ sub(): Promise>; }> +>sub : () => RpcPromise<{}> + + api.sub().then(s => s); +>api.sub().then(s => s) : Promise<{}> +>api.sub().then : (onfulfilled?: ((value: {}) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>api.sub() : RpcPromise<{}> +>api.sub : () => RpcPromise<{}> +>api : Provider<{ sub(): Promise>; }> & StubBase<{ sub(): Promise>; }> +>sub : () => RpcPromise<{}> +>then : (onfulfilled?: ((value: {}) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>s => s : (s: {}) => {} +>s : {} +>s : {} +} + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleEntryOrder.errors.txt b/tsc/testdata/baselines/reference/compiler/varianceCycleEntryOrder.errors.txt new file mode 100644 index 0000000000000..3093fe2786a2e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleEntryOrder.errors.txt @@ -0,0 +1,78 @@ +barFirst.ts(9,1): error TS2322: Type 'Bar<"lit">' is not assignable to type 'Bar'. + Type 'string' is not assignable to type '"lit"'. +barFirst.ts(10,1): error TS2322: Type 'Foo' is not assignable to type 'Foo<"lit">'. + Types of property 'x' are incompatible. + Type 'string' is not assignable to type '"lit"'. +barFirst.ts(11,1): error TS2322: Type 'Foo<"lit">' is not assignable to type 'Foo'. + Types of property 'b' are incompatible. + Type 'Bar>' is not assignable to type 'Bar>'. + Type 'Foo' is not assignable to type 'Foo<"lit">'. + Types of property 'x' are incompatible. + Type 'string' is not assignable to type '"lit"'. +fooFirst.ts(8,1): error TS2322: Type 'Foo' is not assignable to type 'Foo<"lit">'. + Types of property 'x' are incompatible. + Type 'string' is not assignable to type '"lit"'. +fooFirst.ts(9,1): error TS2322: Type 'Foo<"lit">' is not assignable to type 'Foo'. + Types of property 'b' are incompatible. + Type 'Bar>' is not assignable to type 'Bar>'. + Type 'Foo' is not assignable to type 'Foo<"lit">'. + Types of property 'x' are incompatible. + Type 'string' is not assignable to type '"lit"'. +fooFirst.ts(11,1): error TS2322: Type 'Bar<"lit">' is not assignable to type 'Bar'. + Type 'string' is not assignable to type '"lit"'. + + +==== fooFirst.ts (3 errors) ==== + export {}; + + interface Foo { x: T; b: Bar> } + interface Bar { f: (u: U) => void; foo: Foo> } + + declare let fs: Foo, fl: Foo<"lit">; + declare let bs: Bar, bl: Bar<"lit">; + fl = fs; // Error + ~~ +!!! error TS2322: Type 'Foo' is not assignable to type 'Foo<"lit">'. +!!! error TS2322: Types of property 'x' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type '"lit"'. + fs = fl; // Error + ~~ +!!! error TS2322: Type 'Foo<"lit">' is not assignable to type 'Foo'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'Bar>' is not assignable to type 'Bar>'. +!!! error TS2322: Type 'Foo' is not assignable to type 'Foo<"lit">'. +!!! error TS2322: Types of property 'x' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type '"lit"'. + bl = bs; // Error + bs = bl; // Error + ~~ +!!! error TS2322: Type 'Bar<"lit">' is not assignable to type 'Bar'. +!!! error TS2322: Type 'string' is not assignable to type '"lit"'. + +==== barFirst.ts (3 errors) ==== + export {}; + + interface Foo { x: T; b: Bar> } + interface Bar { f: (u: U) => void; foo: Foo> } + + declare let fs: Foo, fl: Foo<"lit">; + declare let bs: Bar, bl: Bar<"lit">; + bl = bs; // Error + bs = bl; // Error + ~~ +!!! error TS2322: Type 'Bar<"lit">' is not assignable to type 'Bar'. +!!! error TS2322: Type 'string' is not assignable to type '"lit"'. + fl = fs; // Error + ~~ +!!! error TS2322: Type 'Foo' is not assignable to type 'Foo<"lit">'. +!!! error TS2322: Types of property 'x' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type '"lit"'. + fs = fl; // Error + ~~ +!!! error TS2322: Type 'Foo<"lit">' is not assignable to type 'Foo'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'Bar>' is not assignable to type 'Bar>'. +!!! error TS2322: Type 'Foo' is not assignable to type 'Foo<"lit">'. +!!! error TS2322: Types of property 'x' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type '"lit"'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleEntryOrder.symbols b/tsc/testdata/baselines/reference/compiler/varianceCycleEntryOrder.symbols new file mode 100644 index 0000000000000..478f02d4a04a7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleEntryOrder.symbols @@ -0,0 +1,106 @@ +//// [tests/cases/compiler/varianceCycleEntryOrder.ts] //// + +=== fooFirst.ts === +export {}; + +interface Foo { x: T; b: Bar> } +>Foo : Symbol(Foo, Decl(fooFirst.ts, 0, 10)) +>T : Symbol(T, Decl(fooFirst.ts, 2, 14)) +>x : Symbol(Foo.x, Decl(fooFirst.ts, 2, 18)) +>T : Symbol(T, Decl(fooFirst.ts, 2, 14)) +>b : Symbol(Foo.b, Decl(fooFirst.ts, 2, 24)) +>Bar : Symbol(Bar, Decl(fooFirst.ts, 2, 41)) +>Foo : Symbol(Foo, Decl(fooFirst.ts, 0, 10)) +>T : Symbol(T, Decl(fooFirst.ts, 2, 14)) + +interface Bar { f: (u: U) => void; foo: Foo> } +>Bar : Symbol(Bar, Decl(fooFirst.ts, 2, 41)) +>U : Symbol(U, Decl(fooFirst.ts, 3, 14)) +>f : Symbol(Bar.f, Decl(fooFirst.ts, 3, 18)) +>u : Symbol(u, Decl(fooFirst.ts, 3, 23)) +>U : Symbol(U, Decl(fooFirst.ts, 3, 14)) +>foo : Symbol(Bar.foo, Decl(fooFirst.ts, 3, 37)) +>Foo : Symbol(Foo, Decl(fooFirst.ts, 0, 10)) +>Bar : Symbol(Bar, Decl(fooFirst.ts, 2, 41)) +>U : Symbol(U, Decl(fooFirst.ts, 3, 14)) + +declare let fs: Foo, fl: Foo<"lit">; +>fs : Symbol(fs, Decl(fooFirst.ts, 5, 11)) +>Foo : Symbol(Foo, Decl(fooFirst.ts, 0, 10)) +>fl : Symbol(fl, Decl(fooFirst.ts, 5, 28)) +>Foo : Symbol(Foo, Decl(fooFirst.ts, 0, 10)) + +declare let bs: Bar, bl: Bar<"lit">; +>bs : Symbol(bs, Decl(fooFirst.ts, 6, 11)) +>Bar : Symbol(Bar, Decl(fooFirst.ts, 2, 41)) +>bl : Symbol(bl, Decl(fooFirst.ts, 6, 28)) +>Bar : Symbol(Bar, Decl(fooFirst.ts, 2, 41)) + +fl = fs; // Error +>fl : Symbol(fl, Decl(fooFirst.ts, 5, 28)) +>fs : Symbol(fs, Decl(fooFirst.ts, 5, 11)) + +fs = fl; // Error +>fs : Symbol(fs, Decl(fooFirst.ts, 5, 11)) +>fl : Symbol(fl, Decl(fooFirst.ts, 5, 28)) + +bl = bs; // Error +>bl : Symbol(bl, Decl(fooFirst.ts, 6, 28)) +>bs : Symbol(bs, Decl(fooFirst.ts, 6, 11)) + +bs = bl; // Error +>bs : Symbol(bs, Decl(fooFirst.ts, 6, 11)) +>bl : Symbol(bl, Decl(fooFirst.ts, 6, 28)) + +=== barFirst.ts === +export {}; + +interface Foo { x: T; b: Bar> } +>Foo : Symbol(Foo, Decl(barFirst.ts, 0, 10)) +>T : Symbol(T, Decl(barFirst.ts, 2, 14)) +>x : Symbol(Foo.x, Decl(barFirst.ts, 2, 18)) +>T : Symbol(T, Decl(barFirst.ts, 2, 14)) +>b : Symbol(Foo.b, Decl(barFirst.ts, 2, 24)) +>Bar : Symbol(Bar, Decl(barFirst.ts, 2, 41)) +>Foo : Symbol(Foo, Decl(barFirst.ts, 0, 10)) +>T : Symbol(T, Decl(barFirst.ts, 2, 14)) + +interface Bar { f: (u: U) => void; foo: Foo> } +>Bar : Symbol(Bar, Decl(barFirst.ts, 2, 41)) +>U : Symbol(U, Decl(barFirst.ts, 3, 14)) +>f : Symbol(Bar.f, Decl(barFirst.ts, 3, 18)) +>u : Symbol(u, Decl(barFirst.ts, 3, 23)) +>U : Symbol(U, Decl(barFirst.ts, 3, 14)) +>foo : Symbol(Bar.foo, Decl(barFirst.ts, 3, 37)) +>Foo : Symbol(Foo, Decl(barFirst.ts, 0, 10)) +>Bar : Symbol(Bar, Decl(barFirst.ts, 2, 41)) +>U : Symbol(U, Decl(barFirst.ts, 3, 14)) + +declare let fs: Foo, fl: Foo<"lit">; +>fs : Symbol(fs, Decl(barFirst.ts, 5, 11)) +>Foo : Symbol(Foo, Decl(barFirst.ts, 0, 10)) +>fl : Symbol(fl, Decl(barFirst.ts, 5, 28)) +>Foo : Symbol(Foo, Decl(barFirst.ts, 0, 10)) + +declare let bs: Bar, bl: Bar<"lit">; +>bs : Symbol(bs, Decl(barFirst.ts, 6, 11)) +>Bar : Symbol(Bar, Decl(barFirst.ts, 2, 41)) +>bl : Symbol(bl, Decl(barFirst.ts, 6, 28)) +>Bar : Symbol(Bar, Decl(barFirst.ts, 2, 41)) + +bl = bs; // Error +>bl : Symbol(bl, Decl(barFirst.ts, 6, 28)) +>bs : Symbol(bs, Decl(barFirst.ts, 6, 11)) + +bs = bl; // Error +>bs : Symbol(bs, Decl(barFirst.ts, 6, 11)) +>bl : Symbol(bl, Decl(barFirst.ts, 6, 28)) + +fl = fs; // Error +>fl : Symbol(fl, Decl(barFirst.ts, 5, 28)) +>fs : Symbol(fs, Decl(barFirst.ts, 5, 11)) + +fs = fl; // Error +>fs : Symbol(fs, Decl(barFirst.ts, 5, 11)) +>fl : Symbol(fl, Decl(barFirst.ts, 5, 28)) + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleEntryOrder.types b/tsc/testdata/baselines/reference/compiler/varianceCycleEntryOrder.types new file mode 100644 index 0000000000000..3e1522dd51543 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleEntryOrder.types @@ -0,0 +1,82 @@ +//// [tests/cases/compiler/varianceCycleEntryOrder.ts] //// + +=== fooFirst.ts === +export {}; + +interface Foo { x: T; b: Bar> } +>x : T +>b : Bar> + +interface Bar { f: (u: U) => void; foo: Foo> } +>f : (u: U) => void +>u : U +>foo : Foo> + +declare let fs: Foo, fl: Foo<"lit">; +>fs : Foo +>fl : Foo<"lit"> + +declare let bs: Bar, bl: Bar<"lit">; +>bs : Bar +>bl : Bar<"lit"> + +fl = fs; // Error +>fl = fs : Foo +>fl : Foo<"lit"> +>fs : Foo + +fs = fl; // Error +>fs = fl : Foo<"lit"> +>fs : Foo +>fl : Foo<"lit"> + +bl = bs; // Error +>bl = bs : Bar +>bl : Bar<"lit"> +>bs : Bar + +bs = bl; // Error +>bs = bl : Bar<"lit"> +>bs : Bar +>bl : Bar<"lit"> + +=== barFirst.ts === +export {}; + +interface Foo { x: T; b: Bar> } +>x : T +>b : Bar> + +interface Bar { f: (u: U) => void; foo: Foo> } +>f : (u: U) => void +>u : U +>foo : Foo> + +declare let fs: Foo, fl: Foo<"lit">; +>fs : Foo +>fl : Foo<"lit"> + +declare let bs: Bar, bl: Bar<"lit">; +>bs : Bar +>bl : Bar<"lit"> + +bl = bs; // Error +>bl = bs : Bar +>bl : Bar<"lit"> +>bs : Bar + +bs = bl; // Error +>bs = bl : Bar<"lit"> +>bs : Bar +>bl : Bar<"lit"> + +fl = fs; // Error +>fl = fs : Foo +>fl : Foo<"lit"> +>fs : Foo + +fs = fl; // Error +>fs = fl : Foo<"lit"> +>fs : Foo +>fl : Foo<"lit"> + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleRedoKeepsDiscardLog.symbols b/tsc/testdata/baselines/reference/compiler/varianceCycleRedoKeepsDiscardLog.symbols new file mode 100644 index 0000000000000..eb4907af8e1b1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleRedoKeepsDiscardLog.symbols @@ -0,0 +1,999 @@ +//// [tests/cases/compiler/varianceCycleRedoKeepsDiscardLog.ts] //// + +=== json-logic-js.d.ts === +export as namespace jsonFactory; +>jsonFactory : Symbol(jsonFactory, Decl(json-logic-js.d.ts, 0, 0)) + +// Disable auto-export +export {}; + +type RenameToIn = { +>RenameToIn : Symbol(RenameToIn, Decl(json-logic-js.d.ts, 3, 10)) +>T : Symbol(T, Decl(json-logic-js.d.ts, 5, 16)) + + [K in keyof T as K extends `in${Uppercase}${Lowercase}` ? `in` : K]: T[K]; +>K : Symbol(K, Decl(json-logic-js.d.ts, 6, 5)) +>T : Symbol(T, Decl(json-logic-js.d.ts, 5, 16)) +>K : Symbol(K, Decl(json-logic-js.d.ts, 6, 5)) +>Uppercase : Symbol(Uppercase, Decl(lib.es5.d.ts, --, --)) +>Lowercase : Symbol(Lowercase, Decl(lib.es5.d.ts, --, --)) +>K : Symbol(K, Decl(json-logic-js.d.ts, 6, 5)) +>T : Symbol(T, Decl(json-logic-js.d.ts, 5, 16)) +>K : Symbol(K, Decl(json-logic-js.d.ts, 6, 5)) + +}; + +/** + * This is a utility type used below for the "if" operation. + * Original: https://stackoverflow.com/a/68373774/765987 + */ +type MAXIMUM_ALLOWED_BOUNDARY = 80; +>MAXIMUM_ALLOWED_BOUNDARY : Symbol(MAXIMUM_ALLOWED_BOUNDARY, Decl(json-logic-js.d.ts, 7, 2)) + +type Mapped< +>Mapped : Symbol(Mapped, Decl(json-logic-js.d.ts, 13, 35)) + + Tuple extends unknown[], +>Tuple : Symbol(Tuple, Decl(json-logic-js.d.ts, 14, 12)) + + Result extends unknown[] = [], +>Result : Symbol(Result, Decl(json-logic-js.d.ts, 15, 28)) + + Count extends readonly number[] = [], +>Count : Symbol(Count, Decl(json-logic-js.d.ts, 16, 34)) + +> = Count["length"] extends MAXIMUM_ALLOWED_BOUNDARY ? Result +>Count : Symbol(Count, Decl(json-logic-js.d.ts, 16, 34)) +>MAXIMUM_ALLOWED_BOUNDARY : Symbol(MAXIMUM_ALLOWED_BOUNDARY, Decl(json-logic-js.d.ts, 7, 2)) +>Result : Symbol(Result, Decl(json-logic-js.d.ts, 15, 28)) + + : Tuple extends [] ? [] +>Tuple : Symbol(Tuple, Decl(json-logic-js.d.ts, 14, 12)) + + : Result extends [] ? Mapped +>Result : Symbol(Result, Decl(json-logic-js.d.ts, 15, 28)) +>Mapped : Symbol(Mapped, Decl(json-logic-js.d.ts, 13, 35)) +>Tuple : Symbol(Tuple, Decl(json-logic-js.d.ts, 14, 12)) +>Tuple : Symbol(Tuple, Decl(json-logic-js.d.ts, 14, 12)) +>Count : Symbol(Count, Decl(json-logic-js.d.ts, 16, 34)) + + : Mapped; +>Mapped : Symbol(Mapped, Decl(json-logic-js.d.ts, 13, 35)) +>Tuple : Symbol(Tuple, Decl(json-logic-js.d.ts, 14, 12)) +>Result : Symbol(Result, Decl(json-logic-js.d.ts, 15, 28)) +>Result : Symbol(Result, Decl(json-logic-js.d.ts, 15, 28)) +>Tuple : Symbol(Tuple, Decl(json-logic-js.d.ts, 14, 12)) +>Count : Symbol(Count, Decl(json-logic-js.d.ts, 16, 34)) + +/** + * Used for the "if" operation, which takes an array of odd length + * and a minimum of three (3) elements. + */ +type AnyArrayOfOddLengthMin3 = [any, ...Mapped<[any, any]>]; +>AnyArrayOfOddLengthMin3 : Symbol(AnyArrayOfOddLengthMin3, Decl(json-logic-js.d.ts, 21, 67)) +>Mapped : Symbol(Mapped, Decl(json-logic-js.d.ts, 13, 35)) + +export type ReservedOperations = +>ReservedOperations : Symbol(ReservedOperations, Decl(json-logic-js.d.ts, 26, 60)) + + | "var" + | "missing" + | "missing_some" + | "if" + | "==" + | "===" + | "!=" + | "!==" + | "!" + | "!!" + | "or" + | "and" + | ">" + | ">=" + | "<" + | "<=" + | "max" + | "min" + | "+" + | "-" + | "*" + | "/" + | "%" + | "map" + | "filter" + | "reduce" + | "all" + | "none" + | "some" + | "merge" + | "in" + | "cat" + | "substr" + | "log"; + +/** + * This can be an object with any key except the reserved keys. + * TODO: Find a way to limit this type to exactly one (1) key, since + * json-logic-js enforces it. See: + * https://github.com/jwadhams/json-logic-js/blob/2.0.2/logic.js#L180 + */ +export type AdditionalOperation = Partial> & { [k: string]: any }; +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>ReservedOperations : Symbol(ReservedOperations, Decl(json-logic-js.d.ts, 26, 60)) +>k : Symbol(k, Decl(json-logic-js.d.ts, 70, 82)) + +export interface AllReservedOperationsInterface { +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) + + var: RulesLogic | [RulesLogic] | [RulesLogic, any] | [RulesLogic, any]; +>var : Symbol(AllReservedOperationsInterface.var, Decl(json-logic-js.d.ts, 72, 93)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + missing: RulesLogic | any[]; +>missing : Symbol(AllReservedOperationsInterface.missing, Decl(json-logic-js.d.ts, 73, 107)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + missing_some: [RulesLogic, RulesLogic | any[]]; +>missing_some : Symbol(AllReservedOperationsInterface.missing_some, Decl(json-logic-js.d.ts, 74, 40)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + if: AnyArrayOfOddLengthMin3; +>if : Symbol(AllReservedOperationsInterface.if, Decl(json-logic-js.d.ts, 75, 67)) +>AnyArrayOfOddLengthMin3 : Symbol(AnyArrayOfOddLengthMin3, Decl(json-logic-js.d.ts, 21, 67)) + + "==": [any, any]; +>"==" : Symbol(AllReservedOperationsInterface["=="], Decl(json-logic-js.d.ts, 76, 32)) + + "===": [any, any]; +>"===" : Symbol(AllReservedOperationsInterface["==="], Decl(json-logic-js.d.ts, 77, 21)) + + "!=": [any, any]; +>"!=" : Symbol(AllReservedOperationsInterface["!="], Decl(json-logic-js.d.ts, 78, 22)) + + "!==": [any, any]; +>"!==" : Symbol(AllReservedOperationsInterface["!=="], Decl(json-logic-js.d.ts, 79, 21)) + + "!": any; +>"!" : Symbol(AllReservedOperationsInterface["!"], Decl(json-logic-js.d.ts, 80, 22)) + + "!!": any; +>"!!" : Symbol(AllReservedOperationsInterface["!!"], Decl(json-logic-js.d.ts, 81, 13)) + + or: Array>; +>or : Symbol(AllReservedOperationsInterface.or, Decl(json-logic-js.d.ts, 82, 14)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + and: Array>; +>and : Symbol(AllReservedOperationsInterface.and, Decl(json-logic-js.d.ts, 83, 34)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + ">": [RulesLogic, RulesLogic]; +>">" : Symbol(AllReservedOperationsInterface[">"], Decl(json-logic-js.d.ts, 84, 35)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + ">=": [RulesLogic, RulesLogic]; +>">=" : Symbol(AllReservedOperationsInterface[">="], Decl(json-logic-js.d.ts, 85, 50)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + "<": [RulesLogic, RulesLogic] | [RulesLogic, RulesLogic, RulesLogic]; +>"<" : Symbol(AllReservedOperationsInterface["<"], Decl(json-logic-js.d.ts, 86, 51)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + "<=": [RulesLogic, RulesLogic] | [RulesLogic, RulesLogic, RulesLogic]; +>"<=" : Symbol(AllReservedOperationsInterface["<="], Decl(json-logic-js.d.ts, 87, 113)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + max: Array>; +>max : Symbol(AllReservedOperationsInterface.max, Decl(json-logic-js.d.ts, 88, 114)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + min: Array>; +>min : Symbol(AllReservedOperationsInterface.min, Decl(json-logic-js.d.ts, 89, 35)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + "+": Array> | RulesLogic; +>"+" : Symbol(AllReservedOperationsInterface["+"], Decl(json-logic-js.d.ts, 90, 35)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + "-": Array> | RulesLogic; +>"-" : Symbol(AllReservedOperationsInterface["-"], Decl(json-logic-js.d.ts, 91, 56)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + "*": Array> | RulesLogic; +>"*" : Symbol(AllReservedOperationsInterface["*"], Decl(json-logic-js.d.ts, 92, 56)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + "/": Array> | RulesLogic; +>"/" : Symbol(AllReservedOperationsInterface["/"], Decl(json-logic-js.d.ts, 93, 56)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + "%": [RulesLogic, RulesLogic]; +>"%" : Symbol(AllReservedOperationsInterface["%"], Decl(json-logic-js.d.ts, 94, 56)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + map: [RulesLogic, RulesLogic]; +>map : Symbol(AllReservedOperationsInterface.map, Decl(json-logic-js.d.ts, 95, 50)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + filter: [RulesLogic, RulesLogic]; +>filter : Symbol(AllReservedOperationsInterface.filter, Decl(json-logic-js.d.ts, 96, 50)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + reduce: [RulesLogic, RulesLogic, RulesLogic]; +>reduce : Symbol(AllReservedOperationsInterface.reduce, Decl(json-logic-js.d.ts, 97, 53)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + all: [Array>, RulesLogic] | [RulesLogic, RulesLogic]; +>all : Symbol(AllReservedOperationsInterface.all, Decl(json-logic-js.d.ts, 98, 73)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + none: [Array>, RulesLogic] | [RulesLogic, RulesLogic]; +>none : Symbol(AllReservedOperationsInterface.none, Decl(json-logic-js.d.ts, 99, 100)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + some: [Array>, RulesLogic] | [RulesLogic, RulesLogic]; +>some : Symbol(AllReservedOperationsInterface.some, Decl(json-logic-js.d.ts, 100, 101)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + merge: Array> | RulesLogic>; +>merge : Symbol(AllReservedOperationsInterface.merge, Decl(json-logic-js.d.ts, 101, 101)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + inArray: [RulesLogic, Array>]; +>inArray : Symbol(AllReservedOperationsInterface.inArray, Decl(json-logic-js.d.ts, 102, 65)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + inString: [RulesLogic, RulesLogic]; +>inString : Symbol(AllReservedOperationsInterface.inString, Decl(json-logic-js.d.ts, 103, 61)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + cat: Array>; +>cat : Symbol(AllReservedOperationsInterface.cat, Decl(json-logic-js.d.ts, 104, 55)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + substr: [RulesLogic, RulesLogic] | [RulesLogic, RulesLogic, RulesLogic]; +>substr : Symbol(AllReservedOperationsInterface.substr, Decl(json-logic-js.d.ts, 105, 35)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) + + log: RulesLogic; +>log : Symbol(AllReservedOperationsInterface.log, Decl(json-logic-js.d.ts, 106, 116)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 72, 48)) +} + +export type JsonLogicVar = Pick< +>JsonLogicVar : Symbol(JsonLogicVar, Decl(json-logic-js.d.ts, 108, 1)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 110, 25)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 110, 25)) + + "var" +>; +export type JsonLogicMissing = Pick< +>JsonLogicMissing : Symbol(JsonLogicMissing, Decl(json-logic-js.d.ts, 113, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 114, 29)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 114, 29)) + + "missing" +>; +export type JsonLogicMissingSome = Pick< +>JsonLogicMissingSome : Symbol(JsonLogicMissingSome, Decl(json-logic-js.d.ts, 117, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 118, 33)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 118, 33)) + + "missing_some" +>; +export type JsonLogicIf = Pick; +>JsonLogicIf : Symbol(JsonLogicIf, Decl(json-logic-js.d.ts, 121, 2)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) + +export type JsonLogicEqual = Pick; +>JsonLogicEqual : Symbol(JsonLogicEqual, Decl(json-logic-js.d.ts, 122, 69)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) + +export type JsonLogicStrictEqual = Pick; +>JsonLogicStrictEqual : Symbol(JsonLogicStrictEqual, Decl(json-logic-js.d.ts, 123, 72)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) + +export type JsonLogicNotEqual = Pick; +>JsonLogicStrictNotEqual : Symbol(JsonLogicStrictNotEqual, Decl(json-logic-js.d.ts, 125, 75)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) + +export type JsonLogicNegation = Pick; +>JsonLogicNegation : Symbol(JsonLogicNegation, Decl(json-logic-js.d.ts, 126, 82)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) + +export type JsonLogicDoubleNegation = Pick; +>JsonLogicDoubleNegation : Symbol(JsonLogicDoubleNegation, Decl(json-logic-js.d.ts, 127, 74)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) + +export type JsonLogicOr = Pick< +>JsonLogicOr : Symbol(JsonLogicOr, Decl(json-logic-js.d.ts, 128, 81)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 129, 24)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 129, 24)) + + "or" +>; +export type JsonLogicAnd = Pick< +>JsonLogicAnd : Symbol(JsonLogicAnd, Decl(json-logic-js.d.ts, 132, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 133, 25)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 133, 25)) + + "and" +>; +export type JsonLogicGreaterThan = Pick< +>JsonLogicGreaterThan : Symbol(JsonLogicGreaterThan, Decl(json-logic-js.d.ts, 136, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 137, 33)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 137, 33)) + + ">" +>; +export type JsonLogicGreaterThanOrEqual = Pick< +>JsonLogicGreaterThanOrEqual : Symbol(JsonLogicGreaterThanOrEqual, Decl(json-logic-js.d.ts, 140, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 141, 40)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 141, 40)) + + ">=" +>; +export type JsonLogicLessThan = Pick< +>JsonLogicLessThan : Symbol(JsonLogicLessThan, Decl(json-logic-js.d.ts, 144, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 145, 30)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 145, 30)) + + "<" +>; +export type JsonLogicLessThanOrEqual = Pick< +>JsonLogicLessThanOrEqual : Symbol(JsonLogicLessThanOrEqual, Decl(json-logic-js.d.ts, 148, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 149, 37)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 149, 37)) + + "<=" +>; +export type JsonLogicMax = Pick< +>JsonLogicMax : Symbol(JsonLogicMax, Decl(json-logic-js.d.ts, 152, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 153, 25)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 153, 25)) + + "max" +>; +export type JsonLogicMin = Pick< +>JsonLogicMin : Symbol(JsonLogicMin, Decl(json-logic-js.d.ts, 156, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 157, 25)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 157, 25)) + + "min" +>; +export type JsonLogicSum = Pick< +>JsonLogicSum : Symbol(JsonLogicSum, Decl(json-logic-js.d.ts, 160, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 161, 25)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 161, 25)) + + "+" +>; +export type JsonLogicDifference = Pick< +>JsonLogicDifference : Symbol(JsonLogicDifference, Decl(json-logic-js.d.ts, 164, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 165, 32)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 165, 32)) + + "-" +>; +export type JsonLogicProduct = Pick< +>JsonLogicProduct : Symbol(JsonLogicProduct, Decl(json-logic-js.d.ts, 168, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 169, 29)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 169, 29)) + + "*" +>; +export type JsonLogicQuotient = Pick< +>JsonLogicQuotient : Symbol(JsonLogicQuotient, Decl(json-logic-js.d.ts, 172, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 173, 30)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 173, 30)) + + "/" +>; +export type JsonLogicRemainder = Pick< +>JsonLogicRemainder : Symbol(JsonLogicRemainder, Decl(json-logic-js.d.ts, 176, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 177, 31)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 177, 31)) + + "%" +>; +export type JsonLogicMap = Pick< +>JsonLogicMap : Symbol(JsonLogicMap, Decl(json-logic-js.d.ts, 180, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 181, 25)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 181, 25)) + + "map" +>; +export type JsonLogicFilter = Pick< +>JsonLogicFilter : Symbol(JsonLogicFilter, Decl(json-logic-js.d.ts, 184, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 185, 28)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 185, 28)) + + "filter" +>; +export type JsonLogicReduce = Pick< +>JsonLogicReduce : Symbol(JsonLogicReduce, Decl(json-logic-js.d.ts, 188, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 189, 28)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 189, 28)) + + "reduce" +>; +export type JsonLogicAll = Pick< +>JsonLogicAll : Symbol(JsonLogicAll, Decl(json-logic-js.d.ts, 192, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 193, 25)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 193, 25)) + + "all" +>; +export type JsonLogicNone = Pick< +>JsonLogicNone : Symbol(JsonLogicNone, Decl(json-logic-js.d.ts, 196, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 197, 26)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 197, 26)) + + "none" +>; +export type JsonLogicSome = Pick< +>JsonLogicSome : Symbol(JsonLogicSome, Decl(json-logic-js.d.ts, 200, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 201, 26)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 201, 26)) + + "some" +>; +export type JsonLogicMerge = Pick< +>JsonLogicMerge : Symbol(JsonLogicMerge, Decl(json-logic-js.d.ts, 204, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 205, 27)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 205, 27)) + + "merge" +>; +export type JsonLogicInArray = RenameToIn< +>JsonLogicInArray : Symbol(JsonLogicInArray, Decl(json-logic-js.d.ts, 208, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 209, 29)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>RenameToIn : Symbol(RenameToIn, Decl(json-logic-js.d.ts, 3, 10)) + + Pick, "inArray"> +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 209, 29)) + +>; +export type JsonLogicInString = RenameToIn< +>JsonLogicInString : Symbol(JsonLogicInString, Decl(json-logic-js.d.ts, 211, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 212, 30)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>RenameToIn : Symbol(RenameToIn, Decl(json-logic-js.d.ts, 3, 10)) + + Pick, "inString"> +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 212, 30)) + +>; +export type JsonLogicCat = Pick< +>JsonLogicCat : Symbol(JsonLogicCat, Decl(json-logic-js.d.ts, 214, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 215, 25)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 215, 25)) + + "cat" +>; +export type JsonLogicSubstr = Pick< +>JsonLogicSubstr : Symbol(JsonLogicSubstr, Decl(json-logic-js.d.ts, 218, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 219, 28)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 219, 28)) + + "substr" +>; +export type JsonLogicLog = Pick< +>JsonLogicLog : Symbol(JsonLogicLog, Decl(json-logic-js.d.ts, 222, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 223, 25)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) + + AllReservedOperationsInterface, +>AllReservedOperationsInterface : Symbol(AllReservedOperationsInterface, Decl(json-logic-js.d.ts, 70, 100)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 223, 25)) + + "log" +>; + +export type RulesLogic = +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) + + | boolean + | string + | number + | null + // Accessing Data - https://jsonlogic.com/operations.html#accessing-data + | JsonLogicVar +>JsonLogicVar : Symbol(JsonLogicVar, Decl(json-logic-js.d.ts, 108, 1)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicMissing +>JsonLogicMissing : Symbol(JsonLogicMissing, Decl(json-logic-js.d.ts, 113, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicMissingSome +>JsonLogicMissingSome : Symbol(JsonLogicMissingSome, Decl(json-logic-js.d.ts, 117, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + // Logic and Boolean Operations - https://jsonlogic.com/operations.html#logic-and-boolean-operations + | JsonLogicIf +>JsonLogicIf : Symbol(JsonLogicIf, Decl(json-logic-js.d.ts, 121, 2)) + + | JsonLogicEqual +>JsonLogicEqual : Symbol(JsonLogicEqual, Decl(json-logic-js.d.ts, 122, 69)) + + | JsonLogicStrictEqual +>JsonLogicStrictEqual : Symbol(JsonLogicStrictEqual, Decl(json-logic-js.d.ts, 123, 72)) + + | JsonLogicNotEqual +>JsonLogicNotEqual : Symbol(JsonLogicNotEqual, Decl(json-logic-js.d.ts, 124, 79)) + + | JsonLogicStrictNotEqual +>JsonLogicStrictNotEqual : Symbol(JsonLogicStrictNotEqual, Decl(json-logic-js.d.ts, 125, 75)) + + | JsonLogicNegation +>JsonLogicNegation : Symbol(JsonLogicNegation, Decl(json-logic-js.d.ts, 126, 82)) + + | JsonLogicDoubleNegation +>JsonLogicDoubleNegation : Symbol(JsonLogicDoubleNegation, Decl(json-logic-js.d.ts, 127, 74)) + + | JsonLogicOr +>JsonLogicOr : Symbol(JsonLogicOr, Decl(json-logic-js.d.ts, 128, 81)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicAnd +>JsonLogicAnd : Symbol(JsonLogicAnd, Decl(json-logic-js.d.ts, 132, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + // Numeric Operations - https://jsonlogic.com/operations.html#numeric-operations + | JsonLogicGreaterThan +>JsonLogicGreaterThan : Symbol(JsonLogicGreaterThan, Decl(json-logic-js.d.ts, 136, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicGreaterThanOrEqual +>JsonLogicGreaterThanOrEqual : Symbol(JsonLogicGreaterThanOrEqual, Decl(json-logic-js.d.ts, 140, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicLessThan +>JsonLogicLessThan : Symbol(JsonLogicLessThan, Decl(json-logic-js.d.ts, 144, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicLessThanOrEqual +>JsonLogicLessThanOrEqual : Symbol(JsonLogicLessThanOrEqual, Decl(json-logic-js.d.ts, 148, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicMax +>JsonLogicMax : Symbol(JsonLogicMax, Decl(json-logic-js.d.ts, 152, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicMin +>JsonLogicMin : Symbol(JsonLogicMin, Decl(json-logic-js.d.ts, 156, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicSum +>JsonLogicSum : Symbol(JsonLogicSum, Decl(json-logic-js.d.ts, 160, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicDifference +>JsonLogicDifference : Symbol(JsonLogicDifference, Decl(json-logic-js.d.ts, 164, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicProduct +>JsonLogicProduct : Symbol(JsonLogicProduct, Decl(json-logic-js.d.ts, 168, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicQuotient +>JsonLogicQuotient : Symbol(JsonLogicQuotient, Decl(json-logic-js.d.ts, 172, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicRemainder +>JsonLogicRemainder : Symbol(JsonLogicRemainder, Decl(json-logic-js.d.ts, 176, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + // Array Operations - https://jsonlogic.com/operations.html#array-operations + | JsonLogicMap +>JsonLogicMap : Symbol(JsonLogicMap, Decl(json-logic-js.d.ts, 180, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicFilter +>JsonLogicFilter : Symbol(JsonLogicFilter, Decl(json-logic-js.d.ts, 184, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicReduce +>JsonLogicReduce : Symbol(JsonLogicReduce, Decl(json-logic-js.d.ts, 188, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicAll +>JsonLogicAll : Symbol(JsonLogicAll, Decl(json-logic-js.d.ts, 192, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicNone +>JsonLogicNone : Symbol(JsonLogicNone, Decl(json-logic-js.d.ts, 196, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicSome +>JsonLogicSome : Symbol(JsonLogicSome, Decl(json-logic-js.d.ts, 200, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicMerge +>JsonLogicMerge : Symbol(JsonLogicMerge, Decl(json-logic-js.d.ts, 204, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicInArray +>JsonLogicInArray : Symbol(JsonLogicInArray, Decl(json-logic-js.d.ts, 208, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + // String Operations - https://jsonlogic.com/operations.html#string-operations + | JsonLogicInString +>JsonLogicInString : Symbol(JsonLogicInString, Decl(json-logic-js.d.ts, 211, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicCat +>JsonLogicCat : Symbol(JsonLogicCat, Decl(json-logic-js.d.ts, 214, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + | JsonLogicSubstr +>JsonLogicSubstr : Symbol(JsonLogicSubstr, Decl(json-logic-js.d.ts, 218, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + // Miscellaneous - https://jsonlogic.com/operations.html#miscellaneous + | JsonLogicLog +>JsonLogicLog : Symbol(JsonLogicLog, Decl(json-logic-js.d.ts, 222, 2)) +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + + // Adding Operations (https://jsonlogic.com/add_operation.html) + | AddOps; +>AddOps : Symbol(AddOps, Decl(json-logic-js.d.ts, 228, 23)) + +export function add_operation(name: string, code: (...args: any[]) => any): void; +>add_operation : Symbol(add_operation, Decl(json-logic-js.d.ts, 275, 13)) +>name : Symbol(name, Decl(json-logic-js.d.ts, 277, 30)) +>code : Symbol(code, Decl(json-logic-js.d.ts, 277, 43)) +>args : Symbol(args, Decl(json-logic-js.d.ts, 277, 51)) + +export function apply(logic: RulesLogic, data?: unknown): any; +>apply : Symbol(apply, Decl(json-logic-js.d.ts, 277, 81)) +>logic : Symbol(logic, Decl(json-logic-js.d.ts, 278, 22)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>AdditionalOperation : Symbol(AdditionalOperation, Decl(json-logic-js.d.ts, 62, 12)) +>data : Symbol(data, Decl(json-logic-js.d.ts, 278, 61)) + +export function rm_operation(name: string): void; +>rm_operation : Symbol(rm_operation, Decl(json-logic-js.d.ts, 278, 83)) +>name : Symbol(name, Decl(json-logic-js.d.ts, 279, 29)) + +// These functions are undocumented, but are exported by the real package +// so they're typed here for completeness. +export function is_logic(logic: any): logic is RulesLogic; +>is_logic : Symbol(is_logic, Decl(json-logic-js.d.ts, 279, 49)) +>logic : Symbol(logic, Decl(json-logic-js.d.ts, 283, 25)) +>logic : Symbol(logic, Decl(json-logic-js.d.ts, 283, 25)) +>RulesLogic : Symbol(RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) + +export function truthy(value: any): boolean; +>truthy : Symbol(truthy, Decl(json-logic-js.d.ts, 283, 58)) +>value : Symbol(value, Decl(json-logic-js.d.ts, 284, 23)) + +export function get_operator(logic: Record): string; +>get_operator : Symbol(get_operator, Decl(json-logic-js.d.ts, 284, 44)) +>logic : Symbol(logic, Decl(json-logic-js.d.ts, 285, 29)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + +export function get_values(logic: Record): any; +>get_values : Symbol(get_values, Decl(json-logic-js.d.ts, 285, 65)) +>logic : Symbol(logic, Decl(json-logic-js.d.ts, 286, 27)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + +export function uses_data(logic: Record): any[]; +>uses_data : Symbol(uses_data, Decl(json-logic-js.d.ts, 286, 60)) +>logic : Symbol(logic, Decl(json-logic-js.d.ts, 287, 26)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + +export function rule_like(rule: any, pattern: any): boolean; +>rule_like : Symbol(rule_like, Decl(json-logic-js.d.ts, 287, 61)) +>rule : Symbol(rule, Decl(json-logic-js.d.ts, 288, 26)) +>pattern : Symbol(pattern, Decl(json-logic-js.d.ts, 288, 36)) + +=== main.ts === +import * as jsonLogic from "./json-logic-js"; +>jsonLogic : Symbol(jsonLogic, Decl(main.ts, 0, 6)) + +type StartsWithAndEndsWith = +>StartsWithAndEndsWith : Symbol(StartsWithAndEndsWith, Decl(main.ts, 0, 45)) + + | { startsWith: [JsonLogicWithAdditionalOperations, JsonLogicWithAdditionalOperations] } +>startsWith : Symbol(startsWith, Decl(main.ts, 3, 7)) +>JsonLogicWithAdditionalOperations : Symbol(JsonLogicWithAdditionalOperations, Decl(main.ts, 4, 91)) +>JsonLogicWithAdditionalOperations : Symbol(JsonLogicWithAdditionalOperations, Decl(main.ts, 4, 91)) + + | { endsWith: [JsonLogicWithAdditionalOperations, JsonLogicWithAdditionalOperations] }; +>endsWith : Symbol(endsWith, Decl(main.ts, 4, 7)) +>JsonLogicWithAdditionalOperations : Symbol(JsonLogicWithAdditionalOperations, Decl(main.ts, 4, 91)) +>JsonLogicWithAdditionalOperations : Symbol(JsonLogicWithAdditionalOperations, Decl(main.ts, 4, 91)) + +type JsonLogicWithAdditionalOperations = jsonLogic.RulesLogic; +>JsonLogicWithAdditionalOperations : Symbol(JsonLogicWithAdditionalOperations, Decl(main.ts, 4, 91)) +>jsonLogic : Symbol(jsonLogic, Decl(main.ts, 0, 6)) +>RulesLogic : Symbol(jsonLogic.RulesLogic, Decl(json-logic-js.d.ts, 226, 2)) +>StartsWithAndEndsWith : Symbol(StartsWithAndEndsWith, Decl(main.ts, 0, 45)) + +const jsonExtendedLogic: JsonLogicWithAdditionalOperations = { +>jsonExtendedLogic : Symbol(jsonExtendedLogic, Decl(main.ts, 6, 5)) +>JsonLogicWithAdditionalOperations : Symbol(JsonLogicWithAdditionalOperations, Decl(main.ts, 4, 91)) + + and: [{ startsWith: ["Springfield", "Spring"] }, { endsWith: ["Springfield", "field"] }], +>and : Symbol(and, Decl(main.ts, 6, 62)) +>startsWith : Symbol(startsWith, Decl(main.ts, 7, 11)) +>endsWith : Symbol(endsWith, Decl(main.ts, 7, 54)) + +}; +jsonLogic.apply(jsonExtendedLogic); +>jsonLogic.apply : Symbol(jsonLogic.apply, Decl(json-logic-js.d.ts, 277, 81)) +>jsonLogic : Symbol(jsonLogic, Decl(main.ts, 0, 6)) +>apply : Symbol(jsonLogic.apply, Decl(json-logic-js.d.ts, 277, 81)) +>jsonExtendedLogic : Symbol(jsonExtendedLogic, Decl(main.ts, 6, 5)) + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleRedoKeepsDiscardLog.types b/tsc/testdata/baselines/reference/compiler/varianceCycleRedoKeepsDiscardLog.types new file mode 100644 index 0000000000000..0d5ee0db7b1f7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleRedoKeepsDiscardLog.types @@ -0,0 +1,518 @@ +//// [tests/cases/compiler/varianceCycleRedoKeepsDiscardLog.ts] //// + +=== json-logic-js.d.ts === +export as namespace jsonFactory; +>jsonFactory : typeof import("./json-logic-js") + +// Disable auto-export +export {}; + +type RenameToIn = { +>RenameToIn : RenameToIn + + [K in keyof T as K extends `in${Uppercase}${Lowercase}` ? `in` : K]: T[K]; +}; + +/** + * This is a utility type used below for the "if" operation. + * Original: https://stackoverflow.com/a/68373774/765987 + */ +type MAXIMUM_ALLOWED_BOUNDARY = 80; +>MAXIMUM_ALLOWED_BOUNDARY : 80 + +type Mapped< +>Mapped : Mapped + + Tuple extends unknown[], + Result extends unknown[] = [], + Count extends readonly number[] = [], +> = Count["length"] extends MAXIMUM_ALLOWED_BOUNDARY ? Result + : Tuple extends [] ? [] + : Result extends [] ? Mapped + : Mapped; +/** + * Used for the "if" operation, which takes an array of odd length + * and a minimum of three (3) elements. + */ +type AnyArrayOfOddLengthMin3 = [any, ...Mapped<[any, any]>]; +>AnyArrayOfOddLengthMin3 : [any, any, any] | [any, any, any, any, any] | [any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] + +export type ReservedOperations = +>ReservedOperations : ReservedOperations + + | "var" + | "missing" + | "missing_some" + | "if" + | "==" + | "===" + | "!=" + | "!==" + | "!" + | "!!" + | "or" + | "and" + | ">" + | ">=" + | "<" + | "<=" + | "max" + | "min" + | "+" + | "-" + | "*" + | "/" + | "%" + | "map" + | "filter" + | "reduce" + | "all" + | "none" + | "some" + | "merge" + | "in" + | "cat" + | "substr" + | "log"; + +/** + * This can be an object with any key except the reserved keys. + * TODO: Find a way to limit this type to exactly one (1) key, since + * json-logic-js enforces it. See: + * https://github.com/jwadhams/json-logic-js/blob/2.0.2/logic.js#L180 + */ +export type AdditionalOperation = Partial> & { [k: string]: any }; +>AdditionalOperation : AdditionalOperation +>k : string + +export interface AllReservedOperationsInterface { + var: RulesLogic | [RulesLogic] | [RulesLogic, any] | [RulesLogic, any]; +>var : [RulesLogic] | [RulesLogic, any] | RulesLogic + + missing: RulesLogic | any[]; +>missing : any[] | RulesLogic + + missing_some: [RulesLogic, RulesLogic | any[]]; +>missing_some : [RulesLogic, any[] | RulesLogic] + + if: AnyArrayOfOddLengthMin3; +>if : [any, any, any] | [any, any, any, any, any] | [any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] | [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any] + + "==": [any, any]; +>"==" : [any, any] + + "===": [any, any]; +>"===" : [any, any] + + "!=": [any, any]; +>"!=" : [any, any] + + "!==": [any, any]; +>"!==" : [any, any] + + "!": any; +>"!" : any + + "!!": any; +>"!!" : any + + or: Array>; +>or : RulesLogic[] + + and: Array>; +>and : RulesLogic[] + + ">": [RulesLogic, RulesLogic]; +>">" : [RulesLogic, RulesLogic] + + ">=": [RulesLogic, RulesLogic]; +>">=" : [RulesLogic, RulesLogic] + + "<": [RulesLogic, RulesLogic] | [RulesLogic, RulesLogic, RulesLogic]; +>"<" : [RulesLogic, RulesLogic] | [RulesLogic, RulesLogic, RulesLogic] + + "<=": [RulesLogic, RulesLogic] | [RulesLogic, RulesLogic, RulesLogic]; +>"<=" : [RulesLogic, RulesLogic] | [RulesLogic, RulesLogic, RulesLogic] + + max: Array>; +>max : RulesLogic[] + + min: Array>; +>min : RulesLogic[] + + "+": Array> | RulesLogic; +>"+" : RulesLogic[] | RulesLogic + + "-": Array> | RulesLogic; +>"-" : RulesLogic[] | RulesLogic + + "*": Array> | RulesLogic; +>"*" : RulesLogic[] | RulesLogic + + "/": Array> | RulesLogic; +>"/" : RulesLogic[] | RulesLogic + + "%": [RulesLogic, RulesLogic]; +>"%" : [RulesLogic, RulesLogic] + + map: [RulesLogic, RulesLogic]; +>map : [RulesLogic, RulesLogic] + + filter: [RulesLogic, RulesLogic]; +>filter : [RulesLogic, RulesLogic] + + reduce: [RulesLogic, RulesLogic, RulesLogic]; +>reduce : [RulesLogic, RulesLogic, RulesLogic] + + all: [Array>, RulesLogic] | [RulesLogic, RulesLogic]; +>all : [RulesLogic[], RulesLogic] | [RulesLogic, RulesLogic] + + none: [Array>, RulesLogic] | [RulesLogic, RulesLogic]; +>none : [RulesLogic[], RulesLogic] | [RulesLogic, RulesLogic] + + some: [Array>, RulesLogic] | [RulesLogic, RulesLogic]; +>some : [RulesLogic[], RulesLogic] | [RulesLogic, RulesLogic] + + merge: Array> | RulesLogic>; +>merge : (RulesLogic[] | RulesLogic)[] + + inArray: [RulesLogic, Array>]; +>inArray : [RulesLogic, RulesLogic[]] + + inString: [RulesLogic, RulesLogic]; +>inString : [RulesLogic, RulesLogic] + + cat: Array>; +>cat : RulesLogic[] + + substr: [RulesLogic, RulesLogic] | [RulesLogic, RulesLogic, RulesLogic]; +>substr : [RulesLogic, RulesLogic] | [RulesLogic, RulesLogic, RulesLogic] + + log: RulesLogic; +>log : RulesLogic +} + +export type JsonLogicVar = Pick< +>JsonLogicVar : JsonLogicVar + + AllReservedOperationsInterface, + "var" +>; +export type JsonLogicMissing = Pick< +>JsonLogicMissing : JsonLogicMissing + + AllReservedOperationsInterface, + "missing" +>; +export type JsonLogicMissingSome = Pick< +>JsonLogicMissingSome : JsonLogicMissingSome + + AllReservedOperationsInterface, + "missing_some" +>; +export type JsonLogicIf = Pick; +>JsonLogicIf : JsonLogicIf + +export type JsonLogicEqual = Pick; +>JsonLogicEqual : JsonLogicEqual + +export type JsonLogicStrictEqual = Pick; +>JsonLogicStrictEqual : JsonLogicStrictEqual + +export type JsonLogicNotEqual = Pick; +>JsonLogicStrictNotEqual : JsonLogicStrictNotEqual + +export type JsonLogicNegation = Pick; +>JsonLogicNegation : JsonLogicNegation + +export type JsonLogicDoubleNegation = Pick; +>JsonLogicDoubleNegation : JsonLogicDoubleNegation + +export type JsonLogicOr = Pick< +>JsonLogicOr : JsonLogicOr + + AllReservedOperationsInterface, + "or" +>; +export type JsonLogicAnd = Pick< +>JsonLogicAnd : JsonLogicAnd + + AllReservedOperationsInterface, + "and" +>; +export type JsonLogicGreaterThan = Pick< +>JsonLogicGreaterThan : JsonLogicGreaterThan + + AllReservedOperationsInterface, + ">" +>; +export type JsonLogicGreaterThanOrEqual = Pick< +>JsonLogicGreaterThanOrEqual : JsonLogicGreaterThanOrEqual + + AllReservedOperationsInterface, + ">=" +>; +export type JsonLogicLessThan = Pick< +>JsonLogicLessThan : JsonLogicLessThan + + AllReservedOperationsInterface, + "<" +>; +export type JsonLogicLessThanOrEqual = Pick< +>JsonLogicLessThanOrEqual : JsonLogicLessThanOrEqual + + AllReservedOperationsInterface, + "<=" +>; +export type JsonLogicMax = Pick< +>JsonLogicMax : JsonLogicMax + + AllReservedOperationsInterface, + "max" +>; +export type JsonLogicMin = Pick< +>JsonLogicMin : JsonLogicMin + + AllReservedOperationsInterface, + "min" +>; +export type JsonLogicSum = Pick< +>JsonLogicSum : JsonLogicSum + + AllReservedOperationsInterface, + "+" +>; +export type JsonLogicDifference = Pick< +>JsonLogicDifference : JsonLogicDifference + + AllReservedOperationsInterface, + "-" +>; +export type JsonLogicProduct = Pick< +>JsonLogicProduct : JsonLogicProduct + + AllReservedOperationsInterface, + "*" +>; +export type JsonLogicQuotient = Pick< +>JsonLogicQuotient : JsonLogicQuotient + + AllReservedOperationsInterface, + "/" +>; +export type JsonLogicRemainder = Pick< +>JsonLogicRemainder : JsonLogicRemainder + + AllReservedOperationsInterface, + "%" +>; +export type JsonLogicMap = Pick< +>JsonLogicMap : JsonLogicMap + + AllReservedOperationsInterface, + "map" +>; +export type JsonLogicFilter = Pick< +>JsonLogicFilter : JsonLogicFilter + + AllReservedOperationsInterface, + "filter" +>; +export type JsonLogicReduce = Pick< +>JsonLogicReduce : JsonLogicReduce + + AllReservedOperationsInterface, + "reduce" +>; +export type JsonLogicAll = Pick< +>JsonLogicAll : JsonLogicAll + + AllReservedOperationsInterface, + "all" +>; +export type JsonLogicNone = Pick< +>JsonLogicNone : JsonLogicNone + + AllReservedOperationsInterface, + "none" +>; +export type JsonLogicSome = Pick< +>JsonLogicSome : JsonLogicSome + + AllReservedOperationsInterface, + "some" +>; +export type JsonLogicMerge = Pick< +>JsonLogicMerge : JsonLogicMerge + + AllReservedOperationsInterface, + "merge" +>; +export type JsonLogicInArray = RenameToIn< +>JsonLogicInArray : RenameToIn, "inArray">> + + Pick, "inArray"> +>; +export type JsonLogicInString = RenameToIn< +>JsonLogicInString : RenameToIn, "inString">> + + Pick, "inString"> +>; +export type JsonLogicCat = Pick< +>JsonLogicCat : JsonLogicCat + + AllReservedOperationsInterface, + "cat" +>; +export type JsonLogicSubstr = Pick< +>JsonLogicSubstr : JsonLogicSubstr + + AllReservedOperationsInterface, + "substr" +>; +export type JsonLogicLog = Pick< +>JsonLogicLog : JsonLogicLog + + AllReservedOperationsInterface, + "log" +>; + +export type RulesLogic = +>RulesLogic : RulesLogic + + | boolean + | string + | number + | null + // Accessing Data - https://jsonlogic.com/operations.html#accessing-data + | JsonLogicVar + | JsonLogicMissing + | JsonLogicMissingSome + // Logic and Boolean Operations - https://jsonlogic.com/operations.html#logic-and-boolean-operations + | JsonLogicIf + | JsonLogicEqual + | JsonLogicStrictEqual + | JsonLogicNotEqual + | JsonLogicStrictNotEqual + | JsonLogicNegation + | JsonLogicDoubleNegation + | JsonLogicOr + | JsonLogicAnd + // Numeric Operations - https://jsonlogic.com/operations.html#numeric-operations + | JsonLogicGreaterThan + | JsonLogicGreaterThanOrEqual + | JsonLogicLessThan + | JsonLogicLessThanOrEqual + | JsonLogicMax + | JsonLogicMin + | JsonLogicSum + | JsonLogicDifference + | JsonLogicProduct + | JsonLogicQuotient + | JsonLogicRemainder + // Array Operations - https://jsonlogic.com/operations.html#array-operations + | JsonLogicMap + | JsonLogicFilter + | JsonLogicReduce + | JsonLogicAll + | JsonLogicNone + | JsonLogicSome + | JsonLogicMerge + | JsonLogicInArray + // String Operations - https://jsonlogic.com/operations.html#string-operations + | JsonLogicInString + | JsonLogicCat + | JsonLogicSubstr + // Miscellaneous - https://jsonlogic.com/operations.html#miscellaneous + | JsonLogicLog + // Adding Operations (https://jsonlogic.com/add_operation.html) + | AddOps; + +export function add_operation(name: string, code: (...args: any[]) => any): void; +>add_operation : (name: string, code: (...args: any[]) => any) => void +>name : string +>code : (...args: any[]) => any +>args : any[] + +export function apply(logic: RulesLogic, data?: unknown): any; +>apply : (logic: RulesLogic, data?: unknown) => any +>logic : RulesLogic +>data : unknown + +export function rm_operation(name: string): void; +>rm_operation : (name: string) => void +>name : string + +// These functions are undocumented, but are exported by the real package +// so they're typed here for completeness. +export function is_logic(logic: any): logic is RulesLogic; +>is_logic : (logic: any) => logic is RulesLogic +>logic : any + +export function truthy(value: any): boolean; +>truthy : (value: any) => boolean +>value : any + +export function get_operator(logic: Record): string; +>get_operator : (logic: Record) => string +>logic : Record + +export function get_values(logic: Record): any; +>get_values : (logic: Record) => any +>logic : Record + +export function uses_data(logic: Record): any[]; +>uses_data : (logic: Record) => any[] +>logic : Record + +export function rule_like(rule: any, pattern: any): boolean; +>rule_like : (rule: any, pattern: any) => boolean +>rule : any +>pattern : any + +=== main.ts === +import * as jsonLogic from "./json-logic-js"; +>jsonLogic : typeof jsonLogic + +type StartsWithAndEndsWith = +>StartsWithAndEndsWith : StartsWithAndEndsWith + + | { startsWith: [JsonLogicWithAdditionalOperations, JsonLogicWithAdditionalOperations] } +>startsWith : [JsonLogicWithAdditionalOperations, JsonLogicWithAdditionalOperations] + + | { endsWith: [JsonLogicWithAdditionalOperations, JsonLogicWithAdditionalOperations] }; +>endsWith : [JsonLogicWithAdditionalOperations, JsonLogicWithAdditionalOperations] + +type JsonLogicWithAdditionalOperations = jsonLogic.RulesLogic; +>JsonLogicWithAdditionalOperations : JsonLogicWithAdditionalOperations +>jsonLogic : any + +const jsonExtendedLogic: JsonLogicWithAdditionalOperations = { +>jsonExtendedLogic : JsonLogicWithAdditionalOperations +>{ and: [{ startsWith: ["Springfield", "Spring"] }, { endsWith: ["Springfield", "field"] }],} : { and: ({ startsWith: [string, string]; } | { endsWith: [string, string]; })[]; } + + and: [{ startsWith: ["Springfield", "Spring"] }, { endsWith: ["Springfield", "field"] }], +>and : ({ startsWith: [string, string]; } | { endsWith: [string, string]; })[] +>[{ startsWith: ["Springfield", "Spring"] }, { endsWith: ["Springfield", "field"] }] : ({ startsWith: [string, string]; } | { endsWith: [string, string]; })[] +>{ startsWith: ["Springfield", "Spring"] } : { startsWith: [string, string]; } +>startsWith : [string, string] +>["Springfield", "Spring"] : [string, string] +>"Springfield" : "Springfield" +>"Spring" : "Spring" +>{ endsWith: ["Springfield", "field"] } : { endsWith: [string, string]; } +>endsWith : [string, string] +>["Springfield", "field"] : [string, string] +>"Springfield" : "Springfield" +>"field" : "field" + +}; +jsonLogic.apply(jsonExtendedLogic); +>jsonLogic.apply(jsonExtendedLogic) : any +>jsonLogic.apply : (logic: jsonLogic.RulesLogic, data?: unknown) => any +>jsonLogic : typeof jsonLogic +>apply : (logic: jsonLogic.RulesLogic, data?: unknown) => any +>jsonExtendedLogic : jsonLogic.JsonLogicAnd + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleStructuralFallback.errors.txt b/tsc/testdata/baselines/reference/compiler/varianceCycleStructuralFallback.errors.txt new file mode 100644 index 0000000000000..85a24505357b2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleStructuralFallback.errors.txt @@ -0,0 +1,86 @@ +maFirst.ts(8,1): error TS2322: Type 'MA<{ p: string; }>' is not assignable to type 'MA<{ p: "lit"; }>'. + The types of 'x.p' are incompatible between these types. + Type 'string' is not assignable to type '"lit"'. +maFirst.ts(9,1): error TS2322: Type 'MA<{ p: "lit"; }>' is not assignable to type 'MA<{ p: string; }>'. + Types of property 'b' are incompatible. + Type 'MB>' is not assignable to type 'MB>'. + Type 'MA<{ p: string; }>' is not assignable to type 'MA<{ p: "lit"; }>'. + The types of 'x.p' are incompatible between these types. + Type 'string' is not assignable to type '"lit"'. +maFirst.ts(11,1): error TS2322: Type 'MB<{ p: "lit"; }>' is not assignable to type 'MB<{ p: string; }>'. + Type '{ p: string; }' is not assignable to type '{ p: "lit"; }'. + Types of property 'p' are incompatible. + Type 'string' is not assignable to type '"lit"'. +mbFirst.ts(9,1): error TS2322: Type 'MB<{ p: "lit"; }>' is not assignable to type 'MB<{ p: string; }>'. + Type '{ p: string; }' is not assignable to type '{ p: "lit"; }'. + Types of property 'p' are incompatible. + Type 'string' is not assignable to type '"lit"'. +mbFirst.ts(10,1): error TS2322: Type 'MA<{ p: string; }>' is not assignable to type 'MA<{ p: "lit"; }>'. + The types of 'x.p' are incompatible between these types. + Type 'string' is not assignable to type '"lit"'. +mbFirst.ts(11,1): error TS2322: Type 'MA<{ p: "lit"; }>' is not assignable to type 'MA<{ p: string; }>'. + Types of property 'b' are incompatible. + Type 'MB>' is not assignable to type 'MB>'. + Type 'MA<{ p: string; }>' is not assignable to type 'MA<{ p: "lit"; }>'. + The types of 'x.p' are incompatible between these types. + Type 'string' is not assignable to type '"lit"'. + + +==== maFirst.ts (3 errors) ==== + export {}; + + type MA = { x: { [K in keyof T]-?: T[K] }; b: MB> }; + type MB = { f: (u: U) => void; a: MA> }; + + declare let as: MA<{ p: string }>, al: MA<{ p: "lit" }>; + declare let bs: MB<{ p: string }>, bl: MB<{ p: "lit" }>; + al = as; + ~~ +!!! error TS2322: Type 'MA<{ p: string; }>' is not assignable to type 'MA<{ p: "lit"; }>'. +!!! error TS2322: The types of 'x.p' are incompatible between these types. +!!! error TS2322: Type 'string' is not assignable to type '"lit"'. + as = al; + ~~ +!!! error TS2322: Type 'MA<{ p: "lit"; }>' is not assignable to type 'MA<{ p: string; }>'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'MB>' is not assignable to type 'MB>'. +!!! error TS2322: Type 'MA<{ p: string; }>' is not assignable to type 'MA<{ p: "lit"; }>'. +!!! error TS2322: The types of 'x.p' are incompatible between these types. +!!! error TS2322: Type 'string' is not assignable to type '"lit"'. + bl = bs; + bs = bl; + ~~ +!!! error TS2322: Type 'MB<{ p: "lit"; }>' is not assignable to type 'MB<{ p: string; }>'. +!!! error TS2322: Type '{ p: string; }' is not assignable to type '{ p: "lit"; }'. +!!! error TS2322: Types of property 'p' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type '"lit"'. + +==== mbFirst.ts (3 errors) ==== + export {}; + + type MA = { x: { [K in keyof T]-?: T[K] }; b: MB> }; + type MB = { f: (u: U) => void; a: MA> }; + + declare let as: MA<{ p: string }>, al: MA<{ p: "lit" }>; + declare let bs: MB<{ p: string }>, bl: MB<{ p: "lit" }>; + bl = bs; + bs = bl; + ~~ +!!! error TS2322: Type 'MB<{ p: "lit"; }>' is not assignable to type 'MB<{ p: string; }>'. +!!! error TS2322: Type '{ p: string; }' is not assignable to type '{ p: "lit"; }'. +!!! error TS2322: Types of property 'p' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type '"lit"'. + al = as; + ~~ +!!! error TS2322: Type 'MA<{ p: string; }>' is not assignable to type 'MA<{ p: "lit"; }>'. +!!! error TS2322: The types of 'x.p' are incompatible between these types. +!!! error TS2322: Type 'string' is not assignable to type '"lit"'. + as = al; + ~~ +!!! error TS2322: Type 'MA<{ p: "lit"; }>' is not assignable to type 'MA<{ p: string; }>'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'MB>' is not assignable to type 'MB>'. +!!! error TS2322: Type 'MA<{ p: string; }>' is not assignable to type 'MA<{ p: "lit"; }>'. +!!! error TS2322: The types of 'x.p' are incompatible between these types. +!!! error TS2322: Type 'string' is not assignable to type '"lit"'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleStructuralFallback.symbols b/tsc/testdata/baselines/reference/compiler/varianceCycleStructuralFallback.symbols new file mode 100644 index 0000000000000..6859a8dde928b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleStructuralFallback.symbols @@ -0,0 +1,120 @@ +//// [tests/cases/compiler/varianceCycleStructuralFallback.ts] //// + +=== maFirst.ts === +export {}; + +type MA = { x: { [K in keyof T]-?: T[K] }; b: MB> }; +>MA : Symbol(MA, Decl(maFirst.ts, 0, 10)) +>T : Symbol(T, Decl(maFirst.ts, 2, 8)) +>x : Symbol(x, Decl(maFirst.ts, 2, 14)) +>K : Symbol(K, Decl(maFirst.ts, 2, 21)) +>T : Symbol(T, Decl(maFirst.ts, 2, 8)) +>T : Symbol(T, Decl(maFirst.ts, 2, 8)) +>K : Symbol(K, Decl(maFirst.ts, 2, 21)) +>b : Symbol(b, Decl(maFirst.ts, 2, 45)) +>MB : Symbol(MB, Decl(maFirst.ts, 2, 61)) +>MA : Symbol(MA, Decl(maFirst.ts, 0, 10)) +>T : Symbol(T, Decl(maFirst.ts, 2, 8)) + +type MB = { f: (u: U) => void; a: MA> }; +>MB : Symbol(MB, Decl(maFirst.ts, 2, 61)) +>U : Symbol(U, Decl(maFirst.ts, 3, 8)) +>f : Symbol(f, Decl(maFirst.ts, 3, 14)) +>u : Symbol(u, Decl(maFirst.ts, 3, 19)) +>U : Symbol(U, Decl(maFirst.ts, 3, 8)) +>a : Symbol(a, Decl(maFirst.ts, 3, 33)) +>MA : Symbol(MA, Decl(maFirst.ts, 0, 10)) +>MB : Symbol(MB, Decl(maFirst.ts, 2, 61)) +>U : Symbol(U, Decl(maFirst.ts, 3, 8)) + +declare let as: MA<{ p: string }>, al: MA<{ p: "lit" }>; +>as : Symbol(as, Decl(maFirst.ts, 5, 11)) +>MA : Symbol(MA, Decl(maFirst.ts, 0, 10)) +>p : Symbol(p, Decl(maFirst.ts, 5, 20)) +>al : Symbol(al, Decl(maFirst.ts, 5, 34)) +>MA : Symbol(MA, Decl(maFirst.ts, 0, 10)) +>p : Symbol(p, Decl(maFirst.ts, 5, 43)) + +declare let bs: MB<{ p: string }>, bl: MB<{ p: "lit" }>; +>bs : Symbol(bs, Decl(maFirst.ts, 6, 11)) +>MB : Symbol(MB, Decl(maFirst.ts, 2, 61)) +>p : Symbol(p, Decl(maFirst.ts, 6, 20)) +>bl : Symbol(bl, Decl(maFirst.ts, 6, 34)) +>MB : Symbol(MB, Decl(maFirst.ts, 2, 61)) +>p : Symbol(p, Decl(maFirst.ts, 6, 43)) + +al = as; +>al : Symbol(al, Decl(maFirst.ts, 5, 34)) +>as : Symbol(as, Decl(maFirst.ts, 5, 11)) + +as = al; +>as : Symbol(as, Decl(maFirst.ts, 5, 11)) +>al : Symbol(al, Decl(maFirst.ts, 5, 34)) + +bl = bs; +>bl : Symbol(bl, Decl(maFirst.ts, 6, 34)) +>bs : Symbol(bs, Decl(maFirst.ts, 6, 11)) + +bs = bl; +>bs : Symbol(bs, Decl(maFirst.ts, 6, 11)) +>bl : Symbol(bl, Decl(maFirst.ts, 6, 34)) + +=== mbFirst.ts === +export {}; + +type MA = { x: { [K in keyof T]-?: T[K] }; b: MB> }; +>MA : Symbol(MA, Decl(mbFirst.ts, 0, 10)) +>T : Symbol(T, Decl(mbFirst.ts, 2, 8)) +>x : Symbol(x, Decl(mbFirst.ts, 2, 14)) +>K : Symbol(K, Decl(mbFirst.ts, 2, 21)) +>T : Symbol(T, Decl(mbFirst.ts, 2, 8)) +>T : Symbol(T, Decl(mbFirst.ts, 2, 8)) +>K : Symbol(K, Decl(mbFirst.ts, 2, 21)) +>b : Symbol(b, Decl(mbFirst.ts, 2, 45)) +>MB : Symbol(MB, Decl(mbFirst.ts, 2, 61)) +>MA : Symbol(MA, Decl(mbFirst.ts, 0, 10)) +>T : Symbol(T, Decl(mbFirst.ts, 2, 8)) + +type MB = { f: (u: U) => void; a: MA> }; +>MB : Symbol(MB, Decl(mbFirst.ts, 2, 61)) +>U : Symbol(U, Decl(mbFirst.ts, 3, 8)) +>f : Symbol(f, Decl(mbFirst.ts, 3, 14)) +>u : Symbol(u, Decl(mbFirst.ts, 3, 19)) +>U : Symbol(U, Decl(mbFirst.ts, 3, 8)) +>a : Symbol(a, Decl(mbFirst.ts, 3, 33)) +>MA : Symbol(MA, Decl(mbFirst.ts, 0, 10)) +>MB : Symbol(MB, Decl(mbFirst.ts, 2, 61)) +>U : Symbol(U, Decl(mbFirst.ts, 3, 8)) + +declare let as: MA<{ p: string }>, al: MA<{ p: "lit" }>; +>as : Symbol(as, Decl(mbFirst.ts, 5, 11)) +>MA : Symbol(MA, Decl(mbFirst.ts, 0, 10)) +>p : Symbol(p, Decl(mbFirst.ts, 5, 20)) +>al : Symbol(al, Decl(mbFirst.ts, 5, 34)) +>MA : Symbol(MA, Decl(mbFirst.ts, 0, 10)) +>p : Symbol(p, Decl(mbFirst.ts, 5, 43)) + +declare let bs: MB<{ p: string }>, bl: MB<{ p: "lit" }>; +>bs : Symbol(bs, Decl(mbFirst.ts, 6, 11)) +>MB : Symbol(MB, Decl(mbFirst.ts, 2, 61)) +>p : Symbol(p, Decl(mbFirst.ts, 6, 20)) +>bl : Symbol(bl, Decl(mbFirst.ts, 6, 34)) +>MB : Symbol(MB, Decl(mbFirst.ts, 2, 61)) +>p : Symbol(p, Decl(mbFirst.ts, 6, 43)) + +bl = bs; +>bl : Symbol(bl, Decl(mbFirst.ts, 6, 34)) +>bs : Symbol(bs, Decl(mbFirst.ts, 6, 11)) + +bs = bl; +>bs : Symbol(bs, Decl(mbFirst.ts, 6, 11)) +>bl : Symbol(bl, Decl(mbFirst.ts, 6, 34)) + +al = as; +>al : Symbol(al, Decl(mbFirst.ts, 5, 34)) +>as : Symbol(as, Decl(mbFirst.ts, 5, 11)) + +as = al; +>as : Symbol(as, Decl(mbFirst.ts, 5, 11)) +>al : Symbol(al, Decl(mbFirst.ts, 5, 34)) + diff --git a/tsc/testdata/baselines/reference/compiler/varianceCycleStructuralFallback.types b/tsc/testdata/baselines/reference/compiler/varianceCycleStructuralFallback.types new file mode 100644 index 0000000000000..e40fcb80e2fea --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCycleStructuralFallback.types @@ -0,0 +1,94 @@ +//// [tests/cases/compiler/varianceCycleStructuralFallback.ts] //// + +=== maFirst.ts === +export {}; + +type MA = { x: { [K in keyof T]-?: T[K] }; b: MB> }; +>MA : MA +>x : { [K in keyof T]-?: T[K]; } +>b : MB> + +type MB = { f: (u: U) => void; a: MA> }; +>MB : MB +>f : (u: U) => void +>u : U +>a : MA> + +declare let as: MA<{ p: string }>, al: MA<{ p: "lit" }>; +>as : MA<{ p: string; }> +>p : string +>al : MA<{ p: "lit"; }> +>p : "lit" + +declare let bs: MB<{ p: string }>, bl: MB<{ p: "lit" }>; +>bs : MB<{ p: string; }> +>p : string +>bl : MB<{ p: "lit"; }> +>p : "lit" + +al = as; +>al = as : MA<{ p: string; }> +>al : MA<{ p: "lit"; }> +>as : MA<{ p: string; }> + +as = al; +>as = al : MA<{ p: "lit"; }> +>as : MA<{ p: string; }> +>al : MA<{ p: "lit"; }> + +bl = bs; +>bl = bs : MB<{ p: string; }> +>bl : MB<{ p: "lit"; }> +>bs : MB<{ p: string; }> + +bs = bl; +>bs = bl : MB<{ p: "lit"; }> +>bs : MB<{ p: string; }> +>bl : MB<{ p: "lit"; }> + +=== mbFirst.ts === +export {}; + +type MA = { x: { [K in keyof T]-?: T[K] }; b: MB> }; +>MA : MA +>x : { [K in keyof T]-?: T[K]; } +>b : MB> + +type MB = { f: (u: U) => void; a: MA> }; +>MB : MB +>f : (u: U) => void +>u : U +>a : MA> + +declare let as: MA<{ p: string }>, al: MA<{ p: "lit" }>; +>as : MA<{ p: string; }> +>p : string +>al : MA<{ p: "lit"; }> +>p : "lit" + +declare let bs: MB<{ p: string }>, bl: MB<{ p: "lit" }>; +>bs : MB<{ p: string; }> +>p : string +>bl : MB<{ p: "lit"; }> +>p : "lit" + +bl = bs; +>bl = bs : MB<{ p: string; }> +>bl : MB<{ p: "lit"; }> +>bs : MB<{ p: string; }> + +bs = bl; +>bs = bl : MB<{ p: "lit"; }> +>bs : MB<{ p: string; }> +>bl : MB<{ p: "lit"; }> + +al = as; +>al = as : MA<{ p: string; }> +>al : MA<{ p: "lit"; }> +>as : MA<{ p: string; }> + +as = al; +>as = al : MA<{ p: "lit"; }> +>as : MA<{ p: string; }> +>al : MA<{ p: "lit"; }> + diff --git a/tsc/testdata/baselines/reference/compiler/varianceDeclarationOrder.errors.txt b/tsc/testdata/baselines/reference/compiler/varianceDeclarationOrder.errors.txt new file mode 100644 index 0000000000000..76e1b58ab4906 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceDeclarationOrder.errors.txt @@ -0,0 +1,31 @@ +refFirst.ts(10,14): error TS2322: Type 'DS<{ total: M; }, string>' is not assignable to type 'DS, string>'. + Property 'total' is missing in type 'Record' but required in type '{ total: M; }'. + + +==== refFirst.ts (1 errors) ==== + type M = { kind: "m" }; + type Filtered = { [K in keyof T as T[K] extends M ? K : never]: T[K] }; + interface Config { measure: keyof T } + interface Ref { dataset: DS, N> } + interface DS { + a(config: Config>): void; + b: Ref; + } + declare const x: DS<{ total: M }, string>; + export const y: DS, string> = x; + ~ +!!! error TS2322: Type 'DS<{ total: M; }, string>' is not assignable to type 'DS, string>'. +!!! error TS2322: Property 'total' is missing in type 'Record' but required in type '{ total: M; }'. + +==== dsFirst.ts (0 errors) ==== + type M = { kind: "m" }; + type Filtered = { [K in keyof T as T[K] extends M ? K : never]: T[K] }; + interface Config { measure: keyof T } + interface DS { + a(config: Config>): void; + b: Ref; + } + interface Ref { dataset: DS, N> } + declare const x: DS<{ total: M }, string>; + export const y: DS, string> = x; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/varianceDeclarationOrder.symbols b/tsc/testdata/baselines/reference/compiler/varianceDeclarationOrder.symbols new file mode 100644 index 0000000000000..a35b1188b91ef --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceDeclarationOrder.symbols @@ -0,0 +1,126 @@ +//// [tests/cases/compiler/varianceDeclarationOrder.ts] //// + +=== refFirst.ts === +type M = { kind: "m" }; +>M : Symbol(M, Decl(refFirst.ts, 0, 0)) +>kind : Symbol(kind, Decl(refFirst.ts, 0, 10)) + +type Filtered = { [K in keyof T as T[K] extends M ? K : never]: T[K] }; +>Filtered : Symbol(Filtered, Decl(refFirst.ts, 0, 23)) +>T : Symbol(T, Decl(refFirst.ts, 1, 14)) +>K : Symbol(K, Decl(refFirst.ts, 1, 22)) +>T : Symbol(T, Decl(refFirst.ts, 1, 14)) +>T : Symbol(T, Decl(refFirst.ts, 1, 14)) +>K : Symbol(K, Decl(refFirst.ts, 1, 22)) +>M : Symbol(M, Decl(refFirst.ts, 0, 0)) +>K : Symbol(K, Decl(refFirst.ts, 1, 22)) +>T : Symbol(T, Decl(refFirst.ts, 1, 14)) +>K : Symbol(K, Decl(refFirst.ts, 1, 22)) + +interface Config { measure: keyof T } +>Config : Symbol(Config, Decl(refFirst.ts, 1, 74)) +>T : Symbol(T, Decl(refFirst.ts, 2, 17)) +>measure : Symbol(Config.measure, Decl(refFirst.ts, 2, 21)) +>T : Symbol(T, Decl(refFirst.ts, 2, 17)) + +interface Ref { dataset: DS, N> } +>Ref : Symbol(Ref, Decl(refFirst.ts, 2, 40)) +>N : Symbol(N, Decl(refFirst.ts, 3, 14)) +>dataset : Symbol(Ref.dataset, Decl(refFirst.ts, 3, 18)) +>DS : Symbol(DS, Decl(refFirst.ts, 3, 54)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>M : Symbol(M, Decl(refFirst.ts, 0, 0)) +>N : Symbol(N, Decl(refFirst.ts, 3, 14)) + +interface DS { +>DS : Symbol(DS, Decl(refFirst.ts, 3, 54)) +>T : Symbol(T, Decl(refFirst.ts, 4, 13)) +>N : Symbol(N, Decl(refFirst.ts, 4, 15)) + + a(config: Config>): void; +>a : Symbol(DS.a, Decl(refFirst.ts, 4, 20)) +>config : Symbol(config, Decl(refFirst.ts, 5, 6)) +>Config : Symbol(Config, Decl(refFirst.ts, 1, 74)) +>Filtered : Symbol(Filtered, Decl(refFirst.ts, 0, 23)) +>T : Symbol(T, Decl(refFirst.ts, 4, 13)) + + b: Ref; +>b : Symbol(DS.b, Decl(refFirst.ts, 5, 41)) +>Ref : Symbol(Ref, Decl(refFirst.ts, 2, 40)) +>N : Symbol(N, Decl(refFirst.ts, 4, 15)) +} +declare const x: DS<{ total: M }, string>; +>x : Symbol(x, Decl(refFirst.ts, 8, 13)) +>DS : Symbol(DS, Decl(refFirst.ts, 3, 54)) +>total : Symbol(total, Decl(refFirst.ts, 8, 21)) +>M : Symbol(M, Decl(refFirst.ts, 0, 0)) + +export const y: DS, string> = x; +>y : Symbol(y, Decl(refFirst.ts, 9, 12)) +>DS : Symbol(DS, Decl(refFirst.ts, 3, 54)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>M : Symbol(M, Decl(refFirst.ts, 0, 0)) +>x : Symbol(x, Decl(refFirst.ts, 8, 13)) + +=== dsFirst.ts === +type M = { kind: "m" }; +>M : Symbol(M, Decl(dsFirst.ts, 0, 0)) +>kind : Symbol(kind, Decl(dsFirst.ts, 0, 10)) + +type Filtered = { [K in keyof T as T[K] extends M ? K : never]: T[K] }; +>Filtered : Symbol(Filtered, Decl(dsFirst.ts, 0, 23)) +>T : Symbol(T, Decl(dsFirst.ts, 1, 14)) +>K : Symbol(K, Decl(dsFirst.ts, 1, 22)) +>T : Symbol(T, Decl(dsFirst.ts, 1, 14)) +>T : Symbol(T, Decl(dsFirst.ts, 1, 14)) +>K : Symbol(K, Decl(dsFirst.ts, 1, 22)) +>M : Symbol(M, Decl(dsFirst.ts, 0, 0)) +>K : Symbol(K, Decl(dsFirst.ts, 1, 22)) +>T : Symbol(T, Decl(dsFirst.ts, 1, 14)) +>K : Symbol(K, Decl(dsFirst.ts, 1, 22)) + +interface Config { measure: keyof T } +>Config : Symbol(Config, Decl(dsFirst.ts, 1, 74)) +>T : Symbol(T, Decl(dsFirst.ts, 2, 17)) +>measure : Symbol(Config.measure, Decl(dsFirst.ts, 2, 21)) +>T : Symbol(T, Decl(dsFirst.ts, 2, 17)) + +interface DS { +>DS : Symbol(DS, Decl(dsFirst.ts, 2, 40)) +>T : Symbol(T, Decl(dsFirst.ts, 3, 13)) +>N : Symbol(N, Decl(dsFirst.ts, 3, 15)) + + a(config: Config>): void; +>a : Symbol(DS.a, Decl(dsFirst.ts, 3, 20)) +>config : Symbol(config, Decl(dsFirst.ts, 4, 6)) +>Config : Symbol(Config, Decl(dsFirst.ts, 1, 74)) +>Filtered : Symbol(Filtered, Decl(dsFirst.ts, 0, 23)) +>T : Symbol(T, Decl(dsFirst.ts, 3, 13)) + + b: Ref; +>b : Symbol(DS.b, Decl(dsFirst.ts, 4, 41)) +>Ref : Symbol(Ref, Decl(dsFirst.ts, 6, 1)) +>N : Symbol(N, Decl(dsFirst.ts, 3, 15)) +} +interface Ref { dataset: DS, N> } +>Ref : Symbol(Ref, Decl(dsFirst.ts, 6, 1)) +>N : Symbol(N, Decl(dsFirst.ts, 7, 14)) +>dataset : Symbol(Ref.dataset, Decl(dsFirst.ts, 7, 18)) +>DS : Symbol(DS, Decl(dsFirst.ts, 2, 40)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>M : Symbol(M, Decl(dsFirst.ts, 0, 0)) +>N : Symbol(N, Decl(dsFirst.ts, 7, 14)) + +declare const x: DS<{ total: M }, string>; +>x : Symbol(x, Decl(dsFirst.ts, 8, 13)) +>DS : Symbol(DS, Decl(dsFirst.ts, 2, 40)) +>total : Symbol(total, Decl(dsFirst.ts, 8, 21)) +>M : Symbol(M, Decl(dsFirst.ts, 0, 0)) + +export const y: DS, string> = x; +>y : Symbol(y, Decl(dsFirst.ts, 9, 12)) +>DS : Symbol(DS, Decl(dsFirst.ts, 2, 40)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>M : Symbol(M, Decl(dsFirst.ts, 0, 0)) +>x : Symbol(x, Decl(dsFirst.ts, 8, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/varianceDeclarationOrder.types b/tsc/testdata/baselines/reference/compiler/varianceDeclarationOrder.types new file mode 100644 index 0000000000000..c084cea2f9d50 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceDeclarationOrder.types @@ -0,0 +1,62 @@ +//// [tests/cases/compiler/varianceDeclarationOrder.ts] //// + +=== refFirst.ts === +type M = { kind: "m" }; +>M : M +>kind : "m" + +type Filtered = { [K in keyof T as T[K] extends M ? K : never]: T[K] }; +>Filtered : Filtered + +interface Config { measure: keyof T } +>measure : keyof T + +interface Ref { dataset: DS, N> } +>dataset : DS, N> + +interface DS { + a(config: Config>): void; +>a : (config: Config>) => void +>config : Config> + + b: Ref; +>b : Ref +} +declare const x: DS<{ total: M }, string>; +>x : DS<{ total: M; }, string> +>total : M + +export const y: DS, string> = x; +>y : DS, string> +>x : DS<{ total: M; }, string> + +=== dsFirst.ts === +type M = { kind: "m" }; +>M : M +>kind : "m" + +type Filtered = { [K in keyof T as T[K] extends M ? K : never]: T[K] }; +>Filtered : Filtered + +interface Config { measure: keyof T } +>measure : keyof T + +interface DS { + a(config: Config>): void; +>a : (config: Config>) => void +>config : Config> + + b: Ref; +>b : Ref +} +interface Ref { dataset: DS, N> } +>dataset : DS, N> + +declare const x: DS<{ total: M }, string>; +>x : DS<{ total: M; }, string> +>total : M + +export const y: DS, string> = x; +>y : DS, string> +>x : DS<{ total: M; }, string> + diff --git a/tsc/testdata/baselines/reference/compiler/varianceMeasuredWithinCircularity.errors.txt b/tsc/testdata/baselines/reference/compiler/varianceMeasuredWithinCircularity.errors.txt new file mode 100644 index 0000000000000..d3d975854426a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceMeasuredWithinCircularity.errors.txt @@ -0,0 +1,63 @@ +varianceMeasuredWithinCircularity.ts(24,5): error TS2322: Type 'Selection' is not assignable to type 'Selection'. + Types of property 'join' are incompatible. + Type '(enter: string | ((elem: Selection) => Selection | TransitionLike)) => Selection' is not assignable to type '(enter: string | ((elem: Selection) => Selection | TransitionLike)) => Selection'. + Types of parameters 'enter' and 'enter' are incompatible. + Type 'string | ((elem: Selection) => Selection | TransitionLike)' is not assignable to type 'string | ((elem: Selection) => Selection | TransitionLike)'. + Type '(elem: Selection) => Selection | TransitionLike' is not assignable to type 'string | ((elem: Selection) => Selection | TransitionLike)'. + Type '(elem: Selection) => Selection | TransitionLike' is not assignable to type '(elem: Selection) => Selection | TransitionLike'. + Type 'Selection | TransitionLike' is not assignable to type 'Selection | TransitionLike'. + Type 'Selection' is not assignable to type 'Selection | TransitionLike'. + Type 'Selection' is not assignable to type 'Selection'. + Types of property 'data' are incompatible. + Type '(key: (parent: Base) => string) => Selection' is not assignable to type '(key: (parent: Derived) => string) => Selection'. + Types of parameters 'key' and 'key' are incompatible. + Types of parameters 'parent' and 'parent' are incompatible. + Property 'derived' is missing in type 'Base' but required in type 'Derived'. + + +==== varianceMeasuredWithinCircularity.ts (1 errors) ==== + // The variances of Selection and TransitionLike depend on each other. + // The callback of `data` requires Selection to be covariant in P, while + // `join` passes Selection to a callback, which then requires it to + // be contravariant in P, so Selection is invariant in P. TransitionLike + // reaches P of a Selection through `selection().children()`, so it is + // invariant in G. Both must hold whichever variance is measured first. + + export {}; + + interface Base { base: string } + interface Derived extends Base { derived: string } + + interface Selection { + data(key: (parent: P) => string): Selection; + join(enter: string | ((elem: Selection) => Selection | TransitionLike)): Selection; + children(): Selection; + } + + interface TransitionLike { + selection(): Selection; + } + + declare let s1: Selection; + let s2: Selection = s1; + ~~ +!!! error TS2322: Type 'Selection' is not assignable to type 'Selection'. +!!! error TS2322: Types of property 'join' are incompatible. +!!! error TS2322: Type '(enter: string | ((elem: Selection) => Selection | TransitionLike)) => Selection' is not assignable to type '(enter: string | ((elem: Selection) => Selection | TransitionLike)) => Selection'. +!!! error TS2322: Types of parameters 'enter' and 'enter' are incompatible. +!!! error TS2322: Type 'string | ((elem: Selection) => Selection | TransitionLike)' is not assignable to type 'string | ((elem: Selection) => Selection | TransitionLike)'. +!!! error TS2322: Type '(elem: Selection) => Selection | TransitionLike' is not assignable to type 'string | ((elem: Selection) => Selection | TransitionLike)'. +!!! error TS2322: Type '(elem: Selection) => Selection | TransitionLike' is not assignable to type '(elem: Selection) => Selection | TransitionLike'. +!!! error TS2322: Type 'Selection | TransitionLike' is not assignable to type 'Selection | TransitionLike'. +!!! error TS2322: Type 'Selection' is not assignable to type 'Selection | TransitionLike'. +!!! error TS2322: Type 'Selection' is not assignable to type 'Selection'. +!!! error TS2322: Types of property 'data' are incompatible. +!!! error TS2322: Type '(key: (parent: Base) => string) => Selection' is not assignable to type '(key: (parent: Derived) => string) => Selection'. +!!! error TS2322: Types of parameters 'key' and 'key' are incompatible. +!!! error TS2322: Types of parameters 'parent' and 'parent' are incompatible. +!!! error TS2322: Property 'derived' is missing in type 'Base' but required in type 'Derived'. +!!! related TS2728 varianceMeasuredWithinCircularity.ts:11:34: 'derived' is declared here. + + declare let t1: TransitionLike; + let t2: TransitionLike = t1; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/varianceMeasuredWithinCircularity.symbols b/tsc/testdata/baselines/reference/compiler/varianceMeasuredWithinCircularity.symbols new file mode 100644 index 0000000000000..23cef834c47e8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceMeasuredWithinCircularity.symbols @@ -0,0 +1,89 @@ +//// [tests/cases/compiler/varianceMeasuredWithinCircularity.ts] //// + +=== varianceMeasuredWithinCircularity.ts === +// The variances of Selection and TransitionLike depend on each other. +// The callback of `data` requires Selection to be covariant in P, while +// `join` passes Selection to a callback, which then requires it to +// be contravariant in P, so Selection is invariant in P. TransitionLike +// reaches P of a Selection through `selection().children()`, so it is +// invariant in G. Both must hold whichever variance is measured first. + +export {}; + +interface Base { base: string } +>Base : Symbol(Base, Decl(varianceMeasuredWithinCircularity.ts, 7, 10)) +>base : Symbol(Base.base, Decl(varianceMeasuredWithinCircularity.ts, 9, 16)) + +interface Derived extends Base { derived: string } +>Derived : Symbol(Derived, Decl(varianceMeasuredWithinCircularity.ts, 9, 31)) +>Base : Symbol(Base, Decl(varianceMeasuredWithinCircularity.ts, 7, 10)) +>derived : Symbol(Derived.derived, Decl(varianceMeasuredWithinCircularity.ts, 10, 32)) + +interface Selection { +>Selection : Symbol(Selection, Decl(varianceMeasuredWithinCircularity.ts, 10, 50)) +>G : Symbol(G, Decl(varianceMeasuredWithinCircularity.ts, 12, 20)) +>P : Symbol(P, Decl(varianceMeasuredWithinCircularity.ts, 12, 22)) + + data(key: (parent: P) => string): Selection; +>data : Symbol(Selection.data, Decl(varianceMeasuredWithinCircularity.ts, 12, 27)) +>key : Symbol(key, Decl(varianceMeasuredWithinCircularity.ts, 13, 9)) +>parent : Symbol(parent, Decl(varianceMeasuredWithinCircularity.ts, 13, 15)) +>P : Symbol(P, Decl(varianceMeasuredWithinCircularity.ts, 12, 22)) +>Selection : Symbol(Selection, Decl(varianceMeasuredWithinCircularity.ts, 10, 50)) +>G : Symbol(G, Decl(varianceMeasuredWithinCircularity.ts, 12, 20)) +>P : Symbol(P, Decl(varianceMeasuredWithinCircularity.ts, 12, 22)) + + join(enter: string | ((elem: Selection) => Selection | TransitionLike)): Selection; +>join : Symbol(Selection.join, Decl(varianceMeasuredWithinCircularity.ts, 13, 54)) +>enter : Symbol(enter, Decl(varianceMeasuredWithinCircularity.ts, 14, 9)) +>elem : Symbol(elem, Decl(varianceMeasuredWithinCircularity.ts, 14, 27)) +>Selection : Symbol(Selection, Decl(varianceMeasuredWithinCircularity.ts, 10, 50)) +>G : Symbol(G, Decl(varianceMeasuredWithinCircularity.ts, 12, 20)) +>P : Symbol(P, Decl(varianceMeasuredWithinCircularity.ts, 12, 22)) +>Selection : Symbol(Selection, Decl(varianceMeasuredWithinCircularity.ts, 10, 50)) +>G : Symbol(G, Decl(varianceMeasuredWithinCircularity.ts, 12, 20)) +>P : Symbol(P, Decl(varianceMeasuredWithinCircularity.ts, 12, 22)) +>TransitionLike : Symbol(TransitionLike, Decl(varianceMeasuredWithinCircularity.ts, 16, 1)) +>G : Symbol(G, Decl(varianceMeasuredWithinCircularity.ts, 12, 20)) +>Selection : Symbol(Selection, Decl(varianceMeasuredWithinCircularity.ts, 10, 50)) +>G : Symbol(G, Decl(varianceMeasuredWithinCircularity.ts, 12, 20)) +>P : Symbol(P, Decl(varianceMeasuredWithinCircularity.ts, 12, 22)) + + children(): Selection; +>children : Symbol(Selection.children, Decl(varianceMeasuredWithinCircularity.ts, 14, 108)) +>Selection : Symbol(Selection, Decl(varianceMeasuredWithinCircularity.ts, 10, 50)) +>G : Symbol(G, Decl(varianceMeasuredWithinCircularity.ts, 12, 20)) +} + +interface TransitionLike { +>TransitionLike : Symbol(TransitionLike, Decl(varianceMeasuredWithinCircularity.ts, 16, 1)) +>G : Symbol(G, Decl(varianceMeasuredWithinCircularity.ts, 18, 25)) + + selection(): Selection; +>selection : Symbol(TransitionLike.selection, Decl(varianceMeasuredWithinCircularity.ts, 18, 29)) +>Selection : Symbol(Selection, Decl(varianceMeasuredWithinCircularity.ts, 10, 50)) +>G : Symbol(G, Decl(varianceMeasuredWithinCircularity.ts, 18, 25)) +} + +declare let s1: Selection; +>s1 : Symbol(s1, Decl(varianceMeasuredWithinCircularity.ts, 22, 11)) +>Selection : Symbol(Selection, Decl(varianceMeasuredWithinCircularity.ts, 10, 50)) +>Derived : Symbol(Derived, Decl(varianceMeasuredWithinCircularity.ts, 9, 31)) + +let s2: Selection = s1; +>s2 : Symbol(s2, Decl(varianceMeasuredWithinCircularity.ts, 23, 3)) +>Selection : Symbol(Selection, Decl(varianceMeasuredWithinCircularity.ts, 10, 50)) +>Base : Symbol(Base, Decl(varianceMeasuredWithinCircularity.ts, 7, 10)) +>s1 : Symbol(s1, Decl(varianceMeasuredWithinCircularity.ts, 22, 11)) + +declare let t1: TransitionLike; +>t1 : Symbol(t1, Decl(varianceMeasuredWithinCircularity.ts, 25, 11)) +>TransitionLike : Symbol(TransitionLike, Decl(varianceMeasuredWithinCircularity.ts, 16, 1)) +>Derived : Symbol(Derived, Decl(varianceMeasuredWithinCircularity.ts, 9, 31)) + +let t2: TransitionLike = t1; +>t2 : Symbol(t2, Decl(varianceMeasuredWithinCircularity.ts, 26, 3)) +>TransitionLike : Symbol(TransitionLike, Decl(varianceMeasuredWithinCircularity.ts, 16, 1)) +>Base : Symbol(Base, Decl(varianceMeasuredWithinCircularity.ts, 7, 10)) +>t1 : Symbol(t1, Decl(varianceMeasuredWithinCircularity.ts, 25, 11)) + diff --git a/tsc/testdata/baselines/reference/compiler/varianceMeasuredWithinCircularity.types b/tsc/testdata/baselines/reference/compiler/varianceMeasuredWithinCircularity.types new file mode 100644 index 0000000000000..e6075d898565c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceMeasuredWithinCircularity.types @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/varianceMeasuredWithinCircularity.ts] //// + +=== varianceMeasuredWithinCircularity.ts === +// The variances of Selection and TransitionLike depend on each other. +// The callback of `data` requires Selection to be covariant in P, while +// `join` passes Selection to a callback, which then requires it to +// be contravariant in P, so Selection is invariant in P. TransitionLike +// reaches P of a Selection through `selection().children()`, so it is +// invariant in G. Both must hold whichever variance is measured first. + +export {}; + +interface Base { base: string } +>base : string + +interface Derived extends Base { derived: string } +>derived : string + +interface Selection { + data(key: (parent: P) => string): Selection; +>data : (key: (parent: P) => string) => Selection +>key : (parent: P) => string +>parent : P + + join(enter: string | ((elem: Selection) => Selection | TransitionLike)): Selection; +>join : (enter: string | ((elem: Selection) => Selection | TransitionLike)) => Selection +>enter : string | ((elem: Selection) => Selection | TransitionLike) +>elem : Selection + + children(): Selection; +>children : () => Selection +} + +interface TransitionLike { + selection(): Selection; +>selection : () => Selection +} + +declare let s1: Selection; +>s1 : Selection + +let s2: Selection = s1; +>s2 : Selection +>s1 : Selection + +declare let t1: TransitionLike; +>t1 : TransitionLike + +let t2: TransitionLike = t1; +>t2 : TransitionLike +>t1 : TransitionLike + diff --git a/tsc/testdata/baselines/reference/compiler/varianceSupersededMeasurementKeepsOtherComparisons(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/varianceSupersededMeasurementKeepsOtherComparisons(checkorder=default).symbols new file mode 100644 index 0000000000000..c191ffdb6c463 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceSupersededMeasurementKeepsOtherComparisons(checkorder=default).symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/varianceSupersededMeasurementKeepsOtherComparisons.ts] //// + +=== varianceSupersededMeasurementKeepsOtherComparisons.ts === +// Reduced from zod v4 with LangGraph's `register` augmentation +// (langchain-ai/openwiki). Measuring the variance of B reaches A, which is +// smaller, so the measurement is superseded and measured again from A. While +// it finishes, comparing the parameters of `m` re-enters B, and its return +// type resolves `Check>`, whose comparison is not part of the +// measurement. It must still compare as it would from scratch, as the +// resolved conditional type is kept. + +declare let b1: B; +>b1 : Symbol(b1, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 8, 11)) +>B : Symbol(B, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 48)) + +declare let b2: B<"s">; +>b2 : Symbol(b2, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 9, 11)) +>B : Symbol(B, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 48)) + +b1 = b2; +>b1 : Symbol(b1, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 8, 11)) +>b2 : Symbol(b2, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 9, 11)) + +interface A { m(x: B): Check>; } +>A : Symbol(A, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 10, 8)) +>T : Symbol(T, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 12)) +>m : Symbol(A.m, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 16)) +>x : Symbol(x, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 19)) +>B : Symbol(B, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 48)) +>T : Symbol(T, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 12)) +>Check : Symbol(Check, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 13, 27)) +>B : Symbol(B, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 48)) + +interface B { a: A; } +>B : Symbol(B, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 48)) +>T : Symbol(T, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 13, 12)) +>a : Symbol(B.a, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 13, 16)) +>A : Symbol(A, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 10, 8)) +>T : Symbol(T, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 13, 12)) + +type Check = U extends { a: unknown } ? "yes" : "no"; +>Check : Symbol(Check, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 13, 27)) +>U : Symbol(U, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 14, 11)) +>U : Symbol(U, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 14, 11)) +>a : Symbol(a, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 14, 27)) + +const v: Check> = "yes"; +>v : Symbol(v, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 16, 5)) +>Check : Symbol(Check, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 13, 27)) +>B : Symbol(B, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 48)) + diff --git a/tsc/testdata/baselines/reference/compiler/varianceSupersededMeasurementKeepsOtherComparisons(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/varianceSupersededMeasurementKeepsOtherComparisons(checkorder=default).types new file mode 100644 index 0000000000000..0e07b1ec22a18 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceSupersededMeasurementKeepsOtherComparisons(checkorder=default).types @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/varianceSupersededMeasurementKeepsOtherComparisons.ts] //// + +=== varianceSupersededMeasurementKeepsOtherComparisons.ts === +// Reduced from zod v4 with LangGraph's `register` augmentation +// (langchain-ai/openwiki). Measuring the variance of B reaches A, which is +// smaller, so the measurement is superseded and measured again from A. While +// it finishes, comparing the parameters of `m` re-enters B, and its return +// type resolves `Check>`, whose comparison is not part of the +// measurement. It must still compare as it would from scratch, as the +// resolved conditional type is kept. + +declare let b1: B; +>b1 : B + +declare let b2: B<"s">; +>b2 : B<"s"> + +b1 = b2; +>b1 = b2 : B<"s"> +>b1 : B +>b2 : B<"s"> + +interface A { m(x: B): Check>; } +>m : (x: B) => Check> +>x : B + +interface B { a: A; } +>a : A + +type Check = U extends { a: unknown } ? "yes" : "no"; +>Check : Check +>a : unknown + +const v: Check> = "yes"; +>v : "yes" +>"yes" : "yes" + diff --git a/tsc/testdata/baselines/reference/compiler/varianceSupersededMeasurementKeepsOtherComparisons(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/varianceSupersededMeasurementKeepsOtherComparisons(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..c191ffdb6c463 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceSupersededMeasurementKeepsOtherComparisons(checkorder=typesfirst).symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/varianceSupersededMeasurementKeepsOtherComparisons.ts] //// + +=== varianceSupersededMeasurementKeepsOtherComparisons.ts === +// Reduced from zod v4 with LangGraph's `register` augmentation +// (langchain-ai/openwiki). Measuring the variance of B reaches A, which is +// smaller, so the measurement is superseded and measured again from A. While +// it finishes, comparing the parameters of `m` re-enters B, and its return +// type resolves `Check>`, whose comparison is not part of the +// measurement. It must still compare as it would from scratch, as the +// resolved conditional type is kept. + +declare let b1: B; +>b1 : Symbol(b1, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 8, 11)) +>B : Symbol(B, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 48)) + +declare let b2: B<"s">; +>b2 : Symbol(b2, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 9, 11)) +>B : Symbol(B, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 48)) + +b1 = b2; +>b1 : Symbol(b1, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 8, 11)) +>b2 : Symbol(b2, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 9, 11)) + +interface A { m(x: B): Check>; } +>A : Symbol(A, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 10, 8)) +>T : Symbol(T, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 12)) +>m : Symbol(A.m, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 16)) +>x : Symbol(x, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 19)) +>B : Symbol(B, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 48)) +>T : Symbol(T, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 12)) +>Check : Symbol(Check, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 13, 27)) +>B : Symbol(B, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 48)) + +interface B { a: A; } +>B : Symbol(B, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 48)) +>T : Symbol(T, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 13, 12)) +>a : Symbol(B.a, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 13, 16)) +>A : Symbol(A, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 10, 8)) +>T : Symbol(T, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 13, 12)) + +type Check = U extends { a: unknown } ? "yes" : "no"; +>Check : Symbol(Check, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 13, 27)) +>U : Symbol(U, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 14, 11)) +>U : Symbol(U, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 14, 11)) +>a : Symbol(a, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 14, 27)) + +const v: Check> = "yes"; +>v : Symbol(v, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 16, 5)) +>Check : Symbol(Check, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 13, 27)) +>B : Symbol(B, Decl(varianceSupersededMeasurementKeepsOtherComparisons.ts, 12, 48)) + diff --git a/tsc/testdata/baselines/reference/compiler/varianceSupersededMeasurementKeepsOtherComparisons(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/varianceSupersededMeasurementKeepsOtherComparisons(checkorder=typesfirst).types new file mode 100644 index 0000000000000..0e07b1ec22a18 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceSupersededMeasurementKeepsOtherComparisons(checkorder=typesfirst).types @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/varianceSupersededMeasurementKeepsOtherComparisons.ts] //// + +=== varianceSupersededMeasurementKeepsOtherComparisons.ts === +// Reduced from zod v4 with LangGraph's `register` augmentation +// (langchain-ai/openwiki). Measuring the variance of B reaches A, which is +// smaller, so the measurement is superseded and measured again from A. While +// it finishes, comparing the parameters of `m` re-enters B, and its return +// type resolves `Check>`, whose comparison is not part of the +// measurement. It must still compare as it would from scratch, as the +// resolved conditional type is kept. + +declare let b1: B; +>b1 : B + +declare let b2: B<"s">; +>b2 : B<"s"> + +b1 = b2; +>b1 = b2 : B<"s"> +>b1 : B +>b2 : B<"s"> + +interface A { m(x: B): Check>; } +>m : (x: B) => Check> +>x : B + +interface B { a: A; } +>a : A + +type Check = U extends { a: unknown } ? "yes" : "no"; +>Check : Check +>a : unknown + +const v: Check> = "yes"; +>v : "yes" +>"yes" : "yes" + diff --git a/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=default).errors.txt new file mode 100644 index 0000000000000..5529a3e5e68c6 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=default).errors.txt @@ -0,0 +1,149 @@ +dependentDestructuredVariablesReferenceInDeclaration1.ts(4,9): error TS2322: Type '{ c: number; f: any; }' is not assignable to type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(4,11): error TS2339: Property 'c' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(4,14): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(4,14): error TS7022: 'f' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +dependentDestructuredVariablesReferenceInDeclaration1.ts(4,45): error TS2448: Block-scoped variable 'f' used before its declaration. +dependentDestructuredVariablesReferenceInDeclaration1.ts(9,9): error TS2322: Type '{ c: number; f: () => any; }' is not assignable to type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(9,11): error TS2339: Property 'c' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(9,14): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(14,9): error TS2322: Type '{ c: number; f: number; g: number; }' is not assignable to type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(14,11): error TS2339: Property 'c' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(14,14): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(14,17): error TS2339: Property 'g' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(20,9): error TS2322: Type '{ c: number; f: number; }' is not assignable to type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(20,11): error TS2339: Property 'c' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(20,14): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(20,14): error TS2451: Cannot redeclare block-scoped variable 'f'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(20,17): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(20,17): error TS2451: Cannot redeclare block-scoped variable 'f'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(25,9): error TS2322: Type '{ c: number; f: number; }' is not assignable to type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(25,11): error TS2339: Property 'c' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(25,14): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(25,17): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(30,14): error TS7022: 'f' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +dependentDestructuredVariablesReferenceInDeclaration1.ts(30,71): error TS2448: Block-scoped variable 'f' used before its declaration. +dependentDestructuredVariablesReferenceInDeclaration1.ts(58,14): error TS2451: Cannot redeclare block-scoped variable 'f'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(58,17): error TS2451: Cannot redeclare block-scoped variable 'f'. + + +==== dependentDestructuredVariablesReferenceInDeclaration1.ts (26 errors) ==== + // https://github.com/microsoft/TypeScript/issues/62993 + + { + const { c, f }: string | number = { c: 0, f }; + ~~~~~~~~ +!!! error TS2322: Type '{ c: number; f: any; }' is not assignable to type 'string | number'. + ~ +!!! error TS2339: Property 'c' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + ~ +!!! error TS7022: 'f' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + ~ +!!! error TS2448: Block-scoped variable 'f' used before its declaration. +!!! related TS2728 dependentDestructuredVariablesReferenceInDeclaration1.ts:4:14: 'f' is declared here. + f; + } + + { + const { c, f }: string | number = { c: 0, f: () => f }; + ~~~~~~~~ +!!! error TS2322: Type '{ c: number; f: () => any; }' is not assignable to type 'string | number'. + ~ +!!! error TS2339: Property 'c' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + f; + } + + { + const { c, f, g = f }: string | number = { c: 0, f: 0, g: 0 }; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ c: number; f: number; g: number; }' is not assignable to type 'string | number'. + ~ +!!! error TS2339: Property 'c' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'g' does not exist on type 'string | number'. + f; + g; + } + + { + const { c, f, f }: string | number = { c: 0, f: 0 }; + ~~~~~~~~~~~ +!!! error TS2322: Type '{ c: number; f: number; }' is not assignable to type 'string | number'. + ~ +!!! error TS2339: Property 'c' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'f'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'f'. + f; + } + + { + const { c, f, f: g }: string | number = { c: 0, f: 0 }; + ~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ c: number; f: number; }' is not assignable to type 'string | number'. + ~ +!!! error TS2339: Property 'c' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + g; + } + + { + const { c, f }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f }; + ~ +!!! error TS7022: 'f' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + ~ +!!! error TS2448: Block-scoped variable 'f' used before its declaration. +!!! related TS2728 dependentDestructuredVariablesReferenceInDeclaration1.ts:30:14: 'f' is declared here. + f; + } + + { + const { c, f }: { c: 0; f: () => unknown } | { c: 1; f: string } = { + c: 0, + f: () => f, + }; + f; + } + + { + const { + c, + f, + g = f, + }: + | { c: 0; f: bigint; g?: bigint | number } + | { c: 1; f: number; g: string } = { + c: 0, + f: 10n, + }; + f; + g; + } + + { + const { c, f, f }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f: 0 }; + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'f'. + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'f'. + f; + } + + { + const { c, f, f: g }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f: 0 }; + g; + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=default).symbols b/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=default).symbols new file mode 100644 index 0000000000000..dd70a6b10cfe7 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=default).symbols @@ -0,0 +1,175 @@ +//// [tests/cases/conformance/controlFlow/dependentDestructuredVariablesReferenceInDeclaration1.ts] //// + +=== dependentDestructuredVariablesReferenceInDeclaration1.ts === +// https://github.com/microsoft/TypeScript/issues/62993 + +{ + const { c, f }: string | number = { c: 0, f }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 3, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 3, 12)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 3, 37)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 3, 43)) + + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 3, 12)) +} + +{ + const { c, f }: string | number = { c: 0, f: () => f }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 8, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 8, 12)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 8, 37)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 8, 43)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 8, 12)) + + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 8, 12)) +} + +{ + const { c, f, g = f }: string | number = { c: 0, f: 0, g: 0 }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 12)) +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 15)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 12)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 44)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 50)) +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 56)) + + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 12)) + + g; +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 15)) +} + +{ + const { c, f, f }: string | number = { c: 0, f: 0 }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 19, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 19, 12)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 19, 15)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 19, 40)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 19, 46)) + + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 19, 12)) +} + +{ + const { c, f, f: g }: string | number = { c: 0, f: 0 }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 24, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 24, 12)) +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 24, 15)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 24, 43)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 24, 49)) + + g; +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 24, 15)) +} + +{ + const { c, f }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 12)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 19)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 25)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 41)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 47)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 63)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 69)) + + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 12)) +} + +{ + const { c, f }: { c: 0; f: () => unknown } | { c: 1; f: string } = { +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 12)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 19)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 25)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 48)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 54)) + + c: 0, +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 70)) + + f: () => f, +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 35, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 12)) + + }; + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 12)) +} + +{ + const { + c, +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 42, 9)) + + f, +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 43, 6)) + + g = f, +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 44, 6)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 43, 6)) + + }: + | { c: 0; f: bigint; g?: bigint | number } +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 47, 7)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 47, 13)) +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 47, 24)) + + | { c: 1; f: number; g: string } = { +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 48, 7)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 48, 13)) +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 48, 24)) + + c: 0, +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 48, 40)) + + f: 10n, +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 49, 9)) + + }; + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 43, 6)) + + g; +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 44, 6)) +} + +{ + const { c, f, f }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f: 0 }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 12)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 15)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 22)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 28)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 44)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 50)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 66)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 72)) + + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 12)) +} + +{ + const { c, f, f: g }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f: 0 }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 12)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 31), Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 53)) +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 15)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 25)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 31)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 47)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 53)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 69)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 75)) + + g; +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 15)) +} + diff --git a/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=default).types b/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=default).types new file mode 100644 index 0000000000000..1e1c61a26976d --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=default).types @@ -0,0 +1,205 @@ +//// [tests/cases/conformance/controlFlow/dependentDestructuredVariablesReferenceInDeclaration1.ts] //// + +=== dependentDestructuredVariablesReferenceInDeclaration1.ts === +// https://github.com/microsoft/TypeScript/issues/62993 + +{ + const { c, f }: string | number = { c: 0, f }; +>c : any +>f : any +>{ c: 0, f } : { c: number; f: any; } +>c : number +>0 : 0 +>f : any + + f; +>f : any +} + +{ + const { c, f }: string | number = { c: 0, f: () => f }; +>c : any +>f : any +>{ c: 0, f: () => f } : { c: number; f: () => any; } +>c : number +>0 : 0 +>f : () => any +>() => f : () => any +>f : any + + f; +>f : any +} + +{ + const { c, f, g = f }: string | number = { c: 0, f: 0, g: 0 }; +>c : any +>f : any +>g : any +>f : any +>{ c: 0, f: 0, g: 0 } : { c: number; f: number; g: number; } +>c : number +>0 : 0 +>f : number +>0 : 0 +>g : number +>0 : 0 + + f; +>f : any + + g; +>g : any +} + +{ + const { c, f, f }: string | number = { c: 0, f: 0 }; +>c : any +>f : any +>f : any +>{ c: 0, f: 0 } : { c: number; f: number; } +>c : number +>0 : 0 +>f : number +>0 : 0 + + f; +>f : any +} + +{ + const { c, f, f: g }: string | number = { c: 0, f: 0 }; +>c : any +>f : any +>f : any +>g : any +>{ c: 0, f: 0 } : { c: number; f: number; } +>c : number +>0 : 0 +>f : number +>0 : 0 + + g; +>g : any +} + +{ + const { c, f }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f }; +>c : 0 | 1 +>f : any +>c : 0 +>f : number +>c : 1 +>f : string +>{ c: 0, f } : { c: 0; f: any; } +>c : 0 +>0 : 0 +>f : any + + f; +>f : string | number +} + +{ + const { c, f }: { c: 0; f: () => unknown } | { c: 1; f: string } = { +>c : 0 | 1 +>f : string | (() => unknown) +>c : 0 +>f : () => unknown +>c : 1 +>f : string +>{ c: 0, f: () => f, } : { c: 0; f: () => string | (() => unknown); } + + c: 0, +>c : 0 +>0 : 0 + + f: () => f, +>f : () => string | (() => unknown) +>() => f : () => string | (() => unknown) +>f : string | (() => unknown) + + }; + f; +>f : () => unknown +} + +{ + const { + c, +>c : 0 | 1 + + f, +>f : number | bigint + + g = f, +>g : string | number | bigint +>f : number | bigint + + }: + | { c: 0; f: bigint; g?: bigint | number } +>c : 0 +>f : bigint +>g : number | bigint | undefined + + | { c: 1; f: number; g: string } = { +>c : 1 +>f : number +>g : string +>{ c: 0, f: 10n, } : { c: 0; f: bigint; } + + c: 0, +>c : 0 +>0 : 0 + + f: 10n, +>f : bigint +>10n : 10n + + }; + f; +>f : bigint + + g; +>g : string | number | bigint +} + +{ + const { c, f, f }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f: 0 }; +>c : 0 | 1 +>f : string | number +>f : string | number +>c : 0 +>f : number +>c : 1 +>f : string +>{ c: 0, f: 0 } : { c: 0; f: number; } +>c : 0 +>0 : 0 +>f : number +>0 : 0 + + f; +>f : number +} + +{ + const { c, f, f: g }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f: 0 }; +>c : 0 | 1 +>f : string | number +>f : any +>g : string | number +>c : 0 +>f : number +>c : 1 +>f : string +>{ c: 0, f: 0 } : { c: 0; f: number; } +>c : 0 +>0 : 0 +>f : number +>0 : 0 + + g; +>g : number +} + diff --git a/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..981a83e22c019 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=typesfirst).errors.txt @@ -0,0 +1,152 @@ +dependentDestructuredVariablesReferenceInDeclaration1.ts(4,9): error TS2322: Type '{ c: number; f: any; }' is not assignable to type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(4,11): error TS2339: Property 'c' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(4,14): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(4,14): error TS7022: 'f' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +dependentDestructuredVariablesReferenceInDeclaration1.ts(4,45): error TS2448: Block-scoped variable 'f' used before its declaration. +dependentDestructuredVariablesReferenceInDeclaration1.ts(9,9): error TS2322: Type '{ c: number; f: () => any; }' is not assignable to type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(9,11): error TS2339: Property 'c' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(9,14): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(14,9): error TS2322: Type '{ c: number; f: number; g: number; }' is not assignable to type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(14,11): error TS2339: Property 'c' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(14,14): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(14,17): error TS2339: Property 'g' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(20,9): error TS2322: Type '{ c: number; f: number; }' is not assignable to type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(20,11): error TS2339: Property 'c' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(20,14): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(20,14): error TS2451: Cannot redeclare block-scoped variable 'f'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(20,17): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(20,17): error TS2451: Cannot redeclare block-scoped variable 'f'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(25,9): error TS2322: Type '{ c: number; f: number; }' is not assignable to type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(25,11): error TS2339: Property 'c' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(25,14): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(25,17): error TS2339: Property 'f' does not exist on type 'string | number'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(30,14): error TS7022: 'f' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +dependentDestructuredVariablesReferenceInDeclaration1.ts(30,71): error TS2448: Block-scoped variable 'f' used before its declaration. +dependentDestructuredVariablesReferenceInDeclaration1.ts(35,14): error TS7022: 'f' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +dependentDestructuredVariablesReferenceInDeclaration1.ts(58,14): error TS2451: Cannot redeclare block-scoped variable 'f'. +dependentDestructuredVariablesReferenceInDeclaration1.ts(58,17): error TS2451: Cannot redeclare block-scoped variable 'f'. + + +==== dependentDestructuredVariablesReferenceInDeclaration1.ts (27 errors) ==== + // https://github.com/microsoft/TypeScript/issues/62993 + + { + const { c, f }: string | number = { c: 0, f }; + ~~~~~~~~ +!!! error TS2322: Type '{ c: number; f: any; }' is not assignable to type 'string | number'. + ~ +!!! error TS2339: Property 'c' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + ~ +!!! error TS7022: 'f' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + ~ +!!! error TS2448: Block-scoped variable 'f' used before its declaration. +!!! related TS2728 dependentDestructuredVariablesReferenceInDeclaration1.ts:4:14: 'f' is declared here. + f; + } + + { + const { c, f }: string | number = { c: 0, f: () => f }; + ~~~~~~~~ +!!! error TS2322: Type '{ c: number; f: () => any; }' is not assignable to type 'string | number'. + ~ +!!! error TS2339: Property 'c' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + f; + } + + { + const { c, f, g = f }: string | number = { c: 0, f: 0, g: 0 }; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ c: number; f: number; g: number; }' is not assignable to type 'string | number'. + ~ +!!! error TS2339: Property 'c' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'g' does not exist on type 'string | number'. + f; + g; + } + + { + const { c, f, f }: string | number = { c: 0, f: 0 }; + ~~~~~~~~~~~ +!!! error TS2322: Type '{ c: number; f: number; }' is not assignable to type 'string | number'. + ~ +!!! error TS2339: Property 'c' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'f'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'f'. + f; + } + + { + const { c, f, f: g }: string | number = { c: 0, f: 0 }; + ~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ c: number; f: number; }' is not assignable to type 'string | number'. + ~ +!!! error TS2339: Property 'c' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + g; + } + + { + const { c, f }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f }; + ~ +!!! error TS7022: 'f' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + ~ +!!! error TS2448: Block-scoped variable 'f' used before its declaration. +!!! related TS2728 dependentDestructuredVariablesReferenceInDeclaration1.ts:30:14: 'f' is declared here. + f; + } + + { + const { c, f }: { c: 0; f: () => unknown } | { c: 1; f: string } = { + ~ +!!! error TS7022: 'f' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + c: 0, + f: () => f, + }; + f; + } + + { + const { + c, + f, + g = f, + }: + | { c: 0; f: bigint; g?: bigint | number } + | { c: 1; f: number; g: string } = { + c: 0, + f: 10n, + }; + f; + g; + } + + { + const { c, f, f }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f: 0 }; + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'f'. + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'f'. + f; + } + + { + const { c, f, f: g }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f: 0 }; + g; + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..dd70a6b10cfe7 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=typesfirst).symbols @@ -0,0 +1,175 @@ +//// [tests/cases/conformance/controlFlow/dependentDestructuredVariablesReferenceInDeclaration1.ts] //// + +=== dependentDestructuredVariablesReferenceInDeclaration1.ts === +// https://github.com/microsoft/TypeScript/issues/62993 + +{ + const { c, f }: string | number = { c: 0, f }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 3, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 3, 12)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 3, 37)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 3, 43)) + + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 3, 12)) +} + +{ + const { c, f }: string | number = { c: 0, f: () => f }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 8, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 8, 12)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 8, 37)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 8, 43)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 8, 12)) + + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 8, 12)) +} + +{ + const { c, f, g = f }: string | number = { c: 0, f: 0, g: 0 }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 12)) +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 15)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 12)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 44)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 50)) +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 56)) + + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 12)) + + g; +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 13, 15)) +} + +{ + const { c, f, f }: string | number = { c: 0, f: 0 }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 19, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 19, 12)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 19, 15)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 19, 40)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 19, 46)) + + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 19, 12)) +} + +{ + const { c, f, f: g }: string | number = { c: 0, f: 0 }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 24, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 24, 12)) +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 24, 15)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 24, 43)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 24, 49)) + + g; +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 24, 15)) +} + +{ + const { c, f }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 12)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 19)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 25)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 41)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 47)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 63)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 69)) + + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 29, 12)) +} + +{ + const { c, f }: { c: 0; f: () => unknown } | { c: 1; f: string } = { +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 12)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 19)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 25)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 48)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 54)) + + c: 0, +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 70)) + + f: () => f, +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 35, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 12)) + + }; + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 34, 12)) +} + +{ + const { + c, +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 42, 9)) + + f, +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 43, 6)) + + g = f, +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 44, 6)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 43, 6)) + + }: + | { c: 0; f: bigint; g?: bigint | number } +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 47, 7)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 47, 13)) +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 47, 24)) + + | { c: 1; f: number; g: string } = { +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 48, 7)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 48, 13)) +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 48, 24)) + + c: 0, +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 48, 40)) + + f: 10n, +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 49, 9)) + + }; + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 43, 6)) + + g; +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 44, 6)) +} + +{ + const { c, f, f }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f: 0 }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 12)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 15)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 22)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 28)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 44)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 50)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 66)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 72)) + + f; +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 57, 12)) +} + +{ + const { c, f, f: g }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f: 0 }; +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 9)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 12)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 31), Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 53)) +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 15)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 25)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 31)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 47)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 53)) +>c : Symbol(c, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 69)) +>f : Symbol(f, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 75)) + + g; +>g : Symbol(g, Decl(dependentDestructuredVariablesReferenceInDeclaration1.ts, 62, 15)) +} + diff --git a/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=typesfirst).types new file mode 100644 index 0000000000000..fda8b5b052297 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/dependentDestructuredVariablesReferenceInDeclaration1(checkorder=typesfirst).types @@ -0,0 +1,205 @@ +//// [tests/cases/conformance/controlFlow/dependentDestructuredVariablesReferenceInDeclaration1.ts] //// + +=== dependentDestructuredVariablesReferenceInDeclaration1.ts === +// https://github.com/microsoft/TypeScript/issues/62993 + +{ + const { c, f }: string | number = { c: 0, f }; +>c : any +>f : any +>{ c: 0, f } : { c: number; f: any; } +>c : number +>0 : 0 +>f : any + + f; +>f : any +} + +{ + const { c, f }: string | number = { c: 0, f: () => f }; +>c : any +>f : any +>{ c: 0, f: () => f } : { c: number; f: () => any; } +>c : number +>0 : 0 +>f : () => any +>() => f : () => any +>f : any + + f; +>f : any +} + +{ + const { c, f, g = f }: string | number = { c: 0, f: 0, g: 0 }; +>c : any +>f : any +>g : any +>f : any +>{ c: 0, f: 0, g: 0 } : { c: number; f: number; g: number; } +>c : number +>0 : 0 +>f : number +>0 : 0 +>g : number +>0 : 0 + + f; +>f : any + + g; +>g : any +} + +{ + const { c, f, f }: string | number = { c: 0, f: 0 }; +>c : any +>f : any +>f : any +>{ c: 0, f: 0 } : { c: number; f: number; } +>c : number +>0 : 0 +>f : number +>0 : 0 + + f; +>f : any +} + +{ + const { c, f, f: g }: string | number = { c: 0, f: 0 }; +>c : any +>f : any +>f : any +>g : any +>{ c: 0, f: 0 } : { c: number; f: number; } +>c : number +>0 : 0 +>f : number +>0 : 0 + + g; +>g : any +} + +{ + const { c, f }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f }; +>c : 0 | 1 +>f : any +>c : 0 +>f : number +>c : 1 +>f : string +>{ c: 0, f } : { c: 0; f: any; } +>c : 0 +>0 : 0 +>f : any + + f; +>f : string | number +} + +{ + const { c, f }: { c: 0; f: () => unknown } | { c: 1; f: string } = { +>c : 0 | 1 +>f : any +>c : 0 +>f : () => unknown +>c : 1 +>f : string +>{ c: 0, f: () => f, } : { c: 0; f: () => string | (() => unknown); } + + c: 0, +>c : 0 +>0 : 0 + + f: () => f, +>f : () => string | (() => unknown) +>() => f : () => string | (() => unknown) +>f : string | (() => unknown) + + }; + f; +>f : () => unknown +} + +{ + const { + c, +>c : 0 | 1 + + f, +>f : number | bigint + + g = f, +>g : string | number | bigint +>f : number | bigint + + }: + | { c: 0; f: bigint; g?: bigint | number } +>c : 0 +>f : bigint +>g : number | bigint | undefined + + | { c: 1; f: number; g: string } = { +>c : 1 +>f : number +>g : string +>{ c: 0, f: 10n, } : { c: 0; f: bigint; } + + c: 0, +>c : 0 +>0 : 0 + + f: 10n, +>f : bigint +>10n : 10n + + }; + f; +>f : bigint + + g; +>g : string | number | bigint +} + +{ + const { c, f, f }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f: 0 }; +>c : 0 | 1 +>f : string | number +>f : string | number +>c : 0 +>f : number +>c : 1 +>f : string +>{ c: 0, f: 0 } : { c: 0; f: number; } +>c : 0 +>0 : 0 +>f : number +>0 : 0 + + f; +>f : number +} + +{ + const { c, f, f: g }: { c: 0; f: number } | { c: 1; f: string } = { c: 0, f: 0 }; +>c : 0 | 1 +>f : string | number +>f : any +>g : string | number +>c : 0 +>f : number +>c : 1 +>f : string +>{ c: 0, f: 0 } : { c: 0; f: number; } +>c : 0 +>0 : 0 +>f : number +>0 : 0 + + g; +>g : number +} + diff --git a/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=default).js b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=default).js new file mode 100644 index 0000000000000..c76356d188d89 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=default).js @@ -0,0 +1,126 @@ +//// [tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts] //// + +//// [destructuringWithLiteralInitializers.ts] +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +f1({ x: 1, y: 1 }); + +// (arg: { x: any, y?: number }) => void +function f2({ x, y = 0 }) { } +f2({ x: 1 }); +f2({ x: 1, y: 1 }); + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +f3({}); +f3({ x: 1 }); +f3({ y: 1 }); +f3({ x: 1, y: 1 }); + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +f4(); +f4({ x: 1, y: 1 }); + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +f5(); +f5({ x: 1 }); +f5({ x: 1, y: 1 }); + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +f6(); +f6({}); +f6({ x: 1 }); +f6({ y: 1 }); +f6({ x: 1, y: 1 }); + +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +f7(); +f7({ a: {} }); +f7({ a: { x: 1 } }); +f7({ a: { y: 1 } }); +f7({ a: { x: 1, y: 1 } }); + +// (arg: [any, any]) => void +function g1([x, y]) { } +g1([1, 1]); + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +g2([1, 1]); + +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } +g3(); +g3([1, 1]); + +// (arg?: [number, number]) => void +function g4([x, y = 0] = [0]) { } +g4(); +g4([1, 1]); + +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +g5(); +g5([1, 1]); + + +//// [destructuringWithLiteralInitializers.js] +"use strict"; +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +f1({ x: 1, y: 1 }); +// (arg: { x: any, y?: number }) => void +function f2({ x, y = 0 }) { } +f2({ x: 1 }); +f2({ x: 1, y: 1 }); +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +f3({}); +f3({ x: 1 }); +f3({ y: 1 }); +f3({ x: 1, y: 1 }); +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +f4(); +f4({ x: 1, y: 1 }); +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +f5(); +f5({ x: 1 }); +f5({ x: 1, y: 1 }); +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +f6(); +f6({}); +f6({ x: 1 }); +f6({ y: 1 }); +f6({ x: 1, y: 1 }); +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +f7(); +f7({ a: {} }); +f7({ a: { x: 1 } }); +f7({ a: { y: 1 } }); +f7({ a: { x: 1, y: 1 } }); +// (arg: [any, any]) => void +function g1([x, y]) { } +g1([1, 1]); +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +g2([1, 1]); +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } +g3(); +g3([1, 1]); +// (arg?: [number, number]) => void +function g4([x, y = 0] = [0]) { } +g4(); +g4([1, 1]); +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +g5(); +g5([1, 1]); diff --git a/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=default).symbols b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=default).symbols new file mode 100644 index 0000000000000..17561c8c14d7b --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=default).symbols @@ -0,0 +1,196 @@ +//// [tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts] //// + +=== destructuringWithLiteralInitializers.ts === +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +>f1 : Symbol(f1, Decl(destructuringWithLiteralInitializers.ts, 0, 0)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 1, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 1, 16)) + +f1({ x: 1, y: 1 }); +>f1 : Symbol(f1, Decl(destructuringWithLiteralInitializers.ts, 0, 0)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 2, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 2, 10)) + +// (arg: { x: any, y?: number }) => void +function f2({ x, y = 0 }) { } +>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 5, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 5, 16)) + +f2({ x: 1 }); +>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 6, 4)) + +f2({ x: 1, y: 1 }); +>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 7, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 7, 10)) + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 10, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 10, 20)) + +f3({}); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) + +f3({ x: 1 }); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 12, 4)) + +f3({ y: 1 }); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 13, 4)) + +f3({ x: 1, y: 1 }); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 14, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 14, 10)) + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 17, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 17, 16)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 17, 24)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 17, 30)) + +f4(); +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19)) + +f4({ x: 1, y: 1 }); +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 19, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 19, 10)) + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 22, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 22, 16)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 22, 28)) + +f5(); +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) + +f5({ x: 1 }); +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 24, 4)) + +f5({ x: 1, y: 1 }); +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 25, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 25, 10)) + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 28, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 28, 20)) + +f6(); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) + +f6({}); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) + +f6({ x: 1 }); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 31, 4)) + +f6({ y: 1 }); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 32, 4)) + +f6({ x: 1, y: 1 }); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 33, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 33, 10)) + +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 36, 39)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 36, 18)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 36, 25)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 36, 39)) + +f7(); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) + +f7({ a: {} }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 38, 4)) + +f7({ a: { x: 1 } }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 39, 4)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 39, 9)) + +f7({ a: { y: 1 } }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 40, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 40, 9)) + +f7({ a: { x: 1, y: 1 } }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 41, 4)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 41, 9)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 41, 15)) + +// (arg: [any, any]) => void +function g1([x, y]) { } +>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 41, 26)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 44, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 44, 15)) + +g1([1, 1]); +>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 41, 26)) + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 48, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 48, 19)) + +g2([1, 1]); +>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) + +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 52, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 52, 15)) + +g3(); +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) + +g3([1, 1]); +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) + +// (arg?: [number, number]) => void +function g4([x, y = 0] = [0]) { } +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 57, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 57, 15)) + +g4(); +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) + +g4([1, 1]); +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) + +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 62, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 62, 19)) + +g5(); +>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11)) + +g5([1, 1]); +>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11)) + diff --git a/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=default).types b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=default).types new file mode 100644 index 0000000000000..d46ab82876d40 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=default).types @@ -0,0 +1,312 @@ +//// [tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts] //// + +=== destructuringWithLiteralInitializers.ts === +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +>f1 : ({ x, y }: { x: any; y: any; }) => void +>x : any +>y : any + +f1({ x: 1, y: 1 }); +>f1({ x: 1, y: 1 }) : void +>f1 : ({ x, y }: { x: any; y: any; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg: { x: any, y?: number }) => void +function f2({ x, y = 0 }) { } +>f2 : ({ x, y }: { x: any; y?: number; }) => void +>x : any +>y : number +>0 : 0 + +f2({ x: 1 }); +>f2({ x: 1 }) : void +>f2 : ({ x, y }: { x: any; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : 1 + +f2({ x: 1, y: 1 }); +>f2({ x: 1, y: 1 }) : void +>f2 : ({ x, y }: { x: any; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +>f3 : ({ x, y }: { x?: number; y?: number; }) => void +>x : number +>0 : 0 +>y : number +>0 : 0 + +f3({}); +>f3({}) : void +>f3 : ({ x, y }: { x?: number; y?: number; }) => void +>{} : {} + +f3({ x: 1 }); +>f3({ x: 1 }) : void +>f3 : ({ x, y }: { x?: number; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : 1 + +f3({ y: 1 }); +>f3({ y: 1 }) : void +>f3 : ({ x, y }: { x?: number; y?: number; }) => void +>{ y: 1 } : { y: number; } +>y : number +>1 : 1 + +f3({ x: 1, y: 1 }); +>f3({ x: 1, y: 1 }) : void +>f3 : ({ x, y }: { x?: number; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +>f4 : ({ x, y }?: { x: number; y: number; }) => void +>x : number +>y : number +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + +f4(); +>f4() : void +>f4 : ({ x, y }?: { x: number; y: number; }) => void + +f4({ x: 1, y: 1 }); +>f4({ x: 1, y: 1 }) : void +>f4 : ({ x, y }?: { x: number; y: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +>f5 : ({ x, y }?: { x: number; y?: number; }) => void +>x : number +>y : number +>0 : 0 +>{ x: 0 } : { x: number; } +>x : number +>0 : 0 + +f5(); +>f5() : void +>f5 : ({ x, y }?: { x: number; y?: number; }) => void + +f5({ x: 1 }); +>f5({ x: 1 }) : void +>f5 : ({ x, y }?: { x: number; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : 1 + +f5({ x: 1, y: 1 }); +>f5({ x: 1, y: 1 }) : void +>f5 : ({ x, y }?: { x: number; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +>f6 : ({ x, y }?: { x?: number; y?: number; }) => void +>x : number +>0 : 0 +>y : number +>0 : 0 +>{} : {} + +f6(); +>f6() : void +>f6 : ({ x, y }?: { x?: number; y?: number; }) => void + +f6({}); +>f6({}) : void +>f6 : ({ x, y }?: { x?: number; y?: number; }) => void +>{} : {} + +f6({ x: 1 }); +>f6({ x: 1 }) : void +>f6 : ({ x, y }?: { x?: number; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : 1 + +f6({ y: 1 }); +>f6({ y: 1 }) : void +>f6 : ({ x, y }?: { x?: number; y?: number; }) => void +>{ y: 1 } : { y: number; } +>y : number +>1 : 1 + +f6({ x: 1, y: 1 }); +>f6({ x: 1, y: 1 }) : void +>f6 : ({ x, y }?: { x?: number; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +>a : any +>x : number +>0 : 0 +>y : number +>0 : 0 +>{ a: {} } : { a: {}; } +>a : {} +>{} : {} + +f7(); +>f7() : void +>f7 : ({ a: { x, y } }?: { a: {}; }) => void + +f7({ a: {} }); +>f7({ a: {} }) : void +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +>{ a: {} } : { a: {}; } +>a : {} +>{} : {} + +f7({ a: { x: 1 } }); +>f7({ a: { x: 1 } }) : void +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +>{ a: { x: 1 } } : { a: { x: number; }; } +>a : { x: number; } +>{ x: 1 } : { x: number; } +>x : number +>1 : 1 + +f7({ a: { y: 1 } }); +>f7({ a: { y: 1 } }) : void +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +>{ a: { y: 1 } } : { a: { y: number; }; } +>a : { y: number; } +>{ y: 1 } : { y: number; } +>y : number +>1 : 1 + +f7({ a: { x: 1, y: 1 } }); +>f7({ a: { x: 1, y: 1 } }) : void +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +>{ a: { x: 1, y: 1 } } : { a: { x: number; y: number; }; } +>a : { x: number; y: number; } +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg: [any, any]) => void +function g1([x, y]) { } +>g1 : ([x, y]: [any, any]) => void +>x : any +>y : any + +g1([1, 1]); +>g1([1, 1]) : void +>g1 : ([x, y]: [any, any]) => void +>[1, 1] : [number, number] +>1 : 1 +>1 : 1 + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +>g2 : ([x, y]: [number?, number?]) => void +>x : number +>0 : 0 +>y : number +>0 : 0 + +g2([1, 1]); +>g2([1, 1]) : void +>g2 : ([x, y]: [number?, number?]) => void +>[1, 1] : [number, number] +>1 : 1 +>1 : 1 + +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } +>g3 : ([x, y]?: [number, number]) => void +>x : number +>y : number +>[0, 0] : [number, number] +>0 : 0 +>0 : 0 + +g3(); +>g3() : void +>g3 : ([x, y]?: [number, number]) => void + +g3([1, 1]); +>g3([1, 1]) : void +>g3 : ([x, y]?: [number, number]) => void +>[1, 1] : [number, number] +>1 : 1 +>1 : 1 + +// (arg?: [number, number]) => void +function g4([x, y = 0] = [0]) { } +>g4 : ([x, y]?: [number, number?]) => void +>x : number +>y : number +>0 : 0 +>[0] : [number] +>0 : 0 + +g4(); +>g4() : void +>g4 : ([x, y]?: [number, number?]) => void + +g4([1, 1]); +>g4([1, 1]) : void +>g4 : ([x, y]?: [number, number?]) => void +>[1, 1] : [number, number] +>1 : 1 +>1 : 1 + +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +>g5 : ([x, y]?: [number?, number?]) => void +>x : number +>0 : 0 +>y : number +>0 : 0 +>[] : [] + +g5(); +>g5() : void +>g5 : ([x, y]?: [number?, number?]) => void + +g5([1, 1]); +>g5([1, 1]) : void +>g5 : ([x, y]?: [number?, number?]) => void +>[1, 1] : [number, number] +>1 : 1 +>1 : 1 + diff --git a/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..ee3b06edc611c --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=typesfirst).errors.txt @@ -0,0 +1,75 @@ +destructuringWithLiteralInitializers.ts(37,20): error TS2339: Property 'x' does not exist on type '{}'. +destructuringWithLiteralInitializers.ts(37,27): error TS2339: Property 'y' does not exist on type '{}'. + + +==== destructuringWithLiteralInitializers.ts (2 errors) ==== + // (arg: { x: any, y: any }) => void + function f1({ x, y }) { } + f1({ x: 1, y: 1 }); + + // (arg: { x: any, y?: number }) => void + function f2({ x, y = 0 }) { } + f2({ x: 1 }); + f2({ x: 1, y: 1 }); + + // (arg: { x?: number, y?: number }) => void + function f3({ x = 0, y = 0 }) { } + f3({}); + f3({ x: 1 }); + f3({ y: 1 }); + f3({ x: 1, y: 1 }); + + // (arg?: { x: number, y: number }) => void + function f4({ x, y } = { x: 0, y: 0 }) { } + f4(); + f4({ x: 1, y: 1 }); + + // (arg?: { x: number, y?: number }) => void + function f5({ x, y = 0 } = { x: 0 }) { } + f5(); + f5({ x: 1 }); + f5({ x: 1, y: 1 }); + + // (arg?: { x?: number, y?: number }) => void + function f6({ x = 0, y = 0 } = {}) { } + f6(); + f6({}); + f6({ x: 1 }); + f6({ y: 1 }); + f6({ x: 1, y: 1 }); + + // (arg?: { a: { x?: number, y?: number } }) => void + function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } + ~ +!!! error TS2339: Property 'x' does not exist on type '{}'. + ~ +!!! error TS2339: Property 'y' does not exist on type '{}'. + f7(); + f7({ a: {} }); + f7({ a: { x: 1 } }); + f7({ a: { y: 1 } }); + f7({ a: { x: 1, y: 1 } }); + + // (arg: [any, any]) => void + function g1([x, y]) { } + g1([1, 1]); + + // (arg: [number, number]) => void + function g2([x = 0, y = 0]) { } + g2([1, 1]); + + // (arg?: [number, number]) => void + function g3([x, y] = [0, 0]) { } + g3(); + g3([1, 1]); + + // (arg?: [number, number]) => void + function g4([x, y = 0] = [0]) { } + g4(); + g4([1, 1]); + + // (arg?: [number, number]) => void + function g5([x = 0, y = 0] = []) { } + g5(); + g5([1, 1]); + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=typesfirst).js new file mode 100644 index 0000000000000..c76356d188d89 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=typesfirst).js @@ -0,0 +1,126 @@ +//// [tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts] //// + +//// [destructuringWithLiteralInitializers.ts] +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +f1({ x: 1, y: 1 }); + +// (arg: { x: any, y?: number }) => void +function f2({ x, y = 0 }) { } +f2({ x: 1 }); +f2({ x: 1, y: 1 }); + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +f3({}); +f3({ x: 1 }); +f3({ y: 1 }); +f3({ x: 1, y: 1 }); + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +f4(); +f4({ x: 1, y: 1 }); + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +f5(); +f5({ x: 1 }); +f5({ x: 1, y: 1 }); + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +f6(); +f6({}); +f6({ x: 1 }); +f6({ y: 1 }); +f6({ x: 1, y: 1 }); + +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +f7(); +f7({ a: {} }); +f7({ a: { x: 1 } }); +f7({ a: { y: 1 } }); +f7({ a: { x: 1, y: 1 } }); + +// (arg: [any, any]) => void +function g1([x, y]) { } +g1([1, 1]); + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +g2([1, 1]); + +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } +g3(); +g3([1, 1]); + +// (arg?: [number, number]) => void +function g4([x, y = 0] = [0]) { } +g4(); +g4([1, 1]); + +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +g5(); +g5([1, 1]); + + +//// [destructuringWithLiteralInitializers.js] +"use strict"; +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +f1({ x: 1, y: 1 }); +// (arg: { x: any, y?: number }) => void +function f2({ x, y = 0 }) { } +f2({ x: 1 }); +f2({ x: 1, y: 1 }); +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +f3({}); +f3({ x: 1 }); +f3({ y: 1 }); +f3({ x: 1, y: 1 }); +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +f4(); +f4({ x: 1, y: 1 }); +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +f5(); +f5({ x: 1 }); +f5({ x: 1, y: 1 }); +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +f6(); +f6({}); +f6({ x: 1 }); +f6({ y: 1 }); +f6({ x: 1, y: 1 }); +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +f7(); +f7({ a: {} }); +f7({ a: { x: 1 } }); +f7({ a: { y: 1 } }); +f7({ a: { x: 1, y: 1 } }); +// (arg: [any, any]) => void +function g1([x, y]) { } +g1([1, 1]); +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +g2([1, 1]); +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } +g3(); +g3([1, 1]); +// (arg?: [number, number]) => void +function g4([x, y = 0] = [0]) { } +g4(); +g4([1, 1]); +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +g5(); +g5([1, 1]); diff --git a/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..17561c8c14d7b --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=typesfirst).symbols @@ -0,0 +1,196 @@ +//// [tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts] //// + +=== destructuringWithLiteralInitializers.ts === +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +>f1 : Symbol(f1, Decl(destructuringWithLiteralInitializers.ts, 0, 0)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 1, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 1, 16)) + +f1({ x: 1, y: 1 }); +>f1 : Symbol(f1, Decl(destructuringWithLiteralInitializers.ts, 0, 0)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 2, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 2, 10)) + +// (arg: { x: any, y?: number }) => void +function f2({ x, y = 0 }) { } +>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 5, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 5, 16)) + +f2({ x: 1 }); +>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 6, 4)) + +f2({ x: 1, y: 1 }); +>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 7, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 7, 10)) + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 10, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 10, 20)) + +f3({}); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) + +f3({ x: 1 }); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 12, 4)) + +f3({ y: 1 }); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 13, 4)) + +f3({ x: 1, y: 1 }); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 14, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 14, 10)) + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 17, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 17, 16)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 17, 24)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 17, 30)) + +f4(); +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19)) + +f4({ x: 1, y: 1 }); +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 19, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 19, 10)) + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 22, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 22, 16)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 22, 28)) + +f5(); +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) + +f5({ x: 1 }); +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 24, 4)) + +f5({ x: 1, y: 1 }); +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 25, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 25, 10)) + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 28, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 28, 20)) + +f6(); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) + +f6({}); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) + +f6({ x: 1 }); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 31, 4)) + +f6({ y: 1 }); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 32, 4)) + +f6({ x: 1, y: 1 }); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 33, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 33, 10)) + +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 36, 39)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 36, 18)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 36, 25)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 36, 39)) + +f7(); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) + +f7({ a: {} }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 38, 4)) + +f7({ a: { x: 1 } }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 39, 4)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 39, 9)) + +f7({ a: { y: 1 } }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 40, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 40, 9)) + +f7({ a: { x: 1, y: 1 } }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 41, 4)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 41, 9)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 41, 15)) + +// (arg: [any, any]) => void +function g1([x, y]) { } +>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 41, 26)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 44, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 44, 15)) + +g1([1, 1]); +>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 41, 26)) + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 48, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 48, 19)) + +g2([1, 1]); +>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) + +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 52, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 52, 15)) + +g3(); +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) + +g3([1, 1]); +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) + +// (arg?: [number, number]) => void +function g4([x, y = 0] = [0]) { } +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 57, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 57, 15)) + +g4(); +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) + +g4([1, 1]); +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) + +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 62, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 62, 19)) + +g5(); +>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11)) + +g5([1, 1]); +>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11)) + diff --git a/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=typesfirst).types new file mode 100644 index 0000000000000..45f5edceff50e --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/destructuringWithLiteralInitializers(checkorder=typesfirst).types @@ -0,0 +1,312 @@ +//// [tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts] //// + +=== destructuringWithLiteralInitializers.ts === +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +>f1 : ({ x, y }: { x: any; y: any; }) => void +>x : any +>y : any + +f1({ x: 1, y: 1 }); +>f1({ x: 1, y: 1 }) : void +>f1 : ({ x, y }: { x: any; y: any; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg: { x: any, y?: number }) => void +function f2({ x, y = 0 }) { } +>f2 : ({ x, y }: { x: any; y?: number; }) => void +>x : any +>y : number +>0 : 0 + +f2({ x: 1 }); +>f2({ x: 1 }) : void +>f2 : ({ x, y }: { x: any; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : 1 + +f2({ x: 1, y: 1 }); +>f2({ x: 1, y: 1 }) : void +>f2 : ({ x, y }: { x: any; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +>f3 : ({ x, y }: { x?: number; y?: number; }) => void +>x : number +>0 : 0 +>y : number +>0 : 0 + +f3({}); +>f3({}) : void +>f3 : ({ x, y }: { x?: number; y?: number; }) => void +>{} : {} + +f3({ x: 1 }); +>f3({ x: 1 }) : void +>f3 : ({ x, y }: { x?: number; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : 1 + +f3({ y: 1 }); +>f3({ y: 1 }) : void +>f3 : ({ x, y }: { x?: number; y?: number; }) => void +>{ y: 1 } : { y: number; } +>y : number +>1 : 1 + +f3({ x: 1, y: 1 }); +>f3({ x: 1, y: 1 }) : void +>f3 : ({ x, y }: { x?: number; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +>f4 : ({ x, y }?: { x: number; y: number; }) => void +>x : number +>y : number +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + +f4(); +>f4() : void +>f4 : ({ x, y }?: { x: number; y: number; }) => void + +f4({ x: 1, y: 1 }); +>f4({ x: 1, y: 1 }) : void +>f4 : ({ x, y }?: { x: number; y: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +>f5 : ({ x, y }?: { x: number; y?: number; }) => void +>x : number +>y : number +>0 : 0 +>{ x: 0 } : { x: number; } +>x : number +>0 : 0 + +f5(); +>f5() : void +>f5 : ({ x, y }?: { x: number; y?: number; }) => void + +f5({ x: 1 }); +>f5({ x: 1 }) : void +>f5 : ({ x, y }?: { x: number; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : 1 + +f5({ x: 1, y: 1 }); +>f5({ x: 1, y: 1 }) : void +>f5 : ({ x, y }?: { x: number; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +>f6 : ({ x, y }?: { x?: number; y?: number; }) => void +>x : number +>0 : 0 +>y : number +>0 : 0 +>{} : {} + +f6(); +>f6() : void +>f6 : ({ x, y }?: { x?: number; y?: number; }) => void + +f6({}); +>f6({}) : void +>f6 : ({ x, y }?: { x?: number; y?: number; }) => void +>{} : {} + +f6({ x: 1 }); +>f6({ x: 1 }) : void +>f6 : ({ x, y }?: { x?: number; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : 1 + +f6({ y: 1 }); +>f6({ y: 1 }) : void +>f6 : ({ x, y }?: { x?: number; y?: number; }) => void +>{ y: 1 } : { y: number; } +>y : number +>1 : 1 + +f6({ x: 1, y: 1 }); +>f6({ x: 1, y: 1 }) : void +>f6 : ({ x, y }?: { x?: number; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +>a : any +>x : any +>0 : 0 +>y : any +>0 : 0 +>{ a: {} } : { a: {}; } +>a : {} +>{} : {} + +f7(); +>f7() : void +>f7 : ({ a: { x, y } }?: { a: {}; }) => void + +f7({ a: {} }); +>f7({ a: {} }) : void +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +>{ a: {} } : { a: {}; } +>a : {} +>{} : {} + +f7({ a: { x: 1 } }); +>f7({ a: { x: 1 } }) : void +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +>{ a: { x: 1 } } : { a: { x: number; }; } +>a : { x: number; } +>{ x: 1 } : { x: number; } +>x : number +>1 : 1 + +f7({ a: { y: 1 } }); +>f7({ a: { y: 1 } }) : void +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +>{ a: { y: 1 } } : { a: { y: number; }; } +>a : { y: number; } +>{ y: 1 } : { y: number; } +>y : number +>1 : 1 + +f7({ a: { x: 1, y: 1 } }); +>f7({ a: { x: 1, y: 1 } }) : void +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +>{ a: { x: 1, y: 1 } } : { a: { x: number; y: number; }; } +>a : { x: number; y: number; } +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>1 : 1 + +// (arg: [any, any]) => void +function g1([x, y]) { } +>g1 : ([x, y]: [any, any]) => void +>x : any +>y : any + +g1([1, 1]); +>g1([1, 1]) : void +>g1 : ([x, y]: [any, any]) => void +>[1, 1] : [number, number] +>1 : 1 +>1 : 1 + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +>g2 : ([x, y]: [number?, number?]) => void +>x : number +>0 : 0 +>y : number +>0 : 0 + +g2([1, 1]); +>g2([1, 1]) : void +>g2 : ([x, y]: [number?, number?]) => void +>[1, 1] : [number, number] +>1 : 1 +>1 : 1 + +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } +>g3 : ([x, y]?: [number, number]) => void +>x : number +>y : number +>[0, 0] : [number, number] +>0 : 0 +>0 : 0 + +g3(); +>g3() : void +>g3 : ([x, y]?: [number, number]) => void + +g3([1, 1]); +>g3([1, 1]) : void +>g3 : ([x, y]?: [number, number]) => void +>[1, 1] : [number, number] +>1 : 1 +>1 : 1 + +// (arg?: [number, number]) => void +function g4([x, y = 0] = [0]) { } +>g4 : ([x, y]?: [number, number?]) => void +>x : number +>y : number +>0 : 0 +>[0] : [number] +>0 : 0 + +g4(); +>g4() : void +>g4 : ([x, y]?: [number, number?]) => void + +g4([1, 1]); +>g4([1, 1]) : void +>g4 : ([x, y]?: [number, number?]) => void +>[1, 1] : [number, number] +>1 : 1 +>1 : 1 + +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +>g5 : ([x, y]?: [number?, number?]) => void +>x : number +>0 : 0 +>y : number +>0 : 0 +>[] : [] + +g5(); +>g5() : void +>g5 : ([x, y]?: [number?, number?]) => void + +g5([1, 1]); +>g5([1, 1]) : void +>g5 : ([x, y]?: [number?, number?]) => void +>[1, 1] : [number, number] +>1 : 1 +>1 : 1 + diff --git a/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=default).errors.txt new file mode 100644 index 0000000000000..3427c0e358148 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=default).errors.txt @@ -0,0 +1,16 @@ +/foo.js(1,15): error TS1005: 'from' expected. +/foo.js(1,15): error TS1141: String literal expected. + + +==== /foo.js (2 errors) ==== + /** @import x = require("types") */ + ~ +!!! error TS1005: 'from' expected. + ~~~~~~~~~~~~~~~~~~ +!!! error TS1141: String literal expected. + +==== /types.ts (0 errors) ==== + export interface Foo { + a: number; + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=default).symbols b/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=default).symbols new file mode 100644 index 0000000000000..fbc59963b3da9 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=default).symbols @@ -0,0 +1,6 @@ +//// [tests/cases/conformance/jsdoc/importTag13.ts] //// + +=== /foo.js === + +/** @import x = require("types") */ + diff --git a/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=default).types b/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=default).types new file mode 100644 index 0000000000000..fbc59963b3da9 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=default).types @@ -0,0 +1,6 @@ +//// [tests/cases/conformance/jsdoc/importTag13.ts] //// + +=== /foo.js === + +/** @import x = require("types") */ + diff --git a/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..de660063858df --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=typesfirst).errors.txt @@ -0,0 +1,19 @@ +/foo.js(1,15): error TS1005: 'from' expected. +/foo.js(1,15): error TS1141: String literal expected. +/foo.js(1,25): error TS2307: Cannot find module 'types' or its corresponding type declarations. + + +==== /foo.js (3 errors) ==== + /** @import x = require("types") */ + ~ +!!! error TS1005: 'from' expected. + ~~~~~~~~~~~~~~~~~~ +!!! error TS1141: String literal expected. + ~~~~~~~ +!!! error TS2307: Cannot find module 'types' or its corresponding type declarations. + +==== /types.ts (0 errors) ==== + export interface Foo { + a: number; + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..fbc59963b3da9 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=typesfirst).symbols @@ -0,0 +1,6 @@ +//// [tests/cases/conformance/jsdoc/importTag13.ts] //// + +=== /foo.js === + +/** @import x = require("types") */ + diff --git a/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=typesfirst).types new file mode 100644 index 0000000000000..fbc59963b3da9 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/importTag13(checkorder=typesfirst).types @@ -0,0 +1,6 @@ +//// [tests/cases/conformance/jsdoc/importTag13.ts] //// + +=== /foo.js === + +/** @import x = require("types") */ + diff --git a/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=default).errors.txt new file mode 100644 index 0000000000000..634c2349e1ecb --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=default).errors.txt @@ -0,0 +1,23 @@ +privateNameNestedClassFieldShadowing.ts(7,31): error TS18014: The property '#x' cannot be accessed on type 'Base' within this class because it is shadowed by another private identifier with the same spelling. + + +==== privateNameNestedClassFieldShadowing.ts (1 errors) ==== + class Base { + #x; + constructor() { + class Derived { + #x; + testBase(x: Base) { + console.log(x.#x); + ~~ +!!! error TS18014: The property '#x' cannot be accessed on type 'Base' within this class because it is shadowed by another private identifier with the same spelling. +!!! related TS18017 privateNameNestedClassFieldShadowing.ts:5:13: The shadowing declaration of '#x' is defined here +!!! related TS18018 privateNameNestedClassFieldShadowing.ts:2:5: The declaration of '#x' that you probably intended to use is defined here + } + testDerived(x: Derived) { + console.log(x.#x); + } + } + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=default).js b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=default).js new file mode 100644 index 0000000000000..4e0c843d1ebc9 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=default).js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/classes/members/privateNames/privateNameNestedClassFieldShadowing.ts] //// + +//// [privateNameNestedClassFieldShadowing.ts] +class Base { + #x; + constructor() { + class Derived { + #x; + testBase(x: Base) { + console.log(x.#x); + } + testDerived(x: Derived) { + console.log(x.#x); + } + } + } +} + + +//// [privateNameNestedClassFieldShadowing.js] +"use strict"; +var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +}; +var _Base_x; +class Base { + constructor() { + var _Derived_x; + _Base_x.set(this, void 0); + class Derived { + constructor() { + _Derived_x.set(this, void 0); + } + testBase(x) { + console.log(__classPrivateFieldGet(x, _Derived_x, "f")); + } + testDerived(x) { + console.log(__classPrivateFieldGet(x, _Derived_x, "f")); + } + } + _Derived_x = new WeakMap(); + } +} +_Base_x = new WeakMap(); diff --git a/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=default).symbols b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=default).symbols new file mode 100644 index 0000000000000..33cee0bc25f14 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=default).symbols @@ -0,0 +1,43 @@ +//// [tests/cases/conformance/classes/members/privateNames/privateNameNestedClassFieldShadowing.ts] //// + +=== privateNameNestedClassFieldShadowing.ts === +class Base { +>Base : Symbol(Base, Decl(privateNameNestedClassFieldShadowing.ts, 0, 0)) + + #x; +>#x : Symbol(Base.#x, Decl(privateNameNestedClassFieldShadowing.ts, 0, 12)) + + constructor() { + class Derived { +>Derived : Symbol(Derived, Decl(privateNameNestedClassFieldShadowing.ts, 2, 19)) + + #x; +>#x : Symbol(Derived.#x, Decl(privateNameNestedClassFieldShadowing.ts, 3, 23)) + + testBase(x: Base) { +>testBase : Symbol(Derived.testBase, Decl(privateNameNestedClassFieldShadowing.ts, 4, 15)) +>x : Symbol(x, Decl(privateNameNestedClassFieldShadowing.ts, 5, 21)) +>Base : Symbol(Base, Decl(privateNameNestedClassFieldShadowing.ts, 0, 0)) + + console.log(x.#x); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>x : Symbol(x, Decl(privateNameNestedClassFieldShadowing.ts, 5, 21)) + } + testDerived(x: Derived) { +>testDerived : Symbol(Derived.testDerived, Decl(privateNameNestedClassFieldShadowing.ts, 7, 13)) +>x : Symbol(x, Decl(privateNameNestedClassFieldShadowing.ts, 8, 24)) +>Derived : Symbol(Derived, Decl(privateNameNestedClassFieldShadowing.ts, 2, 19)) + + console.log(x.#x); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>x.#x : Symbol(Derived.#x, Decl(privateNameNestedClassFieldShadowing.ts, 3, 23)) +>x : Symbol(x, Decl(privateNameNestedClassFieldShadowing.ts, 8, 24)) + } + } + } +} + diff --git a/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=default).types b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=default).types new file mode 100644 index 0000000000000..473319eee8b31 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=default).types @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/classes/members/privateNames/privateNameNestedClassFieldShadowing.ts] //// + +=== privateNameNestedClassFieldShadowing.ts === +class Base { +>Base : Base + + #x; +>#x : any + + constructor() { + class Derived { +>Derived : Derived + + #x; +>#x : any + + testBase(x: Base) { +>testBase : (x: Base) => void +>x : Base + + console.log(x.#x); +>console.log(x.#x) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>x.#x : any +>x : Base + } + testDerived(x: Derived) { +>testDerived : (x: Derived) => void +>x : Derived + + console.log(x.#x); +>console.log(x.#x) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>x.#x : any +>x : Derived + } + } + } +} + diff --git a/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..d4d3aede55faf --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=typesfirst).errors.txt @@ -0,0 +1,23 @@ +privateNameNestedClassFieldShadowing.ts(7,31): error TS18014: The property '#x' cannot be accessed on type 'Base' within this class because it is shadowed by another private identifier with the same spelling. + + +==== privateNameNestedClassFieldShadowing.ts (1 errors) ==== + class Base { + #x; + constructor() { + class Derived { + #x; + testBase(x: Base) { + console.log(x.#x); + ~~ +!!! error TS18014: The property '#x' cannot be accessed on type 'Base' within this class because it is shadowed by another private identifier with the same spelling. +!!! related TS18018 privateNameNestedClassFieldShadowing.ts:2:5: The declaration of '#x' that you probably intended to use is defined here +!!! related TS18017 privateNameNestedClassFieldShadowing.ts:5:13: The shadowing declaration of '#x' is defined here + } + testDerived(x: Derived) { + console.log(x.#x); + } + } + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=typesfirst).js new file mode 100644 index 0000000000000..4e0c843d1ebc9 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=typesfirst).js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/classes/members/privateNames/privateNameNestedClassFieldShadowing.ts] //// + +//// [privateNameNestedClassFieldShadowing.ts] +class Base { + #x; + constructor() { + class Derived { + #x; + testBase(x: Base) { + console.log(x.#x); + } + testDerived(x: Derived) { + console.log(x.#x); + } + } + } +} + + +//// [privateNameNestedClassFieldShadowing.js] +"use strict"; +var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +}; +var _Base_x; +class Base { + constructor() { + var _Derived_x; + _Base_x.set(this, void 0); + class Derived { + constructor() { + _Derived_x.set(this, void 0); + } + testBase(x) { + console.log(__classPrivateFieldGet(x, _Derived_x, "f")); + } + testDerived(x) { + console.log(__classPrivateFieldGet(x, _Derived_x, "f")); + } + } + _Derived_x = new WeakMap(); + } +} +_Base_x = new WeakMap(); diff --git a/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..33cee0bc25f14 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=typesfirst).symbols @@ -0,0 +1,43 @@ +//// [tests/cases/conformance/classes/members/privateNames/privateNameNestedClassFieldShadowing.ts] //// + +=== privateNameNestedClassFieldShadowing.ts === +class Base { +>Base : Symbol(Base, Decl(privateNameNestedClassFieldShadowing.ts, 0, 0)) + + #x; +>#x : Symbol(Base.#x, Decl(privateNameNestedClassFieldShadowing.ts, 0, 12)) + + constructor() { + class Derived { +>Derived : Symbol(Derived, Decl(privateNameNestedClassFieldShadowing.ts, 2, 19)) + + #x; +>#x : Symbol(Derived.#x, Decl(privateNameNestedClassFieldShadowing.ts, 3, 23)) + + testBase(x: Base) { +>testBase : Symbol(Derived.testBase, Decl(privateNameNestedClassFieldShadowing.ts, 4, 15)) +>x : Symbol(x, Decl(privateNameNestedClassFieldShadowing.ts, 5, 21)) +>Base : Symbol(Base, Decl(privateNameNestedClassFieldShadowing.ts, 0, 0)) + + console.log(x.#x); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>x : Symbol(x, Decl(privateNameNestedClassFieldShadowing.ts, 5, 21)) + } + testDerived(x: Derived) { +>testDerived : Symbol(Derived.testDerived, Decl(privateNameNestedClassFieldShadowing.ts, 7, 13)) +>x : Symbol(x, Decl(privateNameNestedClassFieldShadowing.ts, 8, 24)) +>Derived : Symbol(Derived, Decl(privateNameNestedClassFieldShadowing.ts, 2, 19)) + + console.log(x.#x); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>x.#x : Symbol(Derived.#x, Decl(privateNameNestedClassFieldShadowing.ts, 3, 23)) +>x : Symbol(x, Decl(privateNameNestedClassFieldShadowing.ts, 8, 24)) + } + } + } +} + diff --git a/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=typesfirst).types new file mode 100644 index 0000000000000..473319eee8b31 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/privateNameNestedClassFieldShadowing(checkorder=typesfirst).types @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/classes/members/privateNames/privateNameNestedClassFieldShadowing.ts] //// + +=== privateNameNestedClassFieldShadowing.ts === +class Base { +>Base : Base + + #x; +>#x : any + + constructor() { + class Derived { +>Derived : Derived + + #x; +>#x : any + + testBase(x: Base) { +>testBase : (x: Base) => void +>x : Base + + console.log(x.#x); +>console.log(x.#x) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>x.#x : any +>x : Base + } + testDerived(x: Derived) { +>testDerived : (x: Derived) => void +>x : Derived + + console.log(x.#x); +>console.log(x.#x) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>x.#x : any +>x : Derived + } + } + } +} + diff --git a/tsc/testdata/tests/cases/compiler/bigintArbirtraryIdentifier.ts b/tsc/testdata/tests/cases/compiler/bigintArbirtraryIdentifier.ts index 9b281534212e8..63dfdce226f74 100644 --- a/tsc/testdata/tests/cases/compiler/bigintArbirtraryIdentifier.ts +++ b/tsc/testdata/tests/cases/compiler/bigintArbirtraryIdentifier.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: esnext // @module: esnext diff --git a/tsc/testdata/tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts b/tsc/testdata/tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts index 9455c0156930f..bb7452f273d4f 100644 --- a/tsc/testdata/tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts +++ b/tsc/testdata/tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 // @Filename: weird.js // @allowJs: true diff --git a/tsc/testdata/tests/cases/compiler/checkOrderAwaitedCycle.ts b/tsc/testdata/tests/cases/compiler/checkOrderAwaitedCycle.ts new file mode 100644 index 0000000000000..f39f63e9c1f54 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/checkOrderAwaitedCycle.ts @@ -0,0 +1,21 @@ +// @strict: true +// @target: esnext +// @lib: esnext +// @noEmit: true +// @checkOrder: default, reverse, isolated, typesfirst + +// Awaiting a promise whose promised type refers back to it reports a +// circularity wherever it is awaited, whichever is awaited first. + +// @filename: a.ts +type S = string | Promise; +declare const s: S; +declare const p: Promise; +async function f1() { + const a: number = await p; +} + +// @filename: b.ts +async function f2() { + const b: number = await s; +} diff --git a/tsc/testdata/tests/cases/compiler/checkOrderCircularConstraint.ts b/tsc/testdata/tests/cases/compiler/checkOrderCircularConstraint.ts new file mode 100644 index 0000000000000..efca8e2390569 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/checkOrderCircularConstraint.ts @@ -0,0 +1,14 @@ +// @checkOrder: default, reverse, isolated, typesfirst + +// A circular constraint of a declared type parameter is reported at its +// declaration, regardless of which use resolves the constraint first. + +class A { + foo() { + var x!: T; + var a = x.foo(); + var b = new x(123); + var c = x[1]; + var d = x(); + } +} diff --git a/tsc/testdata/tests/cases/compiler/checkOrderCircularDefaults.ts b/tsc/testdata/tests/cases/compiler/checkOrderCircularDefaults.ts new file mode 100644 index 0000000000000..0232579d1f4f7 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/checkOrderCircularDefaults.ts @@ -0,0 +1,16 @@ +// @strict: true +// @declaration: true +// @checkOrder: default, reverse, isolated, typesfirst + +// Which type parameter of a cycle of defaults is circular must not depend +// on which default is resolved first. + +// @filename: a.ts +import type { B } from "./b"; +export interface A { a: T } +export declare const a: A; + +// @filename: b.ts +import type { A } from "./a"; +export interface B { b: U } +export declare const b: B; diff --git a/tsc/testdata/tests/cases/compiler/checkOrderEmitBeforeCheck.ts b/tsc/testdata/tests/cases/compiler/checkOrderEmitBeforeCheck.ts new file mode 100644 index 0000000000000..fd86103b859d3 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/checkOrderEmitBeforeCheck.ts @@ -0,0 +1,19 @@ +// @target: es2015 +// @declaration: true +// @checkOrder: default, isolated + +// The circularity in the mapped type is found by checking the annotation of +// "each". Emitting first must not instead report it at the use import +// elision visits, nor cache the result without the error. +type NonOptionalKeys = { [P in keyof T]: undefined extends T[P] ? never : P }[keyof T]; +type Child = { [P in NonOptionalKeys]: T[P] } + +export interface ListWidget { + "type": "list", + "each": Child; +} + +type ListChild = Child + +declare let x: ListChild; +x.type; diff --git a/tsc/testdata/tests/cases/compiler/checkOrderEnumComputedMember.ts b/tsc/testdata/tests/cases/compiler/checkOrderEnumComputedMember.ts new file mode 100644 index 0000000000000..caaa6629db492 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/checkOrderEnumComputedMember.ts @@ -0,0 +1,12 @@ +// @checkOrder: default, reverse, isolated, typesfirst +// @target: esnext +// @strict: true +// @declaration: true + +enum E { + A = 0, + B = E.A.valueOf(), + C = 1, +} + +const member: Extract = E.C; diff --git a/tsc/testdata/tests/cases/compiler/checkOrderLateBoundMembers.ts b/tsc/testdata/tests/cases/compiler/checkOrderLateBoundMembers.ts new file mode 100644 index 0000000000000..a0e4fa51e4348 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/checkOrderLateBoundMembers.ts @@ -0,0 +1,13 @@ +// @strict: true +// @noEmit: true +// @checkOrder: default, reverse, isolated, typesfirst + +// Resolving the name in a computed property name looks it up in the members +// of the enclosing interface. That must not late-bind those same members, +// or the accessors would not merge with the property when asked first. +const foo = "foo" +interface I { + get [foo](): number; + foo: number; + set [foo](value: number); +} diff --git a/tsc/testdata/tests/cases/compiler/checkOrderModuleExportsAlias.ts b/tsc/testdata/tests/cases/compiler/checkOrderModuleExportsAlias.ts new file mode 100644 index 0000000000000..08d9142ed1bff --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/checkOrderModuleExportsAlias.ts @@ -0,0 +1,8 @@ +// @checkOrder: default, reverse, isolated, typesfirst +// @allowJs: true +// @checkJs: true +// @declaration: true +// @outDir: ./out +// @filename: index.js +module.exports.i = function i() {} +module.exports.ii = module.exports.i; diff --git a/tsc/testdata/tests/cases/compiler/checkOrderParameterInTypeQuery.ts b/tsc/testdata/tests/cases/compiler/checkOrderParameterInTypeQuery.ts new file mode 100644 index 0000000000000..627a5ec7db84d --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/checkOrderParameterInTypeQuery.ts @@ -0,0 +1,19 @@ +// @strict: true +// @target: esnext +// @checkOrder: default, reverse, isolated, typesfirst + +// Whether a parameter named in a reused return type annotation is the same +// symbol in the printed signature must not depend on whether the type of +// the parameter was resolved before the signature was instantiated. + +export class C2 { + #a = 1; + test1() { + class C { + test1(a: C2): typeof a.#a { + return 1; + } + } + return new C().test1(this); + } +} diff --git a/tsc/testdata/tests/cases/compiler/checkOrderRecursiveIndexedAccess.ts b/tsc/testdata/tests/cases/compiler/checkOrderRecursiveIndexedAccess.ts new file mode 100644 index 0000000000000..68f93ef70343d --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/checkOrderRecursiveIndexedAccess.ts @@ -0,0 +1,21 @@ +// @noEmit: true +// @strict: true +// @checkOrder: default, reverse, isolated, typesfirst + +// @filename: recur.ts +export type Recur = + (T extends (unknown[]) ? {} : { [K in keyof T]?: Recur}) | + [...Recur[number][]]; + +// @filename: join.ts +import { Recur } from "./recur"; +export function join(l: Recur[]): Recur { + return ['marker', ...l]; +} + +// @filename: a.ts +import { Recur } from "./recur"; +import { join } from "./join"; +function a(l: Recur[]): void { + const x: Recur | undefined = join(l); +} diff --git a/tsc/testdata/tests/cases/compiler/checkOrderSpreadCycle.ts b/tsc/testdata/tests/cases/compiler/checkOrderSpreadCycle.ts new file mode 100644 index 0000000000000..b9c220019d68b --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/checkOrderSpreadCycle.ts @@ -0,0 +1,31 @@ +// @checkOrder: default, reverse, isolated, typesfirst +// @strict: true +// @module: commonjs +// @target: es2020 +// @allowJs: true +// @declaration: true +// @outDir: /out +// @noImplicitReferences: true + +// @Filename: /ma.js +export { v as pa } from "./xa"; +export const ma = 1; + +// @Filename: /mb.js +export { v as pb } from "./xb"; +export const mb = 1; + +// @Filename: /xa.js +/** @type {typeof import("./mb")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + +// @Filename: /xb.js +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; + +// @Filename: /ia.js +/** @type {typeof import("./ma")} */ +const M = /** @type {any} */ (null); +module.exports = { v: { ...M } }; diff --git a/tsc/testdata/tests/cases/compiler/checkOrderStableInstantiationErrors.ts b/tsc/testdata/tests/cases/compiler/checkOrderStableInstantiationErrors.ts new file mode 100644 index 0000000000000..1cdffd661c908 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/checkOrderStableInstantiationErrors.ts @@ -0,0 +1,30 @@ +// @checkOrder: default, reverse, typesfirst +// @filename: lib.ts +export type Dec = + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; +export type Recur = + N extends 0 ? S : Recur, `${S}_${S}`>; + +// @filename: a.ts +import { Recur } from "./lib"; +export let a: Recur<5, "a">; + +// @filename: b.ts +import { Recur } from "./lib"; +export let b: Recur<5, "a">; + +// @filename: c.ts +class T { + declare a: A; + declare b: any; +} +class L extends T {} +export class X extends L { + declare a: 'a' | 'b'; + declare b: number; + m() { + this.a; + } +} diff --git a/tsc/testdata/tests/cases/compiler/circularAccessorAnnotations.ts b/tsc/testdata/tests/cases/compiler/circularAccessorAnnotations.ts index 01a0d10ffe3d7..76a644bb35537 100644 --- a/tsc/testdata/tests/cases/compiler/circularAccessorAnnotations.ts +++ b/tsc/testdata/tests/cases/compiler/circularAccessorAnnotations.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 // @strict: true // @declaration: true diff --git a/tsc/testdata/tests/cases/compiler/circularIndexedPropertyInstantiation.ts b/tsc/testdata/tests/cases/compiler/circularIndexedPropertyInstantiation.ts new file mode 100644 index 0000000000000..3aa2e3f2b6f02 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/circularIndexedPropertyInstantiation.ts @@ -0,0 +1,6 @@ +// @target: es2015 +// Repro from #14837 + +type Foo = { "true": Foo> }[T]; +let f1: Foo<"true", {}>; +let f2: Foo<"false", {}>; \ No newline at end of file diff --git a/tsc/testdata/tests/cases/compiler/circularInitializerInference.ts b/tsc/testdata/tests/cases/compiler/circularInitializerInference.ts new file mode 100644 index 0000000000000..727b206a54e83 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/circularInitializerInference.ts @@ -0,0 +1,31 @@ +// @target: es2015 +// @strict: true, false + +export {}; + +type IsAny = 0 extends (1 & Type) ? true : false; +type Assert = Condition; + +var comma = (comma, 3); +type CommaInference = Assert>; + +var nestedComma = (comma, nestedComma, comma); +type NestedCommaInference = Assert>; + +var assignment = (assignment = 2); +type AssignmentInference = Assert>; + +var nestedAssignment = (nestedAssignment = nestedAssignment = 2); +type NestedAssignmentInference = Assert>; + +var conditional = conditional ? 0 : 1; +type ConditionalInference = Assert>; + +var logicalAnd = logicalAnd && ""; +type LogicalAndInference = Assert>; + +var propertyAccess = { member: propertyAccess.member }; +type PropertyAccessInference = Assert>; + +const nonCircular: number = 3; +type NonCircularInference = Assert extends false ? true : false>; \ No newline at end of file diff --git a/tsc/testdata/tests/cases/compiler/circularInlineMappedGenericTupleTypeNoCrash.ts b/tsc/testdata/tests/cases/compiler/circularInlineMappedGenericTupleTypeNoCrash.ts index 2bc4f70704151..251464912be0f 100644 --- a/tsc/testdata/tests/cases/compiler/circularInlineMappedGenericTupleTypeNoCrash.ts +++ b/tsc/testdata/tests/cases/compiler/circularInlineMappedGenericTupleTypeNoCrash.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 // @strict: true // @noEmit: true diff --git a/tsc/testdata/tests/cases/compiler/circularReturnTypeSubtypeReductionOrder.ts b/tsc/testdata/tests/cases/compiler/circularReturnTypeSubtypeReductionOrder.ts new file mode 100644 index 0000000000000..76e977a6505b1 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/circularReturnTypeSubtypeReductionOrder.ts @@ -0,0 +1,42 @@ +// @strict: true +// @target: esnext +// @noEmit: true + +// @filename: expression.ts +// Subtype reduction of rebuild's return type relates the class to A, +// which needs b's return type, which needs rebuild's: a cycle. Both +// members report it, whichever return type is requested first, as if +// rebuild's, declared first, were requested first. +interface A { + b(): A; + c: A; +} +declare const flag: boolean; +const A: new () => A = class { + rebuild() { + return flag ? this : new A(); + } + b() { + return this.rebuild(); + } + c() { + return this.rebuild; + } +}; +export {}; + +// @filename: declaration.ts +interface B { + b(): B; +} +declare const flag: boolean; +class K { + rebuild() { + return flag ? this : new B(); + } + b() { + return this.rebuild(); + } +} +const B: new () => B = K; +export {}; diff --git a/tsc/testdata/tests/cases/compiler/circularReturnTypeThroughCallArgumentRelation.ts b/tsc/testdata/tests/cases/compiler/circularReturnTypeThroughCallArgumentRelation.ts new file mode 100644 index 0000000000000..14bc012218d93 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/circularReturnTypeThroughCallArgumentRelation.ts @@ -0,0 +1,44 @@ +// @strict: true +// @noEmit: true +// @checkOrder: default,typesfirst + +// Inferring a method's return type resolves a call whose argument check +// relates the method's own class to an interface containing that method, so +// the relation compares the method while its return type is in progress. +// TypeScript reads the in-progress return type as `any` there without failing +// it, and call resolution hides the resolutions below it, so no TS7023 is +// reported in any check order and the method gets the call's return type. +// (Reduced from meta/lexical HeadingNode.$config and effect SchemaAST getParser.) + +// Through a callback returning an instance (lexical). +interface Base { m(): unknown } +declare function config(config: { f?: () => Base }): void; + +declare const h: Heading; +const b: Base = h; + +class Heading { + m() { + return config({ f: () => create() }); + } +} + +declare function create(): Heading; + +const r: void = new Heading().m(); + +// Passing `this` directly (effect). +type Parser = (input: unknown) => unknown; +interface NullNode { readonly _tag: "Null"; getParser(): Parser } +interface UndefinedNode { readonly _tag: "Undefined"; getParser(): Parser } +type AST = NullNode | UndefinedNode; +declare function fromConst(ast: AST, value: unknown): Parser; + +const NullNode: new () => NullNode = class { + readonly _tag = "Null"; + getParser() { + return fromConst(this, null); + } +}; + +const p: Parser = new NullNode().getParser(); diff --git a/tsc/testdata/tests/cases/compiler/circularReturnTypeThroughCallbackArgument.ts b/tsc/testdata/tests/cases/compiler/circularReturnTypeThroughCallbackArgument.ts new file mode 100644 index 0000000000000..209bc9616d71d --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/circularReturnTypeThroughCallbackArgument.ts @@ -0,0 +1,27 @@ +// @strict: true,false +// @noEmit: true + +declare function fan(g: () => number): number; + +export function a(n: number) { + return fan(() => a(n)); +} + +declare function fanAll(g: () => Promise<{ ok: boolean }>): Promise<{ ok: boolean }>; + +export async function b(n: number) { + if (n > 0) { + return fanAll(() => b(n - 1)); + } + return { ok: true }; +} + +type Result = { success: boolean; [key: string]: unknown }; +interface Other { success: boolean; url: string } +declare function fanOut(generateOne: () => Promise): Promise; +declare const other: Other; + +export async function c(n: number) { + if (n) return other; + return fanOut(() => c(n - 1)); +} diff --git a/tsc/testdata/tests/cases/compiler/circularReturnTypeThroughUncontextualCallbackArgument.ts b/tsc/testdata/tests/cases/compiler/circularReturnTypeThroughUncontextualCallbackArgument.ts new file mode 100644 index 0000000000000..cd367b30e1c03 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/circularReturnTypeThroughUncontextualCallbackArgument.ts @@ -0,0 +1,22 @@ +// @strict: true +// @noEmit: true +// @checkOrder: default,typesfirst + +// `getCreds`'s return type depends on resolving `materialize({ next })`, whose +// argument check needs the return type of the (non-contextually typed) arrow +// `next`, which calls `getCreds` again. TypeScript never reports this cycle in +// any order: call resolution hides the resolutions below it, and the relation +// reads an in-progress return type as `any` without failing it. So no TS7023, +// and `getCreds` returns `number`. (Reduced from OmniRoute auth.ts +// getProviderCredentials/selectNextLeaseCandidate.) + +const x = getCreds(); + +declare function materialize(extra: { next?: (id: string) => unknown }): number; + +function getCreds() { + const next = (id: string) => getCreds(); + return materialize({ next }); +} + +const n: number = getCreds(); diff --git a/tsc/testdata/tests/cases/compiler/circularScopeThunkReverseMapped.ts b/tsc/testdata/tests/cases/compiler/circularScopeThunkReverseMapped.ts new file mode 100644 index 0000000000000..273d8a44b93d3 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/circularScopeThunkReverseMapped.ts @@ -0,0 +1,26 @@ +// @strict: true +// @target: esnext +// @noEmit: true +// @checkOrder: default, typesfirst + +type Resolve = T extends () => infer R ? R : T; +type Validate = { [K in keyof def]: def[K] extends () => infer R ? () => R : def[K] }; +interface Scope { + type(k: k): Resolve; +} +interface Type { + pipe(f: (x: T) => U): Type; +} +declare function scope(def: Validate): Scope; +declare function type(x: T): Type; + +export const $ = scope({ + a: type("string").pipe(function (s) { return s.length; }), + b: () => $.type("a").pipe(function (n) { return n === 0; }), +}); + +// Entered from the function in the first property when queried in reverse +export const $2 = scope({ + a: type("string").pipe(function (s) { return s.length; }), + b: () => $2.type("a").pipe((n: number) => n === 0), +}); diff --git a/tsc/testdata/tests/cases/compiler/classCircularityDiagnostics.ts b/tsc/testdata/tests/cases/compiler/classCircularityDiagnostics.ts new file mode 100644 index 0000000000000..34977b5df2a3d --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/classCircularityDiagnostics.ts @@ -0,0 +1,48 @@ +// @target: esnext +// @noImplicitAny: true, false + +class Direct extends Direct { + static value = 1; + value = 2; +} + +const staticValue = Direct.value; +const instanceValue = new Direct().value; + +class First extends Second {} +class Second extends First {} + +const Expression = class Named extends Named {}; + +class NestedBase extends (class { + static value = 1; + value = 2; +}) {} + +const nestedStaticValue: number = NestedBase.value; +const nestedInstanceValue: number = new NestedBase().value; + +const SelfReferencingBase = class extends (class { + static self = SelfReferencingBase; +}) {}; + +const selfConstructor = SelfReferencingBase.self; + +function mixin {}>(base: Base) { + return class extends base { + static value = 1; + value = 2; + }; +} + +class Mixed extends mixin(NestedBase) {} + +const mixedStaticValue: number = Mixed.value; +const mixedInstanceValue: number = new Mixed().value; + +declare function makeBase(value: number): typeof NestedBase; +class InvalidBaseArgument extends makeBase("invalid") {} +const InvalidExpressionArgument = class extends makeBase("invalid") {}; + +declare function makeInvalidBase(value: number): number; +class InvalidConstructor extends makeInvalidBase("invalid") {} \ No newline at end of file diff --git a/tsc/testdata/tests/cases/compiler/clonedTypeParameterUnionOrder.ts b/tsc/testdata/tests/cases/compiler/clonedTypeParameterUnionOrder.ts new file mode 100644 index 0000000000000..3bfa464b30bde --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/clonedTypeParameterUnionOrder.ts @@ -0,0 +1,15 @@ +// @strict: true +// @noEmit: true +// @checkOrder: default, reverse, typesfirst + +// @filename: a.ts +interface Pair { a: A; b: B } +interface Box { m(x: T): Pair } +declare function call(f: (x: A) => R): (x: A) => R; +declare const bs: Box; +declare const bn: Box; +const n = call(bn.m); + +// @filename: b.ts +declare const c: boolean; +const r = c ? call(bs.m) : call(bn.m); diff --git a/tsc/testdata/tests/cases/compiler/constAssertionBindingPatternQueryOrder.ts b/tsc/testdata/tests/cases/compiler/constAssertionBindingPatternQueryOrder.ts new file mode 100644 index 0000000000000..42517d7d60024 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/constAssertionBindingPatternQueryOrder.ts @@ -0,0 +1,11 @@ +// @strict: true +// @target: esnext +// @lib: esnext +// @noEmit: true +// @checkOrder: default, typesfirst + +declare function settle(fn: () => T): Promise<{ [K in keyof T]: [Awaited] }>; + +async function f() { + const [[a], b] = await settle(() => [Promise.resolve(0), Promise.reject(1)] as const); +} diff --git a/tsc/testdata/tests/cases/compiler/contextualCheckReentryFromOuterTypeParameters.ts b/tsc/testdata/tests/cases/compiler/contextualCheckReentryFromOuterTypeParameters.ts new file mode 100644 index 0000000000000..4d185d6668c8a --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/contextualCheckReentryFromOuterTypeParameters.ts @@ -0,0 +1,17 @@ +// @strict: true +// @noEmit: true + +interface Argv { + command(builder: (args: Argv) => Argv, handler: (args: Arguments) => void): Argv; + option(key: K, options: O): Argv<{ [key in K]: O } & Check>; +} +type Arguments = { [key in keyof T]: T[key] } & { [key: string]: unknown }; +type Check = O extends {} ? {} : {}; +declare const yargs: Argv; + +yargs.command( + (yargs) => yargs.option("a", { type: "string" }), + (argv) => { + const a: { type: string } = argv.a; + }, +); diff --git a/tsc/testdata/tests/cases/compiler/contextualOuterTypeParameters.ts b/tsc/testdata/tests/cases/compiler/contextualOuterTypeParameters.ts index a6ff9ae0a6e48..3ca7c15a2d58c 100644 --- a/tsc/testdata/tests/cases/compiler/contextualOuterTypeParameters.ts +++ b/tsc/testdata/tests/cases/compiler/contextualOuterTypeParameters.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 // @strict: true // @noemit: true @@ -27,3 +28,8 @@ const obj: { f: (x: T) => void } = { type IsObject = { x: typeof t } extends { x: string } ? true : false; } }; + +f(function self(t) { + const s = self; + type P = Parameters; +}); diff --git a/tsc/testdata/tests/cases/compiler/contextualParameterInCircularVariableInitializer.ts b/tsc/testdata/tests/cases/compiler/contextualParameterInCircularVariableInitializer.ts new file mode 100644 index 0000000000000..778d3f13cf9b3 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/contextualParameterInCircularVariableInitializer.ts @@ -0,0 +1,20 @@ +// @strict: true +// @noEmit: true +// @checkOrder: default,typesfirst + +// The initializer of `store` refers to `store` from a callback, so resolving +// the type of `store` re-enters itself. `y` must still get its contextual +// type `string` from `Store` (zustand `create()(...)` pattern), with no +// TS7006, as in main and TS 6.0. + +declare function create(init: () => T): T; + +interface Store { + a: (x: boolean) => void; + b: (y: string) => void; +} + +const store = create(() => ({ + a: (x) => store.b(""), + b: (y) => {}, +})); diff --git a/tsc/testdata/tests/cases/compiler/contextualParameterInReturnTypeCycleOfGenericCall.ts b/tsc/testdata/tests/cases/compiler/contextualParameterInReturnTypeCycleOfGenericCall.ts new file mode 100644 index 0000000000000..aeec88e3ef5b1 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/contextualParameterInReturnTypeCycleOfGenericCall.ts @@ -0,0 +1,17 @@ +// @strict: true +// @noEmit: true +// @checkOrder: default,typesfirst + +// Inferring `T` for `g` needs the return type of the arrow, whose body is a +// call to `f` that is contextually typed by that same return type, a cycle. +// `state` must still get the contextual type `number` (S inferred from +// `initialState`), as in main and TS 6.0 (redux-toolkit `createSlice` inside +// vitest `expect(() => ...)` pattern). + +declare function f S>>(options: { + initialState: S; + reducers: CR; +}): CR; +declare function g(a: T): void; + +g(() => f({ reducers: { a: (state) => state + 1 }, initialState: 0 })); diff --git a/tsc/testdata/tests/cases/compiler/contextualReturnArrayPatternCallback.ts b/tsc/testdata/tests/cases/compiler/contextualReturnArrayPatternCallback.ts index 04519047a9dc7..62b911890c1ed 100644 --- a/tsc/testdata/tests/cases/compiler/contextualReturnArrayPatternCallback.ts +++ b/tsc/testdata/tests/cases/compiler/contextualReturnArrayPatternCallback.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @strict: true interface Matcher { diff --git a/tsc/testdata/tests/cases/compiler/deferredTypeReferenceCycleRollback.ts b/tsc/testdata/tests/cases/compiler/deferredTypeReferenceCycleRollback.ts new file mode 100644 index 0000000000000..a33318012116f --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/deferredTypeReferenceCycleRollback.ts @@ -0,0 +1,20 @@ +// @strict: true +// @noEmit: true + +// A cycle rollback used to reset the type of the Array> +// node while the deferred reference identified by that node survived, +// which crashed a later instantiation of it. + +declare function declare(): void; + +interface PluginObj { + visitor: Visit; +} +type Visit = VisitFn | VisitObj; +type VisitFn = (path: NodePath

) => void; +interface VisitObj {} +declare class NodePath { + parentPath: NodePath>; + get: Get; +} +type Get = T extends Array ? Array> : never; diff --git a/tsc/testdata/tests/cases/compiler/deleteExpressionMustBeOptional.ts b/tsc/testdata/tests/cases/compiler/deleteExpressionMustBeOptional.ts index 223e0027de3cb..3252460f3281f 100644 --- a/tsc/testdata/tests/cases/compiler/deleteExpressionMustBeOptional.ts +++ b/tsc/testdata/tests/cases/compiler/deleteExpressionMustBeOptional.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 // @strict: true, false diff --git a/tsc/testdata/tests/cases/compiler/dependentDestructuringBindingElementInitializer.ts b/tsc/testdata/tests/cases/compiler/dependentDestructuringBindingElementInitializer.ts index 7006dffe572ca..4272774ef918b 100644 --- a/tsc/testdata/tests/cases/compiler/dependentDestructuringBindingElementInitializer.ts +++ b/tsc/testdata/tests/cases/compiler/dependentDestructuringBindingElementInitializer.ts @@ -1,5 +1,6 @@ // @strict: true // @noEmit: true +// @checkOrder: default, typesfirst type U = | { kind: "a"; payload: number; extra?: unknown } diff --git a/tsc/testdata/tests/cases/compiler/enumMemberTypeCacheConsistency.ts b/tsc/testdata/tests/cases/compiler/enumMemberTypeCacheConsistency.ts new file mode 100644 index 0000000000000..74c113fe04cde --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/enumMemberTypeCacheConsistency.ts @@ -0,0 +1,11 @@ +// @target: esnext +// @strict: true +// @declaration: true + +enum E { + A = 0, + B = E.A.valueOf(), + C = 1, +} + +const member: Extract = E.C; \ No newline at end of file diff --git a/tsc/testdata/tests/cases/compiler/exhaustiveSwitchCheckCircularity.ts b/tsc/testdata/tests/cases/compiler/exhaustiveSwitchCheckCircularity.ts index 86492e6c43f58..f3215225893b1 100644 --- a/tsc/testdata/tests/cases/compiler/exhaustiveSwitchCheckCircularity.ts +++ b/tsc/testdata/tests/cases/compiler/exhaustiveSwitchCheckCircularity.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 // @strict: true diff --git a/tsc/testdata/tests/cases/compiler/fallbackToBindingPatternForTypeInference.ts b/tsc/testdata/tests/cases/compiler/fallbackToBindingPatternForTypeInference.ts index 446b9319461cc..1a5a311e5c0dc 100644 --- a/tsc/testdata/tests/cases/compiler/fallbackToBindingPatternForTypeInference.ts +++ b/tsc/testdata/tests/cases/compiler/fallbackToBindingPatternForTypeInference.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 declare function trans(f: (x: T) => string): number; trans(({a}) => a); diff --git a/tsc/testdata/tests/cases/compiler/fixingTypeParametersRepeatedly2.ts b/tsc/testdata/tests/cases/compiler/fixingTypeParametersRepeatedly2.ts index c1949e48bf2ff..acb671e7cb0c2 100644 --- a/tsc/testdata/tests/cases/compiler/fixingTypeParametersRepeatedly2.ts +++ b/tsc/testdata/tests/cases/compiler/fixingTypeParametersRepeatedly2.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 // @strict: false interface Base { diff --git a/tsc/testdata/tests/cases/compiler/genericCallReturnedFunctionParameterDefault.ts b/tsc/testdata/tests/cases/compiler/genericCallReturnedFunctionParameterDefault.ts new file mode 100644 index 0000000000000..91e8220f031aa --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/genericCallReturnedFunctionParameterDefault.ts @@ -0,0 +1,28 @@ +// @strict: true +// @noEmit: true +// @checkOrder: default,typesfirst + +// The function returned from the callback of a generic call has a parameter +// with a default and no annotation. Once T is inferred, the contextual +// signature of the returned function is its own signature, but the parameter +// already has its type (boolean) from the initializer, computed while T was +// being inferred, so there is no circularity: no TS7022, and 'r()(1)' is an +// error. (Reduced from open-design ProjectView.tsx, useCallback returning +// '{ release: (recoverable = false) => ... }'.) + +declare function id(callback: T): T; + +id(() => { + return (x = false) => {}; +}); + +id(() => (y = false) => y); + +id(() => { + return { m(z = false) {} }; +}); + +const r = id(() => { + return (w = 0) => {}; +}); +r()(""); diff --git a/tsc/testdata/tests/cases/compiler/getterCircularityDiagnostics.ts b/tsc/testdata/tests/cases/compiler/getterCircularityDiagnostics.ts new file mode 100644 index 0000000000000..f5533c69336ad --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/getterCircularityDiagnostics.ts @@ -0,0 +1,14 @@ +// @target: es2015 +// @strict: true + +declare const props: Options; + +class Container { + get options() { + return { container: this, ...props } as Options; + } +} + +interface Options { + container?: Container; +} \ No newline at end of file diff --git a/tsc/testdata/tests/cases/compiler/indexedAccessAccessFlagsUnionOrder.ts b/tsc/testdata/tests/cases/compiler/indexedAccessAccessFlagsUnionOrder.ts new file mode 100644 index 0000000000000..b0876e1a14d68 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/indexedAccessAccessFlagsUnionOrder.ts @@ -0,0 +1,13 @@ +// @strict: true +// @noUncheckedIndexedAccess: true +// @noEmit: true +// @checkOrder: default, typesfirst + +function f, K extends keyof T>(obj: T, k: K, b: boolean) { + const x = b ? obj[k] : g(); + const s1: string = x; + const y = b ? g() : obj[k]; + const s2: string = y; +} + +declare function g(): T[K]; diff --git a/tsc/testdata/tests/cases/compiler/inferenceDeeplyNestedCheckOrder.ts b/tsc/testdata/tests/cases/compiler/inferenceDeeplyNestedCheckOrder.ts new file mode 100644 index 0000000000000..9771e61448026 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/inferenceDeeplyNestedCheckOrder.ts @@ -0,0 +1,23 @@ +// @strict: true +// @target: es2015 +// @noEmit: true + +// Inferring from string[][] to Iterable> recurses through the +// [Symbol.iterator] methods of both arrays. Whether that looks like expanding +// recursion must not depend on whether string[] was iterated beforehand. + +// @filename: first.ts +declare function flatten1(iterable: Iterable>): T[]; +declare const lists1: string[][]; +const flat1: null = flatten1(lists1); + +declare const items1: string[]; +for (const item of items1) {} + +// @filename: second.ts +declare const items2: number[]; +for (const item of items2) {} + +declare function flatten2(iterable: Iterable>): T[]; +declare const lists2: number[][]; +const flat2: null = flatten2(lists2); diff --git a/tsc/testdata/tests/cases/compiler/instantiationCouldContainTypeVariablesAfterCycle.ts b/tsc/testdata/tests/cases/compiler/instantiationCouldContainTypeVariablesAfterCycle.ts new file mode 100644 index 0000000000000..c845b6d929174 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/instantiationCouldContainTypeVariablesAfterCycle.ts @@ -0,0 +1,22 @@ +// @strict: true +// @noEmit: true +// @checkOrder: default,typesfirst + +// Query is instantiated with only non-generic arguments, so it (and DeepPartial>) +// can't contain type variables, and inference from Meta must not structurally recurse into +// DeepPartial>. That recursion would expand the infinite DeepPartial and report +// TS5114. The carry-forward of the "could contain type variables" flag set at instantiation time +// must survive even when the instantiation is created inside a circularity that is later discarded. + +declare const a: Meta; +fromMetadata(a); +type DeepPartial = { [P in keyof T]: DeepPartial }; +type Nested = Nested[]; +interface Prop { owner: Meta } +interface Meta { + prop: Prop; + other: any; + query: Query; +} +type Query = { cond: Nested }; +declare function fromMetadata(meta: Meta | DeepPartial>): void; diff --git a/tsc/testdata/tests/cases/compiler/instantiationLimitsCheckOrder.ts b/tsc/testdata/tests/cases/compiler/instantiationLimitsCheckOrder.ts new file mode 100644 index 0000000000000..d20851bc88553 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/instantiationLimitsCheckOrder.ts @@ -0,0 +1,19 @@ +// @noEmit: true + +// The depth limit on instantiations must not depend on what was +// instantiated before. The limit on the number of instantiations does, as +// it only stops runaway instantiations, so it is only tested for a single +// statement whose work nothing else shares. + +type D = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; +type K = `${D}${D}${D}`; + +// Several million instantiations, well over the limit, for one statement. +type Wide = N["length"] extends 8 ? I : { [J in K]: Wide<[...N, 0], [J, I][0]> }[K]; +type WideAll = Wide<[], "">; + +// Over a hundred nested instantiations, half of which already happened for +// another statement. +type Deep = N["length"] extends 60 ? never : Deep<[...N, 0]> | N["length"]; +type DeepTail = Deep<[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]>; +type DeepAll = Deep<[]>; diff --git a/tsc/testdata/tests/cases/compiler/jsdocTypeTagOnContextuallyTypedFunction.ts b/tsc/testdata/tests/cases/compiler/jsdocTypeTagOnContextuallyTypedFunction.ts new file mode 100644 index 0000000000000..fdf0661ace752 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/jsdocTypeTagOnContextuallyTypedFunction.ts @@ -0,0 +1,17 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true +// @strict: true + +// @filename: a.js +/** @type {{ f: (a: string | number, ...rest: unknown[]) => string }} */ +const context = { f: (a) => "" }; + +context.f = + /** @type {(content: string, ...rest: [boolean?]) => string} */ + (content, ...rest) => content.toUpperCase() + rest.length; + +/** @type {(content: string | number) => string} */ +const g = + /** @type {(content: string) => string} */ + (content) => content.toUpperCase(); diff --git a/tsc/testdata/tests/cases/compiler/jsxImportSourceNonPragmaComment.tsx b/tsc/testdata/tests/cases/compiler/jsxImportSourceNonPragmaComment.tsx index 652316735d2e8..09c7889d5aa04 100644 --- a/tsc/testdata/tests/cases/compiler/jsxImportSourceNonPragmaComment.tsx +++ b/tsc/testdata/tests/cases/compiler/jsxImportSourceNonPragmaComment.tsx @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @module: commonjs // @target: es2015 // @jsx: preserve diff --git a/tsc/testdata/tests/cases/compiler/jsxIntrinsicElementsExtendsRecord.tsx b/tsc/testdata/tests/cases/compiler/jsxIntrinsicElementsExtendsRecord.tsx index 52bd71073ce20..2ddc4427d5056 100644 --- a/tsc/testdata/tests/cases/compiler/jsxIntrinsicElementsExtendsRecord.tsx +++ b/tsc/testdata/tests/cases/compiler/jsxIntrinsicElementsExtendsRecord.tsx @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 // @jsx: preserve diff --git a/tsc/testdata/tests/cases/compiler/limitDeepInstantiations.ts b/tsc/testdata/tests/cases/compiler/limitDeepInstantiations.ts index ccb48dec686eb..ba5c710c6fed3 100644 --- a/tsc/testdata/tests/cases/compiler/limitDeepInstantiations.ts +++ b/tsc/testdata/tests/cases/compiler/limitDeepInstantiations.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 // Repro from #14837 diff --git a/tsc/testdata/tests/cases/compiler/narrowedNeverAfterLoopWithAndCondition.ts b/tsc/testdata/tests/cases/compiler/narrowedNeverAfterLoopWithAndCondition.ts new file mode 100644 index 0000000000000..46b9086842fb1 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/narrowedNeverAfterLoopWithAndCondition.ts @@ -0,0 +1,22 @@ +// @strict: true +// @noEmit: true + +// value_def is never inside the if. With a && condition, main and +// Strada leak the loop analysis's incomplete never placeholder +// (silentNever), so the property access is silently allowed and only +// the assignment errors. With `while (x)` they report the access. +function f(x: boolean, y: boolean) { + let value_def: { last_ref: boolean } | null = null; + if (value_def) { + while (x && y); + value_def.last_ref = false; + } +} + +function g(x: boolean) { + let value_def: { last_ref: boolean } | null = null; + if (value_def) { + while (x); + value_def.last_ref = false; + } +} diff --git a/tsc/testdata/tests/cases/compiler/objectLiteralRegularAndWidenedCopyOrder.ts b/tsc/testdata/tests/cases/compiler/objectLiteralRegularAndWidenedCopyOrder.ts new file mode 100644 index 0000000000000..2074b9f29a2c4 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/objectLiteralRegularAndWidenedCopyOrder.ts @@ -0,0 +1,10 @@ +// @strict: true +// @checkOrder: default, typesfirst + +declare const b: boolean; +let x; +x = { a: 1 }; +let arr = []; +arr.push(x); // regular copy of the literal +const y = x; // widened copy of the literal +const z = b ? (b ? arr[0] : y) : { c: 1 }; diff --git a/tsc/testdata/tests/cases/compiler/objectRestUnionInstantiationOrder.ts b/tsc/testdata/tests/cases/compiler/objectRestUnionInstantiationOrder.ts new file mode 100644 index 0000000000000..9a8421765dd31 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/objectRestUnionInstantiationOrder.ts @@ -0,0 +1,11 @@ +// @strict: true +// @noEmit: true +// @checkOrder: default, typesfirst + +function f(v: { k: "a"; a: T } | { k: "b"; b: number }) { + const { k, ...rest } = v; + return { all: rest, onlyB: "b" in rest ? rest : undefined }; +} +const o = f({ k: "a", a: "s" }); +const all = o.all; +const onlyB = o.onlyB; diff --git a/tsc/testdata/tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts b/tsc/testdata/tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts index 5c46a93180392..6265ebecee02e 100644 --- a/tsc/testdata/tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts +++ b/tsc/testdata/tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 // @strict: false interface A { x } diff --git a/tsc/testdata/tests/cases/compiler/parameterBindingDefaultReferencesSiblingThroughCall.ts b/tsc/testdata/tests/cases/compiler/parameterBindingDefaultReferencesSiblingThroughCall.ts new file mode 100644 index 0000000000000..388af19a9c64c --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/parameterBindingDefaultReferencesSiblingThroughCall.ts @@ -0,0 +1,25 @@ +// @strict: true +// @noEmit: true +// @checkOrder: default,typesfirst + +// A default in a destructured parameter that references a sibling element +// makes the sibling's type depend on itself: the type of 'a' comes from the +// parameter initializer '{}', which is padded with the types of the defaults, +// including 'b'. Main reports this cycle (TS7022 on 'a') for 'b = a', but not +// for 'b = id(a)', where the padding reuses the signature resolved while 'a' +// was treated as non-inferrable any during contextual typing of '{}', which +// gives 'b' the type 'unknown' (see tldraw TldrawApp.test.ts). + +declare function id(v: T): T; + +function direct({ a = 1 as number | undefined, b = a } = {}) { + const n: string = b; +} + +function viaCall({ a = 1 as number | undefined, b = id(a) } = {}) { + const n: string = b; +} + +function viaCallArray({ a = 1 as number | undefined, b = id([a]) } = {}) { + const n: string = b; +} diff --git a/tsc/testdata/tests/cases/compiler/recursiveVarianceFixedPoint.ts b/tsc/testdata/tests/cases/compiler/recursiveVarianceFixedPoint.ts new file mode 100755 index 0000000000000..3a26019b2db52 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/recursiveVarianceFixedPoint.ts @@ -0,0 +1,159 @@ +// @strict: true +// @target: es2015 +// @noEmit: true + +// @filename: storeFirst.ts +export {}; + +interface Store { + value: T; + listener: Listener; +} +type Listener = (batch: Store) => void; + +declare let strings: Store; +declare let unknowns: Store; +declare let stringListener: Listener; +declare let unknownListener: Listener; + +unknowns = strings; // Error +unknownListener = stringListener; // Error + +// @filename: listenerFirst.ts +export {}; + +type Listener = (batch: Store) => void; +interface Store { + listener: Listener; + value: T; +} + +declare let strings: Store; +declare let unknowns: Store; +declare let stringListener: Listener; +declare let unknownListener: Listener; + +unknownListener = stringListener; // Error +unknowns = strings; // Error + +// @filename: columnDefFirst.ts +export {}; + +interface ColumnDef { + cell?: (column: Column) => void; +} +interface Column { + accessorFn?: (row: Row) => Value; + columnDef: ColumnDef; +} + +declare let stringColumn: ColumnDef<{ name: string }, string>; +declare let unknownColumn: ColumnDef<{ name: string }, unknown>; + +unknownColumn = stringColumn; // Error +stringColumn = unknownColumn; // Error + +// @filename: columnFirst.ts +export {}; + +interface Column { + columnDef: ColumnDef; + accessorFn?: (row: Row) => Value; +} +interface ColumnDef { + cell?: (column: Column) => void; +} + +declare let stringColumn: ColumnDef<{ name: string }, string>; +declare let unknownColumn: ColumnDef<{ name: string }, unknown>; + +unknownColumn = stringColumn; // Error +stringColumn = unknownColumn; // Error + +// @filename: positiveRecursion.ts +export {}; + +interface Tree { + readonly value: T; + readonly children: readonly Tree[]; + readonly metadata: Map; +} +interface Phantom { + next: Phantom; +} + +declare let stringTree: Tree; +declare let unknownTree: Tree; +declare let stringPhantom: Phantom; +declare let numberPhantom: Phantom; + +unknownTree = stringTree; +stringTree = unknownTree; // Error +stringPhantom = numberPhantom; +numberPhantom = stringPhantom; + +// @filename: nestedComposition.ts +export {}; + +interface Outer { + value: T; + next: Inner>; +} +interface Inner { + consume: (value: T) => void; +} + +declare let strings: Outer; +declare let unknowns: Outer; + +unknowns = strings; // Error +strings = unknowns; // Error + +// @filename: annotations.ts +export {}; + +interface AnnotatedTree { + readonly value: T; + readonly children: AnnotatedTree[]; +} +interface AnnotatedStore { + value: T; + listener: (batch: AnnotatedStore) => void; +} + +declare let stringTree: AnnotatedTree; +declare let unknownTree: AnnotatedTree; +declare let stringStore: AnnotatedStore; +declare let unknownStore: AnnotatedStore; + +unknownTree = stringTree; +stringTree = unknownTree; // Error +unknownStore = stringStore; // Error +stringStore = unknownStore; // Error + +// @filename: structuralMeasurement.ts +export {}; + +interface GenericMethod { + value: T; + next: (value: U) => GenericMethod; +} +interface Projected { + value: T["value"]; + next: Projected; +} +interface Method { + value: T; + accept(value: Method): void; +} + +declare let strings: GenericMethod; +declare let unknowns: GenericMethod; +declare let stringMethod: Method; +declare let unknownMethod: Method; +declare let projected: Projected<{ value: string; extra: number }>; + +unknowns = strings; +strings = unknowns; // Error +unknownMethod = stringMethod; +const widened: Projected<{ value: string }> = projected; diff --git a/tsc/testdata/tests/cases/compiler/relationComplexityError.ts b/tsc/testdata/tests/cases/compiler/relationComplexityError.ts index 7b83dcf8dc6fd..ac2c6c2559ab7 100644 --- a/tsc/testdata/tests/cases/compiler/relationComplexityError.ts +++ b/tsc/testdata/tests/cases/compiler/relationComplexityError.ts @@ -1,17 +1,32 @@ -// @target: es2015 -// @strict: true -// @noEmit: true - -// Repro from #55630 - -type Digits = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7'; -type T1 = `${Digits}${Digits}${Digits}${Digits}` | undefined; -type T2 = { a: string } | { b: number }; - -function f1(x: T1, y: T1 & T2) { - x = y; -} - -function f2(x: T1 | null, y: T1 & T2) { - x = y; // Complexity error -} +// @target: es2015 +// @strict: true +// @noEmit: true +// @checkOrder: default, typesfirst + +// Repro from #55630 +// Every comparison that needs a comparison that is too complex is too complex +// itself, whether or not that comparison happened before. + +type Digits = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7'; +type T1 = `${Digits}${Digits}${Digits}${Digits}` | undefined; +type T2 = { a: string } | { b: number }; + +function f0(x: { p: T1 | null }, y: { p: T1 & T2 }) { + x = y; // Complexity error +} + +function f1(x: T1, y: T1 & T2) { + x = y; +} + +function f2(x: T1 | null, y: T1 & T2) { + x = y; // Complexity error +} + +function f3(x: T1 | null, y: T1 & T2) { + x = y; // Complexity error +} + +function f4(x: { p: T1 | null }, y: { p: T1 & T2 }) { + x = y; // Complexity error +} diff --git a/tsc/testdata/tests/cases/compiler/relationDeeplyNestedCheckOrder.ts b/tsc/testdata/tests/cases/compiler/relationDeeplyNestedCheckOrder.ts new file mode 100644 index 0000000000000..638ea1b62008b --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/relationDeeplyNestedCheckOrder.ts @@ -0,0 +1,17 @@ +// @strict: true +// @noEmit: true + +// Relating 'B<{ a: string }>' to 'B<{ a: "lit" }>' eventually relates 'string' +// to '"lit"' through 'm0.m1.a.m0.m1', but only after measuring the variances +// of 'A', which gives up on deeply nested types. TypeScript reports an error +// for the 'B' assignment only when it is checked before the 'A' assignment; +// the result must not depend on which is checked first. + +type A = { m0: (x: B) => void; m1: { [K in keyof T]: B } }; +type B = { m0: A }; + +declare let a1: A<{ a: string }>, a2: A<{ a: "lit" }>; +declare let b1: B<{ a: string }>, b2: B<{ a: "lit" }>; + +a2 = a1; +b2 = b1; diff --git a/tsc/testdata/tests/cases/compiler/relationMaybeCheckOrder.ts b/tsc/testdata/tests/cases/compiler/relationMaybeCheckOrder.ts new file mode 100644 index 0000000000000..b56c53b300a7a --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/relationMaybeCheckOrder.ts @@ -0,0 +1,24 @@ +// @strict: true +// @noEmit: true + +// Relating to 'keyof M' rejects keys that relate only by assuming a +// comparison still in progress. Relating 'A' to 'B' assumes only itself +// along 'next', so it completes on its own and must be accepted whether +// or not the call to 'h' related 'A' to 'B' first. + +interface A { next: A; v: "a" } +interface B { next: B; v: string } +type M = { [K in keyof T as B]: 1 }; + +declare const a: A; +declare function h(x: B): 1; +declare function h(x: unknown): 2; + +function f() { + function g(x: keyof M): 1; + function g(x: unknown): 2; + function g(x: unknown) { return 1 as any; } + const r: 1 = g(a); +} + +const w: 1 = h(a); diff --git a/tsc/testdata/tests/cases/compiler/relationTruncatedCacheCheckOrder.ts b/tsc/testdata/tests/cases/compiler/relationTruncatedCacheCheckOrder.ts new file mode 100644 index 0000000000000..1332ce5a04d59 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/relationTruncatedCacheCheckOrder.ts @@ -0,0 +1,18 @@ +// @strict: true +// @noEmit: true +// @checkOrder: default, typesfirst + +// Relating 'S<[string]>' to 'R<[string]>' from scratch reaches 'next.leaf' +// before giving up on deeply nested types, and fails there. Inside the +// relation of 'S' to 'R' it is one level deeper and is cut +// short instead. That truncated result must not be cached, so the error for +// 'q = p' must be reported whether or not 'y = x' was checked first. + +type S = { next: S<[T]>; leaf: T extends [[unknown]] ? number : T }; +type R = { next: R<[T]>; leaf: T }; + +declare let x: S, y: R; +declare let p: S<[string]>, q: R<[string]>; + +y = x; +q = p; diff --git a/tsc/testdata/tests/cases/compiler/returnTypeInferenceNotTooBroad.ts b/tsc/testdata/tests/cases/compiler/returnTypeInferenceNotTooBroad.ts index fb987440a546e..72c12f9dd0af5 100644 --- a/tsc/testdata/tests/cases/compiler/returnTypeInferenceNotTooBroad.ts +++ b/tsc/testdata/tests/cases/compiler/returnTypeInferenceNotTooBroad.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 type Signs = { kind: 'a'; a: 3; } | { kind: 'b'; b: 2; } | { kind: 'c'; c: 1; }; interface Opts { diff --git a/tsc/testdata/tests/cases/compiler/sharedMemberLayoutThisIntersectionBase.ts b/tsc/testdata/tests/cases/compiler/sharedMemberLayoutThisIntersectionBase.ts index 71209527ff35b..0d51e874d2db2 100644 --- a/tsc/testdata/tests/cases/compiler/sharedMemberLayoutThisIntersectionBase.ts +++ b/tsc/testdata/tests/cases/compiler/sharedMemberLayoutThisIntersectionBase.ts @@ -1,5 +1,6 @@ // @strict: true // @noEmit: true +// @checkOrder: default, typesfirst interface A { kind: string; m: this["kind"] } interface B { m: "a" } diff --git a/tsc/testdata/tests/cases/compiler/templateLiteralTypeExcessiveLength.ts b/tsc/testdata/tests/cases/compiler/templateLiteralTypeExcessiveLength.ts index eeb573c01c164..77d5e59654843 100644 --- a/tsc/testdata/tests/cases/compiler/templateLiteralTypeExcessiveLength.ts +++ b/tsc/testdata/tests/cases/compiler/templateLiteralTypeExcessiveLength.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @strict: true // Regression test for #63271: `Dec<2>` is `any`, so `Recur` produces both conditional branches and diff --git a/tsc/testdata/tests/cases/compiler/typeParameterHasSelfAsConstraint.ts b/tsc/testdata/tests/cases/compiler/typeParameterHasSelfAsConstraint.ts index 3b2267f54389c..9c99dcb98fa60 100644 --- a/tsc/testdata/tests/cases/compiler/typeParameterHasSelfAsConstraint.ts +++ b/tsc/testdata/tests/cases/compiler/typeParameterHasSelfAsConstraint.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 function foo(x: T): number { return x; diff --git a/tsc/testdata/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts b/tsc/testdata/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts index 6a4517411287d..d834c23767f8f 100644 --- a/tsc/testdata/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts +++ b/tsc/testdata/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 //@noUnusedLocals:true //@noUnusedParameters:true diff --git a/tsc/testdata/tests/cases/compiler/varianceCircularConsistency.ts b/tsc/testdata/tests/cases/compiler/varianceCircularConsistency.ts new file mode 100644 index 0000000000000..c6c3ccb148802 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/varianceCircularConsistency.ts @@ -0,0 +1,29 @@ +// @strict: true +// @noEmit: true + +// Variances of these mutually recursive generics must not depend on values +// measured mid-cycle. Assigning `e` to `EntryPoint` must agree with +// assigning `e.root` to `EntryPoint["root"]`. + +interface Query {} +type Component

= P | ((props: P) => void); +interface Ref { + value: T; +} +interface Rep, Nested, Runtime, Extra> extends Readonly<{ + root: Ref>; +}> {} +type Preloaded = T extends Record> ? { [K in keyof T]: Unwrap> } : never; +interface Props extends Readonly<{ + nested: Preloaded; + queries: Queries; +}> {} +type EntryPointComponent, Nested, Runtime, Extra = {}> = Component>; +type Unwrap = C extends EntryPointComponent ? Readonly<{}> : {}; +type EntryPoint = Rep ? Q : never, never, never, never>; +type GetComponent = T extends EntryPoint ? C : never; + +declare const c: EntryPointComponent<{ q: { readonly variables: { slug: string } } }, {}, { onClick: () => void }>; +declare const e: EntryPoint; +const whole: EntryPoint = e; +const root: EntryPoint["root"] = e.root; diff --git a/tsc/testdata/tests/cases/compiler/varianceCircularityChartjsPlugin.ts b/tsc/testdata/tests/cases/compiler/varianceCircularityChartjsPlugin.ts new file mode 100644 index 0000000000000..b76009f354e84 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/varianceCircularityChartjsPlugin.ts @@ -0,0 +1,74 @@ +// @strict: true +// @target: esnext +// @noEmit: true +// @checkOrder: default,typesfirst + +// Reduced from chart.js typings (PeerTube, Unleash). Chart, TooltipModel and +// ScriptableContext form a variance circularity. ScriptableContext is in +// fact invariant: ScriptableContext<"bar" | "line"> is not assignable to +// ScriptableContext<"bar"> ('dataset.data' differs), so Chart<"bar"> is not +// assignable to Chart and the assignment below must be an error. +// Measuring variances from the circularity's entry, main recorded +// ScriptableContext/TooltipModel as bivariant (measured mid-cycle) and +// accepted it; main reports this error too when ScriptableContext's variance +// is measured first (e.g. after checking a ScriptableContext assignment). + +declare class Element { options: O } +type DeepPartial = T extends Function ? T : T extends object ? _DeepPartialObject : undefined +type _DeepPartialObject = { [P in keyof T]?: DeepPartial } +type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never +type AnyObject = Record +interface ScriptableContext { + dataset: UnionToIntersection> +} +type Scriptable = (ctx: TContext) => T +declare class Chart { + config: ChartConfigurationCustomTypesPerDataset +} +interface Plugin { + id: string; + beforeDraw(chart: Chart): void +} +interface CoreChartOptions { + backgroundColor: Scriptable> +} +interface AnimationSpec { + delay: Scriptable> +} +interface TooltipModel extends Element> { + chart: Chart +} +interface TooltipDatasetCallbacks> { + (this: Model): void +} +interface TooltipOptions { + animation: AnimationSpec +} +interface TooltipDatasetOptions { + callbacks: TooltipDatasetCallbacks +} +interface PluginDatasetOptionsByType { + tooltip: TooltipDatasetOptions +} +interface ChartTypeRegistry { + bar: { defaultDataPoint: [] } + line: { defaultDataPoint: null } +} +type ChartType = keyof ChartTypeRegistry +type DatasetChartOptions = { [key in TType]: {} } +type ChartOptions = Exclude & DatasetChartOptions & TType>, undefined> +interface ChartDatasetProperties { + data: TData +} +type ChartDataset = + DeepPartial> & ChartDatasetProperties +type ChartDatasetCustomTypesPerDataset = DeepPartial> +interface ChartDataCustomTypesPerDataset { + datasets: ChartDatasetCustomTypesPerDataset +} +export interface ChartConfigurationCustomTypesPerDataset { + data: ChartDataCustomTypesPerDataset + options: ChartOptions +} + +const p: Plugin<"bar"> = { id: "x", beforeDraw: (chart: Chart) => {} }; diff --git a/tsc/testdata/tests/cases/compiler/varianceCycleCachedResults.ts b/tsc/testdata/tests/cases/compiler/varianceCycleCachedResults.ts new file mode 100644 index 0000000000000..935dada6a890f --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/varianceCycleCachedResults.ts @@ -0,0 +1,25 @@ +// @strict: true + +// Relating 'Box' to 'Box' measures the variances of 'Box', which +// resolves the return type of 'm', which relates 'Box' to 'Box' +// while those variances are incomplete, reducing the union to 'Box'. +// Resolving 'm' first measures the variances of 'Box' and resolves 'm' again +// inside, the same way, so 'm' returns 'Box' whichever is first. + +// @filename: first.ts +declare let b1: Box; +declare let b2: Box; +b1 = b2; + +// @filename: box.ts +declare let a1: Box; +declare let a2: Box; +declare const cond: boolean; +class Box { + value!: T; + m() { + if (cond) return a1; + return a2; + } +} +const r = new Box().m(); diff --git a/tsc/testdata/tests/cases/compiler/varianceCycleCapnwebRpcStub.ts b/tsc/testdata/tests/cases/compiler/varianceCycleCapnwebRpcStub.ts new file mode 100644 index 0000000000000..990358f14d3ee --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/varianceCycleCapnwebRpcStub.ts @@ -0,0 +1,170 @@ +// @strict: true +// @target: esnext +// @lib: esnext,dom +// @skipLibCheck: true +// @noEmit: true + +// The RpcStub types of capnweb 0.12.0 (MIT license, Copyright (c) 2025 +// Cloudflare, Inc.), as used by cloudflare-os. Stub, Result, MethodOrProperty, +// MaybeCallableProvider and others form a variance circularity in which the +// types measured before it completes are measured unreliable. Comparisons +// of them while it completes must not fall back to comparing structurally, +// or measuring it reaches the instantiation limit (TS2589), and the `.then` +// callback parameter is implicitly any (TS7006). + +// @filename: capnweb.d.ts +// Copyright (c) 2025 Cloudflare, Inc. +// Licensed under the MIT license found in the LICENSE.txt file or at: +// https://opensource.org/license/mit +// This file borrows heavily from `types/defines/rpc.d.ts` in workerd. +// Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s. +// TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`. +// For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to +// accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape) +declare const __RPC_STUB_BRAND: '__RPC_STUB_BRAND'; +declare const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND'; +// Distinguishes mapper placeholders from regular values so param unwrapping can accept them. +declare const __RPC_MAP_VALUE_BRAND: unique symbol; +interface RpcTargetBranded { + [__RPC_TARGET_BRAND]: never; +} +// Types that can be used through `Stub`s +// `never[]` preserves compatibility with strongly-typed function signatures without introducing +// `any` into inference. +type Stubable = RpcTargetBranded | ((...args: never[]) => unknown); +// Note: also true for `any` (call sites that care check `IsAny` first). +type IsUnknown = unknown extends T ? true : false; // Types that can be passed over RPC +// The reason for using a generic type here is to build the serializable subset of RPC-compatible +// composite types. This allows types defined with the "interface" keyword to pass the +// serializable check as well. Otherwise, only types defined with the "type" keyword would pass. +type RpcCompatible = // Allow `unknown` as a leaf so records/interfaces with `unknown` fields remain compatible. +(IsUnknown extends true ? unknown : never) // RPC-compatible base values +| BaseType // RPC-compatible composites +| Map ? RpcCompatible : never, T extends Map ? RpcCompatible : never> | Set ? RpcCompatible : never> | Array ? RpcCompatible : never> | ReadonlyArray ? RpcCompatible : never> | { [K in keyof T as K extends string | number ? K : never]: RpcCompatible } | Promise ? RpcCompatible : never> // Special types +| Stub // Serialized as stubs, see `Stubify` +| Stubable; +// Base type for all RPC stubs, including common memory management methods. +// `T` is used as a marker type for unwrapping `Stub`s later. +interface StubBase extends Disposable { + [__RPC_STUB_BRAND]: T; + dup(): this; + onRpcBroken(callback: (error: any) => void): void; +} +type Stub> = T extends object ? Provider & StubBase : StubBase; +type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | BigUint64Array | BigInt64Array | Float32Array | Float64Array; // This represents all the types that can be sent as-is over an RPC boundary +type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | Blob | ReadableStream // Chunk type can be any RPC-compatible type +| WritableStream // Chunk type can be any RPC-compatible type +| URL | Request | Response | Headers; // Recursively rewrite all `Stubable` types with `Stub`s, and resolve promises. +// Arm ordering matters here: +// - `Promise` must come before `StubBase`: `RpcPromise` matches both, and must resolve +// through the Promise arm rather than pass through as-is. +// - `StubBase` must come before `Stubable`: `Stub` of a callable `T` is itself callable, so +// it matches `Stubable`. Checking `StubBase` first keeps existing stubs as-is instead of +// double-wrapping them as `Stub>`. +// prettier-ignore +type Stubify = T extends Promise ? Stubify : T extends StubBase ? T : T extends Stubable ? Stub : T extends Map ? Map, Stubify> : T extends Set ? Set> : T extends [] ? [] : T extends [infer Head, ...infer Tail] ? [Stubify, ...Stubify] : T extends readonly [] ? readonly [] : T extends readonly [infer Head, ...infer Tail] ? readonly [Stubify, ...Stubify] : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends BaseType ? T // When using "unknown" instead of "any", interfaces are not stubified. +: T extends { + [key: string | number]: any; +} ? { [K in keyof T as K extends string | number ? K : never]: Stubify } : T; +// Recursively rewrite all `Stub`s with the corresponding `T`s. +// Note we use `StubBase` instead of `Stub` here to avoid circular dependencies: +// `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`. +// prettier-ignore +type UnstubifyInner = // Preserve local RpcTarget acceptance, but avoid needless `Stub | Value` unions when the stub +// is already assignable to the value type (important for callback contextual typing). +T extends StubBase ? (T extends V ? UnstubifyInner : (T | UnstubifyInner)) : T extends Promise ? UnstubifyInner : T extends Map ? Map, Unstubify> : T extends Set ? Set> : T extends [] ? [] : T extends [infer Head, ...infer Tail] ? [Unstubify, ...Unstubify] : T extends readonly [] ? readonly [] : T extends readonly [infer Head, ...infer Tail] ? readonly [Unstubify, ...Unstubify] : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends BaseType ? T : T extends { + [key: string | number]: unknown; +} ? { [K in keyof T as K extends string | number ? K : never]: Unstubify } : T; // You can put promises anywhere in the params and they'll be resolved before delivery. +// (This also covers RpcPromise, because it's defined as being a Promise.) +// Map placeholders are also allowed so primitive map callback inputs can be forwarded directly +// into RPC params. +// +// Keep raw non-stub members so generic assignability still works when UnstubifyInner is deferred. +// Remove stub members from mixed unions so callback params don’t get both stub and unstubbed signatures. +// Marker carried by map() callback inputs. This lets primitive placeholders flow through params. +type Unstubify = NonStubMembers | UnstubifyInner | Promise> | MapValuePlaceholder>; +type UnstubifyAll = { [I in keyof A]: Unstubify }; +interface MapValuePlaceholder { + [__RPC_MAP_VALUE_BRAND]: T; +} +type NonStubMembers = Exclude>; // Utility type for adding `Disposable`s to `object` types only. +// Note `unknown & T` is equivalent to `T`. +type MaybeDisposable = T extends object ? Disposable : unknown; // The type behind the public `RpcPromise` (re-exported with its `RpcCompatible` constraint from +// index.ts). Defined here so that `Result`'s arms below resolve to the exact same alias +// instantiation: when both sides of an assignability check are the same alias applied to the +// same type arguments, the checker short-circuits on identity instead of recursing through the +// full structural comparison of these mutually-recursive types. +type RpcPromise$1 = T extends Stubable ? Promise> & Provider & StubBase : Promise & MaybeDisposable> & Provider & StubBase; +// The elision `Result` applies to a bare stub type: unwrap `Stub` back to `T` when the +// payload is `Stubable`. Such stubs await back to a stub either way, so eliding keeps a +// declared `Promise>` return interchangeable with a `Promise` return. +// Plain-interface stubs are NOT elided: `RpcPromise` only awaits to `Stub` when +// `U extends Stubable`, so eliding those would change the awaited type from a stub to a +// stubified record. The payload check is deliberately non-distributive (`[U] extends [...]`). +// `Stub` is not elided either: `[any] extends [Stubable]` is true, so without the `IsAny` +// guard an `any`-payload stub would lose its stub surface. +// Also used by the `RpcPromise` constructor signature (index.ts), which applies exactly this +// transformation so constructing from a promised stub matches the method-return type. +type ElideStub = T extends StubBase ? (IsAny extends true ? T : [U] extends [Stubable] ? U : T) : T; +// What the promise given to `new RpcPromise(...)` may resolve to: the payload itself, or — +// for stubable payloads — a stub of it. `NoInfer` keeps the stub arm out of inference, so an +// inferred `T` is always the promise's own resolution type; the arm only matters when `T` is +// explicitly annotated (`new RpcPromise(promiseOfStub)`). Stubs of non-stubable +// payloads are deliberately rejected: `ElideStub` wouldn't elide those, so accepting one would +// claim the promise awaits to a stubified record while the runtime resolves to a stub. +type PayloadOrStub = T | NoInfer>>; +// Type for method return or property on an RPC interface. +// - Stubable types are replaced by stubs. +// - RpcCompatible types are passed by value, with stubable types replaced by stubs +// and a top-level `Disposer`. +// Everything else can't be passed over RPC. +// Technically, we use custom thenables here, but they quack like `Promise`s. +// Intersecting with `(Maybe)Provider` allows pipelining. +// prettier-ignore +type Result = IsAny extends true ? RpcPromise$1 // `RpcPromise`: always safe to normalize — `Result` is idempotent — so a declared +// `RpcPromise` return produces the same type as a `Promise` return. +: R extends PromiseLike & StubBase ? Result // Bare stubs: elide per `ElideStub` above. Note there is no `RpcCompatible` re-check +// here: anything matching our `StubBase` was produced by machinery that already enforced +// the constraint, and re-evaluating `RpcCompatible` in this arm recurses through its +// `Stub` member back into `Result`, tripping TS2615 circularity errors in mapped +// types. +: R extends StubBase ? RpcPromise$1> : R extends RpcCompatible ? RpcPromise$1 : never; +type IsAny = 0 extends (1 & T) ? true : false; // Type for method or property on an RPC interface. +// For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s. +// Unwrapping `Stub`s allows calling with `Stubable` arguments. +// For properties, rewrite types to be `Result`s. +// In each case, unwrap `Promise`s. +type MethodOrProperty = V extends ((...args: infer P) => infer R) ? (...args: UnstubifyAll

) => Result> : Result>; // Type for the callable part of an `Provider` if `T` is callable. +// This is intersected with methods/properties. +type MaybeCallableProvider = T extends ((...args: any[]) => any) ? MethodOrProperty : unknown; +type TupleIndexKeys> = Extract; +type MapCallbackValue = // `Omit` removes call signatures, so re-intersect callable provider behavior. +T extends unknown ? Omit, keyof Promise> & MaybeCallableProvider & MapValuePlaceholder : never; +type InvalidNativePromiseInMapResult = T extends unknown ? InvalidNativePromiseInMapResultImpl : never; +type InvalidNativePromiseInMapResultImpl = [T] extends [Seen] ? never // RpcPromise is modeled as Promise & StubBase, so allow promise-like stub values. +: T extends StubBase ? never // Native thenables cannot be represented in map recordings, even when typed as PromiseLike. +: T extends PromiseLike ? T : T extends Map ? InvalidNativePromiseInMapResult | InvalidNativePromiseInMapResult : T extends Set ? InvalidNativePromiseInMapResult : T extends readonly [] ? never : T extends readonly [infer Head, ...infer Tail] ? InvalidNativePromiseInMapResult | InvalidNativePromiseInMapResult : T extends ReadonlyArray ? InvalidNativePromiseInMapResult : T extends { + [key: string | number]: unknown; +} ? InvalidNativePromiseInMapResult], Seen | T> : never; +type MapCallbackReturn = InvalidNativePromiseInMapResult extends never ? T : never; +type ArrayProvider = { [K in number]: MethodOrProperty } & { + map(callback: (elem: MapCallbackValue) => MapCallbackReturn): Result>; +}; +type TupleProvider> = { [K in TupleIndexKeys]: MethodOrProperty } & ArrayProvider; // Base type for all other types providing RPC-like interfaces. +// Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types. +// `__RPC_TARGET_BRAND` deliberately flows through the key mapping (as a `never` property) so +// stubs of branded targets stay assignable to workers-types' `Stubable`. Such stubs match our +// `Stubable` too — harmless, since all machinery checks `StubBase` before `Stubable`. +type Provider = MaybeCallableProvider & (T extends ReadonlyArray ? number extends T["length"] ? ArrayProvider : TupleProvider : { [K in Exclude>]: MethodOrProperty } & { + map(callback: (value: MapCallbackValue>) => MapCallbackReturn): Result>; +}); +export type RpcStub> = Stub; + +// @filename: main.ts +import type { RpcStub } from "./capnweb"; + +declare const api: RpcStub<{ sub(): Promise> }>; +export async function f() { + await api.sub(); + api.sub().then(s => s); +} diff --git a/tsc/testdata/tests/cases/compiler/varianceCycleDiscardedDiagnostics.ts b/tsc/testdata/tests/cases/compiler/varianceCycleDiscardedDiagnostics.ts new file mode 100644 index 0000000000000..9b61b16136fc2 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/varianceCycleDiscardedDiagnostics.ts @@ -0,0 +1,28 @@ +// @strict: true +// @target: es2022 +// @noEmit: true + +// Measuring the variances of Bar resolves the type of Value, which picks an +// overload by relating Foo to Foo while the variances of Bar are +// still being measured. Diagnostics from that attempt must not outlive it, +// and the result must not depend on whether Value or the variances of Bar +// are needed first. + +interface A { a: string } +interface B { foo: string } +declare function pick(x: Foo): A; +declare function pick(x: object): B; + +class Bar { + x!: T; + Value = pick(new Foo(this)).foo; +} + +class Foo { + bar!: Bar; + constructor(bar: Bar) { + this.bar = bar; + } +} + +const v: number = new Bar().Value; diff --git a/tsc/testdata/tests/cases/compiler/varianceCycleEnteredAfterCanonicalEntry.ts b/tsc/testdata/tests/cases/compiler/varianceCycleEnteredAfterCanonicalEntry.ts new file mode 100644 index 0000000000000..6ac9f01d74269 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/varianceCycleEnteredAfterCanonicalEntry.ts @@ -0,0 +1,32 @@ +// @strict: true +// @target: esnext +// @noEmit: true +// @checkOrder: default,typesfirst + +// Reduced from capnweb's RpcStub types (cloudflare-os). Measuring the variance +// of Stubify enters a circularity (Stubify -> Stub -> Provider -> +// MethodOrProperty -> Result -> RpcPromise -> Stubify) whose canonical entry is +// Stub, so the measurement from Stubify is discarded and the circularity +// measured again from Stub. The discarded measurement once ran to completion, +// which on the full types took long enough to exceed the instantiation limit. + +interface StubBase { + brand: T; +} +type Stub = T extends object ? Provider & StubBase : StubBase; +type Stubify = T extends StubBase ? T : T extends Function ? Stub : T; +type RpcPromise = Promise> & Provider & StubBase; +type Result = R extends StubBase ? Result : RpcPromise; +type MethodOrProperty = V extends (...args: infer P) => infer R ? (...args: P) => Result> : Result>; +type Provider = { [K in keyof T]: MethodOrProperty }; + +function f(x: Stubify, y: Stubify) { + y = x; + x = y; +} + +declare const api: Stub<{ sub(): Promise> }>; +export async function g() { + await api.sub(); + api.sub().then(s => s); +} diff --git a/tsc/testdata/tests/cases/compiler/varianceCycleEntryOrder.ts b/tsc/testdata/tests/cases/compiler/varianceCycleEntryOrder.ts new file mode 100644 index 0000000000000..e7d881c167dcf --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/varianceCycleEntryOrder.ts @@ -0,0 +1,32 @@ +// @strict: true +// @noEmit: true + +// Foo and Bar are both invariant: Foo through x and the contravariant +// use of Foo in Bar, and Bar through f and the invariant Foo>. +// Their variances should not depend on which is measured first. + +// @filename: fooFirst.ts +export {}; + +interface Foo { x: T; b: Bar> } +interface Bar { f: (u: U) => void; foo: Foo> } + +declare let fs: Foo, fl: Foo<"lit">; +declare let bs: Bar, bl: Bar<"lit">; +fl = fs; // Error +fs = fl; // Error +bl = bs; // Error +bs = bl; // Error + +// @filename: barFirst.ts +export {}; + +interface Foo { x: T; b: Bar> } +interface Bar { f: (u: U) => void; foo: Foo> } + +declare let fs: Foo, fl: Foo<"lit">; +declare let bs: Bar, bl: Bar<"lit">; +bl = bs; // Error +bs = bl; // Error +fl = fs; // Error +fs = fl; // Error diff --git a/tsc/testdata/tests/cases/compiler/varianceCycleRedoKeepsDiscardLog.ts b/tsc/testdata/tests/cases/compiler/varianceCycleRedoKeepsDiscardLog.ts new file mode 100644 index 0000000000000..201c3c562d110 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/varianceCycleRedoKeepsDiscardLog.ts @@ -0,0 +1,312 @@ +// @strict: true +// @module: node16 +// @noEmit: true + +// The types of DefinitelyTyped's json-logic-js (MIT license). Measuring the +// variances of the RulesLogic circularity again from its canonical entry +// re-enters measurements whose own circularities may still be discarded, so +// what is cached while it is re-entered must be logged, or a discarded +// measurement leaves results behind and `apply` rejects its argument. + +// @filename: json-logic-js.d.ts +export as namespace jsonFactory; + +// Disable auto-export +export {}; + +type RenameToIn = { + [K in keyof T as K extends `in${Uppercase}${Lowercase}` ? `in` : K]: T[K]; +}; + +/** + * This is a utility type used below for the "if" operation. + * Original: https://stackoverflow.com/a/68373774/765987 + */ +type MAXIMUM_ALLOWED_BOUNDARY = 80; +type Mapped< + Tuple extends unknown[], + Result extends unknown[] = [], + Count extends readonly number[] = [], +> = Count["length"] extends MAXIMUM_ALLOWED_BOUNDARY ? Result + : Tuple extends [] ? [] + : Result extends [] ? Mapped + : Mapped; +/** + * Used for the "if" operation, which takes an array of odd length + * and a minimum of three (3) elements. + */ +type AnyArrayOfOddLengthMin3 = [any, ...Mapped<[any, any]>]; + +export type ReservedOperations = + | "var" + | "missing" + | "missing_some" + | "if" + | "==" + | "===" + | "!=" + | "!==" + | "!" + | "!!" + | "or" + | "and" + | ">" + | ">=" + | "<" + | "<=" + | "max" + | "min" + | "+" + | "-" + | "*" + | "/" + | "%" + | "map" + | "filter" + | "reduce" + | "all" + | "none" + | "some" + | "merge" + | "in" + | "cat" + | "substr" + | "log"; + +/** + * This can be an object with any key except the reserved keys. + * TODO: Find a way to limit this type to exactly one (1) key, since + * json-logic-js enforces it. See: + * https://github.com/jwadhams/json-logic-js/blob/2.0.2/logic.js#L180 + */ +export type AdditionalOperation = Partial> & { [k: string]: any }; + +export interface AllReservedOperationsInterface { + var: RulesLogic | [RulesLogic] | [RulesLogic, any] | [RulesLogic, any]; + missing: RulesLogic | any[]; + missing_some: [RulesLogic, RulesLogic | any[]]; + if: AnyArrayOfOddLengthMin3; + "==": [any, any]; + "===": [any, any]; + "!=": [any, any]; + "!==": [any, any]; + "!": any; + "!!": any; + or: Array>; + and: Array>; + ">": [RulesLogic, RulesLogic]; + ">=": [RulesLogic, RulesLogic]; + "<": [RulesLogic, RulesLogic] | [RulesLogic, RulesLogic, RulesLogic]; + "<=": [RulesLogic, RulesLogic] | [RulesLogic, RulesLogic, RulesLogic]; + max: Array>; + min: Array>; + "+": Array> | RulesLogic; + "-": Array> | RulesLogic; + "*": Array> | RulesLogic; + "/": Array> | RulesLogic; + "%": [RulesLogic, RulesLogic]; + map: [RulesLogic, RulesLogic]; + filter: [RulesLogic, RulesLogic]; + reduce: [RulesLogic, RulesLogic, RulesLogic]; + all: [Array>, RulesLogic] | [RulesLogic, RulesLogic]; + none: [Array>, RulesLogic] | [RulesLogic, RulesLogic]; + some: [Array>, RulesLogic] | [RulesLogic, RulesLogic]; + merge: Array> | RulesLogic>; + inArray: [RulesLogic, Array>]; + inString: [RulesLogic, RulesLogic]; + cat: Array>; + substr: [RulesLogic, RulesLogic] | [RulesLogic, RulesLogic, RulesLogic]; + log: RulesLogic; +} + +export type JsonLogicVar = Pick< + AllReservedOperationsInterface, + "var" +>; +export type JsonLogicMissing = Pick< + AllReservedOperationsInterface, + "missing" +>; +export type JsonLogicMissingSome = Pick< + AllReservedOperationsInterface, + "missing_some" +>; +export type JsonLogicIf = Pick; +export type JsonLogicEqual = Pick; +export type JsonLogicStrictEqual = Pick; +export type JsonLogicNotEqual = Pick; +export type JsonLogicNegation = Pick; +export type JsonLogicDoubleNegation = Pick; +export type JsonLogicOr = Pick< + AllReservedOperationsInterface, + "or" +>; +export type JsonLogicAnd = Pick< + AllReservedOperationsInterface, + "and" +>; +export type JsonLogicGreaterThan = Pick< + AllReservedOperationsInterface, + ">" +>; +export type JsonLogicGreaterThanOrEqual = Pick< + AllReservedOperationsInterface, + ">=" +>; +export type JsonLogicLessThan = Pick< + AllReservedOperationsInterface, + "<" +>; +export type JsonLogicLessThanOrEqual = Pick< + AllReservedOperationsInterface, + "<=" +>; +export type JsonLogicMax = Pick< + AllReservedOperationsInterface, + "max" +>; +export type JsonLogicMin = Pick< + AllReservedOperationsInterface, + "min" +>; +export type JsonLogicSum = Pick< + AllReservedOperationsInterface, + "+" +>; +export type JsonLogicDifference = Pick< + AllReservedOperationsInterface, + "-" +>; +export type JsonLogicProduct = Pick< + AllReservedOperationsInterface, + "*" +>; +export type JsonLogicQuotient = Pick< + AllReservedOperationsInterface, + "/" +>; +export type JsonLogicRemainder = Pick< + AllReservedOperationsInterface, + "%" +>; +export type JsonLogicMap = Pick< + AllReservedOperationsInterface, + "map" +>; +export type JsonLogicFilter = Pick< + AllReservedOperationsInterface, + "filter" +>; +export type JsonLogicReduce = Pick< + AllReservedOperationsInterface, + "reduce" +>; +export type JsonLogicAll = Pick< + AllReservedOperationsInterface, + "all" +>; +export type JsonLogicNone = Pick< + AllReservedOperationsInterface, + "none" +>; +export type JsonLogicSome = Pick< + AllReservedOperationsInterface, + "some" +>; +export type JsonLogicMerge = Pick< + AllReservedOperationsInterface, + "merge" +>; +export type JsonLogicInArray = RenameToIn< + Pick, "inArray"> +>; +export type JsonLogicInString = RenameToIn< + Pick, "inString"> +>; +export type JsonLogicCat = Pick< + AllReservedOperationsInterface, + "cat" +>; +export type JsonLogicSubstr = Pick< + AllReservedOperationsInterface, + "substr" +>; +export type JsonLogicLog = Pick< + AllReservedOperationsInterface, + "log" +>; + +export type RulesLogic = + | boolean + | string + | number + | null + // Accessing Data - https://jsonlogic.com/operations.html#accessing-data + | JsonLogicVar + | JsonLogicMissing + | JsonLogicMissingSome + // Logic and Boolean Operations - https://jsonlogic.com/operations.html#logic-and-boolean-operations + | JsonLogicIf + | JsonLogicEqual + | JsonLogicStrictEqual + | JsonLogicNotEqual + | JsonLogicStrictNotEqual + | JsonLogicNegation + | JsonLogicDoubleNegation + | JsonLogicOr + | JsonLogicAnd + // Numeric Operations - https://jsonlogic.com/operations.html#numeric-operations + | JsonLogicGreaterThan + | JsonLogicGreaterThanOrEqual + | JsonLogicLessThan + | JsonLogicLessThanOrEqual + | JsonLogicMax + | JsonLogicMin + | JsonLogicSum + | JsonLogicDifference + | JsonLogicProduct + | JsonLogicQuotient + | JsonLogicRemainder + // Array Operations - https://jsonlogic.com/operations.html#array-operations + | JsonLogicMap + | JsonLogicFilter + | JsonLogicReduce + | JsonLogicAll + | JsonLogicNone + | JsonLogicSome + | JsonLogicMerge + | JsonLogicInArray + // String Operations - https://jsonlogic.com/operations.html#string-operations + | JsonLogicInString + | JsonLogicCat + | JsonLogicSubstr + // Miscellaneous - https://jsonlogic.com/operations.html#miscellaneous + | JsonLogicLog + // Adding Operations (https://jsonlogic.com/add_operation.html) + | AddOps; + +export function add_operation(name: string, code: (...args: any[]) => any): void; +export function apply(logic: RulesLogic, data?: unknown): any; +export function rm_operation(name: string): void; + +// These functions are undocumented, but are exported by the real package +// so they're typed here for completeness. +export function is_logic(logic: any): logic is RulesLogic; +export function truthy(value: any): boolean; +export function get_operator(logic: Record): string; +export function get_values(logic: Record): any; +export function uses_data(logic: Record): any[]; +export function rule_like(rule: any, pattern: any): boolean; + +// @filename: main.ts +import * as jsonLogic from "./json-logic-js"; + +type StartsWithAndEndsWith = + | { startsWith: [JsonLogicWithAdditionalOperations, JsonLogicWithAdditionalOperations] } + | { endsWith: [JsonLogicWithAdditionalOperations, JsonLogicWithAdditionalOperations] }; +type JsonLogicWithAdditionalOperations = jsonLogic.RulesLogic; +const jsonExtendedLogic: JsonLogicWithAdditionalOperations = { + and: [{ startsWith: ["Springfield", "Spring"] }, { endsWith: ["Springfield", "field"] }], +}; +jsonLogic.apply(jsonExtendedLogic); diff --git a/tsc/testdata/tests/cases/compiler/varianceCycleStructuralFallback.ts b/tsc/testdata/tests/cases/compiler/varianceCycleStructuralFallback.ts new file mode 100644 index 0000000000000..e3d0f7deff7f5 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/varianceCycleStructuralFallback.ts @@ -0,0 +1,33 @@ +// @strict: true +// @noEmit: true + +// The -? mapped type makes the variance of MA unmeasurable, so comparisons +// of instantiations of MA made while measuring the variances of MA and MB +// fall back to structural comparisons. The variances should not depend on +// which type is measured first. + +// @filename: maFirst.ts +export {}; + +type MA = { x: { [K in keyof T]-?: T[K] }; b: MB> }; +type MB = { f: (u: U) => void; a: MA> }; + +declare let as: MA<{ p: string }>, al: MA<{ p: "lit" }>; +declare let bs: MB<{ p: string }>, bl: MB<{ p: "lit" }>; +al = as; +as = al; +bl = bs; +bs = bl; + +// @filename: mbFirst.ts +export {}; + +type MA = { x: { [K in keyof T]-?: T[K] }; b: MB> }; +type MB = { f: (u: U) => void; a: MA> }; + +declare let as: MA<{ p: string }>, al: MA<{ p: "lit" }>; +declare let bs: MB<{ p: string }>, bl: MB<{ p: "lit" }>; +bl = bs; +bs = bl; +al = as; +as = al; diff --git a/tsc/testdata/tests/cases/compiler/varianceDeclarationOrder.ts b/tsc/testdata/tests/cases/compiler/varianceDeclarationOrder.ts new file mode 100644 index 0000000000000..077b736ce3fb4 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/varianceDeclarationOrder.ts @@ -0,0 +1,30 @@ +// @strict: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/64891 +// The variances of DS must not depend on whether Ref, which mentions DS, +// is declared first. + +// @filename: refFirst.ts +type M = { kind: "m" }; +type Filtered = { [K in keyof T as T[K] extends M ? K : never]: T[K] }; +interface Config { measure: keyof T } +interface Ref { dataset: DS, N> } +interface DS { + a(config: Config>): void; + b: Ref; +} +declare const x: DS<{ total: M }, string>; +export const y: DS, string> = x; + +// @filename: dsFirst.ts +type M = { kind: "m" }; +type Filtered = { [K in keyof T as T[K] extends M ? K : never]: T[K] }; +interface Config { measure: keyof T } +interface DS { + a(config: Config>): void; + b: Ref; +} +interface Ref { dataset: DS, N> } +declare const x: DS<{ total: M }, string>; +export const y: DS, string> = x; diff --git a/tsc/testdata/tests/cases/compiler/varianceMeasuredWithinCircularity.ts b/tsc/testdata/tests/cases/compiler/varianceMeasuredWithinCircularity.ts new file mode 100644 index 0000000000000..712ee43f4f782 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/varianceMeasuredWithinCircularity.ts @@ -0,0 +1,30 @@ +// @strict: true +// @noEmit: true + +// The variances of Selection and TransitionLike depend on each other. +// The callback of `data` requires Selection to be covariant in P, while +// `join` passes Selection to a callback, which then requires it to +// be contravariant in P, so Selection is invariant in P. TransitionLike +// reaches P of a Selection through `selection().children()`, so it is +// invariant in G. Both must hold whichever variance is measured first. + +export {}; + +interface Base { base: string } +interface Derived extends Base { derived: string } + +interface Selection { + data(key: (parent: P) => string): Selection; + join(enter: string | ((elem: Selection) => Selection | TransitionLike)): Selection; + children(): Selection; +} + +interface TransitionLike { + selection(): Selection; +} + +declare let s1: Selection; +let s2: Selection = s1; + +declare let t1: TransitionLike; +let t2: TransitionLike = t1; diff --git a/tsc/testdata/tests/cases/compiler/varianceSupersededMeasurementKeepsOtherComparisons.ts b/tsc/testdata/tests/cases/compiler/varianceSupersededMeasurementKeepsOtherComparisons.ts new file mode 100644 index 0000000000000..c17ed38541bc4 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/varianceSupersededMeasurementKeepsOtherComparisons.ts @@ -0,0 +1,21 @@ +// @strict: true +// @noEmit: true +// @checkOrder: default,typesfirst + +// Reduced from zod v4 with LangGraph's `register` augmentation +// (langchain-ai/openwiki). Measuring the variance of B reaches A, which is +// smaller, so the measurement is superseded and measured again from A. While +// it finishes, comparing the parameters of `m` re-enters B, and its return +// type resolves `Check>`, whose comparison is not part of the +// measurement. It must still compare as it would from scratch, as the +// resolved conditional type is kept. + +declare let b1: B; +declare let b2: B<"s">; +b1 = b2; + +interface A { m(x: B): Check>; } +interface B { a: A; } +type Check = U extends { a: unknown } ? "yes" : "no"; + +const v: Check> = "yes"; diff --git a/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameNestedClassFieldShadowing.ts b/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameNestedClassFieldShadowing.ts index 45e3ab2f45218..598881ff0189c 100644 --- a/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameNestedClassFieldShadowing.ts +++ b/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameNestedClassFieldShadowing.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @strict: false // @target: es2015 diff --git a/tsc/testdata/tests/cases/conformance/controlFlow/dependentDestructuredVariablesReferenceInDeclaration1.ts b/tsc/testdata/tests/cases/conformance/controlFlow/dependentDestructuredVariablesReferenceInDeclaration1.ts index d72cb1553711e..d3f2b2d3c8455 100644 --- a/tsc/testdata/tests/cases/conformance/controlFlow/dependentDestructuredVariablesReferenceInDeclaration1.ts +++ b/tsc/testdata/tests/cases/conformance/controlFlow/dependentDestructuredVariablesReferenceInDeclaration1.ts @@ -1,6 +1,7 @@ // @strict: true // @target: esnext // @noEmit: true +// @checkOrder: default, typesfirst // https://github.com/microsoft/TypeScript/issues/62993 diff --git a/tsc/testdata/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts b/tsc/testdata/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts index 613a3966e161f..ff48d5a86f727 100644 --- a/tsc/testdata/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts +++ b/tsc/testdata/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 // @strict: false // (arg: { x: any, y: any }) => void diff --git a/tsc/testdata/tests/cases/conformance/jsdoc/importTag13.ts b/tsc/testdata/tests/cases/conformance/jsdoc/importTag13.ts index 7ad42b8c9fee2..d811998b4c3c5 100644 --- a/tsc/testdata/tests/cases/conformance/jsdoc/importTag13.ts +++ b/tsc/testdata/tests/cases/conformance/jsdoc/importTag13.ts @@ -1,3 +1,4 @@ +// @checkOrder: default, typesfirst // @target: es2015 // @checkJs: true // @allowJs: true

+ +interface VisitObj {} +declare class NodePath { +>NodePath : NodePath + + parentPath: NodePath>; +>parentPath : NodePath> + + get: Get; +>get : Get +} +type Get = T extends Array ? Array> : never; +>Get : Get + diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=false).errors.txt b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=false).errors.txt new file mode 100644 index 0000000000000..a1514a254b857 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=false).errors.txt @@ -0,0 +1,47 @@ +deleteExpressionMustBeOptional.ts(34,10): error TS2339: Property 'j' does not exist on type 'Foo'. + + +==== deleteExpressionMustBeOptional.ts (1 errors) ==== + interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never + } + + interface AA { + [s: string]: number + } + + type BB = { + [P in keyof any]: number + } + + declare const f: Foo + declare const a: AA + declare const b: BB + + delete f.a + delete f.b + delete f.c + delete f.d + delete f.e + delete f.f + delete f.g + delete f.h + delete f.i + delete f.j + ~ +!!! error TS2339: Property 'j' does not exist on type 'Foo'. + + delete a.a + delete a.b + + delete b.a + delete b.b + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=false).js b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=false).js new file mode 100644 index 0000000000000..262eac63738f9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=false).js @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/deleteExpressionMustBeOptional.ts] //// + +//// [deleteExpressionMustBeOptional.ts] +interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never +} + +interface AA { + [s: string]: number +} + +type BB = { + [P in keyof any]: number +} + +declare const f: Foo +declare const a: AA +declare const b: BB + +delete f.a +delete f.b +delete f.c +delete f.d +delete f.e +delete f.f +delete f.g +delete f.h +delete f.i +delete f.j + +delete a.a +delete a.b + +delete b.a +delete b.b + + +//// [deleteExpressionMustBeOptional.js] +"use strict"; +delete f.a; +delete f.b; +delete f.c; +delete f.d; +delete f.e; +delete f.f; +delete f.g; +delete f.h; +delete f.i; +delete f.j; +delete a.a; +delete a.b; +delete b.a; +delete b.b; diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=false).symbols b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=false).symbols new file mode 100644 index 0000000000000..9182dec2bc43d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=false).symbols @@ -0,0 +1,124 @@ +//// [tests/cases/compiler/deleteExpressionMustBeOptional.ts] //// + +=== deleteExpressionMustBeOptional.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + + a: number +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + + b: number | undefined +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + + c: number | null +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + + d?: number +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + + e: number | undefined | null +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + + f?: number | undefined | null +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + + g: unknown +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + + h: any +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + + i: never +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +} + +interface AA { +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + + [s: string]: number +>s : Symbol(s, Decl(deleteExpressionMustBeOptional.ts, 13, 5)) +} + +type BB = { +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + + [P in keyof any]: number +>P : Symbol(P, Decl(deleteExpressionMustBeOptional.ts, 17, 5)) +} + +declare const f: Foo +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + +declare const a: AA +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + +declare const b: BB +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + +delete f.a +>f.a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + +delete f.b +>f.b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + +delete f.c +>f.c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + +delete f.d +>f.d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + +delete f.e +>f.e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + +delete f.f +>f.f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + +delete f.g +>f.g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + +delete f.h +>f.h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + +delete f.i +>f.i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) + +delete f.j +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) + +delete a.a +>a.a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) + +delete a.b +>a.b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) + +delete b.a +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + +delete b.b +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=false).types b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=false).types new file mode 100644 index 0000000000000..3c0777475c7fc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=false).types @@ -0,0 +1,136 @@ +//// [tests/cases/compiler/deleteExpressionMustBeOptional.ts] //// + +=== deleteExpressionMustBeOptional.ts === +interface Foo { + a: number +>a : number + + b: number | undefined +>b : number + + c: number | null +>c : number + + d?: number +>d : number + + e: number | undefined | null +>e : number + + f?: number | undefined | null +>f : number + + g: unknown +>g : unknown + + h: any +>h : any + + i: never +>i : never +} + +interface AA { + [s: string]: number +>s : string +} + +type BB = { +>BB : BB + + [P in keyof any]: number +} + +declare const f: Foo +>f : Foo + +declare const a: AA +>a : AA + +declare const b: BB +>b : BB + +delete f.a +>delete f.a : boolean +>f.a : number +>f : Foo +>a : number + +delete f.b +>delete f.b : boolean +>f.b : number +>f : Foo +>b : number + +delete f.c +>delete f.c : boolean +>f.c : number +>f : Foo +>c : number + +delete f.d +>delete f.d : boolean +>f.d : number +>f : Foo +>d : number + +delete f.e +>delete f.e : boolean +>f.e : number +>f : Foo +>e : number + +delete f.f +>delete f.f : boolean +>f.f : number +>f : Foo +>f : number + +delete f.g +>delete f.g : boolean +>f.g : unknown +>f : Foo +>g : unknown + +delete f.h +>delete f.h : boolean +>f.h : any +>f : Foo +>h : any + +delete f.i +>delete f.i : boolean +>f.i : never +>f : Foo +>i : never + +delete f.j +>delete f.j : boolean +>f.j : any +>f : Foo +>j : any + +delete a.a +>delete a.a : boolean +>a.a : number +>a : AA +>a : number + +delete a.b +>delete a.b : boolean +>a.b : number +>a : AA +>b : number + +delete b.a +>delete b.a : boolean +>b.a : number +>b : BB +>a : number + +delete b.b +>delete b.b : boolean +>b.b : number +>b : BB +>b : number + diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=true).errors.txt b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=true).errors.txt new file mode 100644 index 0000000000000..f3abcf0386f5b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=true).errors.txt @@ -0,0 +1,53 @@ +deleteExpressionMustBeOptional.ts(25,8): error TS2790: The operand of a 'delete' operator must be optional. +deleteExpressionMustBeOptional.ts(27,8): error TS2790: The operand of a 'delete' operator must be optional. +deleteExpressionMustBeOptional.ts(34,10): error TS2339: Property 'j' does not exist on type 'Foo'. + + +==== deleteExpressionMustBeOptional.ts (3 errors) ==== + interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never + } + + interface AA { + [s: string]: number + } + + type BB = { + [P in keyof any]: number + } + + declare const f: Foo + declare const a: AA + declare const b: BB + + delete f.a + ~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete f.b + delete f.c + ~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete f.d + delete f.e + delete f.f + delete f.g + delete f.h + delete f.i + delete f.j + ~ +!!! error TS2339: Property 'j' does not exist on type 'Foo'. + + delete a.a + delete a.b + + delete b.a + delete b.b + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=true).js b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=true).js new file mode 100644 index 0000000000000..262eac63738f9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=true).js @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/deleteExpressionMustBeOptional.ts] //// + +//// [deleteExpressionMustBeOptional.ts] +interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never +} + +interface AA { + [s: string]: number +} + +type BB = { + [P in keyof any]: number +} + +declare const f: Foo +declare const a: AA +declare const b: BB + +delete f.a +delete f.b +delete f.c +delete f.d +delete f.e +delete f.f +delete f.g +delete f.h +delete f.i +delete f.j + +delete a.a +delete a.b + +delete b.a +delete b.b + + +//// [deleteExpressionMustBeOptional.js] +"use strict"; +delete f.a; +delete f.b; +delete f.c; +delete f.d; +delete f.e; +delete f.f; +delete f.g; +delete f.h; +delete f.i; +delete f.j; +delete a.a; +delete a.b; +delete b.a; +delete b.b; diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=true).symbols b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=true).symbols new file mode 100644 index 0000000000000..9182dec2bc43d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=true).symbols @@ -0,0 +1,124 @@ +//// [tests/cases/compiler/deleteExpressionMustBeOptional.ts] //// + +=== deleteExpressionMustBeOptional.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + + a: number +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + + b: number | undefined +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + + c: number | null +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + + d?: number +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + + e: number | undefined | null +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + + f?: number | undefined | null +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + + g: unknown +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + + h: any +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + + i: never +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +} + +interface AA { +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + + [s: string]: number +>s : Symbol(s, Decl(deleteExpressionMustBeOptional.ts, 13, 5)) +} + +type BB = { +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + + [P in keyof any]: number +>P : Symbol(P, Decl(deleteExpressionMustBeOptional.ts, 17, 5)) +} + +declare const f: Foo +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + +declare const a: AA +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + +declare const b: BB +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + +delete f.a +>f.a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + +delete f.b +>f.b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + +delete f.c +>f.c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + +delete f.d +>f.d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + +delete f.e +>f.e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + +delete f.f +>f.f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + +delete f.g +>f.g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + +delete f.h +>f.h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + +delete f.i +>f.i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) + +delete f.j +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) + +delete a.a +>a.a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) + +delete a.b +>a.b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) + +delete b.a +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + +delete b.b +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=true).types b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=true).types new file mode 100644 index 0000000000000..9a17de9e03b2e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=default,strict=true).types @@ -0,0 +1,136 @@ +//// [tests/cases/compiler/deleteExpressionMustBeOptional.ts] //// + +=== deleteExpressionMustBeOptional.ts === +interface Foo { + a: number +>a : number + + b: number | undefined +>b : number | undefined + + c: number | null +>c : number | null + + d?: number +>d : number | undefined + + e: number | undefined | null +>e : number | null | undefined + + f?: number | undefined | null +>f : number | null | undefined + + g: unknown +>g : unknown + + h: any +>h : any + + i: never +>i : never +} + +interface AA { + [s: string]: number +>s : string +} + +type BB = { +>BB : BB + + [P in keyof any]: number +} + +declare const f: Foo +>f : Foo + +declare const a: AA +>a : AA + +declare const b: BB +>b : BB + +delete f.a +>delete f.a : boolean +>f.a : number +>f : Foo +>a : number + +delete f.b +>delete f.b : boolean +>f.b : number | undefined +>f : Foo +>b : number | undefined + +delete f.c +>delete f.c : boolean +>f.c : number | null +>f : Foo +>c : number | null + +delete f.d +>delete f.d : boolean +>f.d : number | undefined +>f : Foo +>d : number | undefined + +delete f.e +>delete f.e : boolean +>f.e : number | null | undefined +>f : Foo +>e : number | null | undefined + +delete f.f +>delete f.f : boolean +>f.f : number | null | undefined +>f : Foo +>f : number | null | undefined + +delete f.g +>delete f.g : boolean +>f.g : unknown +>f : Foo +>g : unknown + +delete f.h +>delete f.h : boolean +>f.h : any +>f : Foo +>h : any + +delete f.i +>delete f.i : boolean +>f.i : never +>f : Foo +>i : never + +delete f.j +>delete f.j : boolean +>f.j : any +>f : Foo +>j : any + +delete a.a +>delete a.a : boolean +>a.a : number +>a : AA +>a : number + +delete a.b +>delete a.b : boolean +>a.b : number +>a : AA +>b : number + +delete b.a +>delete b.a : boolean +>b.a : number +>b : BB +>a : number + +delete b.b +>delete b.b : boolean +>b.b : number +>b : BB +>b : number + diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=false).errors.txt b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=false).errors.txt new file mode 100644 index 0000000000000..a1514a254b857 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=false).errors.txt @@ -0,0 +1,47 @@ +deleteExpressionMustBeOptional.ts(34,10): error TS2339: Property 'j' does not exist on type 'Foo'. + + +==== deleteExpressionMustBeOptional.ts (1 errors) ==== + interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never + } + + interface AA { + [s: string]: number + } + + type BB = { + [P in keyof any]: number + } + + declare const f: Foo + declare const a: AA + declare const b: BB + + delete f.a + delete f.b + delete f.c + delete f.d + delete f.e + delete f.f + delete f.g + delete f.h + delete f.i + delete f.j + ~ +!!! error TS2339: Property 'j' does not exist on type 'Foo'. + + delete a.a + delete a.b + + delete b.a + delete b.b + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=false).js b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=false).js new file mode 100644 index 0000000000000..262eac63738f9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=false).js @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/deleteExpressionMustBeOptional.ts] //// + +//// [deleteExpressionMustBeOptional.ts] +interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never +} + +interface AA { + [s: string]: number +} + +type BB = { + [P in keyof any]: number +} + +declare const f: Foo +declare const a: AA +declare const b: BB + +delete f.a +delete f.b +delete f.c +delete f.d +delete f.e +delete f.f +delete f.g +delete f.h +delete f.i +delete f.j + +delete a.a +delete a.b + +delete b.a +delete b.b + + +//// [deleteExpressionMustBeOptional.js] +"use strict"; +delete f.a; +delete f.b; +delete f.c; +delete f.d; +delete f.e; +delete f.f; +delete f.g; +delete f.h; +delete f.i; +delete f.j; +delete a.a; +delete a.b; +delete b.a; +delete b.b; diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=false).symbols b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=false).symbols new file mode 100644 index 0000000000000..9182dec2bc43d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=false).symbols @@ -0,0 +1,124 @@ +//// [tests/cases/compiler/deleteExpressionMustBeOptional.ts] //// + +=== deleteExpressionMustBeOptional.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + + a: number +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + + b: number | undefined +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + + c: number | null +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + + d?: number +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + + e: number | undefined | null +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + + f?: number | undefined | null +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + + g: unknown +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + + h: any +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + + i: never +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +} + +interface AA { +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + + [s: string]: number +>s : Symbol(s, Decl(deleteExpressionMustBeOptional.ts, 13, 5)) +} + +type BB = { +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + + [P in keyof any]: number +>P : Symbol(P, Decl(deleteExpressionMustBeOptional.ts, 17, 5)) +} + +declare const f: Foo +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + +declare const a: AA +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + +declare const b: BB +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + +delete f.a +>f.a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + +delete f.b +>f.b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + +delete f.c +>f.c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + +delete f.d +>f.d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + +delete f.e +>f.e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + +delete f.f +>f.f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + +delete f.g +>f.g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + +delete f.h +>f.h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + +delete f.i +>f.i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) + +delete f.j +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) + +delete a.a +>a.a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) + +delete a.b +>a.b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) + +delete b.a +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + +delete b.b +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=false).types b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=false).types new file mode 100644 index 0000000000000..3c0777475c7fc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=false).types @@ -0,0 +1,136 @@ +//// [tests/cases/compiler/deleteExpressionMustBeOptional.ts] //// + +=== deleteExpressionMustBeOptional.ts === +interface Foo { + a: number +>a : number + + b: number | undefined +>b : number + + c: number | null +>c : number + + d?: number +>d : number + + e: number | undefined | null +>e : number + + f?: number | undefined | null +>f : number + + g: unknown +>g : unknown + + h: any +>h : any + + i: never +>i : never +} + +interface AA { + [s: string]: number +>s : string +} + +type BB = { +>BB : BB + + [P in keyof any]: number +} + +declare const f: Foo +>f : Foo + +declare const a: AA +>a : AA + +declare const b: BB +>b : BB + +delete f.a +>delete f.a : boolean +>f.a : number +>f : Foo +>a : number + +delete f.b +>delete f.b : boolean +>f.b : number +>f : Foo +>b : number + +delete f.c +>delete f.c : boolean +>f.c : number +>f : Foo +>c : number + +delete f.d +>delete f.d : boolean +>f.d : number +>f : Foo +>d : number + +delete f.e +>delete f.e : boolean +>f.e : number +>f : Foo +>e : number + +delete f.f +>delete f.f : boolean +>f.f : number +>f : Foo +>f : number + +delete f.g +>delete f.g : boolean +>f.g : unknown +>f : Foo +>g : unknown + +delete f.h +>delete f.h : boolean +>f.h : any +>f : Foo +>h : any + +delete f.i +>delete f.i : boolean +>f.i : never +>f : Foo +>i : never + +delete f.j +>delete f.j : boolean +>f.j : any +>f : Foo +>j : any + +delete a.a +>delete a.a : boolean +>a.a : number +>a : AA +>a : number + +delete a.b +>delete a.b : boolean +>a.b : number +>a : AA +>b : number + +delete b.a +>delete b.a : boolean +>b.a : number +>b : BB +>a : number + +delete b.b +>delete b.b : boolean +>b.b : number +>b : BB +>b : number + diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=true).errors.txt b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=true).errors.txt new file mode 100644 index 0000000000000..d3c1fd53cc93f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=true).errors.txt @@ -0,0 +1,59 @@ +deleteExpressionMustBeOptional.ts(25,8): error TS2790: The operand of a 'delete' operator must be optional. +deleteExpressionMustBeOptional.ts(27,8): error TS2790: The operand of a 'delete' operator must be optional. +deleteExpressionMustBeOptional.ts(34,10): error TS2339: Property 'j' does not exist on type 'Foo'. +deleteExpressionMustBeOptional.ts(36,8): error TS2790: The operand of a 'delete' operator must be optional. +deleteExpressionMustBeOptional.ts(37,8): error TS2790: The operand of a 'delete' operator must be optional. + + +==== deleteExpressionMustBeOptional.ts (5 errors) ==== + interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never + } + + interface AA { + [s: string]: number + } + + type BB = { + [P in keyof any]: number + } + + declare const f: Foo + declare const a: AA + declare const b: BB + + delete f.a + ~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete f.b + delete f.c + ~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete f.d + delete f.e + delete f.f + delete f.g + delete f.h + delete f.i + delete f.j + ~ +!!! error TS2339: Property 'j' does not exist on type 'Foo'. + + delete a.a + ~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete a.b + ~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + + delete b.a + delete b.b + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=true).js b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=true).js new file mode 100644 index 0000000000000..262eac63738f9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=true).js @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/deleteExpressionMustBeOptional.ts] //// + +//// [deleteExpressionMustBeOptional.ts] +interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never +} + +interface AA { + [s: string]: number +} + +type BB = { + [P in keyof any]: number +} + +declare const f: Foo +declare const a: AA +declare const b: BB + +delete f.a +delete f.b +delete f.c +delete f.d +delete f.e +delete f.f +delete f.g +delete f.h +delete f.i +delete f.j + +delete a.a +delete a.b + +delete b.a +delete b.b + + +//// [deleteExpressionMustBeOptional.js] +"use strict"; +delete f.a; +delete f.b; +delete f.c; +delete f.d; +delete f.e; +delete f.f; +delete f.g; +delete f.h; +delete f.i; +delete f.j; +delete a.a; +delete a.b; +delete b.a; +delete b.b; diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=true).symbols b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=true).symbols new file mode 100644 index 0000000000000..9182dec2bc43d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=true).symbols @@ -0,0 +1,124 @@ +//// [tests/cases/compiler/deleteExpressionMustBeOptional.ts] //// + +=== deleteExpressionMustBeOptional.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + + a: number +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + + b: number | undefined +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + + c: number | null +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + + d?: number +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + + e: number | undefined | null +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + + f?: number | undefined | null +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + + g: unknown +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + + h: any +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + + i: never +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +} + +interface AA { +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + + [s: string]: number +>s : Symbol(s, Decl(deleteExpressionMustBeOptional.ts, 13, 5)) +} + +type BB = { +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + + [P in keyof any]: number +>P : Symbol(P, Decl(deleteExpressionMustBeOptional.ts, 17, 5)) +} + +declare const f: Foo +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + +declare const a: AA +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + +declare const b: BB +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + +delete f.a +>f.a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + +delete f.b +>f.b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + +delete f.c +>f.c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + +delete f.d +>f.d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + +delete f.e +>f.e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + +delete f.f +>f.f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + +delete f.g +>f.g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + +delete f.h +>f.h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + +delete f.i +>f.i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) + +delete f.j +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) + +delete a.a +>a.a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>a : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) + +delete a.b +>a.b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>b : Symbol(AA.__index, Decl(deleteExpressionMustBeOptional.ts, 12, 14)) + +delete b.a +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + +delete b.b +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=true).types b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=true).types new file mode 100644 index 0000000000000..9a17de9e03b2e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/deleteExpressionMustBeOptional(checkorder=typesfirst,strict=true).types @@ -0,0 +1,136 @@ +//// [tests/cases/compiler/deleteExpressionMustBeOptional.ts] //// + +=== deleteExpressionMustBeOptional.ts === +interface Foo { + a: number +>a : number + + b: number | undefined +>b : number | undefined + + c: number | null +>c : number | null + + d?: number +>d : number | undefined + + e: number | undefined | null +>e : number | null | undefined + + f?: number | undefined | null +>f : number | null | undefined + + g: unknown +>g : unknown + + h: any +>h : any + + i: never +>i : never +} + +interface AA { + [s: string]: number +>s : string +} + +type BB = { +>BB : BB + + [P in keyof any]: number +} + +declare const f: Foo +>f : Foo + +declare const a: AA +>a : AA + +declare const b: BB +>b : BB + +delete f.a +>delete f.a : boolean +>f.a : number +>f : Foo +>a : number + +delete f.b +>delete f.b : boolean +>f.b : number | undefined +>f : Foo +>b : number | undefined + +delete f.c +>delete f.c : boolean +>f.c : number | null +>f : Foo +>c : number | null + +delete f.d +>delete f.d : boolean +>f.d : number | undefined +>f : Foo +>d : number | undefined + +delete f.e +>delete f.e : boolean +>f.e : number | null | undefined +>f : Foo +>e : number | null | undefined + +delete f.f +>delete f.f : boolean +>f.f : number | null | undefined +>f : Foo +>f : number | null | undefined + +delete f.g +>delete f.g : boolean +>f.g : unknown +>f : Foo +>g : unknown + +delete f.h +>delete f.h : boolean +>f.h : any +>f : Foo +>h : any + +delete f.i +>delete f.i : boolean +>f.i : never +>f : Foo +>i : never + +delete f.j +>delete f.j : boolean +>f.j : any +>f : Foo +>j : any + +delete a.a +>delete a.a : boolean +>a.a : number +>a : AA +>a : number + +delete a.b +>delete a.b : boolean +>a.b : number +>a : AA +>b : number + +delete b.a +>delete b.a : boolean +>b.a : number +>b : BB +>a : number + +delete b.b +>delete b.b : boolean +>b.b : number +>b : BB +>b : number + diff --git a/tsc/testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer(checkorder=default).symbols new file mode 100644 index 0000000000000..0aaf38011344f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer(checkorder=default).symbols @@ -0,0 +1,62 @@ +//// [tests/cases/compiler/dependentDestructuringBindingElementInitializer.ts] //// + +=== dependentDestructuringBindingElementInitializer.ts === +type U = +>U : Symbol(U, Decl(dependentDestructuringBindingElementInitializer.ts, 0, 0)) + + | { kind: "a"; payload: number; extra?: unknown } +>kind : Symbol(kind, Decl(dependentDestructuringBindingElementInitializer.ts, 1, 7)) +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 1, 18)) +>extra : Symbol(extra, Decl(dependentDestructuringBindingElementInitializer.ts, 1, 35)) + + | { kind: "b"; payload: string; extra?: unknown }; +>kind : Symbol(kind, Decl(dependentDestructuringBindingElementInitializer.ts, 2, 7)) +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 2, 18)) +>extra : Symbol(extra, Decl(dependentDestructuringBindingElementInitializer.ts, 2, 35)) + +declare const u: U; +>u : Symbol(u, Decl(dependentDestructuringBindingElementInitializer.ts, 4, 13)) +>U : Symbol(U, Decl(dependentDestructuringBindingElementInitializer.ts, 0, 0)) + +const { + kind, +>kind : Symbol(kind, Decl(dependentDestructuringBindingElementInitializer.ts, 6, 7)) + + payload, +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 7, 9)) + + extra = kind === "a" ? payload.toFixed() : payload.toUpperCase(), +>extra : Symbol(extra, Decl(dependentDestructuringBindingElementInitializer.ts, 8, 12)) +>kind : Symbol(kind, Decl(dependentDestructuringBindingElementInitializer.ts, 6, 7)) +>payload.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 7, 9)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>payload.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 7, 9)) +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) + +} = u; +>u : Symbol(u, Decl(dependentDestructuringBindingElementInitializer.ts, 4, 13)) + +function f({ +>f : Symbol(f, Decl(dependentDestructuringBindingElementInitializer.ts, 10, 6)) + + kind, +>kind : Symbol(kind, Decl(dependentDestructuringBindingElementInitializer.ts, 12, 12)) + + payload, +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 13, 9)) + + extra = kind === "a" ? payload.toFixed() : payload.toUpperCase(), +>extra : Symbol(extra, Decl(dependentDestructuringBindingElementInitializer.ts, 14, 12)) +>kind : Symbol(kind, Decl(dependentDestructuringBindingElementInitializer.ts, 12, 12)) +>payload.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 13, 9)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>payload.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 13, 9)) +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) + +}: U) {} +>U : Symbol(U, Decl(dependentDestructuringBindingElementInitializer.ts, 0, 0)) + diff --git a/tsc/testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer(checkorder=default).types new file mode 100644 index 0000000000000..0dcd3d8a64cef --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer(checkorder=default).types @@ -0,0 +1,70 @@ +//// [tests/cases/compiler/dependentDestructuringBindingElementInitializer.ts] //// + +=== dependentDestructuringBindingElementInitializer.ts === +type U = +>U : U + + | { kind: "a"; payload: number; extra?: unknown } +>kind : "a" +>payload : number +>extra : unknown + + | { kind: "b"; payload: string; extra?: unknown }; +>kind : "b" +>payload : string +>extra : unknown + +declare const u: U; +>u : U + +const { + kind, +>kind : "a" | "b" + + payload, +>payload : string | number + + extra = kind === "a" ? payload.toFixed() : payload.toUpperCase(), +>extra : unknown +>kind === "a" ? payload.toFixed() : payload.toUpperCase() : string +>kind === "a" : boolean +>kind : "a" | "b" +>"a" : "a" +>payload.toFixed() : string +>payload.toFixed : (fractionDigits?: number) => string +>payload : number +>toFixed : (fractionDigits?: number) => string +>payload.toUpperCase() : string +>payload.toUpperCase : () => string +>payload : string +>toUpperCase : () => string + +} = u; +>u : U + +function f({ +>f : ({ kind, payload, extra, }: U) => void + + kind, +>kind : "a" | "b" + + payload, +>payload : string | number + + extra = kind === "a" ? payload.toFixed() : payload.toUpperCase(), +>extra : unknown +>kind === "a" ? payload.toFixed() : payload.toUpperCase() : string +>kind === "a" : boolean +>kind : "a" | "b" +>"a" : "a" +>payload.toFixed() : string +>payload.toFixed : (fractionDigits?: number) => string +>payload : number +>toFixed : (fractionDigits?: number) => string +>payload.toUpperCase() : string +>payload.toUpperCase : () => string +>payload : string +>toUpperCase : () => string + +}: U) {} + diff --git a/tsc/testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..0aaf38011344f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer(checkorder=typesfirst).symbols @@ -0,0 +1,62 @@ +//// [tests/cases/compiler/dependentDestructuringBindingElementInitializer.ts] //// + +=== dependentDestructuringBindingElementInitializer.ts === +type U = +>U : Symbol(U, Decl(dependentDestructuringBindingElementInitializer.ts, 0, 0)) + + | { kind: "a"; payload: number; extra?: unknown } +>kind : Symbol(kind, Decl(dependentDestructuringBindingElementInitializer.ts, 1, 7)) +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 1, 18)) +>extra : Symbol(extra, Decl(dependentDestructuringBindingElementInitializer.ts, 1, 35)) + + | { kind: "b"; payload: string; extra?: unknown }; +>kind : Symbol(kind, Decl(dependentDestructuringBindingElementInitializer.ts, 2, 7)) +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 2, 18)) +>extra : Symbol(extra, Decl(dependentDestructuringBindingElementInitializer.ts, 2, 35)) + +declare const u: U; +>u : Symbol(u, Decl(dependentDestructuringBindingElementInitializer.ts, 4, 13)) +>U : Symbol(U, Decl(dependentDestructuringBindingElementInitializer.ts, 0, 0)) + +const { + kind, +>kind : Symbol(kind, Decl(dependentDestructuringBindingElementInitializer.ts, 6, 7)) + + payload, +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 7, 9)) + + extra = kind === "a" ? payload.toFixed() : payload.toUpperCase(), +>extra : Symbol(extra, Decl(dependentDestructuringBindingElementInitializer.ts, 8, 12)) +>kind : Symbol(kind, Decl(dependentDestructuringBindingElementInitializer.ts, 6, 7)) +>payload.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 7, 9)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>payload.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 7, 9)) +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) + +} = u; +>u : Symbol(u, Decl(dependentDestructuringBindingElementInitializer.ts, 4, 13)) + +function f({ +>f : Symbol(f, Decl(dependentDestructuringBindingElementInitializer.ts, 10, 6)) + + kind, +>kind : Symbol(kind, Decl(dependentDestructuringBindingElementInitializer.ts, 12, 12)) + + payload, +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 13, 9)) + + extra = kind === "a" ? payload.toFixed() : payload.toUpperCase(), +>extra : Symbol(extra, Decl(dependentDestructuringBindingElementInitializer.ts, 14, 12)) +>kind : Symbol(kind, Decl(dependentDestructuringBindingElementInitializer.ts, 12, 12)) +>payload.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 13, 9)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>payload.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>payload : Symbol(payload, Decl(dependentDestructuringBindingElementInitializer.ts, 13, 9)) +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) + +}: U) {} +>U : Symbol(U, Decl(dependentDestructuringBindingElementInitializer.ts, 0, 0)) + diff --git a/tsc/testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer(checkorder=typesfirst).types new file mode 100644 index 0000000000000..265e9b075cacf --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer(checkorder=typesfirst).types @@ -0,0 +1,70 @@ +//// [tests/cases/compiler/dependentDestructuringBindingElementInitializer.ts] //// + +=== dependentDestructuringBindingElementInitializer.ts === +type U = +>U : U + + | { kind: "a"; payload: number; extra?: unknown } +>kind : "a" +>payload : number +>extra : unknown + + | { kind: "b"; payload: string; extra?: unknown }; +>kind : "b" +>payload : string +>extra : unknown + +declare const u: U; +>u : U + +const { + kind, +>kind : "a" | "b" + + payload, +>payload : string | number + + extra = kind === "a" ? payload.toFixed() : payload.toUpperCase(), +>extra : any +>kind === "a" ? payload.toFixed() : payload.toUpperCase() : any +>kind === "a" : boolean +>kind : "a" | "b" +>"a" : "a" +>payload.toFixed() : string +>payload.toFixed : (fractionDigits?: number) => string +>payload : number +>toFixed : (fractionDigits?: number) => string +>payload.toUpperCase() : string +>payload.toUpperCase : () => string +>payload : string +>toUpperCase : () => string + +} = u; +>u : U + +function f({ +>f : ({ kind, payload, extra, }: U) => void + + kind, +>kind : "a" | "b" + + payload, +>payload : string | number + + extra = kind === "a" ? payload.toFixed() : payload.toUpperCase(), +>extra : unknown +>kind === "a" ? payload.toFixed() : payload.toUpperCase() : string +>kind === "a" : boolean +>kind : "a" | "b" +>"a" : "a" +>payload.toFixed() : string +>payload.toFixed : (fractionDigits?: number) => string +>payload : number +>toFixed : (fractionDigits?: number) => string +>payload.toUpperCase() : string +>payload.toUpperCase : () => string +>payload : string +>toUpperCase : () => string + +}: U) {} + diff --git a/tsc/testdata/baselines/reference/compiler/enumMemberTypeCacheConsistency.js b/tsc/testdata/baselines/reference/compiler/enumMemberTypeCacheConsistency.js new file mode 100644 index 0000000000000..774af8292c6a9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/enumMemberTypeCacheConsistency.js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/enumMemberTypeCacheConsistency.ts] //// + +//// [enumMemberTypeCacheConsistency.ts] +enum E { + A = 0, + B = E.A.valueOf(), + C = 1, +} + +const member: Extract = E.C; + +//// [enumMemberTypeCacheConsistency.js] +"use strict"; +var E; +(function (E) { + E[E["A"] = 0] = "A"; + E[E["B"] = E.A.valueOf()] = "B"; + E[E["C"] = 1] = "C"; +})(E || (E = {})); +const member = E.C; + + +//// [enumMemberTypeCacheConsistency.d.ts] +declare enum E { + A = 0, + B, + C = 1 +} +declare const member: Extract; diff --git a/tsc/testdata/baselines/reference/compiler/enumMemberTypeCacheConsistency.symbols b/tsc/testdata/baselines/reference/compiler/enumMemberTypeCacheConsistency.symbols new file mode 100644 index 0000000000000..d527b2792f38e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/enumMemberTypeCacheConsistency.symbols @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/enumMemberTypeCacheConsistency.ts] //// + +=== enumMemberTypeCacheConsistency.ts === +enum E { +>E : Symbol(E, Decl(enumMemberTypeCacheConsistency.ts, 0, 0)) + + A = 0, +>A : Symbol(E.A, Decl(enumMemberTypeCacheConsistency.ts, 0, 8)) + + B = E.A.valueOf(), +>B : Symbol(E.B, Decl(enumMemberTypeCacheConsistency.ts, 1, 10)) +>E.A.valueOf : Symbol(Number.valueOf, Decl(lib.es5.d.ts, --, --)) +>E.A : Symbol(E.A, Decl(enumMemberTypeCacheConsistency.ts, 0, 8)) +>E : Symbol(E, Decl(enumMemberTypeCacheConsistency.ts, 0, 0)) +>A : Symbol(E.A, Decl(enumMemberTypeCacheConsistency.ts, 0, 8)) +>valueOf : Symbol(Number.valueOf, Decl(lib.es5.d.ts, --, --)) + + C = 1, +>C : Symbol(E.C, Decl(enumMemberTypeCacheConsistency.ts, 2, 22)) +} + +const member: Extract = E.C; +>member : Symbol(member, Decl(enumMemberTypeCacheConsistency.ts, 6, 5)) +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) +>E : Symbol(E, Decl(enumMemberTypeCacheConsistency.ts, 0, 0)) +>E.C : Symbol(E.C, Decl(enumMemberTypeCacheConsistency.ts, 2, 22)) +>E : Symbol(E, Decl(enumMemberTypeCacheConsistency.ts, 0, 0)) +>C : Symbol(E.C, Decl(enumMemberTypeCacheConsistency.ts, 2, 22)) + diff --git a/tsc/testdata/baselines/reference/compiler/enumMemberTypeCacheConsistency.types b/tsc/testdata/baselines/reference/compiler/enumMemberTypeCacheConsistency.types new file mode 100644 index 0000000000000..118dbac02ec0b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/enumMemberTypeCacheConsistency.types @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/enumMemberTypeCacheConsistency.ts] //// + +=== enumMemberTypeCacheConsistency.ts === +enum E { +>E : E + + A = 0, +>A : E.A +>0 : 0 + + B = E.A.valueOf(), +>B : E.B +>E.A.valueOf() : number +>E.A.valueOf : () => number +>E.A : E.A +>E : typeof E +>A : E.A +>valueOf : () => number + + C = 1, +>C : E.C +>1 : 1 +} + +const member: Extract = E.C; +>member : E.C +>E.C : E.C +>E : typeof E +>C : E.C + diff --git a/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=default).errors.txt new file mode 100644 index 0000000000000..a309088cfbee7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=default).errors.txt @@ -0,0 +1,43 @@ +exhaustiveSwitchCheckCircularity.ts(14,26): error TS2345: Argument of type '"bbb"' is not assignable to parameter of type 'never'. + + +==== exhaustiveSwitchCheckCircularity.ts (1 errors) ==== + // Repro from #47539 + + declare function isNever(n: never): boolean; + + function f() { + let foo: "aaa" | "bbb" = "aaa"; + while (true) { + switch (foo) { + case "aaa": + } + if (foo === "aaa") { + foo = "bbb"; + } + else if (isNever(foo)) { // Error expected + ~~~ +!!! error TS2345: Argument of type '"bbb"' is not assignable to parameter of type 'never'. + break; + } + } + } + + // Repro from #51688 + + declare function functionB(key: string): string; + + function functionC(): void { + let unionVal: "A" | "B" = "A"; + while (true) { + let key: string; + switch (unionVal) { + case "A": { + key = "AA"; + break; + } + } + functionB(key); + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=default).js new file mode 100644 index 0000000000000..8357fd67e0c74 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=default).js @@ -0,0 +1,71 @@ +//// [tests/cases/compiler/exhaustiveSwitchCheckCircularity.ts] //// + +//// [exhaustiveSwitchCheckCircularity.ts] +// Repro from #47539 + +declare function isNever(n: never): boolean; + +function f() { + let foo: "aaa" | "bbb" = "aaa"; + while (true) { + switch (foo) { + case "aaa": + } + if (foo === "aaa") { + foo = "bbb"; + } + else if (isNever(foo)) { // Error expected + break; + } + } +} + +// Repro from #51688 + +declare function functionB(key: string): string; + +function functionC(): void { + let unionVal: "A" | "B" = "A"; + while (true) { + let key: string; + switch (unionVal) { + case "A": { + key = "AA"; + break; + } + } + functionB(key); + } +} + + +//// [exhaustiveSwitchCheckCircularity.js] +"use strict"; +// Repro from #47539 +function f() { + let foo = "aaa"; + while (true) { + switch (foo) { + case "aaa": + } + if (foo === "aaa") { + foo = "bbb"; + } + else if (isNever(foo)) { // Error expected + break; + } + } +} +function functionC() { + let unionVal = "A"; + while (true) { + let key; + switch (unionVal) { + case "A": { + key = "AA"; + break; + } + } + functionB(key); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=default).symbols new file mode 100644 index 0000000000000..61aad225f49ab --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=default).symbols @@ -0,0 +1,68 @@ +//// [tests/cases/compiler/exhaustiveSwitchCheckCircularity.ts] //// + +=== exhaustiveSwitchCheckCircularity.ts === +// Repro from #47539 + +declare function isNever(n: never): boolean; +>isNever : Symbol(isNever, Decl(exhaustiveSwitchCheckCircularity.ts, 0, 0)) +>n : Symbol(n, Decl(exhaustiveSwitchCheckCircularity.ts, 2, 25)) + +function f() { +>f : Symbol(f, Decl(exhaustiveSwitchCheckCircularity.ts, 2, 44)) + + let foo: "aaa" | "bbb" = "aaa"; +>foo : Symbol(foo, Decl(exhaustiveSwitchCheckCircularity.ts, 5, 7)) + + while (true) { + switch (foo) { +>foo : Symbol(foo, Decl(exhaustiveSwitchCheckCircularity.ts, 5, 7)) + + case "aaa": + } + if (foo === "aaa") { +>foo : Symbol(foo, Decl(exhaustiveSwitchCheckCircularity.ts, 5, 7)) + + foo = "bbb"; +>foo : Symbol(foo, Decl(exhaustiveSwitchCheckCircularity.ts, 5, 7)) + } + else if (isNever(foo)) { // Error expected +>isNever : Symbol(isNever, Decl(exhaustiveSwitchCheckCircularity.ts, 0, 0)) +>foo : Symbol(foo, Decl(exhaustiveSwitchCheckCircularity.ts, 5, 7)) + + break; + } + } +} + +// Repro from #51688 + +declare function functionB(key: string): string; +>functionB : Symbol(functionB, Decl(exhaustiveSwitchCheckCircularity.ts, 17, 1)) +>key : Symbol(key, Decl(exhaustiveSwitchCheckCircularity.ts, 21, 27)) + +function functionC(): void { +>functionC : Symbol(functionC, Decl(exhaustiveSwitchCheckCircularity.ts, 21, 48)) + + let unionVal: "A" | "B" = "A"; +>unionVal : Symbol(unionVal, Decl(exhaustiveSwitchCheckCircularity.ts, 24, 7)) + + while (true) { + let key: string; +>key : Symbol(key, Decl(exhaustiveSwitchCheckCircularity.ts, 26, 11)) + + switch (unionVal) { +>unionVal : Symbol(unionVal, Decl(exhaustiveSwitchCheckCircularity.ts, 24, 7)) + + case "A": { + key = "AA"; +>key : Symbol(key, Decl(exhaustiveSwitchCheckCircularity.ts, 26, 11)) + + break; + } + } + functionB(key); +>functionB : Symbol(functionB, Decl(exhaustiveSwitchCheckCircularity.ts, 17, 1)) +>key : Symbol(key, Decl(exhaustiveSwitchCheckCircularity.ts, 26, 11)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=default).types new file mode 100644 index 0000000000000..a7b44f6811ab9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=default).types @@ -0,0 +1,85 @@ +//// [tests/cases/compiler/exhaustiveSwitchCheckCircularity.ts] //// + +=== exhaustiveSwitchCheckCircularity.ts === +// Repro from #47539 + +declare function isNever(n: never): boolean; +>isNever : (n: never) => boolean +>n : never + +function f() { +>f : () => void + + let foo: "aaa" | "bbb" = "aaa"; +>foo : "aaa" | "bbb" +>"aaa" : "aaa" + + while (true) { +>true : true + + switch (foo) { +>foo : "aaa" | "bbb" + + case "aaa": +>"aaa" : "aaa" + } + if (foo === "aaa") { +>foo === "aaa" : boolean +>foo : "aaa" | "bbb" +>"aaa" : "aaa" + + foo = "bbb"; +>foo = "bbb" : "bbb" +>foo : "aaa" | "bbb" +>"bbb" : "bbb" + } + else if (isNever(foo)) { // Error expected +>isNever(foo) : boolean +>isNever : (n: never) => boolean +>foo : "bbb" + + break; + } + } +} + +// Repro from #51688 + +declare function functionB(key: string): string; +>functionB : (key: string) => string +>key : string + +function functionC(): void { +>functionC : () => void + + let unionVal: "A" | "B" = "A"; +>unionVal : "A" | "B" +>"A" : "A" + + while (true) { +>true : true + + let key: string; +>key : string + + switch (unionVal) { +>unionVal : "A" + + case "A": { +>"A" : "A" + + key = "AA"; +>key = "AA" : "AA" +>key : string +>"AA" : "AA" + + break; + } + } + functionB(key); +>functionB(key) : string +>functionB : (key: string) => string +>key : string + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..a309088cfbee7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=typesfirst).errors.txt @@ -0,0 +1,43 @@ +exhaustiveSwitchCheckCircularity.ts(14,26): error TS2345: Argument of type '"bbb"' is not assignable to parameter of type 'never'. + + +==== exhaustiveSwitchCheckCircularity.ts (1 errors) ==== + // Repro from #47539 + + declare function isNever(n: never): boolean; + + function f() { + let foo: "aaa" | "bbb" = "aaa"; + while (true) { + switch (foo) { + case "aaa": + } + if (foo === "aaa") { + foo = "bbb"; + } + else if (isNever(foo)) { // Error expected + ~~~ +!!! error TS2345: Argument of type '"bbb"' is not assignable to parameter of type 'never'. + break; + } + } + } + + // Repro from #51688 + + declare function functionB(key: string): string; + + function functionC(): void { + let unionVal: "A" | "B" = "A"; + while (true) { + let key: string; + switch (unionVal) { + case "A": { + key = "AA"; + break; + } + } + functionB(key); + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=typesfirst).js new file mode 100644 index 0000000000000..8357fd67e0c74 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=typesfirst).js @@ -0,0 +1,71 @@ +//// [tests/cases/compiler/exhaustiveSwitchCheckCircularity.ts] //// + +//// [exhaustiveSwitchCheckCircularity.ts] +// Repro from #47539 + +declare function isNever(n: never): boolean; + +function f() { + let foo: "aaa" | "bbb" = "aaa"; + while (true) { + switch (foo) { + case "aaa": + } + if (foo === "aaa") { + foo = "bbb"; + } + else if (isNever(foo)) { // Error expected + break; + } + } +} + +// Repro from #51688 + +declare function functionB(key: string): string; + +function functionC(): void { + let unionVal: "A" | "B" = "A"; + while (true) { + let key: string; + switch (unionVal) { + case "A": { + key = "AA"; + break; + } + } + functionB(key); + } +} + + +//// [exhaustiveSwitchCheckCircularity.js] +"use strict"; +// Repro from #47539 +function f() { + let foo = "aaa"; + while (true) { + switch (foo) { + case "aaa": + } + if (foo === "aaa") { + foo = "bbb"; + } + else if (isNever(foo)) { // Error expected + break; + } + } +} +function functionC() { + let unionVal = "A"; + while (true) { + let key; + switch (unionVal) { + case "A": { + key = "AA"; + break; + } + } + functionB(key); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..61aad225f49ab --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=typesfirst).symbols @@ -0,0 +1,68 @@ +//// [tests/cases/compiler/exhaustiveSwitchCheckCircularity.ts] //// + +=== exhaustiveSwitchCheckCircularity.ts === +// Repro from #47539 + +declare function isNever(n: never): boolean; +>isNever : Symbol(isNever, Decl(exhaustiveSwitchCheckCircularity.ts, 0, 0)) +>n : Symbol(n, Decl(exhaustiveSwitchCheckCircularity.ts, 2, 25)) + +function f() { +>f : Symbol(f, Decl(exhaustiveSwitchCheckCircularity.ts, 2, 44)) + + let foo: "aaa" | "bbb" = "aaa"; +>foo : Symbol(foo, Decl(exhaustiveSwitchCheckCircularity.ts, 5, 7)) + + while (true) { + switch (foo) { +>foo : Symbol(foo, Decl(exhaustiveSwitchCheckCircularity.ts, 5, 7)) + + case "aaa": + } + if (foo === "aaa") { +>foo : Symbol(foo, Decl(exhaustiveSwitchCheckCircularity.ts, 5, 7)) + + foo = "bbb"; +>foo : Symbol(foo, Decl(exhaustiveSwitchCheckCircularity.ts, 5, 7)) + } + else if (isNever(foo)) { // Error expected +>isNever : Symbol(isNever, Decl(exhaustiveSwitchCheckCircularity.ts, 0, 0)) +>foo : Symbol(foo, Decl(exhaustiveSwitchCheckCircularity.ts, 5, 7)) + + break; + } + } +} + +// Repro from #51688 + +declare function functionB(key: string): string; +>functionB : Symbol(functionB, Decl(exhaustiveSwitchCheckCircularity.ts, 17, 1)) +>key : Symbol(key, Decl(exhaustiveSwitchCheckCircularity.ts, 21, 27)) + +function functionC(): void { +>functionC : Symbol(functionC, Decl(exhaustiveSwitchCheckCircularity.ts, 21, 48)) + + let unionVal: "A" | "B" = "A"; +>unionVal : Symbol(unionVal, Decl(exhaustiveSwitchCheckCircularity.ts, 24, 7)) + + while (true) { + let key: string; +>key : Symbol(key, Decl(exhaustiveSwitchCheckCircularity.ts, 26, 11)) + + switch (unionVal) { +>unionVal : Symbol(unionVal, Decl(exhaustiveSwitchCheckCircularity.ts, 24, 7)) + + case "A": { + key = "AA"; +>key : Symbol(key, Decl(exhaustiveSwitchCheckCircularity.ts, 26, 11)) + + break; + } + } + functionB(key); +>functionB : Symbol(functionB, Decl(exhaustiveSwitchCheckCircularity.ts, 17, 1)) +>key : Symbol(key, Decl(exhaustiveSwitchCheckCircularity.ts, 26, 11)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=typesfirst).types new file mode 100644 index 0000000000000..651cd4a45a647 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/exhaustiveSwitchCheckCircularity(checkorder=typesfirst).types @@ -0,0 +1,85 @@ +//// [tests/cases/compiler/exhaustiveSwitchCheckCircularity.ts] //// + +=== exhaustiveSwitchCheckCircularity.ts === +// Repro from #47539 + +declare function isNever(n: never): boolean; +>isNever : (n: never) => boolean +>n : never + +function f() { +>f : () => void + + let foo: "aaa" | "bbb" = "aaa"; +>foo : "aaa" | "bbb" +>"aaa" : "aaa" + + while (true) { +>true : true + + switch (foo) { +>foo : "aaa" | "bbb" + + case "aaa": +>"aaa" : "aaa" + } + if (foo === "aaa") { +>foo === "aaa" : boolean +>foo : "aaa" | "bbb" +>"aaa" : "aaa" + + foo = "bbb"; +>foo = "bbb" : "bbb" +>foo : "aaa" | "bbb" +>"bbb" : "bbb" + } + else if (isNever(foo)) { // Error expected +>isNever(foo) : boolean +>isNever : (n: never) => boolean +>foo : never + + break; + } + } +} + +// Repro from #51688 + +declare function functionB(key: string): string; +>functionB : (key: string) => string +>key : string + +function functionC(): void { +>functionC : () => void + + let unionVal: "A" | "B" = "A"; +>unionVal : "A" | "B" +>"A" : "A" + + while (true) { +>true : true + + let key: string; +>key : string + + switch (unionVal) { +>unionVal : "A" + + case "A": { +>"A" : "A" + + key = "AA"; +>key = "AA" : "AA" +>key : string +>"AA" : "AA" + + break; + } + } + functionB(key); +>functionB(key) : string +>functionB : (key: string) => string +>key : string + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=default).errors.txt new file mode 100644 index 0000000000000..9a04ca00910e5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=default).errors.txt @@ -0,0 +1,45 @@ +fallbackToBindingPatternForTypeInference.ts(2,7): error TS2345: Argument of type '({ a }: { a: any; }) => any' is not assignable to parameter of type '(x: unknown) => string'. + Types of parameters '__0' and 'x' are incompatible. + Type 'unknown' is not assignable to type '{ a: any; }'. +fallbackToBindingPatternForTypeInference.ts(3,7): error TS2345: Argument of type '([b, c]: [any, any]) => string' is not assignable to parameter of type '(x: unknown) => string'. + Types of parameters '__0' and 'x' are incompatible. + Type 'unknown' is not assignable to type '[any, any]'. +fallbackToBindingPatternForTypeInference.ts(4,7): error TS2345: Argument of type '({ d: [e, f] }: { d: [any, any]; }) => string' is not assignable to parameter of type '(x: unknown) => string'. + Types of parameters '__0' and 'x' are incompatible. + Type 'unknown' is not assignable to type '{ d: [any, any]; }'. +fallbackToBindingPatternForTypeInference.ts(5,7): error TS2345: Argument of type '([{ g }, { h }]: [{ g: any; }, { h: any; }]) => string' is not assignable to parameter of type '(x: unknown) => string'. + Types of parameters '__0' and 'x' are incompatible. + Type 'unknown' is not assignable to type '[{ g: any; }, { h: any; }]'. +fallbackToBindingPatternForTypeInference.ts(6,7): error TS2345: Argument of type '({ a, b }: { a: any; b?: number | undefined; }) => any' is not assignable to parameter of type '(x: unknown) => string'. + Types of parameters '__0' and 'x' are incompatible. + Type 'unknown' is not assignable to type '{ a: any; b?: number | undefined; }'. + + +==== fallbackToBindingPatternForTypeInference.ts (5 errors) ==== + declare function trans(f: (x: T) => string): number; + trans(({a}) => a); + ~~~~~~~~~~ +!!! error TS2345: Argument of type '({ a }: { a: any; }) => any' is not assignable to parameter of type '(x: unknown) => string'. +!!! error TS2345: Types of parameters '__0' and 'x' are incompatible. +!!! error TS2345: Type 'unknown' is not assignable to type '{ a: any; }'. + trans(([b,c]) => 'foo'); + ~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '([b, c]: [any, any]) => string' is not assignable to parameter of type '(x: unknown) => string'. +!!! error TS2345: Types of parameters '__0' and 'x' are incompatible. +!!! error TS2345: Type 'unknown' is not assignable to type '[any, any]'. + trans(({d: [e,f]}) => 'foo'); + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '({ d: [e, f] }: { d: [any, any]; }) => string' is not assignable to parameter of type '(x: unknown) => string'. +!!! error TS2345: Types of parameters '__0' and 'x' are incompatible. +!!! error TS2345: Type 'unknown' is not assignable to type '{ d: [any, any]; }'. + trans(([{g},{h}]) => 'foo'); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '([{ g }, { h }]: [{ g: any; }, { h: any; }]) => string' is not assignable to parameter of type '(x: unknown) => string'. +!!! error TS2345: Types of parameters '__0' and 'x' are incompatible. +!!! error TS2345: Type 'unknown' is not assignable to type '[{ g: any; }, { h: any; }]'. + trans(({a, b = 10}) => a); + ~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '({ a, b }: { a: any; b?: number | undefined; }) => any' is not assignable to parameter of type '(x: unknown) => string'. +!!! error TS2345: Types of parameters '__0' and 'x' are incompatible. +!!! error TS2345: Type 'unknown' is not assignable to type '{ a: any; b?: number | undefined; }'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=default).js new file mode 100644 index 0000000000000..60378832d9d6a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=default).js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/fallbackToBindingPatternForTypeInference.ts] //// + +//// [fallbackToBindingPatternForTypeInference.ts] +declare function trans(f: (x: T) => string): number; +trans(({a}) => a); +trans(([b,c]) => 'foo'); +trans(({d: [e,f]}) => 'foo'); +trans(([{g},{h}]) => 'foo'); +trans(({a, b = 10}) => a); + + +//// [fallbackToBindingPatternForTypeInference.js] +"use strict"; +trans(({ a }) => a); +trans(([b, c]) => 'foo'); +trans(({ d: [e, f] }) => 'foo'); +trans(([{ g }, { h }]) => 'foo'); +trans(({ a, b = 10 }) => a); diff --git a/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=default).symbols new file mode 100644 index 0000000000000..7e6456be8db3c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=default).symbols @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/fallbackToBindingPatternForTypeInference.ts] //// + +=== fallbackToBindingPatternForTypeInference.ts === +declare function trans(f: (x: T) => string): number; +>trans : Symbol(trans, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 0)) +>T : Symbol(T, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 23)) +>f : Symbol(f, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 26)) +>x : Symbol(x, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 30)) +>T : Symbol(T, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 23)) + +trans(({a}) => a); +>trans : Symbol(trans, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 0)) +>a : Symbol(a, Decl(fallbackToBindingPatternForTypeInference.ts, 1, 8)) +>a : Symbol(a, Decl(fallbackToBindingPatternForTypeInference.ts, 1, 8)) + +trans(([b,c]) => 'foo'); +>trans : Symbol(trans, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 0)) +>b : Symbol(b, Decl(fallbackToBindingPatternForTypeInference.ts, 2, 8)) +>c : Symbol(c, Decl(fallbackToBindingPatternForTypeInference.ts, 2, 10)) + +trans(({d: [e,f]}) => 'foo'); +>trans : Symbol(trans, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 0)) +>e : Symbol(e, Decl(fallbackToBindingPatternForTypeInference.ts, 3, 12)) +>f : Symbol(f, Decl(fallbackToBindingPatternForTypeInference.ts, 3, 14)) + +trans(([{g},{h}]) => 'foo'); +>trans : Symbol(trans, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 0)) +>g : Symbol(g, Decl(fallbackToBindingPatternForTypeInference.ts, 4, 9)) +>h : Symbol(h, Decl(fallbackToBindingPatternForTypeInference.ts, 4, 13)) + +trans(({a, b = 10}) => a); +>trans : Symbol(trans, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 0)) +>a : Symbol(a, Decl(fallbackToBindingPatternForTypeInference.ts, 5, 8)) +>b : Symbol(b, Decl(fallbackToBindingPatternForTypeInference.ts, 5, 10)) +>a : Symbol(a, Decl(fallbackToBindingPatternForTypeInference.ts, 5, 8)) + diff --git a/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=default).types new file mode 100644 index 0000000000000..be3950ad98131 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=default).types @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/fallbackToBindingPatternForTypeInference.ts] //// + +=== fallbackToBindingPatternForTypeInference.ts === +declare function trans(f: (x: T) => string): number; +>trans : (f: (x: T) => string) => number +>f : (x: T) => string +>x : T + +trans(({a}) => a); +>trans(({a}) => a) : number +>trans : (f: (x: T) => string) => number +>({a}) => a : ({ a }: { a: any; }) => any +>a : any +>a : any + +trans(([b,c]) => 'foo'); +>trans(([b,c]) => 'foo') : number +>trans : (f: (x: T) => string) => number +>([b,c]) => 'foo' : ([b, c]: [any, any]) => string +>b : any +>c : any +>'foo' : "foo" + +trans(({d: [e,f]}) => 'foo'); +>trans(({d: [e,f]}) => 'foo') : number +>trans : (f: (x: T) => string) => number +>({d: [e,f]}) => 'foo' : ({ d: [e, f] }: { d: [any, any]; }) => string +>d : any +>e : any +>f : any +>'foo' : "foo" + +trans(([{g},{h}]) => 'foo'); +>trans(([{g},{h}]) => 'foo') : number +>trans : (f: (x: T) => string) => number +>([{g},{h}]) => 'foo' : ([{ g }, { h }]: [{ g: any; }, { h: any; }]) => string +>g : any +>h : any +>'foo' : "foo" + +trans(({a, b = 10}) => a); +>trans(({a, b = 10}) => a) : number +>trans : (f: (x: T) => string) => number +>({a, b = 10}) => a : ({ a, b }: { a: any; b?: number | undefined; }) => any +>a : any +>b : number +>10 : 10 +>a : any + diff --git a/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..37a59b2d11dea --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=typesfirst).errors.txt @@ -0,0 +1,51 @@ +fallbackToBindingPatternForTypeInference.ts(2,7): error TS2345: Argument of type '({ a }: { a: any; }) => any' is not assignable to parameter of type '(x: unknown) => string'. + Types of parameters '__0' and 'x' are incompatible. + Type 'unknown' is not assignable to type '{ a: any; }'. +fallbackToBindingPatternForTypeInference.ts(2,9): error TS2339: Property 'a' does not exist on type 'unknown'. +fallbackToBindingPatternForTypeInference.ts(3,7): error TS2345: Argument of type '([b, c]: [any, any]) => string' is not assignable to parameter of type '(x: unknown) => string'. + Types of parameters '__0' and 'x' are incompatible. + Type 'unknown' is not assignable to type '[any, any]'. +fallbackToBindingPatternForTypeInference.ts(4,7): error TS2345: Argument of type '({ d: [e, f] }: { d: [any, any]; }) => string' is not assignable to parameter of type '(x: unknown) => string'. + Types of parameters '__0' and 'x' are incompatible. + Type 'unknown' is not assignable to type '{ d: [any, any]; }'. +fallbackToBindingPatternForTypeInference.ts(5,7): error TS2345: Argument of type '([{ g }, { h }]: [{ g: any; }, { h: any; }]) => string' is not assignable to parameter of type '(x: unknown) => string'. + Types of parameters '__0' and 'x' are incompatible. + Type 'unknown' is not assignable to type '[{ g: any; }, { h: any; }]'. +fallbackToBindingPatternForTypeInference.ts(6,7): error TS2345: Argument of type '({ a, b }: { a: any; b?: number | undefined; }) => any' is not assignable to parameter of type '(x: unknown) => string'. + Types of parameters '__0' and 'x' are incompatible. + Type 'unknown' is not assignable to type '{ a: any; b?: number | undefined; }'. +fallbackToBindingPatternForTypeInference.ts(6,9): error TS2339: Property 'a' does not exist on type 'unknown'. + + +==== fallbackToBindingPatternForTypeInference.ts (7 errors) ==== + declare function trans(f: (x: T) => string): number; + trans(({a}) => a); + ~~~~~~~~~~ +!!! error TS2345: Argument of type '({ a }: { a: any; }) => any' is not assignable to parameter of type '(x: unknown) => string'. +!!! error TS2345: Types of parameters '__0' and 'x' are incompatible. +!!! error TS2345: Type 'unknown' is not assignable to type '{ a: any; }'. + ~ +!!! error TS2339: Property 'a' does not exist on type 'unknown'. + trans(([b,c]) => 'foo'); + ~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '([b, c]: [any, any]) => string' is not assignable to parameter of type '(x: unknown) => string'. +!!! error TS2345: Types of parameters '__0' and 'x' are incompatible. +!!! error TS2345: Type 'unknown' is not assignable to type '[any, any]'. + trans(({d: [e,f]}) => 'foo'); + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '({ d: [e, f] }: { d: [any, any]; }) => string' is not assignable to parameter of type '(x: unknown) => string'. +!!! error TS2345: Types of parameters '__0' and 'x' are incompatible. +!!! error TS2345: Type 'unknown' is not assignable to type '{ d: [any, any]; }'. + trans(([{g},{h}]) => 'foo'); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '([{ g }, { h }]: [{ g: any; }, { h: any; }]) => string' is not assignable to parameter of type '(x: unknown) => string'. +!!! error TS2345: Types of parameters '__0' and 'x' are incompatible. +!!! error TS2345: Type 'unknown' is not assignable to type '[{ g: any; }, { h: any; }]'. + trans(({a, b = 10}) => a); + ~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '({ a, b }: { a: any; b?: number | undefined; }) => any' is not assignable to parameter of type '(x: unknown) => string'. +!!! error TS2345: Types of parameters '__0' and 'x' are incompatible. +!!! error TS2345: Type 'unknown' is not assignable to type '{ a: any; b?: number | undefined; }'. + ~ +!!! error TS2339: Property 'a' does not exist on type 'unknown'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=typesfirst).js new file mode 100644 index 0000000000000..60378832d9d6a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=typesfirst).js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/fallbackToBindingPatternForTypeInference.ts] //// + +//// [fallbackToBindingPatternForTypeInference.ts] +declare function trans(f: (x: T) => string): number; +trans(({a}) => a); +trans(([b,c]) => 'foo'); +trans(({d: [e,f]}) => 'foo'); +trans(([{g},{h}]) => 'foo'); +trans(({a, b = 10}) => a); + + +//// [fallbackToBindingPatternForTypeInference.js] +"use strict"; +trans(({ a }) => a); +trans(([b, c]) => 'foo'); +trans(({ d: [e, f] }) => 'foo'); +trans(([{ g }, { h }]) => 'foo'); +trans(({ a, b = 10 }) => a); diff --git a/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..7e6456be8db3c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=typesfirst).symbols @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/fallbackToBindingPatternForTypeInference.ts] //// + +=== fallbackToBindingPatternForTypeInference.ts === +declare function trans(f: (x: T) => string): number; +>trans : Symbol(trans, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 0)) +>T : Symbol(T, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 23)) +>f : Symbol(f, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 26)) +>x : Symbol(x, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 30)) +>T : Symbol(T, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 23)) + +trans(({a}) => a); +>trans : Symbol(trans, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 0)) +>a : Symbol(a, Decl(fallbackToBindingPatternForTypeInference.ts, 1, 8)) +>a : Symbol(a, Decl(fallbackToBindingPatternForTypeInference.ts, 1, 8)) + +trans(([b,c]) => 'foo'); +>trans : Symbol(trans, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 0)) +>b : Symbol(b, Decl(fallbackToBindingPatternForTypeInference.ts, 2, 8)) +>c : Symbol(c, Decl(fallbackToBindingPatternForTypeInference.ts, 2, 10)) + +trans(({d: [e,f]}) => 'foo'); +>trans : Symbol(trans, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 0)) +>e : Symbol(e, Decl(fallbackToBindingPatternForTypeInference.ts, 3, 12)) +>f : Symbol(f, Decl(fallbackToBindingPatternForTypeInference.ts, 3, 14)) + +trans(([{g},{h}]) => 'foo'); +>trans : Symbol(trans, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 0)) +>g : Symbol(g, Decl(fallbackToBindingPatternForTypeInference.ts, 4, 9)) +>h : Symbol(h, Decl(fallbackToBindingPatternForTypeInference.ts, 4, 13)) + +trans(({a, b = 10}) => a); +>trans : Symbol(trans, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 0)) +>a : Symbol(a, Decl(fallbackToBindingPatternForTypeInference.ts, 5, 8)) +>b : Symbol(b, Decl(fallbackToBindingPatternForTypeInference.ts, 5, 10)) +>a : Symbol(a, Decl(fallbackToBindingPatternForTypeInference.ts, 5, 8)) + diff --git a/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=typesfirst).types new file mode 100644 index 0000000000000..be3950ad98131 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fallbackToBindingPatternForTypeInference(checkorder=typesfirst).types @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/fallbackToBindingPatternForTypeInference.ts] //// + +=== fallbackToBindingPatternForTypeInference.ts === +declare function trans(f: (x: T) => string): number; +>trans : (f: (x: T) => string) => number +>f : (x: T) => string +>x : T + +trans(({a}) => a); +>trans(({a}) => a) : number +>trans : (f: (x: T) => string) => number +>({a}) => a : ({ a }: { a: any; }) => any +>a : any +>a : any + +trans(([b,c]) => 'foo'); +>trans(([b,c]) => 'foo') : number +>trans : (f: (x: T) => string) => number +>([b,c]) => 'foo' : ([b, c]: [any, any]) => string +>b : any +>c : any +>'foo' : "foo" + +trans(({d: [e,f]}) => 'foo'); +>trans(({d: [e,f]}) => 'foo') : number +>trans : (f: (x: T) => string) => number +>({d: [e,f]}) => 'foo' : ({ d: [e, f] }: { d: [any, any]; }) => string +>d : any +>e : any +>f : any +>'foo' : "foo" + +trans(([{g},{h}]) => 'foo'); +>trans(([{g},{h}]) => 'foo') : number +>trans : (f: (x: T) => string) => number +>([{g},{h}]) => 'foo' : ([{ g }, { h }]: [{ g: any; }, { h: any; }]) => string +>g : any +>h : any +>'foo' : "foo" + +trans(({a, b = 10}) => a); +>trans(({a, b = 10}) => a) : number +>trans : (f: (x: T) => string) => number +>({a, b = 10}) => a : ({ a, b }: { a: any; b?: number | undefined; }) => any +>a : any +>b : number +>10 : 10 +>a : any + diff --git a/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=default).errors.txt new file mode 100644 index 0000000000000..29a93731f366b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=default).errors.txt @@ -0,0 +1,29 @@ +fixingTypeParametersRepeatedly2.ts(11,32): error TS2741: Property 'toBase' is missing in type 'Base' but required in type 'Derived'. +fixingTypeParametersRepeatedly2.ts(17,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'result' must be of type 'Derived', but here has type 'Base'. + + +==== fixingTypeParametersRepeatedly2.ts (2 errors) ==== + interface Base { + baseProp; + } + interface Derived extends Base { + toBase(): Base; + } + + declare var derived: Derived; + + declare function foo(x: T, func: (p: T) => T): T; + var result = foo(derived, d => d.toBase()); + ~~~~~~~~~~ +!!! error TS2741: Property 'toBase' is missing in type 'Base' but required in type 'Derived'. +!!! related TS2728 fixingTypeParametersRepeatedly2.ts:5:5: 'toBase' is declared here. +!!! related TS6502 fixingTypeParametersRepeatedly2.ts:10:37: The expected type comes from the return type of this signature. + + // bar should type check just like foo. + // The same error should be observed in both cases. + declare function bar(x: T, func: (p: T) => T): T; + declare function bar(x: T, func: (p: T) => T): T; + var result = bar(derived, d => d.toBase()); + ~~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'result' must be of type 'Derived', but here has type 'Base'. +!!! related TS6203 fixingTypeParametersRepeatedly2.ts:11:5: 'result' was also declared here. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=default).js new file mode 100644 index 0000000000000..f3ab2ec0b70b2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=default).js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/fixingTypeParametersRepeatedly2.ts] //// + +//// [fixingTypeParametersRepeatedly2.ts] +interface Base { + baseProp; +} +interface Derived extends Base { + toBase(): Base; +} + +declare var derived: Derived; + +declare function foo(x: T, func: (p: T) => T): T; +var result = foo(derived, d => d.toBase()); + +// bar should type check just like foo. +// The same error should be observed in both cases. +declare function bar(x: T, func: (p: T) => T): T; +declare function bar(x: T, func: (p: T) => T): T; +var result = bar(derived, d => d.toBase()); + +//// [fixingTypeParametersRepeatedly2.js] +"use strict"; +var result = foo(derived, d => d.toBase()); +var result = bar(derived, d => d.toBase()); diff --git a/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=default).symbols new file mode 100644 index 0000000000000..7dc3504e7d3da --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=default).symbols @@ -0,0 +1,75 @@ +//// [tests/cases/compiler/fixingTypeParametersRepeatedly2.ts] //// + +=== fixingTypeParametersRepeatedly2.ts === +interface Base { +>Base : Symbol(Base, Decl(fixingTypeParametersRepeatedly2.ts, 0, 0)) + + baseProp; +>baseProp : Symbol(Base.baseProp, Decl(fixingTypeParametersRepeatedly2.ts, 0, 16)) +} +interface Derived extends Base { +>Derived : Symbol(Derived, Decl(fixingTypeParametersRepeatedly2.ts, 2, 1)) +>Base : Symbol(Base, Decl(fixingTypeParametersRepeatedly2.ts, 0, 0)) + + toBase(): Base; +>toBase : Symbol(Derived.toBase, Decl(fixingTypeParametersRepeatedly2.ts, 3, 32)) +>Base : Symbol(Base, Decl(fixingTypeParametersRepeatedly2.ts, 0, 0)) +} + +declare var derived: Derived; +>derived : Symbol(derived, Decl(fixingTypeParametersRepeatedly2.ts, 7, 11)) +>Derived : Symbol(Derived, Decl(fixingTypeParametersRepeatedly2.ts, 2, 1)) + +declare function foo(x: T, func: (p: T) => T): T; +>foo : Symbol(foo, Decl(fixingTypeParametersRepeatedly2.ts, 7, 29)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 9, 21)) +>x : Symbol(x, Decl(fixingTypeParametersRepeatedly2.ts, 9, 24)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 9, 21)) +>func : Symbol(func, Decl(fixingTypeParametersRepeatedly2.ts, 9, 29)) +>p : Symbol(p, Decl(fixingTypeParametersRepeatedly2.ts, 9, 37)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 9, 21)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 9, 21)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 9, 21)) + +var result = foo(derived, d => d.toBase()); +>result : Symbol(result, Decl(fixingTypeParametersRepeatedly2.ts, 10, 3), Decl(fixingTypeParametersRepeatedly2.ts, 16, 3)) +>foo : Symbol(foo, Decl(fixingTypeParametersRepeatedly2.ts, 7, 29)) +>derived : Symbol(derived, Decl(fixingTypeParametersRepeatedly2.ts, 7, 11)) +>d : Symbol(d, Decl(fixingTypeParametersRepeatedly2.ts, 10, 25)) +>d.toBase : Symbol(Derived.toBase, Decl(fixingTypeParametersRepeatedly2.ts, 3, 32)) +>d : Symbol(d, Decl(fixingTypeParametersRepeatedly2.ts, 10, 25)) +>toBase : Symbol(Derived.toBase, Decl(fixingTypeParametersRepeatedly2.ts, 3, 32)) + +// bar should type check just like foo. +// The same error should be observed in both cases. +declare function bar(x: T, func: (p: T) => T): T; +>bar : Symbol(bar, Decl(fixingTypeParametersRepeatedly2.ts, 10, 43), Decl(fixingTypeParametersRepeatedly2.ts, 14, 52)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 14, 21)) +>x : Symbol(x, Decl(fixingTypeParametersRepeatedly2.ts, 14, 24)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 14, 21)) +>func : Symbol(func, Decl(fixingTypeParametersRepeatedly2.ts, 14, 29)) +>p : Symbol(p, Decl(fixingTypeParametersRepeatedly2.ts, 14, 37)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 14, 21)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 14, 21)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 14, 21)) + +declare function bar(x: T, func: (p: T) => T): T; +>bar : Symbol(bar, Decl(fixingTypeParametersRepeatedly2.ts, 10, 43), Decl(fixingTypeParametersRepeatedly2.ts, 14, 52)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 15, 21)) +>x : Symbol(x, Decl(fixingTypeParametersRepeatedly2.ts, 15, 24)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 15, 21)) +>func : Symbol(func, Decl(fixingTypeParametersRepeatedly2.ts, 15, 29)) +>p : Symbol(p, Decl(fixingTypeParametersRepeatedly2.ts, 15, 37)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 15, 21)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 15, 21)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 15, 21)) + +var result = bar(derived, d => d.toBase()); +>result : Symbol(result, Decl(fixingTypeParametersRepeatedly2.ts, 10, 3), Decl(fixingTypeParametersRepeatedly2.ts, 16, 3)) +>bar : Symbol(bar, Decl(fixingTypeParametersRepeatedly2.ts, 10, 43), Decl(fixingTypeParametersRepeatedly2.ts, 14, 52)) +>derived : Symbol(derived, Decl(fixingTypeParametersRepeatedly2.ts, 7, 11)) +>d : Symbol(d, Decl(fixingTypeParametersRepeatedly2.ts, 16, 25)) +>d.toBase : Symbol(Derived.toBase, Decl(fixingTypeParametersRepeatedly2.ts, 3, 32)) +>d : Symbol(d, Decl(fixingTypeParametersRepeatedly2.ts, 16, 25)) +>toBase : Symbol(Derived.toBase, Decl(fixingTypeParametersRepeatedly2.ts, 3, 32)) + diff --git a/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=default).types new file mode 100644 index 0000000000000..0a8fca14e9475 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=default).types @@ -0,0 +1,59 @@ +//// [tests/cases/compiler/fixingTypeParametersRepeatedly2.ts] //// + +=== fixingTypeParametersRepeatedly2.ts === +interface Base { + baseProp; +>baseProp : any +} +interface Derived extends Base { + toBase(): Base; +>toBase : () => Base +} + +declare var derived: Derived; +>derived : Derived + +declare function foo(x: T, func: (p: T) => T): T; +>foo : (x: T, func: (p: T) => T) => T +>x : T +>func : (p: T) => T +>p : T + +var result = foo(derived, d => d.toBase()); +>result : Derived +>foo(derived, d => d.toBase()) : Derived +>foo : (x: T, func: (p: T) => T) => T +>derived : Derived +>d => d.toBase() : (d: Derived) => Base +>d : Derived +>d.toBase() : Base +>d.toBase : () => Base +>d : Derived +>toBase : () => Base + +// bar should type check just like foo. +// The same error should be observed in both cases. +declare function bar(x: T, func: (p: T) => T): T; +>bar : { (x: T, func: (p: T) => T): T; (x: T_1, func: (p: T_1) => T_1): T_1; } +>x : T +>func : (p: T) => T +>p : T + +declare function bar(x: T, func: (p: T) => T): T; +>bar : { (x: T_1, func: (p: T_1) => T_1): T_1; (x: T, func: (p: T) => T): T; } +>x : T +>func : (p: T) => T +>p : T + +var result = bar(derived, d => d.toBase()); +>result : Derived +>bar(derived, d => d.toBase()) : Base +>bar : { (x: T, func: (p: T) => T): T; (x: T, func: (p: T) => T): T; } +>derived : Derived +>d => d.toBase() : (d: Derived) => Base +>d : Derived +>d.toBase() : Base +>d.toBase : () => Base +>d : Derived +>toBase : () => Base + diff --git a/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..eaf9da009a413 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=typesfirst).errors.txt @@ -0,0 +1,32 @@ +fixingTypeParametersRepeatedly2.ts(11,32): error TS2741: Property 'toBase' is missing in type 'Base' but required in type 'Derived'. +fixingTypeParametersRepeatedly2.ts(17,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'result' must be of type 'Derived', but here has type 'Base'. +fixingTypeParametersRepeatedly2.ts(17,34): error TS2339: Property 'toBase' does not exist on type 'Base'. + + +==== fixingTypeParametersRepeatedly2.ts (3 errors) ==== + interface Base { + baseProp; + } + interface Derived extends Base { + toBase(): Base; + } + + declare var derived: Derived; + + declare function foo(x: T, func: (p: T) => T): T; + var result = foo(derived, d => d.toBase()); + ~~~~~~~~~~ +!!! error TS2741: Property 'toBase' is missing in type 'Base' but required in type 'Derived'. +!!! related TS2728 fixingTypeParametersRepeatedly2.ts:5:5: 'toBase' is declared here. +!!! related TS6502 fixingTypeParametersRepeatedly2.ts:10:37: The expected type comes from the return type of this signature. + + // bar should type check just like foo. + // The same error should be observed in both cases. + declare function bar(x: T, func: (p: T) => T): T; + declare function bar(x: T, func: (p: T) => T): T; + var result = bar(derived, d => d.toBase()); + ~~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'result' must be of type 'Derived', but here has type 'Base'. +!!! related TS6203 fixingTypeParametersRepeatedly2.ts:11:5: 'result' was also declared here. + ~~~~~~ +!!! error TS2339: Property 'toBase' does not exist on type 'Base'. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=typesfirst).js new file mode 100644 index 0000000000000..f3ab2ec0b70b2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=typesfirst).js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/fixingTypeParametersRepeatedly2.ts] //// + +//// [fixingTypeParametersRepeatedly2.ts] +interface Base { + baseProp; +} +interface Derived extends Base { + toBase(): Base; +} + +declare var derived: Derived; + +declare function foo(x: T, func: (p: T) => T): T; +var result = foo(derived, d => d.toBase()); + +// bar should type check just like foo. +// The same error should be observed in both cases. +declare function bar(x: T, func: (p: T) => T): T; +declare function bar(x: T, func: (p: T) => T): T; +var result = bar(derived, d => d.toBase()); + +//// [fixingTypeParametersRepeatedly2.js] +"use strict"; +var result = foo(derived, d => d.toBase()); +var result = bar(derived, d => d.toBase()); diff --git a/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..7dc3504e7d3da --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=typesfirst).symbols @@ -0,0 +1,75 @@ +//// [tests/cases/compiler/fixingTypeParametersRepeatedly2.ts] //// + +=== fixingTypeParametersRepeatedly2.ts === +interface Base { +>Base : Symbol(Base, Decl(fixingTypeParametersRepeatedly2.ts, 0, 0)) + + baseProp; +>baseProp : Symbol(Base.baseProp, Decl(fixingTypeParametersRepeatedly2.ts, 0, 16)) +} +interface Derived extends Base { +>Derived : Symbol(Derived, Decl(fixingTypeParametersRepeatedly2.ts, 2, 1)) +>Base : Symbol(Base, Decl(fixingTypeParametersRepeatedly2.ts, 0, 0)) + + toBase(): Base; +>toBase : Symbol(Derived.toBase, Decl(fixingTypeParametersRepeatedly2.ts, 3, 32)) +>Base : Symbol(Base, Decl(fixingTypeParametersRepeatedly2.ts, 0, 0)) +} + +declare var derived: Derived; +>derived : Symbol(derived, Decl(fixingTypeParametersRepeatedly2.ts, 7, 11)) +>Derived : Symbol(Derived, Decl(fixingTypeParametersRepeatedly2.ts, 2, 1)) + +declare function foo(x: T, func: (p: T) => T): T; +>foo : Symbol(foo, Decl(fixingTypeParametersRepeatedly2.ts, 7, 29)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 9, 21)) +>x : Symbol(x, Decl(fixingTypeParametersRepeatedly2.ts, 9, 24)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 9, 21)) +>func : Symbol(func, Decl(fixingTypeParametersRepeatedly2.ts, 9, 29)) +>p : Symbol(p, Decl(fixingTypeParametersRepeatedly2.ts, 9, 37)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 9, 21)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 9, 21)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 9, 21)) + +var result = foo(derived, d => d.toBase()); +>result : Symbol(result, Decl(fixingTypeParametersRepeatedly2.ts, 10, 3), Decl(fixingTypeParametersRepeatedly2.ts, 16, 3)) +>foo : Symbol(foo, Decl(fixingTypeParametersRepeatedly2.ts, 7, 29)) +>derived : Symbol(derived, Decl(fixingTypeParametersRepeatedly2.ts, 7, 11)) +>d : Symbol(d, Decl(fixingTypeParametersRepeatedly2.ts, 10, 25)) +>d.toBase : Symbol(Derived.toBase, Decl(fixingTypeParametersRepeatedly2.ts, 3, 32)) +>d : Symbol(d, Decl(fixingTypeParametersRepeatedly2.ts, 10, 25)) +>toBase : Symbol(Derived.toBase, Decl(fixingTypeParametersRepeatedly2.ts, 3, 32)) + +// bar should type check just like foo. +// The same error should be observed in both cases. +declare function bar(x: T, func: (p: T) => T): T; +>bar : Symbol(bar, Decl(fixingTypeParametersRepeatedly2.ts, 10, 43), Decl(fixingTypeParametersRepeatedly2.ts, 14, 52)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 14, 21)) +>x : Symbol(x, Decl(fixingTypeParametersRepeatedly2.ts, 14, 24)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 14, 21)) +>func : Symbol(func, Decl(fixingTypeParametersRepeatedly2.ts, 14, 29)) +>p : Symbol(p, Decl(fixingTypeParametersRepeatedly2.ts, 14, 37)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 14, 21)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 14, 21)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 14, 21)) + +declare function bar(x: T, func: (p: T) => T): T; +>bar : Symbol(bar, Decl(fixingTypeParametersRepeatedly2.ts, 10, 43), Decl(fixingTypeParametersRepeatedly2.ts, 14, 52)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 15, 21)) +>x : Symbol(x, Decl(fixingTypeParametersRepeatedly2.ts, 15, 24)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 15, 21)) +>func : Symbol(func, Decl(fixingTypeParametersRepeatedly2.ts, 15, 29)) +>p : Symbol(p, Decl(fixingTypeParametersRepeatedly2.ts, 15, 37)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 15, 21)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 15, 21)) +>T : Symbol(T, Decl(fixingTypeParametersRepeatedly2.ts, 15, 21)) + +var result = bar(derived, d => d.toBase()); +>result : Symbol(result, Decl(fixingTypeParametersRepeatedly2.ts, 10, 3), Decl(fixingTypeParametersRepeatedly2.ts, 16, 3)) +>bar : Symbol(bar, Decl(fixingTypeParametersRepeatedly2.ts, 10, 43), Decl(fixingTypeParametersRepeatedly2.ts, 14, 52)) +>derived : Symbol(derived, Decl(fixingTypeParametersRepeatedly2.ts, 7, 11)) +>d : Symbol(d, Decl(fixingTypeParametersRepeatedly2.ts, 16, 25)) +>d.toBase : Symbol(Derived.toBase, Decl(fixingTypeParametersRepeatedly2.ts, 3, 32)) +>d : Symbol(d, Decl(fixingTypeParametersRepeatedly2.ts, 16, 25)) +>toBase : Symbol(Derived.toBase, Decl(fixingTypeParametersRepeatedly2.ts, 3, 32)) + diff --git a/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=typesfirst).types new file mode 100644 index 0000000000000..a94614635d95a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fixingTypeParametersRepeatedly2(checkorder=typesfirst).types @@ -0,0 +1,59 @@ +//// [tests/cases/compiler/fixingTypeParametersRepeatedly2.ts] //// + +=== fixingTypeParametersRepeatedly2.ts === +interface Base { + baseProp; +>baseProp : any +} +interface Derived extends Base { + toBase(): Base; +>toBase : () => Base +} + +declare var derived: Derived; +>derived : Derived + +declare function foo(x: T, func: (p: T) => T): T; +>foo : (x: T, func: (p: T) => T) => T +>x : T +>func : (p: T) => T +>p : T + +var result = foo(derived, d => d.toBase()); +>result : Derived +>foo(derived, d => d.toBase()) : Derived +>foo : (x: T, func: (p: T) => T) => T +>derived : Derived +>d => d.toBase() : (d: Derived) => Base +>d : Derived +>d.toBase() : Base +>d.toBase : () => Base +>d : Derived +>toBase : () => Base + +// bar should type check just like foo. +// The same error should be observed in both cases. +declare function bar(x: T, func: (p: T) => T): T; +>bar : { (x: T, func: (p: T) => T): T; (x: T_1, func: (p: T_1) => T_1): T_1; } +>x : T +>func : (p: T) => T +>p : T + +declare function bar(x: T, func: (p: T) => T): T; +>bar : { (x: T_1, func: (p: T_1) => T_1): T_1; (x: T, func: (p: T) => T): T; } +>x : T +>func : (p: T) => T +>p : T + +var result = bar(derived, d => d.toBase()); +>result : Derived +>bar(derived, d => d.toBase()) : Base +>bar : { (x: T, func: (p: T) => T): T; (x: T, func: (p: T) => T): T; } +>derived : Derived +>d => d.toBase() : (d: Derived) => Base +>d : Derived +>d.toBase() : Base +>d.toBase : any +>d : Derived +>toBase : any + diff --git a/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=default).errors.txt new file mode 100644 index 0000000000000..adfc91cadd7fc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=default).errors.txt @@ -0,0 +1,31 @@ +genericCallReturnedFunctionParameterDefault.ts(24,5): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + + +==== genericCallReturnedFunctionParameterDefault.ts (1 errors) ==== + // The function returned from the callback of a generic call has a parameter + // with a default and no annotation. Once T is inferred, the contextual + // signature of the returned function is its own signature, but the parameter + // already has its type (boolean) from the initializer, computed while T was + // being inferred, so there is no circularity: no TS7022, and 'r()(1)' is an + // error. (Reduced from open-design ProjectView.tsx, useCallback returning + // '{ release: (recoverable = false) => ... }'.) + + declare function id(callback: T): T; + + id(() => { + return (x = false) => {}; + }); + + id(() => (y = false) => y); + + id(() => { + return { m(z = false) {} }; + }); + + const r = id(() => { + return (w = 0) => {}; + }); + r()(""); + ~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=default).symbols new file mode 100644 index 0000000000000..ee8aa11e466f0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=default).symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/genericCallReturnedFunctionParameterDefault.ts] //// + +=== genericCallReturnedFunctionParameterDefault.ts === +// The function returned from the callback of a generic call has a parameter +// with a default and no annotation. Once T is inferred, the contextual +// signature of the returned function is its own signature, but the parameter +// already has its type (boolean) from the initializer, computed while T was +// being inferred, so there is no circularity: no TS7022, and 'r()(1)' is an +// error. (Reduced from open-design ProjectView.tsx, useCallback returning +// '{ release: (recoverable = false) => ... }'.) + +declare function id(callback: T): T; +>id : Symbol(id, Decl(genericCallReturnedFunctionParameterDefault.ts, 0, 0)) +>T : Symbol(T, Decl(genericCallReturnedFunctionParameterDefault.ts, 8, 20)) +>callback : Symbol(callback, Decl(genericCallReturnedFunctionParameterDefault.ts, 8, 23)) +>T : Symbol(T, Decl(genericCallReturnedFunctionParameterDefault.ts, 8, 20)) +>T : Symbol(T, Decl(genericCallReturnedFunctionParameterDefault.ts, 8, 20)) + +id(() => { +>id : Symbol(id, Decl(genericCallReturnedFunctionParameterDefault.ts, 0, 0)) + + return (x = false) => {}; +>x : Symbol(x, Decl(genericCallReturnedFunctionParameterDefault.ts, 11, 12)) + +}); + +id(() => (y = false) => y); +>id : Symbol(id, Decl(genericCallReturnedFunctionParameterDefault.ts, 0, 0)) +>y : Symbol(y, Decl(genericCallReturnedFunctionParameterDefault.ts, 14, 10)) +>y : Symbol(y, Decl(genericCallReturnedFunctionParameterDefault.ts, 14, 10)) + +id(() => { +>id : Symbol(id, Decl(genericCallReturnedFunctionParameterDefault.ts, 0, 0)) + + return { m(z = false) {} }; +>m : Symbol(m, Decl(genericCallReturnedFunctionParameterDefault.ts, 17, 12)) +>z : Symbol(z, Decl(genericCallReturnedFunctionParameterDefault.ts, 17, 15)) + +}); + +const r = id(() => { +>r : Symbol(r, Decl(genericCallReturnedFunctionParameterDefault.ts, 20, 5)) +>id : Symbol(id, Decl(genericCallReturnedFunctionParameterDefault.ts, 0, 0)) + + return (w = 0) => {}; +>w : Symbol(w, Decl(genericCallReturnedFunctionParameterDefault.ts, 21, 12)) + +}); +r()(""); +>r : Symbol(r, Decl(genericCallReturnedFunctionParameterDefault.ts, 20, 5)) + diff --git a/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=default).types new file mode 100644 index 0000000000000..a8c98c3242e89 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=default).types @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/genericCallReturnedFunctionParameterDefault.ts] //// + +=== genericCallReturnedFunctionParameterDefault.ts === +// The function returned from the callback of a generic call has a parameter +// with a default and no annotation. Once T is inferred, the contextual +// signature of the returned function is its own signature, but the parameter +// already has its type (boolean) from the initializer, computed while T was +// being inferred, so there is no circularity: no TS7022, and 'r()(1)' is an +// error. (Reduced from open-design ProjectView.tsx, useCallback returning +// '{ release: (recoverable = false) => ... }'.) + +declare function id(callback: T): T; +>id : (callback: T) => T +>callback : T + +id(() => { +>id(() => { return (x = false) => {};}) : () => (x?: boolean) => void +>id : (callback: T) => T +>() => { return (x = false) => {};} : () => (x?: boolean) => void + + return (x = false) => {}; +>(x = false) => {} : (x?: boolean) => void +>x : boolean +>false : false + +}); + +id(() => (y = false) => y); +>id(() => (y = false) => y) : () => (y?: boolean) => boolean +>id : (callback: T) => T +>() => (y = false) => y : () => (y?: boolean) => boolean +>(y = false) => y : (y?: boolean) => boolean +>y : boolean +>false : false +>y : boolean + +id(() => { +>id(() => { return { m(z = false) {} };}) : () => { m(z?: boolean): void; } +>id : (callback: T) => T +>() => { return { m(z = false) {} };} : () => { m(z?: boolean): void; } + + return { m(z = false) {} }; +>{ m(z = false) {} } : { m(z?: boolean): void; } +>m : (z?: boolean) => void +>z : boolean +>false : false + +}); + +const r = id(() => { +>r : () => (w?: number) => void +>id(() => { return (w = 0) => {};}) : () => (w?: number) => void +>id : (callback: T) => T +>() => { return (w = 0) => {};} : () => (w?: number) => void + + return (w = 0) => {}; +>(w = 0) => {} : (w?: number) => void +>w : number +>0 : 0 + +}); +r()(""); +>r()("") : void +>r() : (w?: number) => void +>r : () => (w?: number) => void +>"" : "" + diff --git a/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..adfc91cadd7fc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=typesfirst).errors.txt @@ -0,0 +1,31 @@ +genericCallReturnedFunctionParameterDefault.ts(24,5): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + + +==== genericCallReturnedFunctionParameterDefault.ts (1 errors) ==== + // The function returned from the callback of a generic call has a parameter + // with a default and no annotation. Once T is inferred, the contextual + // signature of the returned function is its own signature, but the parameter + // already has its type (boolean) from the initializer, computed while T was + // being inferred, so there is no circularity: no TS7022, and 'r()(1)' is an + // error. (Reduced from open-design ProjectView.tsx, useCallback returning + // '{ release: (recoverable = false) => ... }'.) + + declare function id(callback: T): T; + + id(() => { + return (x = false) => {}; + }); + + id(() => (y = false) => y); + + id(() => { + return { m(z = false) {} }; + }); + + const r = id(() => { + return (w = 0) => {}; + }); + r()(""); + ~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..ee8aa11e466f0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=typesfirst).symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/genericCallReturnedFunctionParameterDefault.ts] //// + +=== genericCallReturnedFunctionParameterDefault.ts === +// The function returned from the callback of a generic call has a parameter +// with a default and no annotation. Once T is inferred, the contextual +// signature of the returned function is its own signature, but the parameter +// already has its type (boolean) from the initializer, computed while T was +// being inferred, so there is no circularity: no TS7022, and 'r()(1)' is an +// error. (Reduced from open-design ProjectView.tsx, useCallback returning +// '{ release: (recoverable = false) => ... }'.) + +declare function id(callback: T): T; +>id : Symbol(id, Decl(genericCallReturnedFunctionParameterDefault.ts, 0, 0)) +>T : Symbol(T, Decl(genericCallReturnedFunctionParameterDefault.ts, 8, 20)) +>callback : Symbol(callback, Decl(genericCallReturnedFunctionParameterDefault.ts, 8, 23)) +>T : Symbol(T, Decl(genericCallReturnedFunctionParameterDefault.ts, 8, 20)) +>T : Symbol(T, Decl(genericCallReturnedFunctionParameterDefault.ts, 8, 20)) + +id(() => { +>id : Symbol(id, Decl(genericCallReturnedFunctionParameterDefault.ts, 0, 0)) + + return (x = false) => {}; +>x : Symbol(x, Decl(genericCallReturnedFunctionParameterDefault.ts, 11, 12)) + +}); + +id(() => (y = false) => y); +>id : Symbol(id, Decl(genericCallReturnedFunctionParameterDefault.ts, 0, 0)) +>y : Symbol(y, Decl(genericCallReturnedFunctionParameterDefault.ts, 14, 10)) +>y : Symbol(y, Decl(genericCallReturnedFunctionParameterDefault.ts, 14, 10)) + +id(() => { +>id : Symbol(id, Decl(genericCallReturnedFunctionParameterDefault.ts, 0, 0)) + + return { m(z = false) {} }; +>m : Symbol(m, Decl(genericCallReturnedFunctionParameterDefault.ts, 17, 12)) +>z : Symbol(z, Decl(genericCallReturnedFunctionParameterDefault.ts, 17, 15)) + +}); + +const r = id(() => { +>r : Symbol(r, Decl(genericCallReturnedFunctionParameterDefault.ts, 20, 5)) +>id : Symbol(id, Decl(genericCallReturnedFunctionParameterDefault.ts, 0, 0)) + + return (w = 0) => {}; +>w : Symbol(w, Decl(genericCallReturnedFunctionParameterDefault.ts, 21, 12)) + +}); +r()(""); +>r : Symbol(r, Decl(genericCallReturnedFunctionParameterDefault.ts, 20, 5)) + diff --git a/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=typesfirst).types new file mode 100644 index 0000000000000..a8c98c3242e89 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericCallReturnedFunctionParameterDefault(checkorder=typesfirst).types @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/genericCallReturnedFunctionParameterDefault.ts] //// + +=== genericCallReturnedFunctionParameterDefault.ts === +// The function returned from the callback of a generic call has a parameter +// with a default and no annotation. Once T is inferred, the contextual +// signature of the returned function is its own signature, but the parameter +// already has its type (boolean) from the initializer, computed while T was +// being inferred, so there is no circularity: no TS7022, and 'r()(1)' is an +// error. (Reduced from open-design ProjectView.tsx, useCallback returning +// '{ release: (recoverable = false) => ... }'.) + +declare function id(callback: T): T; +>id : (callback: T) => T +>callback : T + +id(() => { +>id(() => { return (x = false) => {};}) : () => (x?: boolean) => void +>id : (callback: T) => T +>() => { return (x = false) => {};} : () => (x?: boolean) => void + + return (x = false) => {}; +>(x = false) => {} : (x?: boolean) => void +>x : boolean +>false : false + +}); + +id(() => (y = false) => y); +>id(() => (y = false) => y) : () => (y?: boolean) => boolean +>id : (callback: T) => T +>() => (y = false) => y : () => (y?: boolean) => boolean +>(y = false) => y : (y?: boolean) => boolean +>y : boolean +>false : false +>y : boolean + +id(() => { +>id(() => { return { m(z = false) {} };}) : () => { m(z?: boolean): void; } +>id : (callback: T) => T +>() => { return { m(z = false) {} };} : () => { m(z?: boolean): void; } + + return { m(z = false) {} }; +>{ m(z = false) {} } : { m(z?: boolean): void; } +>m : (z?: boolean) => void +>z : boolean +>false : false + +}); + +const r = id(() => { +>r : () => (w?: number) => void +>id(() => { return (w = 0) => {};}) : () => (w?: number) => void +>id : (callback: T) => T +>() => { return (w = 0) => {};} : () => (w?: number) => void + + return (w = 0) => {}; +>(w = 0) => {} : (w?: number) => void +>w : number +>0 : 0 + +}); +r()(""); +>r()("") : void +>r() : (w?: number) => void +>r : () => (w?: number) => void +>"" : "" + diff --git a/tsc/testdata/baselines/reference/compiler/getterCircularityDiagnostics.errors.txt b/tsc/testdata/baselines/reference/compiler/getterCircularityDiagnostics.errors.txt new file mode 100644 index 0000000000000..ada42d0527e20 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/getterCircularityDiagnostics.errors.txt @@ -0,0 +1,17 @@ +getterCircularityDiagnostics.ts(4,9): error TS7023: 'options' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. + + +==== getterCircularityDiagnostics.ts (1 errors) ==== + declare const props: Options; + + class Container { + get options() { + ~~~~~~~ +!!! error TS7023: 'options' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. + return { container: this, ...props } as Options; + } + } + + interface Options { + container?: Container; + } \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/getterCircularityDiagnostics.js b/tsc/testdata/baselines/reference/compiler/getterCircularityDiagnostics.js new file mode 100644 index 0000000000000..e7507ff16bec4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/getterCircularityDiagnostics.js @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/getterCircularityDiagnostics.ts] //// + +//// [getterCircularityDiagnostics.ts] +declare const props: Options; + +class Container { + get options() { + return { container: this, ...props } as Options; + } +} + +interface Options { + container?: Container; +} + +//// [getterCircularityDiagnostics.js] +"use strict"; +class Container { + get options() { + return Object.assign({ container: this }, props); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/getterCircularityDiagnostics.symbols b/tsc/testdata/baselines/reference/compiler/getterCircularityDiagnostics.symbols new file mode 100644 index 0000000000000..7ef53202b8061 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/getterCircularityDiagnostics.symbols @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/getterCircularityDiagnostics.ts] //// + +=== getterCircularityDiagnostics.ts === +declare const props: Options; +>props : Symbol(props, Decl(getterCircularityDiagnostics.ts, 0, 13)) +>Options : Symbol(Options, Decl(getterCircularityDiagnostics.ts, 6, 1)) + +class Container { +>Container : Symbol(Container, Decl(getterCircularityDiagnostics.ts, 0, 29)) + + get options() { +>options : Symbol(Container.options, Decl(getterCircularityDiagnostics.ts, 2, 17)) + + return { container: this, ...props } as Options; +>container : Symbol(container, Decl(getterCircularityDiagnostics.ts, 4, 16)) +>this : Symbol(Container, Decl(getterCircularityDiagnostics.ts, 0, 29)) +>props : Symbol(props, Decl(getterCircularityDiagnostics.ts, 0, 13)) +>Options : Symbol(Options, Decl(getterCircularityDiagnostics.ts, 6, 1)) + } +} + +interface Options { +>Options : Symbol(Options, Decl(getterCircularityDiagnostics.ts, 6, 1)) + + container?: Container; +>container : Symbol(Options.container, Decl(getterCircularityDiagnostics.ts, 8, 19)) +>Container : Symbol(Container, Decl(getterCircularityDiagnostics.ts, 0, 29)) +} diff --git a/tsc/testdata/baselines/reference/compiler/getterCircularityDiagnostics.types b/tsc/testdata/baselines/reference/compiler/getterCircularityDiagnostics.types new file mode 100644 index 0000000000000..03f8b125b218d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/getterCircularityDiagnostics.types @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/getterCircularityDiagnostics.ts] //// + +=== getterCircularityDiagnostics.ts === +declare const props: Options; +>props : Options + +class Container { +>Container : Container + + get options() { +>options : any + + return { container: this, ...props } as Options; +>{ container: this, ...props } as Options : Options +>{ container: this, ...props } : { container: Container; } +>container : this +>this : this +>props : Options + } +} + +interface Options { + container?: Container; +>container : Container | undefined +} diff --git a/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=default).errors.txt new file mode 100644 index 0000000000000..b1e49290327ec --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=default).errors.txt @@ -0,0 +1,22 @@ +indexedAccessAccessFlagsUnionOrder.ts(3,11): error TS2322: Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +indexedAccessAccessFlagsUnionOrder.ts(5,11): error TS2322: Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. + + +==== indexedAccessAccessFlagsUnionOrder.ts (2 errors) ==== + function f, K extends keyof T>(obj: T, k: K, b: boolean) { + const x = b ? obj[k] : g(); + const s1: string = x; + ~~ +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + const y = b ? g() : obj[k]; + const s2: string = y; + ~~ +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + } + + declare function g(): T[K]; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=default).symbols new file mode 100644 index 0000000000000..1c03287916ff1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=default).symbols @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/indexedAccessAccessFlagsUnionOrder.ts] //// + +=== indexedAccessAccessFlagsUnionOrder.ts === +function f, K extends keyof T>(obj: T, k: K, b: boolean) { +>f : Symbol(f, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 0)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 11)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>K : Symbol(K, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 44)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 11)) +>obj : Symbol(obj, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 64)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 11)) +>k : Symbol(k, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 71)) +>K : Symbol(K, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 44)) +>b : Symbol(b, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 77)) + + const x = b ? obj[k] : g(); +>x : Symbol(x, Decl(indexedAccessAccessFlagsUnionOrder.ts, 1, 9)) +>b : Symbol(b, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 77)) +>obj : Symbol(obj, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 64)) +>k : Symbol(k, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 71)) +>g : Symbol(g, Decl(indexedAccessAccessFlagsUnionOrder.ts, 5, 1)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 11)) +>K : Symbol(K, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 44)) + + const s1: string = x; +>s1 : Symbol(s1, Decl(indexedAccessAccessFlagsUnionOrder.ts, 2, 9)) +>x : Symbol(x, Decl(indexedAccessAccessFlagsUnionOrder.ts, 1, 9)) + + const y = b ? g() : obj[k]; +>y : Symbol(y, Decl(indexedAccessAccessFlagsUnionOrder.ts, 3, 9)) +>b : Symbol(b, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 77)) +>g : Symbol(g, Decl(indexedAccessAccessFlagsUnionOrder.ts, 5, 1)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 11)) +>K : Symbol(K, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 44)) +>obj : Symbol(obj, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 64)) +>k : Symbol(k, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 71)) + + const s2: string = y; +>s2 : Symbol(s2, Decl(indexedAccessAccessFlagsUnionOrder.ts, 4, 9)) +>y : Symbol(y, Decl(indexedAccessAccessFlagsUnionOrder.ts, 3, 9)) +} + +declare function g(): T[K]; +>g : Symbol(g, Decl(indexedAccessAccessFlagsUnionOrder.ts, 5, 1)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 7, 19)) +>K : Symbol(K, Decl(indexedAccessAccessFlagsUnionOrder.ts, 7, 21)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 7, 19)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 7, 19)) +>K : Symbol(K, Decl(indexedAccessAccessFlagsUnionOrder.ts, 7, 21)) + diff --git a/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=default).types new file mode 100644 index 0000000000000..5f8f696fbf930 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=default).types @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/indexedAccessAccessFlagsUnionOrder.ts] //// + +=== indexedAccessAccessFlagsUnionOrder.ts === +function f, K extends keyof T>(obj: T, k: K, b: boolean) { +>f : , K extends keyof T>(obj: T, k: K, b: boolean) => void +>obj : T +>k : K +>b : boolean + + const x = b ? obj[k] : g(); +>x : T[K] +>b ? obj[k] : g() : T[K] +>b : boolean +>obj[k] : T[K] +>obj : T +>k : K +>g() : T[K] +>g : () => T_1[K_1] + + const s1: string = x; +>s1 : string +>x : string | undefined + + const y = b ? g() : obj[k]; +>y : T[K] +>b ? g() : obj[k] : T[K] +>b : boolean +>g() : T[K] +>g : () => T_1[K_1] +>obj[k] : T[K] +>obj : T +>k : K + + const s2: string = y; +>s2 : string +>y : string | undefined +} + +declare function g(): T[K]; +>g : () => T[K] + diff --git a/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..1c03287916ff1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=typesfirst).symbols @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/indexedAccessAccessFlagsUnionOrder.ts] //// + +=== indexedAccessAccessFlagsUnionOrder.ts === +function f, K extends keyof T>(obj: T, k: K, b: boolean) { +>f : Symbol(f, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 0)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 11)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>K : Symbol(K, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 44)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 11)) +>obj : Symbol(obj, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 64)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 11)) +>k : Symbol(k, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 71)) +>K : Symbol(K, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 44)) +>b : Symbol(b, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 77)) + + const x = b ? obj[k] : g(); +>x : Symbol(x, Decl(indexedAccessAccessFlagsUnionOrder.ts, 1, 9)) +>b : Symbol(b, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 77)) +>obj : Symbol(obj, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 64)) +>k : Symbol(k, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 71)) +>g : Symbol(g, Decl(indexedAccessAccessFlagsUnionOrder.ts, 5, 1)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 11)) +>K : Symbol(K, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 44)) + + const s1: string = x; +>s1 : Symbol(s1, Decl(indexedAccessAccessFlagsUnionOrder.ts, 2, 9)) +>x : Symbol(x, Decl(indexedAccessAccessFlagsUnionOrder.ts, 1, 9)) + + const y = b ? g() : obj[k]; +>y : Symbol(y, Decl(indexedAccessAccessFlagsUnionOrder.ts, 3, 9)) +>b : Symbol(b, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 77)) +>g : Symbol(g, Decl(indexedAccessAccessFlagsUnionOrder.ts, 5, 1)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 11)) +>K : Symbol(K, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 44)) +>obj : Symbol(obj, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 64)) +>k : Symbol(k, Decl(indexedAccessAccessFlagsUnionOrder.ts, 0, 71)) + + const s2: string = y; +>s2 : Symbol(s2, Decl(indexedAccessAccessFlagsUnionOrder.ts, 4, 9)) +>y : Symbol(y, Decl(indexedAccessAccessFlagsUnionOrder.ts, 3, 9)) +} + +declare function g(): T[K]; +>g : Symbol(g, Decl(indexedAccessAccessFlagsUnionOrder.ts, 5, 1)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 7, 19)) +>K : Symbol(K, Decl(indexedAccessAccessFlagsUnionOrder.ts, 7, 21)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 7, 19)) +>T : Symbol(T, Decl(indexedAccessAccessFlagsUnionOrder.ts, 7, 19)) +>K : Symbol(K, Decl(indexedAccessAccessFlagsUnionOrder.ts, 7, 21)) + diff --git a/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=typesfirst).types new file mode 100644 index 0000000000000..3842ea2cb6352 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/indexedAccessAccessFlagsUnionOrder(checkorder=typesfirst).types @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/indexedAccessAccessFlagsUnionOrder.ts] //// + +=== indexedAccessAccessFlagsUnionOrder.ts === +function f, K extends keyof T>(obj: T, k: K, b: boolean) { +>f : , K extends keyof T>(obj: T, k: K, b: boolean) => void +>obj : T +>k : K +>b : boolean + + const x = b ? obj[k] : g(); +>x : T[K] +>b ? obj[k] : g() : T[K] +>b : boolean +>obj[k] : T[K] +>obj : T +>k : K +>g() : T[K] +>g : () => T_1[K_1] + + const s1: string = x; +>s1 : string +>x : T[K] + + const y = b ? g() : obj[k]; +>y : T[K] +>b ? g() : obj[k] : T[K] +>b : boolean +>g() : T[K] +>g : () => T_1[K_1] +>obj[k] : T[K] +>obj : T +>k : K + + const s2: string = y; +>s2 : string +>y : T[K] +} + +declare function g(): T[K]; +>g : () => T[K] + diff --git a/tsc/testdata/baselines/reference/compiler/inferenceDeeplyNestedCheckOrder.errors.txt b/tsc/testdata/baselines/reference/compiler/inferenceDeeplyNestedCheckOrder.errors.txt new file mode 100644 index 0000000000000..32e5d2c00be81 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/inferenceDeeplyNestedCheckOrder.errors.txt @@ -0,0 +1,24 @@ +first.ts(3,7): error TS2322: Type 'unknown[]' is not assignable to type 'null'. +second.ts(6,7): error TS2322: Type 'number[]' is not assignable to type 'null'. + + +==== first.ts (1 errors) ==== + declare function flatten1(iterable: Iterable>): T[]; + declare const lists1: string[][]; + const flat1: null = flatten1(lists1); + ~~~~~ +!!! error TS2322: Type 'unknown[]' is not assignable to type 'null'. + + declare const items1: string[]; + for (const item of items1) {} + +==== second.ts (1 errors) ==== + declare const items2: number[]; + for (const item of items2) {} + + declare function flatten2(iterable: Iterable>): T[]; + declare const lists2: number[][]; + const flat2: null = flatten2(lists2); + ~~~~~ +!!! error TS2322: Type 'number[]' is not assignable to type 'null'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/inferenceDeeplyNestedCheckOrder.symbols b/tsc/testdata/baselines/reference/compiler/inferenceDeeplyNestedCheckOrder.symbols new file mode 100644 index 0000000000000..57cb4ce9d6984 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/inferenceDeeplyNestedCheckOrder.symbols @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/inferenceDeeplyNestedCheckOrder.ts] //// + +=== first.ts === +declare function flatten1(iterable: Iterable>): T[]; +>flatten1 : Symbol(flatten1, Decl(first.ts, 0, 0)) +>T : Symbol(T, Decl(first.ts, 0, 26)) +>iterable : Symbol(iterable, Decl(first.ts, 0, 29)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) +>T : Symbol(T, Decl(first.ts, 0, 26)) +>T : Symbol(T, Decl(first.ts, 0, 26)) + +declare const lists1: string[][]; +>lists1 : Symbol(lists1, Decl(first.ts, 1, 13)) + +const flat1: null = flatten1(lists1); +>flat1 : Symbol(flat1, Decl(first.ts, 2, 5)) +>flatten1 : Symbol(flatten1, Decl(first.ts, 0, 0)) +>lists1 : Symbol(lists1, Decl(first.ts, 1, 13)) + +declare const items1: string[]; +>items1 : Symbol(items1, Decl(first.ts, 4, 13)) + +for (const item of items1) {} +>item : Symbol(item, Decl(first.ts, 5, 10)) +>items1 : Symbol(items1, Decl(first.ts, 4, 13)) + +=== second.ts === +declare const items2: number[]; +>items2 : Symbol(items2, Decl(second.ts, 0, 13)) + +for (const item of items2) {} +>item : Symbol(item, Decl(second.ts, 1, 10)) +>items2 : Symbol(items2, Decl(second.ts, 0, 13)) + +declare function flatten2(iterable: Iterable>): T[]; +>flatten2 : Symbol(flatten2, Decl(second.ts, 1, 29)) +>T : Symbol(T, Decl(second.ts, 3, 26)) +>iterable : Symbol(iterable, Decl(second.ts, 3, 29)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) +>T : Symbol(T, Decl(second.ts, 3, 26)) +>T : Symbol(T, Decl(second.ts, 3, 26)) + +declare const lists2: number[][]; +>lists2 : Symbol(lists2, Decl(second.ts, 4, 13)) + +const flat2: null = flatten2(lists2); +>flat2 : Symbol(flat2, Decl(second.ts, 5, 5)) +>flatten2 : Symbol(flatten2, Decl(second.ts, 1, 29)) +>lists2 : Symbol(lists2, Decl(second.ts, 4, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/inferenceDeeplyNestedCheckOrder.types b/tsc/testdata/baselines/reference/compiler/inferenceDeeplyNestedCheckOrder.types new file mode 100644 index 0000000000000..c1fc223370a61 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/inferenceDeeplyNestedCheckOrder.types @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/inferenceDeeplyNestedCheckOrder.ts] //// + +=== first.ts === +declare function flatten1(iterable: Iterable>): T[]; +>flatten1 : (iterable: Iterable>) => T[] +>iterable : Iterable> + +declare const lists1: string[][]; +>lists1 : string[][] + +const flat1: null = flatten1(lists1); +>flat1 : null +>flatten1(lists1) : unknown[] +>flatten1 : (iterable: Iterable>) => T[] +>lists1 : string[][] + +declare const items1: string[]; +>items1 : string[] + +for (const item of items1) {} +>item : string +>items1 : string[] + +=== second.ts === +declare const items2: number[]; +>items2 : number[] + +for (const item of items2) {} +>item : number +>items2 : number[] + +declare function flatten2(iterable: Iterable>): T[]; +>flatten2 : (iterable: Iterable>) => T[] +>iterable : Iterable> + +declare const lists2: number[][]; +>lists2 : number[][] + +const flat2: null = flatten2(lists2); +>flat2 : null +>flatten2(lists2) : number[] +>flatten2 : (iterable: Iterable>) => T[] +>lists2 : number[][] + diff --git a/tsc/testdata/baselines/reference/compiler/instantiationCouldContainTypeVariablesAfterCycle(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/instantiationCouldContainTypeVariablesAfterCycle(checkorder=default).symbols new file mode 100644 index 0000000000000..0031705ad6203 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/instantiationCouldContainTypeVariablesAfterCycle(checkorder=default).symbols @@ -0,0 +1,69 @@ +//// [tests/cases/compiler/instantiationCouldContainTypeVariablesAfterCycle.ts] //// + +=== instantiationCouldContainTypeVariablesAfterCycle.ts === +// Query is instantiated with only non-generic arguments, so it (and DeepPartial>) +// can't contain type variables, and inference from Meta must not structurally recurse into +// DeepPartial>. That recursion would expand the infinite DeepPartial and report +// TS5114. The carry-forward of the "could contain type variables" flag set at instantiation time +// must survive even when the instantiation is created inside a circularity that is later discarded. + +declare const a: Meta; +>a : Symbol(a, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 6, 13)) +>Meta : Symbol(Meta, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 36)) + +fromMetadata(a); +>fromMetadata : Symbol(fromMetadata, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 16, 33)) +>a : Symbol(a, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 6, 13)) + +type DeepPartial = { [P in keyof T]: DeepPartial }; +>DeepPartial : Symbol(DeepPartial, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 7, 16)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 17)) +>P : Symbol(P, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 25)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 17)) +>DeepPartial : Symbol(DeepPartial, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 7, 16)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 17)) +>P : Symbol(P, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 25)) + +type Nested = Nested[]; +>Nested : Symbol(Nested, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 60)) +>Nested : Symbol(Nested, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 60)) + +interface Prop { owner: Meta } +>Prop : Symbol(Prop, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 9, 23)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 15)) +>owner : Symbol(Prop.owner, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 19)) +>Meta : Symbol(Meta, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 36)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 15)) + +interface Meta { +>Meta : Symbol(Meta, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 36)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 11, 15)) + + prop: Prop; +>prop : Symbol(Meta.prop, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 11, 19)) +>Prop : Symbol(Prop, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 9, 23)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 11, 15)) + + other: any; +>other : Symbol(Meta.other, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 12, 18)) + + query: Query; +>query : Symbol(Meta.query, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 13, 15)) +>Query : Symbol(Query, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 15, 1)) +} +type Query = { cond: Nested }; +>Query : Symbol(Query, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 15, 1)) +>X : Symbol(X, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 16, 11)) +>cond : Symbol(cond, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 16, 17)) +>Nested : Symbol(Nested, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 60)) + +declare function fromMetadata(meta: Meta | DeepPartial>): void; +>fromMetadata : Symbol(fromMetadata, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 16, 33)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 17, 30)) +>meta : Symbol(meta, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 17, 33)) +>Meta : Symbol(Meta, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 36)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 17, 30)) +>DeepPartial : Symbol(DeepPartial, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 7, 16)) +>Meta : Symbol(Meta, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 36)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 17, 30)) + diff --git a/tsc/testdata/baselines/reference/compiler/instantiationCouldContainTypeVariablesAfterCycle(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/instantiationCouldContainTypeVariablesAfterCycle(checkorder=default).types new file mode 100644 index 0000000000000..1541a7890f5e6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/instantiationCouldContainTypeVariablesAfterCycle(checkorder=default).types @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/instantiationCouldContainTypeVariablesAfterCycle.ts] //// + +=== instantiationCouldContainTypeVariablesAfterCycle.ts === +// Query is instantiated with only non-generic arguments, so it (and DeepPartial>) +// can't contain type variables, and inference from Meta must not structurally recurse into +// DeepPartial>. That recursion would expand the infinite DeepPartial and report +// TS5114. The carry-forward of the "could contain type variables" flag set at instantiation time +// must survive even when the instantiation is created inside a circularity that is later discarded. + +declare const a: Meta; +>a : Meta + +fromMetadata(a); +>fromMetadata(a) : void +>fromMetadata : (meta: Meta | DeepPartial>) => void +>a : Meta + +type DeepPartial = { [P in keyof T]: DeepPartial }; +>DeepPartial : DeepPartial + +type Nested = Nested[]; +>Nested : Nested + +interface Prop { owner: Meta } +>owner : Meta + +interface Meta { + prop: Prop; +>prop : Prop + + other: any; +>other : any + + query: Query; +>query : Query +} +type Query = { cond: Nested }; +>Query : Query +>cond : Nested + +declare function fromMetadata(meta: Meta | DeepPartial>): void; +>fromMetadata : (meta: Meta | DeepPartial>) => void +>meta : DeepPartial> | Meta + diff --git a/tsc/testdata/baselines/reference/compiler/instantiationCouldContainTypeVariablesAfterCycle(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/instantiationCouldContainTypeVariablesAfterCycle(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..0031705ad6203 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/instantiationCouldContainTypeVariablesAfterCycle(checkorder=typesfirst).symbols @@ -0,0 +1,69 @@ +//// [tests/cases/compiler/instantiationCouldContainTypeVariablesAfterCycle.ts] //// + +=== instantiationCouldContainTypeVariablesAfterCycle.ts === +// Query is instantiated with only non-generic arguments, so it (and DeepPartial>) +// can't contain type variables, and inference from Meta must not structurally recurse into +// DeepPartial>. That recursion would expand the infinite DeepPartial and report +// TS5114. The carry-forward of the "could contain type variables" flag set at instantiation time +// must survive even when the instantiation is created inside a circularity that is later discarded. + +declare const a: Meta; +>a : Symbol(a, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 6, 13)) +>Meta : Symbol(Meta, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 36)) + +fromMetadata(a); +>fromMetadata : Symbol(fromMetadata, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 16, 33)) +>a : Symbol(a, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 6, 13)) + +type DeepPartial = { [P in keyof T]: DeepPartial }; +>DeepPartial : Symbol(DeepPartial, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 7, 16)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 17)) +>P : Symbol(P, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 25)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 17)) +>DeepPartial : Symbol(DeepPartial, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 7, 16)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 17)) +>P : Symbol(P, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 25)) + +type Nested = Nested[]; +>Nested : Symbol(Nested, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 60)) +>Nested : Symbol(Nested, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 60)) + +interface Prop { owner: Meta } +>Prop : Symbol(Prop, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 9, 23)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 15)) +>owner : Symbol(Prop.owner, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 19)) +>Meta : Symbol(Meta, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 36)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 15)) + +interface Meta { +>Meta : Symbol(Meta, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 36)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 11, 15)) + + prop: Prop; +>prop : Symbol(Meta.prop, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 11, 19)) +>Prop : Symbol(Prop, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 9, 23)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 11, 15)) + + other: any; +>other : Symbol(Meta.other, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 12, 18)) + + query: Query; +>query : Symbol(Meta.query, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 13, 15)) +>Query : Symbol(Query, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 15, 1)) +} +type Query = { cond: Nested }; +>Query : Symbol(Query, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 15, 1)) +>X : Symbol(X, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 16, 11)) +>cond : Symbol(cond, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 16, 17)) +>Nested : Symbol(Nested, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 8, 60)) + +declare function fromMetadata(meta: Meta | DeepPartial>): void; +>fromMetadata : Symbol(fromMetadata, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 16, 33)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 17, 30)) +>meta : Symbol(meta, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 17, 33)) +>Meta : Symbol(Meta, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 36)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 17, 30)) +>DeepPartial : Symbol(DeepPartial, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 7, 16)) +>Meta : Symbol(Meta, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 10, 36)) +>T : Symbol(T, Decl(instantiationCouldContainTypeVariablesAfterCycle.ts, 17, 30)) + diff --git a/tsc/testdata/baselines/reference/compiler/instantiationCouldContainTypeVariablesAfterCycle(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/instantiationCouldContainTypeVariablesAfterCycle(checkorder=typesfirst).types new file mode 100644 index 0000000000000..1541a7890f5e6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/instantiationCouldContainTypeVariablesAfterCycle(checkorder=typesfirst).types @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/instantiationCouldContainTypeVariablesAfterCycle.ts] //// + +=== instantiationCouldContainTypeVariablesAfterCycle.ts === +// Query is instantiated with only non-generic arguments, so it (and DeepPartial>) +// can't contain type variables, and inference from Meta must not structurally recurse into +// DeepPartial>. That recursion would expand the infinite DeepPartial and report +// TS5114. The carry-forward of the "could contain type variables" flag set at instantiation time +// must survive even when the instantiation is created inside a circularity that is later discarded. + +declare const a: Meta; +>a : Meta + +fromMetadata(a); +>fromMetadata(a) : void +>fromMetadata : (meta: Meta | DeepPartial>) => void +>a : Meta + +type DeepPartial = { [P in keyof T]: DeepPartial }; +>DeepPartial : DeepPartial + +type Nested = Nested[]; +>Nested : Nested + +interface Prop { owner: Meta } +>owner : Meta + +interface Meta { + prop: Prop; +>prop : Prop + + other: any; +>other : any + + query: Query; +>query : Query +} +type Query = { cond: Nested }; +>Query : Query +>cond : Nested + +declare function fromMetadata(meta: Meta | DeepPartial>): void; +>fromMetadata : (meta: Meta | DeepPartial>) => void +>meta : DeepPartial> | Meta + diff --git a/tsc/testdata/baselines/reference/compiler/instantiationLimitsCheckOrder.errors.txt b/tsc/testdata/baselines/reference/compiler/instantiationLimitsCheckOrder.errors.txt new file mode 100644 index 0000000000000..69dd6c2b622df --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/instantiationLimitsCheckOrder.errors.txt @@ -0,0 +1,24 @@ +instantiationLimitsCheckOrder.ts(11,16): error TS2589: Type instantiation is excessively deep and possibly infinite. + + +==== instantiationLimitsCheckOrder.ts (1 errors) ==== + // The depth limit on instantiations must not depend on what was + // instantiated before. The limit on the number of instantiations does, as + // it only stops runaway instantiations, so it is only tested for a single + // statement whose work nothing else shares. + + type D = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; + type K = `${D}${D}${D}`; + + // Several million instantiations, well over the limit, for one statement. + type Wide = N["length"] extends 8 ? I : { [J in K]: Wide<[...N, 0], [J, I][0]> }[K]; + type WideAll = Wide<[], "">; + ~~~~~~~~~~~~ +!!! error TS2589: Type instantiation is excessively deep and possibly infinite. + + // Over a hundred nested instantiations, half of which already happened for + // another statement. + type Deep = N["length"] extends 60 ? never : Deep<[...N, 0]> | N["length"]; + type DeepTail = Deep<[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]>; + type DeepAll = Deep<[]>; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/instantiationLimitsCheckOrder.symbols b/tsc/testdata/baselines/reference/compiler/instantiationLimitsCheckOrder.symbols new file mode 100644 index 0000000000000..c49f0e567e06e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/instantiationLimitsCheckOrder.symbols @@ -0,0 +1,54 @@ +//// [tests/cases/compiler/instantiationLimitsCheckOrder.ts] //// + +=== instantiationLimitsCheckOrder.ts === +// The depth limit on instantiations must not depend on what was +// instantiated before. The limit on the number of instantiations does, as +// it only stops runaway instantiations, so it is only tested for a single +// statement whose work nothing else shares. + +type D = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; +>D : Symbol(D, Decl(instantiationLimitsCheckOrder.ts, 0, 0)) + +type K = `${D}${D}${D}`; +>K : Symbol(K, Decl(instantiationLimitsCheckOrder.ts, 5, 47)) +>D : Symbol(D, Decl(instantiationLimitsCheckOrder.ts, 0, 0)) +>D : Symbol(D, Decl(instantiationLimitsCheckOrder.ts, 0, 0)) +>D : Symbol(D, Decl(instantiationLimitsCheckOrder.ts, 0, 0)) + +// Several million instantiations, well over the limit, for one statement. +type Wide = N["length"] extends 8 ? I : { [J in K]: Wide<[...N, 0], [J, I][0]> }[K]; +>Wide : Symbol(Wide, Decl(instantiationLimitsCheckOrder.ts, 6, 24)) +>N : Symbol(N, Decl(instantiationLimitsCheckOrder.ts, 9, 10)) +>I : Symbol(I, Decl(instantiationLimitsCheckOrder.ts, 9, 24)) +>N : Symbol(N, Decl(instantiationLimitsCheckOrder.ts, 9, 10)) +>I : Symbol(I, Decl(instantiationLimitsCheckOrder.ts, 9, 24)) +>J : Symbol(J, Decl(instantiationLimitsCheckOrder.ts, 9, 61)) +>K : Symbol(K, Decl(instantiationLimitsCheckOrder.ts, 5, 47)) +>Wide : Symbol(Wide, Decl(instantiationLimitsCheckOrder.ts, 6, 24)) +>N : Symbol(N, Decl(instantiationLimitsCheckOrder.ts, 9, 10)) +>J : Symbol(J, Decl(instantiationLimitsCheckOrder.ts, 9, 61)) +>I : Symbol(I, Decl(instantiationLimitsCheckOrder.ts, 9, 24)) +>K : Symbol(K, Decl(instantiationLimitsCheckOrder.ts, 5, 47)) + +type WideAll = Wide<[], "">; +>WideAll : Symbol(WideAll, Decl(instantiationLimitsCheckOrder.ts, 9, 102)) +>Wide : Symbol(Wide, Decl(instantiationLimitsCheckOrder.ts, 6, 24)) + +// Over a hundred nested instantiations, half of which already happened for +// another statement. +type Deep = N["length"] extends 60 ? never : Deep<[...N, 0]> | N["length"]; +>Deep : Symbol(Deep, Decl(instantiationLimitsCheckOrder.ts, 10, 28)) +>N : Symbol(N, Decl(instantiationLimitsCheckOrder.ts, 14, 10)) +>N : Symbol(N, Decl(instantiationLimitsCheckOrder.ts, 14, 10)) +>Deep : Symbol(Deep, Decl(instantiationLimitsCheckOrder.ts, 10, 28)) +>N : Symbol(N, Decl(instantiationLimitsCheckOrder.ts, 14, 10)) +>N : Symbol(N, Decl(instantiationLimitsCheckOrder.ts, 14, 10)) + +type DeepTail = Deep<[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]>; +>DeepTail : Symbol(DeepTail, Decl(instantiationLimitsCheckOrder.ts, 14, 90)) +>Deep : Symbol(Deep, Decl(instantiationLimitsCheckOrder.ts, 10, 28)) + +type DeepAll = Deep<[]>; +>DeepAll : Symbol(DeepAll, Decl(instantiationLimitsCheckOrder.ts, 15, 113)) +>Deep : Symbol(Deep, Decl(instantiationLimitsCheckOrder.ts, 10, 28)) + diff --git a/tsc/testdata/baselines/reference/compiler/instantiationLimitsCheckOrder.types b/tsc/testdata/baselines/reference/compiler/instantiationLimitsCheckOrder.types new file mode 100644 index 0000000000000..5227b6c530923 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/instantiationLimitsCheckOrder.types @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/instantiationLimitsCheckOrder.ts] //// + +=== instantiationLimitsCheckOrder.ts === +// The depth limit on instantiations must not depend on what was +// instantiated before. The limit on the number of instantiations does, as +// it only stops runaway instantiations, so it is only tested for a single +// statement whose work nothing else shares. + +type D = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; +>D : D + +type K = `${D}${D}${D}`; +>K : "000" | "001" | "002" | "003" | "004" | "005" | "006" | "007" | "008" | "009" | "010" | "011" | "012" | "013" | "014" | "015" | "016" | "017" | "018" | "019" | "020" | "021" | "022" | "023" | "024" | "025" | "026" | "027" | "028" | "029" | "030" | "031" | "032" | "033" | "034" | "035" | "036" | "037" | "038" | "039" | "040" | "041" | "042" | "043" | "044" | "045" | "046" | "047" | "048" | "049" | "050" | "051" | "052" | "053" | "054" | "055" | "056" | "057" | "058" | "059" | "060" | "061" | "062" | "063" | "064" | "065" | "066" | "067" | "068" | "069" | "070" | "071" | "072" | "073" | "074" | "075" | "076" | "077" | "078" | "079" | "080" | "081" | "082" | "083" | "084" | "085" | "086" | "087" | "088" | "089" | "090" | "091" | "092" | "093" | "094" | "095" | "096" | "097" | "098" | "099" | "100" | "101" | "102" | "103" | "104" | "105" | "106" | "107" | "108" | "109" | "110" | "111" | "112" | "113" | "114" | "115" | "116" | "117" | "118" | "119" | "120" | "121" | "122" | "123" | "124" | "125" | "126" | "127" | "128" | "129" | "130" | "131" | "132" | "133" | "134" | "135" | "136" | "137" | "138" | "139" | "140" | "141" | "142" | "143" | "144" | "145" | "146" | "147" | "148" | "149" | "150" | "151" | "152" | "153" | "154" | "155" | "156" | "157" | "158" | "159" | "160" | "161" | "162" | "163" | "164" | "165" | "166" | "167" | "168" | "169" | "170" | "171" | "172" | "173" | "174" | "175" | "176" | "177" | "178" | "179" | "180" | "181" | "182" | "183" | "184" | "185" | "186" | "187" | "188" | "189" | "190" | "191" | "192" | "193" | "194" | "195" | "196" | "197" | "198" | "199" | "200" | "201" | "202" | "203" | "204" | "205" | "206" | "207" | "208" | "209" | "210" | "211" | "212" | "213" | "214" | "215" | "216" | "217" | "218" | "219" | "220" | "221" | "222" | "223" | "224" | "225" | "226" | "227" | "228" | "229" | "230" | "231" | "232" | "233" | "234" | "235" | "236" | "237" | "238" | "239" | "240" | "241" | "242" | "243" | "244" | "245" | "246" | "247" | "248" | "249" | "250" | "251" | "252" | "253" | "254" | "255" | "256" | "257" | "258" | "259" | "260" | "261" | "262" | "263" | "264" | "265" | "266" | "267" | "268" | "269" | "270" | "271" | "272" | "273" | "274" | "275" | "276" | "277" | "278" | "279" | "280" | "281" | "282" | "283" | "284" | "285" | "286" | "287" | "288" | "289" | "290" | "291" | "292" | "293" | "294" | "295" | "296" | "297" | "298" | "299" | "300" | "301" | "302" | "303" | "304" | "305" | "306" | "307" | "308" | "309" | "310" | "311" | "312" | "313" | "314" | "315" | "316" | "317" | "318" | "319" | "320" | "321" | "322" | "323" | "324" | "325" | "326" | "327" | "328" | "329" | "330" | "331" | "332" | "333" | "334" | "335" | "336" | "337" | "338" | "339" | "340" | "341" | "342" | "343" | "344" | "345" | "346" | "347" | "348" | "349" | "350" | "351" | "352" | "353" | "354" | "355" | "356" | "357" | "358" | "359" | "360" | "361" | "362" | "363" | "364" | "365" | "366" | "367" | "368" | "369" | "370" | "371" | "372" | "373" | "374" | "375" | "376" | "377" | "378" | "379" | "380" | "381" | "382" | "383" | "384" | "385" | "386" | "387" | "388" | "389" | "390" | "391" | "392" | "393" | "394" | "395" | "396" | "397" | "398" | "399" | "400" | "401" | "402" | "403" | "404" | "405" | "406" | "407" | "408" | "409" | "410" | "411" | "412" | "413" | "414" | "415" | "416" | "417" | "418" | "419" | "420" | "421" | "422" | "423" | "424" | "425" | "426" | "427" | "428" | "429" | "430" | "431" | "432" | "433" | "434" | "435" | "436" | "437" | "438" | "439" | "440" | "441" | "442" | "443" | "444" | "445" | "446" | "447" | "448" | "449" | "450" | "451" | "452" | "453" | "454" | "455" | "456" | "457" | "458" | "459" | "460" | "461" | "462" | "463" | "464" | "465" | "466" | "467" | "468" | "469" | "470" | "471" | "472" | "473" | "474" | "475" | "476" | "477" | "478" | "479" | "480" | "481" | "482" | "483" | "484" | "485" | "486" | "487" | "488" | "489" | "490" | "491" | "492" | "493" | "494" | "495" | "496" | "497" | "498" | "499" | "500" | "501" | "502" | "503" | "504" | "505" | "506" | "507" | "508" | "509" | "510" | "511" | "512" | "513" | "514" | "515" | "516" | "517" | "518" | "519" | "520" | "521" | "522" | "523" | "524" | "525" | "526" | "527" | "528" | "529" | "530" | "531" | "532" | "533" | "534" | "535" | "536" | "537" | "538" | "539" | "540" | "541" | "542" | "543" | "544" | "545" | "546" | "547" | "548" | "549" | "550" | "551" | "552" | "553" | "554" | "555" | "556" | "557" | "558" | "559" | "560" | "561" | "562" | "563" | "564" | "565" | "566" | "567" | "568" | "569" | "570" | "571" | "572" | "573" | "574" | "575" | "576" | "577" | "578" | "579" | "580" | "581" | "582" | "583" | "584" | "585" | "586" | "587" | "588" | "589" | "590" | "591" | "592" | "593" | "594" | "595" | "596" | "597" | "598" | "599" | "600" | "601" | "602" | "603" | "604" | "605" | "606" | "607" | "608" | "609" | "610" | "611" | "612" | "613" | "614" | "615" | "616" | "617" | "618" | "619" | "620" | "621" | "622" | "623" | "624" | "625" | "626" | "627" | "628" | "629" | "630" | "631" | "632" | "633" | "634" | "635" | "636" | "637" | "638" | "639" | "640" | "641" | "642" | "643" | "644" | "645" | "646" | "647" | "648" | "649" | "650" | "651" | "652" | "653" | "654" | "655" | "656" | "657" | "658" | "659" | "660" | "661" | "662" | "663" | "664" | "665" | "666" | "667" | "668" | "669" | "670" | "671" | "672" | "673" | "674" | "675" | "676" | "677" | "678" | "679" | "680" | "681" | "682" | "683" | "684" | "685" | "686" | "687" | "688" | "689" | "690" | "691" | "692" | "693" | "694" | "695" | "696" | "697" | "698" | "699" | "700" | "701" | "702" | "703" | "704" | "705" | "706" | "707" | "708" | "709" | "710" | "711" | "712" | "713" | "714" | "715" | "716" | "717" | "718" | "719" | "720" | "721" | "722" | "723" | "724" | "725" | "726" | "727" | "728" | "729" | "730" | "731" | "732" | "733" | "734" | "735" | "736" | "737" | "738" | "739" | "740" | "741" | "742" | "743" | "744" | "745" | "746" | "747" | "748" | "749" | "750" | "751" | "752" | "753" | "754" | "755" | "756" | "757" | "758" | "759" | "760" | "761" | "762" | "763" | "764" | "765" | "766" | "767" | "768" | "769" | "770" | "771" | "772" | "773" | "774" | "775" | "776" | "777" | "778" | "779" | "780" | "781" | "782" | "783" | "784" | "785" | "786" | "787" | "788" | "789" | "790" | "791" | "792" | "793" | "794" | "795" | "796" | "797" | "798" | "799" | "800" | "801" | "802" | "803" | "804" | "805" | "806" | "807" | "808" | "809" | "810" | "811" | "812" | "813" | "814" | "815" | "816" | "817" | "818" | "819" | "820" | "821" | "822" | "823" | "824" | "825" | "826" | "827" | "828" | "829" | "830" | "831" | "832" | "833" | "834" | "835" | "836" | "837" | "838" | "839" | "840" | "841" | "842" | "843" | "844" | "845" | "846" | "847" | "848" | "849" | "850" | "851" | "852" | "853" | "854" | "855" | "856" | "857" | "858" | "859" | "860" | "861" | "862" | "863" | "864" | "865" | "866" | "867" | "868" | "869" | "870" | "871" | "872" | "873" | "874" | "875" | "876" | "877" | "878" | "879" | "880" | "881" | "882" | "883" | "884" | "885" | "886" | "887" | "888" | "889" | "890" | "891" | "892" | "893" | "894" | "895" | "896" | "897" | "898" | "899" | "900" | "901" | "902" | "903" | "904" | "905" | "906" | "907" | "908" | "909" | "910" | "911" | "912" | "913" | "914" | "915" | "916" | "917" | "918" | "919" | "920" | "921" | "922" | "923" | "924" | "925" | "926" | "927" | "928" | "929" | "930" | "931" | "932" | "933" | "934" | "935" | "936" | "937" | "938" | "939" | "940" | "941" | "942" | "943" | "944" | "945" | "946" | "947" | "948" | "949" | "950" | "951" | "952" | "953" | "954" | "955" | "956" | "957" | "958" | "959" | "960" | "961" | "962" | "963" | "964" | "965" | "966" | "967" | "968" | "969" | "970" | "971" | "972" | "973" | "974" | "975" | "976" | "977" | "978" | "979" | "980" | "981" | "982" | "983" | "984" | "985" | "986" | "987" | "988" | "989" | "990" | "991" | "992" | "993" | "994" | "995" | "996" | "997" | "998" | "999" + +// Several million instantiations, well over the limit, for one statement. +type Wide = N["length"] extends 8 ? I : { [J in K]: Wide<[...N, 0], [J, I][0]> }[K]; +>Wide : Wide + +type WideAll = Wide<[], "">; +>WideAll : any + +// Over a hundred nested instantiations, half of which already happened for +// another statement. +type Deep = N["length"] extends 60 ? never : Deep<[...N, 0]> | N["length"]; +>Deep : Deep + +type DeepTail = Deep<[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]>; +>DeepTail : 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 + +type DeepAll = Deep<[]>; +>DeepAll : 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 + diff --git a/tsc/testdata/baselines/reference/compiler/jsdocTypeTagOnContextuallyTypedFunction.errors.txt b/tsc/testdata/baselines/reference/compiler/jsdocTypeTagOnContextuallyTypedFunction.errors.txt new file mode 100644 index 0000000000000..f9f9a2d8d5885 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsdocTypeTagOnContextuallyTypedFunction.errors.txt @@ -0,0 +1,33 @@ +a.js(4,1): error TS2322: Type '(content: string, rest_0?: boolean | undefined) => string' is not assignable to type '(a: string | number, ...rest: unknown[]) => string'. + Types of parameters 'content' and 'a' are incompatible. + Type 'string | number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. +a.js(9,7): error TS2322: Type '(content: string) => string' is not assignable to type '(content: string | number) => string'. + Types of parameters 'content' and 'content' are incompatible. + Type 'string | number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. + + +==== a.js (2 errors) ==== + /** @type {{ f: (a: string | number, ...rest: unknown[]) => string }} */ + const context = { f: (a) => "" }; + + context.f = + ~~~~~~~~~ +!!! error TS2322: Type '(content: string, rest_0?: boolean | undefined) => string' is not assignable to type '(a: string | number, ...rest: unknown[]) => string'. +!!! error TS2322: Types of parameters 'content' and 'a' are incompatible. +!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + /** @type {(content: string, ...rest: [boolean?]) => string} */ + (content, ...rest) => content.toUpperCase() + rest.length; + + /** @type {(content: string | number) => string} */ + const g = + ~ +!!! error TS2322: Type '(content: string) => string' is not assignable to type '(content: string | number) => string'. +!!! error TS2322: Types of parameters 'content' and 'content' are incompatible. +!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + /** @type {(content: string) => string} */ + (content) => content.toUpperCase(); + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/jsdocTypeTagOnContextuallyTypedFunction.symbols b/tsc/testdata/baselines/reference/compiler/jsdocTypeTagOnContextuallyTypedFunction.symbols new file mode 100644 index 0000000000000..15ffe15bb65e2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsdocTypeTagOnContextuallyTypedFunction.symbols @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/jsdocTypeTagOnContextuallyTypedFunction.ts] //// + +=== a.js === +/** @type {{ f: (a: string | number, ...rest: unknown[]) => string }} */ +const context = { f: (a) => "" }; +>context : Symbol(context, Decl(a.js, 1, 5)) +>f : Symbol(f, Decl(a.js, 1, 17)) +>a : Symbol(a, Decl(a.js, 1, 22)) + +context.f = +>context.f : Symbol(f, Decl(a.js, 0, 12)) +>context : Symbol(context, Decl(a.js, 1, 5)) +>f : Symbol(f, Decl(a.js, 0, 12)) + + /** @type {(content: string, ...rest: [boolean?]) => string} */ + (content, ...rest) => content.toUpperCase() + rest.length; +>content : Symbol(content, Decl(a.js, 5, 5)) +>rest : Symbol(rest, Decl(a.js, 5, 13)) +>content.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>content : Symbol(content, Decl(a.js, 5, 5)) +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>rest.length : Symbol(length) +>rest : Symbol(rest, Decl(a.js, 5, 13)) +>length : Symbol(length) + +/** @type {(content: string | number) => string} */ +const g = +>g : Symbol(g, Decl(a.js, 8, 5)) + + /** @type {(content: string) => string} */ + (content) => content.toUpperCase(); +>content : Symbol(content, Decl(a.js, 10, 5)) +>content.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>content : Symbol(content, Decl(a.js, 10, 5)) +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/jsdocTypeTagOnContextuallyTypedFunction.types b/tsc/testdata/baselines/reference/compiler/jsdocTypeTagOnContextuallyTypedFunction.types new file mode 100644 index 0000000000000..6defe743de587 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsdocTypeTagOnContextuallyTypedFunction.types @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/jsdocTypeTagOnContextuallyTypedFunction.ts] //// + +=== a.js === +/** @type {{ f: (a: string | number, ...rest: unknown[]) => string }} */ +const context = { f: (a) => "" }; +>context : { f: (a: string | number, ...rest: unknown[]) => string; } +>{ f: (a) => "" } : { f: (a: string | number) => string; } +>f : (a: string | number) => string +>(a) => "" : (a: string | number) => string +>a : string | number +>"" : "" + +context.f = +>context.f = /** @type {(content: string, ...rest: [boolean?]) => string} */ (content, ...rest) => content.toUpperCase() + rest.length : (content: string, rest_0?: boolean | undefined) => string +>context.f : (a: string | number, ...rest: unknown[]) => string +>context : { f: (a: string | number, ...rest: unknown[]) => string; } +>f : (a: string | number, ...rest: unknown[]) => string + + /** @type {(content: string, ...rest: [boolean?]) => string} */ + (content, ...rest) => content.toUpperCase() + rest.length; +>(content, ...rest) => content.toUpperCase() + rest.length : (content: string, rest_0?: boolean | undefined) => string +>content : string +>rest : [(boolean | undefined)?] +>content.toUpperCase() + rest.length : string +>content.toUpperCase() : string +>content.toUpperCase : () => string +>content : string +>toUpperCase : () => string +>rest.length : 0 | 1 +>rest : [(boolean | undefined)?] +>length : 0 | 1 + +/** @type {(content: string | number) => string} */ +const g = +>g : (content: string | number) => string + + /** @type {(content: string) => string} */ + (content) => content.toUpperCase(); +>(content) => content.toUpperCase() : (content: string) => string +>content : string +>content.toUpperCase() : string +>content.toUpperCase : () => string +>content : string +>toUpperCase : () => string + diff --git a/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=default).errors.txt new file mode 100644 index 0000000000000..191dc50e4166c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=default).errors.txt @@ -0,0 +1,33 @@ +jsxImportSourceNonPragmaComment.tsx(3,21): error TS2307: Cannot find module '@emotion/react' or its corresponding type declarations. +jsxImportSourceNonPragmaComment.tsx(7,5): error TS2875: This JSX tag requires the module path '@emotion/react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. +jsxImportSourceNonPragmaComment.tsx(7,5): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. + + +==== jsxImportSourceNonPragmaComment.tsx (3 errors) ==== + /* eslint-disable react/react-in-jsx-scope -- Unaware of @jsxImportSource */ + /** @jsxImportSource @emotion/react */ + import { css } from "@emotion/react"; + ~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module '@emotion/react' or its corresponding type declarations. + + export default function Component() { + return ( + + ~~~~~~ +!!! error TS2875: This JSX tag requires the module path '@emotion/react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. + ~~~~~~ +!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. + ); + } \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=default).js new file mode 100644 index 0000000000000..e58934ed59b6b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=default).js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/jsxImportSourceNonPragmaComment.tsx] //// + +//// [jsxImportSourceNonPragmaComment.tsx] +/* eslint-disable react/react-in-jsx-scope -- Unaware of @jsxImportSource */ +/** @jsxImportSource @emotion/react */ +import { css } from "@emotion/react"; + +export default function Component() { + return ( + + ); +} + +//// [jsxImportSourceNonPragmaComment.jsx] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = Component; +/* eslint-disable react/react-in-jsx-scope -- Unaware of @jsxImportSource */ +/** @jsxImportSource @emotion/react */ +const react_1 = require("@emotion/react"); +function Component() { + return (); +} diff --git a/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=default).symbols new file mode 100644 index 0000000000000..d12b587e7c215 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=default).symbols @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/jsxImportSourceNonPragmaComment.tsx] //// + +=== jsxImportSourceNonPragmaComment.tsx === +/* eslint-disable react/react-in-jsx-scope -- Unaware of @jsxImportSource */ +/** @jsxImportSource @emotion/react */ +import { css } from "@emotion/react"; +>css : Symbol(css, Decl(jsxImportSourceNonPragmaComment.tsx, 2, 8)) + +export default function Component() { +>Component : Symbol(Component, Decl(jsxImportSourceNonPragmaComment.tsx, 2, 37)) + + return ( + css : Symbol(css, Decl(jsxImportSourceNonPragmaComment.tsx, 6, 10)) +>css : Symbol(css, Decl(jsxImportSourceNonPragmaComment.tsx, 2, 8)) + + color: red; + `} + /> + ); +} diff --git a/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=default).types new file mode 100644 index 0000000000000..5300452403d62 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=default).types @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/jsxImportSourceNonPragmaComment.tsx] //// + +=== jsxImportSourceNonPragmaComment.tsx === +/* eslint-disable react/react-in-jsx-scope -- Unaware of @jsxImportSource */ +/** @jsxImportSource @emotion/react */ +import { css } from "@emotion/react"; +>css : any + +export default function Component() { +>Component : () => any + + return ( +>( ) : any + + : any +>input : any + + css={css` +>css : any +>css` color: red; ` : any +>css : any +>` color: red; ` : "\n color: red;\n " + + color: red; + `} + /> + ); +} diff --git a/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..b45ab387a625b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=typesfirst).errors.txt @@ -0,0 +1,37 @@ +jsxImportSourceNonPragmaComment.tsx(3,21): error TS2307: Cannot find module '@emotion/react' or its corresponding type declarations. +jsxImportSourceNonPragmaComment.tsx(7,5): error TS2875: This JSX tag requires the module path '@emotion/react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. +jsxImportSourceNonPragmaComment.tsx(7,5): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. +jsxImportSourceNonPragmaComment.tsx(7,6): error TS2552: Cannot find name 'input'. Did you mean 'oninput'? + + +==== jsxImportSourceNonPragmaComment.tsx (4 errors) ==== + /* eslint-disable react/react-in-jsx-scope -- Unaware of @jsxImportSource */ + /** @jsxImportSource @emotion/react */ + import { css } from "@emotion/react"; + ~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module '@emotion/react' or its corresponding type declarations. + + export default function Component() { + return ( + + ~~~~~~ +!!! error TS2875: This JSX tag requires the module path '@emotion/react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. + ~~~~~~ +!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. + ); + } \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=typesfirst).js new file mode 100644 index 0000000000000..e58934ed59b6b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=typesfirst).js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/jsxImportSourceNonPragmaComment.tsx] //// + +//// [jsxImportSourceNonPragmaComment.tsx] +/* eslint-disable react/react-in-jsx-scope -- Unaware of @jsxImportSource */ +/** @jsxImportSource @emotion/react */ +import { css } from "@emotion/react"; + +export default function Component() { + return ( + + ); +} + +//// [jsxImportSourceNonPragmaComment.jsx] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = Component; +/* eslint-disable react/react-in-jsx-scope -- Unaware of @jsxImportSource */ +/** @jsxImportSource @emotion/react */ +const react_1 = require("@emotion/react"); +function Component() { + return (); +} diff --git a/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..d12b587e7c215 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=typesfirst).symbols @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/jsxImportSourceNonPragmaComment.tsx] //// + +=== jsxImportSourceNonPragmaComment.tsx === +/* eslint-disable react/react-in-jsx-scope -- Unaware of @jsxImportSource */ +/** @jsxImportSource @emotion/react */ +import { css } from "@emotion/react"; +>css : Symbol(css, Decl(jsxImportSourceNonPragmaComment.tsx, 2, 8)) + +export default function Component() { +>Component : Symbol(Component, Decl(jsxImportSourceNonPragmaComment.tsx, 2, 37)) + + return ( + css : Symbol(css, Decl(jsxImportSourceNonPragmaComment.tsx, 6, 10)) +>css : Symbol(css, Decl(jsxImportSourceNonPragmaComment.tsx, 2, 8)) + + color: red; + `} + /> + ); +} diff --git a/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=typesfirst).types new file mode 100644 index 0000000000000..5300452403d62 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxImportSourceNonPragmaComment(checkorder=typesfirst).types @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/jsxImportSourceNonPragmaComment.tsx] //// + +=== jsxImportSourceNonPragmaComment.tsx === +/* eslint-disable react/react-in-jsx-scope -- Unaware of @jsxImportSource */ +/** @jsxImportSource @emotion/react */ +import { css } from "@emotion/react"; +>css : any + +export default function Component() { +>Component : () => any + + return ( +>( ) : any + + : any +>input : any + + css={css` +>css : any +>css` color: red; ` : any +>css : any +>` color: red; ` : "\n color: red;\n " + + color: red; + `} + /> + ); +} diff --git a/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=default).js new file mode 100644 index 0000000000000..4c58e6e84ff1d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=default).js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/jsxIntrinsicElementsExtendsRecord.tsx] //// + +//// [index.tsx] +declare namespace JSX { + interface IntrinsicElements extends Record {} +} + +; + + +//// [index.jsx] +"use strict"; +; diff --git a/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=default).symbols new file mode 100644 index 0000000000000..c42caaed5098d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=default).symbols @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/jsxIntrinsicElementsExtendsRecord.tsx] //// + +=== index.tsx === +declare namespace JSX { +>JSX : Symbol(JSX, Decl(index.tsx, 0, 0)) + + interface IntrinsicElements extends Record {} +>IntrinsicElements : Symbol(IntrinsicElements, Decl(index.tsx, 0, 23)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +} + +; +>a : Symbol(JSX.IntrinsicElements, Decl(index.tsx, 0, 23)) + diff --git a/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=default).types new file mode 100644 index 0000000000000..30632f23d7dc4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=default).types @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/jsxIntrinsicElementsExtendsRecord.tsx] //// + +=== index.tsx === +declare namespace JSX { + interface IntrinsicElements extends Record {} +} + +; +> : error +>a : any + diff --git a/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..183a3fdcdd653 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=typesfirst).errors.txt @@ -0,0 +1,12 @@ +index.tsx(5,2): error TS2304: Cannot find name 'a'. + + +==== index.tsx (1 errors) ==== + declare namespace JSX { + interface IntrinsicElements extends Record {} + } + + ; + ~ +!!! error TS2304: Cannot find name 'a'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=typesfirst).js new file mode 100644 index 0000000000000..4c58e6e84ff1d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=typesfirst).js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/jsxIntrinsicElementsExtendsRecord.tsx] //// + +//// [index.tsx] +declare namespace JSX { + interface IntrinsicElements extends Record {} +} + +; + + +//// [index.jsx] +"use strict"; +; diff --git a/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..c42caaed5098d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=typesfirst).symbols @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/jsxIntrinsicElementsExtendsRecord.tsx] //// + +=== index.tsx === +declare namespace JSX { +>JSX : Symbol(JSX, Decl(index.tsx, 0, 0)) + + interface IntrinsicElements extends Record {} +>IntrinsicElements : Symbol(IntrinsicElements, Decl(index.tsx, 0, 23)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +} + +; +>a : Symbol(JSX.IntrinsicElements, Decl(index.tsx, 0, 23)) + diff --git a/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=typesfirst).types new file mode 100644 index 0000000000000..a2a76b6e77eed --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxIntrinsicElementsExtendsRecord(checkorder=typesfirst).types @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/jsxIntrinsicElementsExtendsRecord.tsx] //// + +=== index.tsx === +declare namespace JSX { + interface IntrinsicElements extends Record {} +} + +; +> : any +>a : any + diff --git a/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=default).errors.txt new file mode 100644 index 0000000000000..a1b033edf54ba --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=default).errors.txt @@ -0,0 +1,15 @@ +limitDeepInstantiations.ts(4,9): error TS5114: Instantiations of type 'Foo' appear infinitely circular. +limitDeepInstantiations.ts(5,13): error TS2344: Type '"false"' does not satisfy the constraint '"true"'. + + +==== limitDeepInstantiations.ts (2 errors) ==== + // Repro from #14837 + + type Foo = { "true": Foo> }[T]; + let f1: Foo<"true", {}>; + ~~~~~~~~~~~~~~~ +!!! error TS5114: Instantiations of type 'Foo' appear infinitely circular. + let f2: Foo<"false", {}>; + ~~~~~~~ +!!! error TS2344: Type '"false"' does not satisfy the constraint '"true"'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=default).js new file mode 100644 index 0000000000000..5c149c0177558 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=default).js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/limitDeepInstantiations.ts] //// + +//// [limitDeepInstantiations.ts] +// Repro from #14837 + +type Foo = { "true": Foo> }[T]; +let f1: Foo<"true", {}>; +let f2: Foo<"false", {}>; + + +//// [limitDeepInstantiations.js] +"use strict"; +// Repro from #14837 +let f1; +let f2; diff --git a/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=default).symbols new file mode 100644 index 0000000000000..73413334b6b82 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=default).symbols @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/limitDeepInstantiations.ts] //// + +=== limitDeepInstantiations.ts === +// Repro from #14837 + +type Foo = { "true": Foo> }[T]; +>Foo : Symbol(Foo, Decl(limitDeepInstantiations.ts, 0, 0)) +>T : Symbol(T, Decl(limitDeepInstantiations.ts, 2, 9)) +>B : Symbol(B, Decl(limitDeepInstantiations.ts, 2, 26)) +>"true" : Symbol("true", Decl(limitDeepInstantiations.ts, 2, 33)) +>Foo : Symbol(Foo, Decl(limitDeepInstantiations.ts, 0, 0)) +>T : Symbol(T, Decl(limitDeepInstantiations.ts, 2, 9)) +>Foo : Symbol(Foo, Decl(limitDeepInstantiations.ts, 0, 0)) +>T : Symbol(T, Decl(limitDeepInstantiations.ts, 2, 9)) +>B : Symbol(B, Decl(limitDeepInstantiations.ts, 2, 26)) +>T : Symbol(T, Decl(limitDeepInstantiations.ts, 2, 9)) + +let f1: Foo<"true", {}>; +>f1 : Symbol(f1, Decl(limitDeepInstantiations.ts, 3, 3)) +>Foo : Symbol(Foo, Decl(limitDeepInstantiations.ts, 0, 0)) + +let f2: Foo<"false", {}>; +>f2 : Symbol(f2, Decl(limitDeepInstantiations.ts, 4, 3)) +>Foo : Symbol(Foo, Decl(limitDeepInstantiations.ts, 0, 0)) + diff --git a/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=default).types new file mode 100644 index 0000000000000..520205007876c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=default).types @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/limitDeepInstantiations.ts] //// + +=== limitDeepInstantiations.ts === +// Repro from #14837 + +type Foo = { "true": Foo> }[T]; +>Foo : Foo +>"true" : Foo> + +let f1: Foo<"true", {}>; +>f1 : any + +let f2: Foo<"false", {}>; +>f2 : unknown + diff --git a/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..2998e94608985 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=typesfirst).errors.txt @@ -0,0 +1,14 @@ +error TS5114: Instantiations of type 'Foo' appear infinitely circular. +limitDeepInstantiations.ts(5,13): error TS2344: Type '"false"' does not satisfy the constraint '"true"'. + + +!!! error TS5114: Instantiations of type 'Foo' appear infinitely circular. +==== limitDeepInstantiations.ts (1 errors) ==== + // Repro from #14837 + + type Foo = { "true": Foo> }[T]; + let f1: Foo<"true", {}>; + let f2: Foo<"false", {}>; + ~~~~~~~ +!!! error TS2344: Type '"false"' does not satisfy the constraint '"true"'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=typesfirst).js new file mode 100644 index 0000000000000..5c149c0177558 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=typesfirst).js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/limitDeepInstantiations.ts] //// + +//// [limitDeepInstantiations.ts] +// Repro from #14837 + +type Foo = { "true": Foo> }[T]; +let f1: Foo<"true", {}>; +let f2: Foo<"false", {}>; + + +//// [limitDeepInstantiations.js] +"use strict"; +// Repro from #14837 +let f1; +let f2; diff --git a/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..73413334b6b82 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=typesfirst).symbols @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/limitDeepInstantiations.ts] //// + +=== limitDeepInstantiations.ts === +// Repro from #14837 + +type Foo = { "true": Foo> }[T]; +>Foo : Symbol(Foo, Decl(limitDeepInstantiations.ts, 0, 0)) +>T : Symbol(T, Decl(limitDeepInstantiations.ts, 2, 9)) +>B : Symbol(B, Decl(limitDeepInstantiations.ts, 2, 26)) +>"true" : Symbol("true", Decl(limitDeepInstantiations.ts, 2, 33)) +>Foo : Symbol(Foo, Decl(limitDeepInstantiations.ts, 0, 0)) +>T : Symbol(T, Decl(limitDeepInstantiations.ts, 2, 9)) +>Foo : Symbol(Foo, Decl(limitDeepInstantiations.ts, 0, 0)) +>T : Symbol(T, Decl(limitDeepInstantiations.ts, 2, 9)) +>B : Symbol(B, Decl(limitDeepInstantiations.ts, 2, 26)) +>T : Symbol(T, Decl(limitDeepInstantiations.ts, 2, 9)) + +let f1: Foo<"true", {}>; +>f1 : Symbol(f1, Decl(limitDeepInstantiations.ts, 3, 3)) +>Foo : Symbol(Foo, Decl(limitDeepInstantiations.ts, 0, 0)) + +let f2: Foo<"false", {}>; +>f2 : Symbol(f2, Decl(limitDeepInstantiations.ts, 4, 3)) +>Foo : Symbol(Foo, Decl(limitDeepInstantiations.ts, 0, 0)) + diff --git a/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=typesfirst).types new file mode 100644 index 0000000000000..520205007876c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations(checkorder=typesfirst).types @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/limitDeepInstantiations.ts] //// + +=== limitDeepInstantiations.ts === +// Repro from #14837 + +type Foo = { "true": Foo> }[T]; +>Foo : Foo +>"true" : Foo> + +let f1: Foo<"true", {}>; +>f1 : any + +let f2: Foo<"false", {}>; +>f2 : unknown + diff --git a/tsc/testdata/baselines/reference/compiler/narrowedNeverAfterLoopWithAndCondition.errors.txt b/tsc/testdata/baselines/reference/compiler/narrowedNeverAfterLoopWithAndCondition.errors.txt new file mode 100644 index 0000000000000..0ba88e426e409 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/narrowedNeverAfterLoopWithAndCondition.errors.txt @@ -0,0 +1,29 @@ +narrowedNeverAfterLoopWithAndCondition.ts(9,9): error TS2322: Type 'false' is not assignable to type 'never'. +narrowedNeverAfterLoopWithAndCondition.ts(17,19): error TS2339: Property 'last_ref' does not exist on type 'never'. + + +==== narrowedNeverAfterLoopWithAndCondition.ts (2 errors) ==== + // value_def is never inside the if. With a && condition, main and + // Strada leak the loop analysis's incomplete never placeholder + // (silentNever), so the property access is silently allowed and only + // the assignment errors. With `while (x)` they report the access. + function f(x: boolean, y: boolean) { + let value_def: { last_ref: boolean } | null = null; + if (value_def) { + while (x && y); + value_def.last_ref = false; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'never'. + } + } + + function g(x: boolean) { + let value_def: { last_ref: boolean } | null = null; + if (value_def) { + while (x); + value_def.last_ref = false; + ~~~~~~~~ +!!! error TS2339: Property 'last_ref' does not exist on type 'never'. + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/narrowedNeverAfterLoopWithAndCondition.symbols b/tsc/testdata/baselines/reference/compiler/narrowedNeverAfterLoopWithAndCondition.symbols new file mode 100644 index 0000000000000..4320e2396f293 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/narrowedNeverAfterLoopWithAndCondition.symbols @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/narrowedNeverAfterLoopWithAndCondition.ts] //// + +=== narrowedNeverAfterLoopWithAndCondition.ts === +// value_def is never inside the if. With a && condition, main and +// Strada leak the loop analysis's incomplete never placeholder +// (silentNever), so the property access is silently allowed and only +// the assignment errors. With `while (x)` they report the access. +function f(x: boolean, y: boolean) { +>f : Symbol(f, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 0, 0)) +>x : Symbol(x, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 4, 11)) +>y : Symbol(y, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 4, 22)) + + let value_def: { last_ref: boolean } | null = null; +>value_def : Symbol(value_def, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 5, 7)) +>last_ref : Symbol(last_ref, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 5, 20)) + + if (value_def) { +>value_def : Symbol(value_def, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 5, 7)) + + while (x && y); +>x : Symbol(x, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 4, 11)) +>y : Symbol(y, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 4, 22)) + + value_def.last_ref = false; +>value_def : Symbol(value_def, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 5, 7)) + } +} + +function g(x: boolean) { +>g : Symbol(g, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 10, 1)) +>x : Symbol(x, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 12, 11)) + + let value_def: { last_ref: boolean } | null = null; +>value_def : Symbol(value_def, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 13, 7)) +>last_ref : Symbol(last_ref, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 13, 20)) + + if (value_def) { +>value_def : Symbol(value_def, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 13, 7)) + + while (x); +>x : Symbol(x, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 12, 11)) + + value_def.last_ref = false; +>value_def : Symbol(value_def, Decl(narrowedNeverAfterLoopWithAndCondition.ts, 13, 7)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/narrowedNeverAfterLoopWithAndCondition.types b/tsc/testdata/baselines/reference/compiler/narrowedNeverAfterLoopWithAndCondition.types new file mode 100644 index 0000000000000..ec7b2e4bfcb90 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/narrowedNeverAfterLoopWithAndCondition.types @@ -0,0 +1,56 @@ +//// [tests/cases/compiler/narrowedNeverAfterLoopWithAndCondition.ts] //// + +=== narrowedNeverAfterLoopWithAndCondition.ts === +// value_def is never inside the if. With a && condition, main and +// Strada leak the loop analysis's incomplete never placeholder +// (silentNever), so the property access is silently allowed and only +// the assignment errors. With `while (x)` they report the access. +function f(x: boolean, y: boolean) { +>f : (x: boolean, y: boolean) => void +>x : boolean +>y : boolean + + let value_def: { last_ref: boolean } | null = null; +>value_def : { last_ref: boolean; } | null +>last_ref : boolean + + if (value_def) { +>value_def : null + + while (x && y); +>x && y : boolean +>x : boolean +>y : boolean + + value_def.last_ref = false; +>value_def.last_ref = false : false +>value_def.last_ref : any +>value_def : never +>last_ref : any +>false : false + } +} + +function g(x: boolean) { +>g : (x: boolean) => void +>x : boolean + + let value_def: { last_ref: boolean } | null = null; +>value_def : { last_ref: boolean; } | null +>last_ref : boolean + + if (value_def) { +>value_def : null + + while (x); +>x : boolean + + value_def.last_ref = false; +>value_def.last_ref = false : false +>value_def.last_ref : any +>value_def : never +>last_ref : any +>false : false + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=default).js new file mode 100644 index 0000000000000..c4a71d9b83c23 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=default).js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/objectLiteralRegularAndWidenedCopyOrder.ts] //// + +//// [objectLiteralRegularAndWidenedCopyOrder.ts] +declare const b: boolean; +let x; +x = { a: 1 }; +let arr = []; +arr.push(x); // regular copy of the literal +const y = x; // widened copy of the literal +const z = b ? (b ? arr[0] : y) : { c: 1 }; + + +//// [objectLiteralRegularAndWidenedCopyOrder.js] +"use strict"; +let x; +x = { a: 1 }; +let arr = []; +arr.push(x); // regular copy of the literal +const y = x; // widened copy of the literal +const z = b ? (b ? arr[0] : y) : { c: 1 }; diff --git a/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=default).symbols new file mode 100644 index 0000000000000..4ff568c410bfc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=default).symbols @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/objectLiteralRegularAndWidenedCopyOrder.ts] //// + +=== objectLiteralRegularAndWidenedCopyOrder.ts === +declare const b: boolean; +>b : Symbol(b, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 0, 13)) + +let x; +>x : Symbol(x, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 1, 3)) + +x = { a: 1 }; +>x : Symbol(x, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 1, 3)) +>a : Symbol(a, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 2, 5)) + +let arr = []; +>arr : Symbol(arr, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 3, 3)) + +arr.push(x); // regular copy of the literal +>arr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 3, 3)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 1, 3)) + +const y = x; // widened copy of the literal +>y : Symbol(y, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 5, 5)) +>x : Symbol(x, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 1, 3)) + +const z = b ? (b ? arr[0] : y) : { c: 1 }; +>z : Symbol(z, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 6, 5)) +>b : Symbol(b, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 0, 13)) +>b : Symbol(b, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 0, 13)) +>arr : Symbol(arr, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 3, 3)) +>y : Symbol(y, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 5, 5)) +>c : Symbol(c, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 6, 34)) + diff --git a/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=default).types new file mode 100644 index 0000000000000..407435a6f1e42 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=default).types @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/objectLiteralRegularAndWidenedCopyOrder.ts] //// + +=== objectLiteralRegularAndWidenedCopyOrder.ts === +declare const b: boolean; +>b : boolean + +let x; +>x : any + +x = { a: 1 }; +>x = { a: 1 } : { a: number; } +>x : any +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 + +let arr = []; +>arr : any[] +>[] : never[] + +arr.push(x); // regular copy of the literal +>arr.push(x) : number +>arr.push : (...items: any[]) => number +>arr : any[] +>push : (...items: any[]) => number +>x : { a: number; } + +const y = x; // widened copy of the literal +>y : { a: number; } +>x : { a: number; } + +const z = b ? (b ? arr[0] : y) : { c: 1 }; +>z : { a: number; c?: undefined; } | { a?: undefined; c: number; } +>b ? (b ? arr[0] : y) : { c: 1 } : { a: number; } | { c: number; } +>b : boolean +>(b ? arr[0] : y) : { a: number; } +>b ? arr[0] : y : { a: number; } +>b : true +>arr[0] : { a: number; } +>arr : { a: number; }[] +>0 : 0 +>y : { a: number; } +>{ c: 1 } : { c: number; } +>c : number +>1 : 1 + diff --git a/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=typesfirst).js new file mode 100644 index 0000000000000..c4a71d9b83c23 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=typesfirst).js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/objectLiteralRegularAndWidenedCopyOrder.ts] //// + +//// [objectLiteralRegularAndWidenedCopyOrder.ts] +declare const b: boolean; +let x; +x = { a: 1 }; +let arr = []; +arr.push(x); // regular copy of the literal +const y = x; // widened copy of the literal +const z = b ? (b ? arr[0] : y) : { c: 1 }; + + +//// [objectLiteralRegularAndWidenedCopyOrder.js] +"use strict"; +let x; +x = { a: 1 }; +let arr = []; +arr.push(x); // regular copy of the literal +const y = x; // widened copy of the literal +const z = b ? (b ? arr[0] : y) : { c: 1 }; diff --git a/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..4ff568c410bfc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=typesfirst).symbols @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/objectLiteralRegularAndWidenedCopyOrder.ts] //// + +=== objectLiteralRegularAndWidenedCopyOrder.ts === +declare const b: boolean; +>b : Symbol(b, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 0, 13)) + +let x; +>x : Symbol(x, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 1, 3)) + +x = { a: 1 }; +>x : Symbol(x, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 1, 3)) +>a : Symbol(a, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 2, 5)) + +let arr = []; +>arr : Symbol(arr, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 3, 3)) + +arr.push(x); // regular copy of the literal +>arr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 3, 3)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 1, 3)) + +const y = x; // widened copy of the literal +>y : Symbol(y, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 5, 5)) +>x : Symbol(x, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 1, 3)) + +const z = b ? (b ? arr[0] : y) : { c: 1 }; +>z : Symbol(z, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 6, 5)) +>b : Symbol(b, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 0, 13)) +>b : Symbol(b, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 0, 13)) +>arr : Symbol(arr, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 3, 3)) +>y : Symbol(y, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 5, 5)) +>c : Symbol(c, Decl(objectLiteralRegularAndWidenedCopyOrder.ts, 6, 34)) + diff --git a/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=typesfirst).types new file mode 100644 index 0000000000000..c357eab575d5b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectLiteralRegularAndWidenedCopyOrder(checkorder=typesfirst).types @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/objectLiteralRegularAndWidenedCopyOrder.ts] //// + +=== objectLiteralRegularAndWidenedCopyOrder.ts === +declare const b: boolean; +>b : boolean + +let x; +>x : any + +x = { a: 1 }; +>x = { a: 1 } : { a: number; } +>x : any +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 + +let arr = []; +>arr : any[] +>[] : never[] + +arr.push(x); // regular copy of the literal +>arr.push(x) : number +>arr.push : (...items: any[]) => number +>arr : any[] +>push : (...items: any[]) => number +>x : { a: number; } + +const y = x; // widened copy of the literal +>y : { a: number; } +>x : { a: number; } + +const z = b ? (b ? arr[0] : y) : { c: 1 }; +>z : { a: number; } | { c: number; } +>b ? (b ? arr[0] : y) : { c: 1 } : { a: number; } | { c: number; } +>b : boolean +>(b ? arr[0] : y) : { a: number; } +>b ? arr[0] : y : { a: number; } +>b : true +>arr[0] : { a: number; } +>arr : { a: number; }[] +>0 : 0 +>y : { a: number; } +>{ c: 1 } : { c: number; } +>c : number +>1 : 1 + diff --git a/tsc/testdata/baselines/reference/compiler/objectRestUnionInstantiationOrder(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/objectRestUnionInstantiationOrder(checkorder=default).symbols new file mode 100644 index 0000000000000..49bd036214070 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectRestUnionInstantiationOrder(checkorder=default).symbols @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/objectRestUnionInstantiationOrder.ts] //// + +=== objectRestUnionInstantiationOrder.ts === +function f(v: { k: "a"; a: T } | { k: "b"; b: number }) { +>f : Symbol(f, Decl(objectRestUnionInstantiationOrder.ts, 0, 0)) +>T : Symbol(T, Decl(objectRestUnionInstantiationOrder.ts, 0, 11)) +>v : Symbol(v, Decl(objectRestUnionInstantiationOrder.ts, 0, 14)) +>k : Symbol(k, Decl(objectRestUnionInstantiationOrder.ts, 0, 18)) +>a : Symbol(a, Decl(objectRestUnionInstantiationOrder.ts, 0, 26)) +>T : Symbol(T, Decl(objectRestUnionInstantiationOrder.ts, 0, 11)) +>k : Symbol(k, Decl(objectRestUnionInstantiationOrder.ts, 0, 37)) +>b : Symbol(b, Decl(objectRestUnionInstantiationOrder.ts, 0, 45)) + + const { k, ...rest } = v; +>k : Symbol(k, Decl(objectRestUnionInstantiationOrder.ts, 1, 11)) +>rest : Symbol(rest, Decl(objectRestUnionInstantiationOrder.ts, 1, 14)) +>v : Symbol(v, Decl(objectRestUnionInstantiationOrder.ts, 0, 14)) + + return { all: rest, onlyB: "b" in rest ? rest : undefined }; +>all : Symbol(all, Decl(objectRestUnionInstantiationOrder.ts, 2, 12)) +>rest : Symbol(rest, Decl(objectRestUnionInstantiationOrder.ts, 1, 14)) +>onlyB : Symbol(onlyB, Decl(objectRestUnionInstantiationOrder.ts, 2, 23)) +>rest : Symbol(rest, Decl(objectRestUnionInstantiationOrder.ts, 1, 14)) +>rest : Symbol(rest, Decl(objectRestUnionInstantiationOrder.ts, 1, 14)) +>undefined : Symbol(undefined) +} +const o = f({ k: "a", a: "s" }); +>o : Symbol(o, Decl(objectRestUnionInstantiationOrder.ts, 4, 5)) +>f : Symbol(f, Decl(objectRestUnionInstantiationOrder.ts, 0, 0)) +>k : Symbol(k, Decl(objectRestUnionInstantiationOrder.ts, 4, 13)) +>a : Symbol(a, Decl(objectRestUnionInstantiationOrder.ts, 4, 21)) + +const all = o.all; +>all : Symbol(all, Decl(objectRestUnionInstantiationOrder.ts, 5, 5)) +>o.all : Symbol(all, Decl(objectRestUnionInstantiationOrder.ts, 2, 12)) +>o : Symbol(o, Decl(objectRestUnionInstantiationOrder.ts, 4, 5)) +>all : Symbol(all, Decl(objectRestUnionInstantiationOrder.ts, 2, 12)) + +const onlyB = o.onlyB; +>onlyB : Symbol(onlyB, Decl(objectRestUnionInstantiationOrder.ts, 6, 5)) +>o.onlyB : Symbol(onlyB, Decl(objectRestUnionInstantiationOrder.ts, 2, 23)) +>o : Symbol(o, Decl(objectRestUnionInstantiationOrder.ts, 4, 5)) +>onlyB : Symbol(onlyB, Decl(objectRestUnionInstantiationOrder.ts, 2, 23)) + diff --git a/tsc/testdata/baselines/reference/compiler/objectRestUnionInstantiationOrder(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/objectRestUnionInstantiationOrder(checkorder=default).types new file mode 100644 index 0000000000000..b0974642e75b9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectRestUnionInstantiationOrder(checkorder=default).types @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/objectRestUnionInstantiationOrder.ts] //// + +=== objectRestUnionInstantiationOrder.ts === +function f(v: { k: "a"; a: T } | { k: "b"; b: number }) { +>f : (v: { k: "a"; a: T; } | { k: "b"; b: number; }) => { all: { a: T; } | { b: number; }; onlyB: { b: number; } | undefined; } +>v : { k: "a"; a: T; } | { k: "b"; b: number; } +>k : "a" +>a : T +>k : "b" +>b : number + + const { k, ...rest } = v; +>k : "a" | "b" +>rest : { a: T; } | { b: number; } +>v : { k: "a"; a: T; } | { k: "b"; b: number; } + + return { all: rest, onlyB: "b" in rest ? rest : undefined }; +>{ all: rest, onlyB: "b" in rest ? rest : undefined } : { all: { a: T; } | { b: number; }; onlyB: { b: number; } | undefined; } +>all : { a: T; } | { b: number; } +>rest : { a: T; } | { b: number; } +>onlyB : { b: number; } | undefined +>"b" in rest ? rest : undefined : { b: number; } | undefined +>"b" in rest : boolean +>"b" : "b" +>rest : { a: T; } | { b: number; } +>rest : { b: number; } +>undefined : undefined +} +const o = f({ k: "a", a: "s" }); +>o : { all: { a: string; } | { b: number; }; onlyB: { b: number; } | undefined; } +>f({ k: "a", a: "s" }) : { all: { a: string; } | { b: number; }; onlyB: { b: number; } | undefined; } +>f : (v: { k: "a"; a: T; } | { k: "b"; b: number; }) => { all: { a: T; } | { b: number; }; onlyB: { b: number; } | undefined; } +>{ k: "a", a: "s" } : { k: "a"; a: string; } +>k : "a" +>"a" : "a" +>a : string +>"s" : "s" + +const all = o.all; +>all : { a: string; } | { b: number; } +>o.all : { a: string; } | { b: number; } +>o : { all: { a: string; } | { b: number; }; onlyB: { b: number; } | undefined; } +>all : { a: string; } | { b: number; } + +const onlyB = o.onlyB; +>onlyB : { b: number; } | undefined +>o.onlyB : { b: number; } | undefined +>o : { all: { a: string; } | { b: number; }; onlyB: { b: number; } | undefined; } +>onlyB : { b: number; } | undefined + diff --git a/tsc/testdata/baselines/reference/compiler/objectRestUnionInstantiationOrder(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/objectRestUnionInstantiationOrder(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..49bd036214070 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectRestUnionInstantiationOrder(checkorder=typesfirst).symbols @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/objectRestUnionInstantiationOrder.ts] //// + +=== objectRestUnionInstantiationOrder.ts === +function f(v: { k: "a"; a: T } | { k: "b"; b: number }) { +>f : Symbol(f, Decl(objectRestUnionInstantiationOrder.ts, 0, 0)) +>T : Symbol(T, Decl(objectRestUnionInstantiationOrder.ts, 0, 11)) +>v : Symbol(v, Decl(objectRestUnionInstantiationOrder.ts, 0, 14)) +>k : Symbol(k, Decl(objectRestUnionInstantiationOrder.ts, 0, 18)) +>a : Symbol(a, Decl(objectRestUnionInstantiationOrder.ts, 0, 26)) +>T : Symbol(T, Decl(objectRestUnionInstantiationOrder.ts, 0, 11)) +>k : Symbol(k, Decl(objectRestUnionInstantiationOrder.ts, 0, 37)) +>b : Symbol(b, Decl(objectRestUnionInstantiationOrder.ts, 0, 45)) + + const { k, ...rest } = v; +>k : Symbol(k, Decl(objectRestUnionInstantiationOrder.ts, 1, 11)) +>rest : Symbol(rest, Decl(objectRestUnionInstantiationOrder.ts, 1, 14)) +>v : Symbol(v, Decl(objectRestUnionInstantiationOrder.ts, 0, 14)) + + return { all: rest, onlyB: "b" in rest ? rest : undefined }; +>all : Symbol(all, Decl(objectRestUnionInstantiationOrder.ts, 2, 12)) +>rest : Symbol(rest, Decl(objectRestUnionInstantiationOrder.ts, 1, 14)) +>onlyB : Symbol(onlyB, Decl(objectRestUnionInstantiationOrder.ts, 2, 23)) +>rest : Symbol(rest, Decl(objectRestUnionInstantiationOrder.ts, 1, 14)) +>rest : Symbol(rest, Decl(objectRestUnionInstantiationOrder.ts, 1, 14)) +>undefined : Symbol(undefined) +} +const o = f({ k: "a", a: "s" }); +>o : Symbol(o, Decl(objectRestUnionInstantiationOrder.ts, 4, 5)) +>f : Symbol(f, Decl(objectRestUnionInstantiationOrder.ts, 0, 0)) +>k : Symbol(k, Decl(objectRestUnionInstantiationOrder.ts, 4, 13)) +>a : Symbol(a, Decl(objectRestUnionInstantiationOrder.ts, 4, 21)) + +const all = o.all; +>all : Symbol(all, Decl(objectRestUnionInstantiationOrder.ts, 5, 5)) +>o.all : Symbol(all, Decl(objectRestUnionInstantiationOrder.ts, 2, 12)) +>o : Symbol(o, Decl(objectRestUnionInstantiationOrder.ts, 4, 5)) +>all : Symbol(all, Decl(objectRestUnionInstantiationOrder.ts, 2, 12)) + +const onlyB = o.onlyB; +>onlyB : Symbol(onlyB, Decl(objectRestUnionInstantiationOrder.ts, 6, 5)) +>o.onlyB : Symbol(onlyB, Decl(objectRestUnionInstantiationOrder.ts, 2, 23)) +>o : Symbol(o, Decl(objectRestUnionInstantiationOrder.ts, 4, 5)) +>onlyB : Symbol(onlyB, Decl(objectRestUnionInstantiationOrder.ts, 2, 23)) + diff --git a/tsc/testdata/baselines/reference/compiler/objectRestUnionInstantiationOrder(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/objectRestUnionInstantiationOrder(checkorder=typesfirst).types new file mode 100644 index 0000000000000..858790155480b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectRestUnionInstantiationOrder(checkorder=typesfirst).types @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/objectRestUnionInstantiationOrder.ts] //// + +=== objectRestUnionInstantiationOrder.ts === +function f(v: { k: "a"; a: T } | { k: "b"; b: number }) { +>f : (v: { k: "a"; a: T; } | { k: "b"; b: number; }) => { all: { a: T; } | { b: number; }; onlyB: { b: number; } | undefined; } +>v : { k: "a"; a: T; } | { k: "b"; b: number; } +>k : "a" +>a : T +>k : "b" +>b : number + + const { k, ...rest } = v; +>k : "a" | "b" +>rest : { a: T; } | { b: number; } +>v : { k: "a"; a: T; } | { k: "b"; b: number; } + + return { all: rest, onlyB: "b" in rest ? rest : undefined }; +>{ all: rest, onlyB: "b" in rest ? rest : undefined } : { all: { a: T; } | { b: number; }; onlyB: { b: number; } | undefined; } +>all : { a: T; } | { b: number; } +>rest : { a: T; } | { b: number; } +>onlyB : { b: number; } | undefined +>"b" in rest ? rest : undefined : { b: number; } | undefined +>"b" in rest : boolean +>"b" : "b" +>rest : { a: T; } | { b: number; } +>rest : { b: number; } +>undefined : undefined +} +const o = f({ k: "a", a: "s" }); +>o : { all: { b: number; } | { a: string; }; onlyB: { b: number; } | undefined; } +>f({ k: "a", a: "s" }) : { all: { b: number; } | { a: string; }; onlyB: { b: number; } | undefined; } +>f : (v: { k: "a"; a: T; } | { k: "b"; b: number; }) => { all: { a: T; } | { b: number; }; onlyB: { b: number; } | undefined; } +>{ k: "a", a: "s" } : { k: "a"; a: string; } +>k : "a" +>"a" : "a" +>a : string +>"s" : "s" + +const all = o.all; +>all : { b: number; } | { a: string; } +>o.all : { b: number; } | { a: string; } +>o : { all: { b: number; } | { a: string; }; onlyB: { b: number; } | undefined; } +>all : { b: number; } | { a: string; } + +const onlyB = o.onlyB; +>onlyB : { b: number; } | undefined +>o.onlyB : { b: number; } | undefined +>o : { all: { b: number; } | { a: string; }; onlyB: { b: number; } | undefined; } +>onlyB : { b: number; } | undefined + diff --git a/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=default).errors.txt new file mode 100644 index 0000000000000..47be7df4a2a28 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=default).errors.txt @@ -0,0 +1,80 @@ +overloadresolutionWithConstraintCheckingDeferred.ts(14,26): error TS2769: No overload matches this call. + The last overload gave the following error. + Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. + Types of parameters 'x' and 'x' are incompatible. + Property 'q' is missing in type 'B' but required in type 'D'. +overloadresolutionWithConstraintCheckingDeferred.ts(14,37): error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. +overloadresolutionWithConstraintCheckingDeferred.ts(16,27): error TS2769: No overload matches this call. + The last overload gave the following error. + Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. + Types of parameters 'x' and 'x' are incompatible. + Property 'q' is missing in type 'B' but required in type 'D'. +overloadresolutionWithConstraintCheckingDeferred.ts(16,38): error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. +overloadresolutionWithConstraintCheckingDeferred.ts(18,27): error TS2769: No overload matches this call. + The last overload gave the following error. + Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. + Types of parameters 'x' and 'x' are incompatible. + Property 'q' is missing in type 'B' but required in type 'D'. +overloadresolutionWithConstraintCheckingDeferred.ts(19,14): error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. +overloadresolutionWithConstraintCheckingDeferred.ts(19,32): error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. + + +==== overloadresolutionWithConstraintCheckingDeferred.ts (7 errors) ==== + interface A { x } + interface B { x; y } + interface C { z } + interface D { q } + + class G { + constructor(x: T) { } + } + + declare function foo(arg: (x: D) => number): string; + declare function foo(arg: (x: C) => any): string; + declare function foo(arg: (x: B) => any): number; + + var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. + ~~~~~~~~~~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: The last overload gave the following error. +!!! error TS2769: Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. +!!! error TS2769: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2769: Property 'q' is missing in type 'B' but required in type 'D'. +!!! related TS2728 overloadresolutionWithConstraintCheckingDeferred.ts:4:15: 'q' is declared here. +!!! related TS2771 overloadresolutionWithConstraintCheckingDeferred.ts:12:18: The last overload is declared here. + ~ +!!! error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. +!!! related TS2728 overloadresolutionWithConstraintCheckingDeferred.ts:1:15: 'x' is declared here. + + var result2: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: The last overload gave the following error. +!!! error TS2769: Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. +!!! error TS2769: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2769: Property 'q' is missing in type 'B' but required in type 'D'. +!!! related TS2728 overloadresolutionWithConstraintCheckingDeferred.ts:4:15: 'q' is declared here. +!!! related TS2771 overloadresolutionWithConstraintCheckingDeferred.ts:12:18: The last overload is declared here. + ~~~~~~~~ +!!! error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. +!!! related TS2728 overloadresolutionWithConstraintCheckingDeferred.ts:1:15: 'x' is declared here. + + var result3: string = foo(x => { // x has type D + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: The last overload gave the following error. +!!! error TS2769: Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. +!!! error TS2769: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2769: Property 'q' is missing in type 'B' but required in type 'D'. +!!! related TS2728 overloadresolutionWithConstraintCheckingDeferred.ts:4:15: 'q' is declared here. +!!! related TS2771 overloadresolutionWithConstraintCheckingDeferred.ts:12:18: The last overload is declared here. + var y: G = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error + ~~~~~~~~ +!!! error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. +!!! related TS2728 overloadresolutionWithConstraintCheckingDeferred.ts:1:15: 'x' is declared here. + ~ +!!! error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. +!!! related TS2728 overloadresolutionWithConstraintCheckingDeferred.ts:1:15: 'x' is declared here. + return y; + }); + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=default).js new file mode 100644 index 0000000000000..bf035f63927a4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=default).js @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts] //// + +//// [overloadresolutionWithConstraintCheckingDeferred.ts] +interface A { x } +interface B { x; y } +interface C { z } +interface D { q } + +class G { + constructor(x: T) { } +} + +declare function foo(arg: (x: D) => number): string; +declare function foo(arg: (x: C) => any): string; +declare function foo(arg: (x: B) => any): number; + +var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. + +var result2: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. + +var result3: string = foo(x => { // x has type D + var y: G = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error + return y; +}); + + +//// [overloadresolutionWithConstraintCheckingDeferred.js] +"use strict"; +class G { + constructor(x) { } +} +var result = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. +var result2 = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. +var result3 = foo(x => { + var y = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error + return y; +}); diff --git a/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=default).symbols new file mode 100644 index 0000000000000..c06f37a086801 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=default).symbols @@ -0,0 +1,80 @@ +//// [tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts] //// + +=== overloadresolutionWithConstraintCheckingDeferred.ts === +interface A { x } +>A : Symbol(A, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 0)) +>x : Symbol(A.x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 13)) + +interface B { x; y } +>B : Symbol(B, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 17)) +>x : Symbol(B.x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 1, 13)) +>y : Symbol(B.y, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 1, 16)) + +interface C { z } +>C : Symbol(C, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 1, 20)) +>z : Symbol(C.z, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 2, 13)) + +interface D { q } +>D : Symbol(D, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 2, 17)) +>q : Symbol(D.q, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 13)) + +class G { +>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17)) +>T : Symbol(T, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 5, 8)) +>A : Symbol(A, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 0)) + + constructor(x: T) { } +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 6, 16)) +>T : Symbol(T, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 5, 8)) +} + +declare function foo(arg: (x: D) => number): string; +>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49)) +>arg : Symbol(arg, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 21)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 27)) +>D : Symbol(D, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 2, 17)) + +declare function foo(arg: (x: C) => any): string; +>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49)) +>arg : Symbol(arg, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 21)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 27)) +>C : Symbol(C, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 1, 20)) + +declare function foo(arg: (x: B) => any): number; +>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49)) +>arg : Symbol(arg, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 11, 21)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 11, 27)) +>B : Symbol(B, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 17)) + +var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. +>result : Symbol(result, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 13, 3)) +>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 13, 25)) +>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 13, 25)) + +var result2: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. +>result2 : Symbol(result2, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 15, 3)) +>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 15, 26)) +>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 15, 26)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 15, 26)) + +var result3: string = foo(x => { // x has type D +>result3 : Symbol(result3, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 17, 3)) +>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 17, 26)) + + var y: G = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error +>y : Symbol(y, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 18, 7)) +>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 17, 26)) +>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 17, 26)) + + return y; +>y : Symbol(y, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 18, 7)) + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=default).types new file mode 100644 index 0000000000000..df9ec39e7e837 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=default).types @@ -0,0 +1,78 @@ +//// [tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts] //// + +=== overloadresolutionWithConstraintCheckingDeferred.ts === +interface A { x } +>x : any + +interface B { x; y } +>x : any +>y : any + +interface C { z } +>z : any + +interface D { q } +>q : any + +class G { +>G : G + + constructor(x: T) { } +>x : T +} + +declare function foo(arg: (x: D) => number): string; +>foo : { (arg: (x: D) => number): string; (arg: (x: C) => any): string; (arg: (x: B) => any): number; } +>arg : (x: D) => number +>x : D + +declare function foo(arg: (x: C) => any): string; +>foo : { (arg: (x: D) => number): string; (arg: (x: C) => any): string; (arg: (x: B) => any): number; } +>arg : (x: C) => any +>x : C + +declare function foo(arg: (x: B) => any): number; +>foo : { (arg: (x: D) => number): string; (arg: (x: C) => any): string; (arg: (x: B) => any): number; } +>arg : (x: B) => any +>x : B + +var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. +>result : number +>foo(x => new G(x)) : never +>foo : { (arg: (x: D) => number): string; (arg: (x: C) => any): string; (arg: (x: B) => any): number; } +>x => new G(x) : (x: D) => G +>x : D +>new G(x) : G +>G : typeof G +>x : D + +var result2: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. +>result2 : number +>foo(x => new G(x)) : never +>foo : { (arg: (x: D) => number): string; (arg: (x: C) => any): string; (arg: (x: B) => any): number; } +>x => new G(x) : (x: D) => G +>x : D +>new G(x) : G +>G : typeof G +>x : D +>x : D + +var result3: string = foo(x => { // x has type D +>result3 : string +>foo(x => { // x has type D var y: G = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error return y;}) : never +>foo : { (arg: (x: D) => number): string; (arg: (x: C) => any): string; (arg: (x: B) => any): number; } +>x => { // x has type D var y: G = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error return y;} : (x: D) => G +>x : D + + var y: G = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error +>y : G +>x : D +>new G(x) : G +>G : typeof G +>x : D + + return y; +>y : G + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..e93dbcc6cad6b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=typesfirst).errors.txt @@ -0,0 +1,76 @@ +overloadresolutionWithConstraintCheckingDeferred.ts(14,26): error TS2769: No overload matches this call. + The last overload gave the following error. + Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. + Types of parameters 'x' and 'x' are incompatible. + Property 'q' is missing in type 'B' but required in type 'D'. +overloadresolutionWithConstraintCheckingDeferred.ts(14,37): error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. +overloadresolutionWithConstraintCheckingDeferred.ts(16,27): error TS2769: No overload matches this call. + The last overload gave the following error. + Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. + Types of parameters 'x' and 'x' are incompatible. + Property 'q' is missing in type 'B' but required in type 'D'. +overloadresolutionWithConstraintCheckingDeferred.ts(16,38): error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. +overloadresolutionWithConstraintCheckingDeferred.ts(18,27): error TS2769: No overload matches this call. + The last overload gave the following error. + Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. + Types of parameters 'x' and 'x' are incompatible. + Property 'q' is missing in type 'B' but required in type 'D'. +overloadresolutionWithConstraintCheckingDeferred.ts(19,32): error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. + + +==== overloadresolutionWithConstraintCheckingDeferred.ts (6 errors) ==== + interface A { x } + interface B { x; y } + interface C { z } + interface D { q } + + class G { + constructor(x: T) { } + } + + declare function foo(arg: (x: D) => number): string; + declare function foo(arg: (x: C) => any): string; + declare function foo(arg: (x: B) => any): number; + + var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. + ~~~~~~~~~~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: The last overload gave the following error. +!!! error TS2769: Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. +!!! error TS2769: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2769: Property 'q' is missing in type 'B' but required in type 'D'. +!!! related TS2728 overloadresolutionWithConstraintCheckingDeferred.ts:4:15: 'q' is declared here. +!!! related TS2771 overloadresolutionWithConstraintCheckingDeferred.ts:12:18: The last overload is declared here. + ~ +!!! error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. +!!! related TS2728 overloadresolutionWithConstraintCheckingDeferred.ts:1:15: 'x' is declared here. + + var result2: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: The last overload gave the following error. +!!! error TS2769: Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. +!!! error TS2769: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2769: Property 'q' is missing in type 'B' but required in type 'D'. +!!! related TS2728 overloadresolutionWithConstraintCheckingDeferred.ts:4:15: 'q' is declared here. +!!! related TS2771 overloadresolutionWithConstraintCheckingDeferred.ts:12:18: The last overload is declared here. + ~~~~~~~~ +!!! error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. +!!! related TS2728 overloadresolutionWithConstraintCheckingDeferred.ts:1:15: 'x' is declared here. + + var result3: string = foo(x => { // x has type D + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: The last overload gave the following error. +!!! error TS2769: Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. +!!! error TS2769: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2769: Property 'q' is missing in type 'B' but required in type 'D'. +!!! related TS2728 overloadresolutionWithConstraintCheckingDeferred.ts:4:15: 'q' is declared here. +!!! related TS2771 overloadresolutionWithConstraintCheckingDeferred.ts:12:18: The last overload is declared here. + var y: G = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error + ~ +!!! error TS2741: Property 'x' is missing in type 'D' but required in type 'A'. +!!! related TS2728 overloadresolutionWithConstraintCheckingDeferred.ts:1:15: 'x' is declared here. + return y; + }); + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=typesfirst).js new file mode 100644 index 0000000000000..bf035f63927a4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=typesfirst).js @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts] //// + +//// [overloadresolutionWithConstraintCheckingDeferred.ts] +interface A { x } +interface B { x; y } +interface C { z } +interface D { q } + +class G { + constructor(x: T) { } +} + +declare function foo(arg: (x: D) => number): string; +declare function foo(arg: (x: C) => any): string; +declare function foo(arg: (x: B) => any): number; + +var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. + +var result2: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. + +var result3: string = foo(x => { // x has type D + var y: G = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error + return y; +}); + + +//// [overloadresolutionWithConstraintCheckingDeferred.js] +"use strict"; +class G { + constructor(x) { } +} +var result = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. +var result2 = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. +var result3 = foo(x => { + var y = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error + return y; +}); diff --git a/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..c06f37a086801 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=typesfirst).symbols @@ -0,0 +1,80 @@ +//// [tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts] //// + +=== overloadresolutionWithConstraintCheckingDeferred.ts === +interface A { x } +>A : Symbol(A, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 0)) +>x : Symbol(A.x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 13)) + +interface B { x; y } +>B : Symbol(B, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 17)) +>x : Symbol(B.x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 1, 13)) +>y : Symbol(B.y, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 1, 16)) + +interface C { z } +>C : Symbol(C, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 1, 20)) +>z : Symbol(C.z, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 2, 13)) + +interface D { q } +>D : Symbol(D, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 2, 17)) +>q : Symbol(D.q, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 13)) + +class G { +>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17)) +>T : Symbol(T, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 5, 8)) +>A : Symbol(A, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 0)) + + constructor(x: T) { } +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 6, 16)) +>T : Symbol(T, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 5, 8)) +} + +declare function foo(arg: (x: D) => number): string; +>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49)) +>arg : Symbol(arg, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 21)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 27)) +>D : Symbol(D, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 2, 17)) + +declare function foo(arg: (x: C) => any): string; +>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49)) +>arg : Symbol(arg, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 21)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 27)) +>C : Symbol(C, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 1, 20)) + +declare function foo(arg: (x: B) => any): number; +>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49)) +>arg : Symbol(arg, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 11, 21)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 11, 27)) +>B : Symbol(B, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 17)) + +var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. +>result : Symbol(result, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 13, 3)) +>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 13, 25)) +>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 13, 25)) + +var result2: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. +>result2 : Symbol(result2, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 15, 3)) +>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 15, 26)) +>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 15, 26)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 15, 26)) + +var result3: string = foo(x => { // x has type D +>result3 : Symbol(result3, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 17, 3)) +>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 17, 26)) + + var y: G = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error +>y : Symbol(y, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 18, 7)) +>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 17, 26)) +>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17)) +>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 17, 26)) + + return y; +>y : Symbol(y, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 18, 7)) + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=typesfirst).types new file mode 100644 index 0000000000000..7eb08e3ac8acb --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/overloadresolutionWithConstraintCheckingDeferred(checkorder=typesfirst).types @@ -0,0 +1,78 @@ +//// [tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts] //// + +=== overloadresolutionWithConstraintCheckingDeferred.ts === +interface A { x } +>x : any + +interface B { x; y } +>x : any +>y : any + +interface C { z } +>z : any + +interface D { q } +>q : any + +class G { +>G : G + + constructor(x: T) { } +>x : T +} + +declare function foo(arg: (x: D) => number): string; +>foo : { (arg: (x: D) => number): string; (arg: (x: C) => any): string; (arg: (x: B) => any): number; } +>arg : (x: D) => number +>x : D + +declare function foo(arg: (x: C) => any): string; +>foo : { (arg: (x: D) => number): string; (arg: (x: C) => any): string; (arg: (x: B) => any): number; } +>arg : (x: C) => any +>x : C + +declare function foo(arg: (x: B) => any): number; +>foo : { (arg: (x: D) => number): string; (arg: (x: C) => any): string; (arg: (x: B) => any): number; } +>arg : (x: B) => any +>x : B + +var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. +>result : number +>foo(x => new G(x)) : never +>foo : { (arg: (x: D) => number): string; (arg: (x: C) => any): string; (arg: (x: B) => any): number; } +>x => new G(x) : (x: D) => G +>x : D +>new G(x) : G +>G : typeof G +>x : any + +var result2: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked. +>result2 : number +>foo(x => new G(x)) : never +>foo : { (arg: (x: D) => number): string; (arg: (x: C) => any): string; (arg: (x: B) => any): number; } +>x => new G(x) : (x: D) => G +>x : D +>new G(x) : G +>G : typeof G +>x : D +>x : any + +var result3: string = foo(x => { // x has type D +>result3 : string +>foo(x => { // x has type D var y: G = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error return y;}) : never +>foo : { (arg: (x: D) => number): string; (arg: (x: C) => any): string; (arg: (x: B) => any): number; } +>x => { // x has type D var y: G = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error return y;} : (x: D) => G +>x : D + + var y: G = new G(x); // error that D does not satisfy constraint, y is of type G, entire call to foo is an error +>y : G +>x : D +>new G(x) : G +>G : typeof G +>x : D + + return y; +>y : G + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=default).errors.txt new file mode 100644 index 0000000000000..fab2d38147e93 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=default).errors.txt @@ -0,0 +1,34 @@ +parameterBindingDefaultReferencesSiblingThroughCall.ts(11,19): error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +parameterBindingDefaultReferencesSiblingThroughCall.ts(16,11): error TS2322: Type 'unknown' is not assignable to type 'string'. +parameterBindingDefaultReferencesSiblingThroughCall.ts(20,11): error TS2322: Type 'any[]' is not assignable to type 'string'. + + +==== parameterBindingDefaultReferencesSiblingThroughCall.ts (3 errors) ==== + // A default in a destructured parameter that references a sibling element + // makes the sibling's type depend on itself: the type of 'a' comes from the + // parameter initializer '{}', which is padded with the types of the defaults, + // including 'b'. Main reports this cycle (TS7022 on 'a') for 'b = a', but not + // for 'b = id(a)', where the padding reuses the signature resolved while 'a' + // was treated as non-inferrable any during contextual typing of '{}', which + // gives 'b' the type 'unknown' (see tldraw TldrawApp.test.ts). + + declare function id(v: T): T; + + function direct({ a = 1 as number | undefined, b = a } = {}) { + ~ +!!! error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + const n: string = b; + } + + function viaCall({ a = 1 as number | undefined, b = id(a) } = {}) { + const n: string = b; + ~ +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. + } + + function viaCallArray({ a = 1 as number | undefined, b = id([a]) } = {}) { + const n: string = b; + ~ +!!! error TS2322: Type 'any[]' is not assignable to type 'string'. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=default).symbols new file mode 100644 index 0000000000000..06dbf91e4f588 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=default).symbols @@ -0,0 +1,53 @@ +//// [tests/cases/compiler/parameterBindingDefaultReferencesSiblingThroughCall.ts] //// + +=== parameterBindingDefaultReferencesSiblingThroughCall.ts === +// A default in a destructured parameter that references a sibling element +// makes the sibling's type depend on itself: the type of 'a' comes from the +// parameter initializer '{}', which is padded with the types of the defaults, +// including 'b'. Main reports this cycle (TS7022 on 'a') for 'b = a', but not +// for 'b = id(a)', where the padding reuses the signature resolved while 'a' +// was treated as non-inferrable any during contextual typing of '{}', which +// gives 'b' the type 'unknown' (see tldraw TldrawApp.test.ts). + +declare function id(v: T): T; +>id : Symbol(id, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 0, 0)) +>T : Symbol(T, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 8, 20)) +>v : Symbol(v, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 8, 23)) +>T : Symbol(T, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 8, 20)) +>T : Symbol(T, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 8, 20)) + +function direct({ a = 1 as number | undefined, b = a } = {}) { +>direct : Symbol(direct, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 8, 32)) +>a : Symbol(a, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 10, 17)) +>b : Symbol(b, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 10, 46)) +>a : Symbol(a, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 10, 17)) + + const n: string = b; +>n : Symbol(n, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 11, 9)) +>b : Symbol(b, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 10, 46)) +} + +function viaCall({ a = 1 as number | undefined, b = id(a) } = {}) { +>viaCall : Symbol(viaCall, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 12, 1)) +>a : Symbol(a, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 14, 18)) +>b : Symbol(b, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 14, 47)) +>id : Symbol(id, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 0, 0)) +>a : Symbol(a, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 14, 18)) + + const n: string = b; +>n : Symbol(n, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 15, 9)) +>b : Symbol(b, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 14, 47)) +} + +function viaCallArray({ a = 1 as number | undefined, b = id([a]) } = {}) { +>viaCallArray : Symbol(viaCallArray, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 16, 1)) +>a : Symbol(a, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 18, 23)) +>b : Symbol(b, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 18, 52)) +>id : Symbol(id, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 0, 0)) +>a : Symbol(a, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 18, 23)) + + const n: string = b; +>n : Symbol(n, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 19, 9)) +>b : Symbol(b, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 18, 52)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=default).types new file mode 100644 index 0000000000000..d8b5d78c1e02b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=default).types @@ -0,0 +1,62 @@ +//// [tests/cases/compiler/parameterBindingDefaultReferencesSiblingThroughCall.ts] //// + +=== parameterBindingDefaultReferencesSiblingThroughCall.ts === +// A default in a destructured parameter that references a sibling element +// makes the sibling's type depend on itself: the type of 'a' comes from the +// parameter initializer '{}', which is padded with the types of the defaults, +// including 'b'. Main reports this cycle (TS7022 on 'a') for 'b = a', but not +// for 'b = id(a)', where the padding reuses the signature resolved while 'a' +// was treated as non-inferrable any during contextual typing of '{}', which +// gives 'b' the type 'unknown' (see tldraw TldrawApp.test.ts). + +declare function id(v: T): T; +>id : (v: T) => T +>v : T + +function direct({ a = 1 as number | undefined, b = a } = {}) { +>direct : ({ a, b }?: { a?: number | undefined; b?: any; }) => void +>a : any +>1 as number | undefined : number | undefined +>1 : 1 +>b : any +>a : any +>{} : {} + + const n: string = b; +>n : string +>b : any +} + +function viaCall({ a = 1 as number | undefined, b = id(a) } = {}) { +>viaCall : ({ a, b }?: { a?: number | undefined; b?: unknown; }) => void +>a : number | undefined +>1 as number | undefined : number | undefined +>1 : 1 +>b : unknown +>id(a) : unknown +>id : (v: T) => T +>a : number | undefined +>{} : {} + + const n: string = b; +>n : string +>b : unknown +} + +function viaCallArray({ a = 1 as number | undefined, b = id([a]) } = {}) { +>viaCallArray : ({ a, b }?: { a?: number | undefined; b?: any[] | undefined; }) => void +>a : number | undefined +>1 as number | undefined : number | undefined +>1 : 1 +>b : any[] +>id([a]) : any[] +>id : (v: T) => T +>[a] : (number | undefined)[] +>a : number | undefined +>{} : {} + + const n: string = b; +>n : string +>b : any[] +} + diff --git a/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..fab2d38147e93 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=typesfirst).errors.txt @@ -0,0 +1,34 @@ +parameterBindingDefaultReferencesSiblingThroughCall.ts(11,19): error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +parameterBindingDefaultReferencesSiblingThroughCall.ts(16,11): error TS2322: Type 'unknown' is not assignable to type 'string'. +parameterBindingDefaultReferencesSiblingThroughCall.ts(20,11): error TS2322: Type 'any[]' is not assignable to type 'string'. + + +==== parameterBindingDefaultReferencesSiblingThroughCall.ts (3 errors) ==== + // A default in a destructured parameter that references a sibling element + // makes the sibling's type depend on itself: the type of 'a' comes from the + // parameter initializer '{}', which is padded with the types of the defaults, + // including 'b'. Main reports this cycle (TS7022 on 'a') for 'b = a', but not + // for 'b = id(a)', where the padding reuses the signature resolved while 'a' + // was treated as non-inferrable any during contextual typing of '{}', which + // gives 'b' the type 'unknown' (see tldraw TldrawApp.test.ts). + + declare function id(v: T): T; + + function direct({ a = 1 as number | undefined, b = a } = {}) { + ~ +!!! error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + const n: string = b; + } + + function viaCall({ a = 1 as number | undefined, b = id(a) } = {}) { + const n: string = b; + ~ +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. + } + + function viaCallArray({ a = 1 as number | undefined, b = id([a]) } = {}) { + const n: string = b; + ~ +!!! error TS2322: Type 'any[]' is not assignable to type 'string'. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..06dbf91e4f588 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=typesfirst).symbols @@ -0,0 +1,53 @@ +//// [tests/cases/compiler/parameterBindingDefaultReferencesSiblingThroughCall.ts] //// + +=== parameterBindingDefaultReferencesSiblingThroughCall.ts === +// A default in a destructured parameter that references a sibling element +// makes the sibling's type depend on itself: the type of 'a' comes from the +// parameter initializer '{}', which is padded with the types of the defaults, +// including 'b'. Main reports this cycle (TS7022 on 'a') for 'b = a', but not +// for 'b = id(a)', where the padding reuses the signature resolved while 'a' +// was treated as non-inferrable any during contextual typing of '{}', which +// gives 'b' the type 'unknown' (see tldraw TldrawApp.test.ts). + +declare function id(v: T): T; +>id : Symbol(id, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 0, 0)) +>T : Symbol(T, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 8, 20)) +>v : Symbol(v, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 8, 23)) +>T : Symbol(T, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 8, 20)) +>T : Symbol(T, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 8, 20)) + +function direct({ a = 1 as number | undefined, b = a } = {}) { +>direct : Symbol(direct, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 8, 32)) +>a : Symbol(a, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 10, 17)) +>b : Symbol(b, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 10, 46)) +>a : Symbol(a, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 10, 17)) + + const n: string = b; +>n : Symbol(n, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 11, 9)) +>b : Symbol(b, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 10, 46)) +} + +function viaCall({ a = 1 as number | undefined, b = id(a) } = {}) { +>viaCall : Symbol(viaCall, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 12, 1)) +>a : Symbol(a, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 14, 18)) +>b : Symbol(b, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 14, 47)) +>id : Symbol(id, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 0, 0)) +>a : Symbol(a, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 14, 18)) + + const n: string = b; +>n : Symbol(n, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 15, 9)) +>b : Symbol(b, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 14, 47)) +} + +function viaCallArray({ a = 1 as number | undefined, b = id([a]) } = {}) { +>viaCallArray : Symbol(viaCallArray, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 16, 1)) +>a : Symbol(a, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 18, 23)) +>b : Symbol(b, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 18, 52)) +>id : Symbol(id, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 0, 0)) +>a : Symbol(a, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 18, 23)) + + const n: string = b; +>n : Symbol(n, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 19, 9)) +>b : Symbol(b, Decl(parameterBindingDefaultReferencesSiblingThroughCall.ts, 18, 52)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=typesfirst).types new file mode 100644 index 0000000000000..d8b5d78c1e02b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/parameterBindingDefaultReferencesSiblingThroughCall(checkorder=typesfirst).types @@ -0,0 +1,62 @@ +//// [tests/cases/compiler/parameterBindingDefaultReferencesSiblingThroughCall.ts] //// + +=== parameterBindingDefaultReferencesSiblingThroughCall.ts === +// A default in a destructured parameter that references a sibling element +// makes the sibling's type depend on itself: the type of 'a' comes from the +// parameter initializer '{}', which is padded with the types of the defaults, +// including 'b'. Main reports this cycle (TS7022 on 'a') for 'b = a', but not +// for 'b = id(a)', where the padding reuses the signature resolved while 'a' +// was treated as non-inferrable any during contextual typing of '{}', which +// gives 'b' the type 'unknown' (see tldraw TldrawApp.test.ts). + +declare function id(v: T): T; +>id : (v: T) => T +>v : T + +function direct({ a = 1 as number | undefined, b = a } = {}) { +>direct : ({ a, b }?: { a?: number | undefined; b?: any; }) => void +>a : any +>1 as number | undefined : number | undefined +>1 : 1 +>b : any +>a : any +>{} : {} + + const n: string = b; +>n : string +>b : any +} + +function viaCall({ a = 1 as number | undefined, b = id(a) } = {}) { +>viaCall : ({ a, b }?: { a?: number | undefined; b?: unknown; }) => void +>a : number | undefined +>1 as number | undefined : number | undefined +>1 : 1 +>b : unknown +>id(a) : unknown +>id : (v: T) => T +>a : number | undefined +>{} : {} + + const n: string = b; +>n : string +>b : unknown +} + +function viaCallArray({ a = 1 as number | undefined, b = id([a]) } = {}) { +>viaCallArray : ({ a, b }?: { a?: number | undefined; b?: any[] | undefined; }) => void +>a : number | undefined +>1 as number | undefined : number | undefined +>1 : 1 +>b : any[] +>id([a]) : any[] +>id : (v: T) => T +>[a] : (number | undefined)[] +>a : number | undefined +>{} : {} + + const n: string = b; +>n : string +>b : any[] +} + diff --git a/tsc/testdata/baselines/reference/compiler/recursiveVarianceFixedPoint.errors.txt b/tsc/testdata/baselines/reference/compiler/recursiveVarianceFixedPoint.errors.txt new file mode 100644 index 0000000000000..1b54f45a5c6a5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/recursiveVarianceFixedPoint.errors.txt @@ -0,0 +1,227 @@ +annotations.ts(18,1): error TS2322: Type 'AnnotatedTree' is not assignable to type 'AnnotatedTree'. + Type 'unknown' is not assignable to type 'string'. +annotations.ts(19,1): error TS2322: Type 'AnnotatedStore' is not assignable to type 'AnnotatedStore'. + Types of property 'listener' are incompatible. + Type '(batch: AnnotatedStore) => void' is not assignable to type '(batch: AnnotatedStore) => void'. + Types of parameters 'batch' and 'batch' are incompatible. + Type 'AnnotatedStore' is not assignable to type 'AnnotatedStore'. + Types of property 'value' are incompatible. + Type 'unknown[]' is not assignable to type 'string[]'. + Type 'unknown' is not assignable to type 'string'. +annotations.ts(20,1): error TS2322: Type 'AnnotatedStore' is not assignable to type 'AnnotatedStore'. + Types of property 'value' are incompatible. + Type 'unknown' is not assignable to type 'string'. +columnDefFirst.ts(14,1): error TS2322: Type 'ColumnDef<{ name: string; }, string>' is not assignable to type 'ColumnDef<{ name: string; }, unknown>'. + Type 'unknown' is not assignable to type 'string'. +listenerFirst.ts(14,1): error TS2322: Type 'Listener' is not assignable to type 'Listener'. + Type 'unknown' is not assignable to type 'string'. +nestedComposition.ts(14,1): error TS2322: Type 'Outer' is not assignable to type 'Outer'. + Types of property 'next' are incompatible. + Type 'Inner>' is not assignable to type 'Inner>'. + Type 'Outer' is not assignable to type 'Outer'. + Types of property 'value' are incompatible. + Type 'unknown' is not assignable to type 'string'. +nestedComposition.ts(15,1): error TS2322: Type 'Outer' is not assignable to type 'Outer'. + Types of property 'value' are incompatible. + Type 'unknown' is not assignable to type 'string'. +positiveRecursion.ts(18,1): error TS2322: Type 'Tree' is not assignable to type 'Tree'. + Type 'unknown' is not assignable to type 'string'. +structuralMeasurement.ts(23,1): error TS2322: Type 'GenericMethod' is not assignable to type 'GenericMethod'. + Type 'unknown' is not assignable to type 'string'. + + +==== storeFirst.ts (0 errors) ==== + export {}; + + interface Store { + value: T; + listener: Listener; + } + type Listener = (batch: Store) => void; + + declare let strings: Store; + declare let unknowns: Store; + declare let stringListener: Listener; + declare let unknownListener: Listener; + + unknowns = strings; // Error + unknownListener = stringListener; // Error + +==== listenerFirst.ts (1 errors) ==== + export {}; + + type Listener = (batch: Store) => void; + interface Store { + listener: Listener; + value: T; + } + + declare let strings: Store; + declare let unknowns: Store; + declare let stringListener: Listener; + declare let unknownListener: Listener; + + unknownListener = stringListener; // Error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'Listener' is not assignable to type 'Listener'. +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. + unknowns = strings; // Error + +==== columnDefFirst.ts (1 errors) ==== + export {}; + + interface ColumnDef { + cell?: (column: Column) => void; + } + interface Column { + accessorFn?: (row: Row) => Value; + columnDef: ColumnDef; + } + + declare let stringColumn: ColumnDef<{ name: string }, string>; + declare let unknownColumn: ColumnDef<{ name: string }, unknown>; + + unknownColumn = stringColumn; // Error + ~~~~~~~~~~~~~ +!!! error TS2322: Type 'ColumnDef<{ name: string; }, string>' is not assignable to type 'ColumnDef<{ name: string; }, unknown>'. +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. + stringColumn = unknownColumn; // Error + +==== columnFirst.ts (0 errors) ==== + export {}; + + interface Column { + columnDef: ColumnDef; + accessorFn?: (row: Row) => Value; + } + interface ColumnDef { + cell?: (column: Column) => void; + } + + declare let stringColumn: ColumnDef<{ name: string }, string>; + declare let unknownColumn: ColumnDef<{ name: string }, unknown>; + + unknownColumn = stringColumn; // Error + stringColumn = unknownColumn; // Error + +==== positiveRecursion.ts (1 errors) ==== + export {}; + + interface Tree { + readonly value: T; + readonly children: readonly Tree[]; + readonly metadata: Map; + } + interface Phantom { + next: Phantom; + } + + declare let stringTree: Tree; + declare let unknownTree: Tree; + declare let stringPhantom: Phantom; + declare let numberPhantom: Phantom; + + unknownTree = stringTree; + stringTree = unknownTree; // Error + ~~~~~~~~~~ +!!! error TS2322: Type 'Tree' is not assignable to type 'Tree'. +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. + stringPhantom = numberPhantom; + numberPhantom = stringPhantom; + +==== nestedComposition.ts (2 errors) ==== + export {}; + + interface Outer { + value: T; + next: Inner>; + } + interface Inner { + consume: (value: T) => void; + } + + declare let strings: Outer; + declare let unknowns: Outer; + + unknowns = strings; // Error + ~~~~~~~~ +!!! error TS2322: Type 'Outer' is not assignable to type 'Outer'. +!!! error TS2322: Types of property 'next' are incompatible. +!!! error TS2322: Type 'Inner>' is not assignable to type 'Inner>'. +!!! error TS2322: Type 'Outer' is not assignable to type 'Outer'. +!!! error TS2322: Types of property 'value' are incompatible. +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. + strings = unknowns; // Error + ~~~~~~~ +!!! error TS2322: Type 'Outer' is not assignable to type 'Outer'. +!!! error TS2322: Types of property 'value' are incompatible. +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. + +==== annotations.ts (3 errors) ==== + export {}; + + interface AnnotatedTree { + readonly value: T; + readonly children: AnnotatedTree[]; + } + interface AnnotatedStore { + value: T; + listener: (batch: AnnotatedStore) => void; + } + + declare let stringTree: AnnotatedTree; + declare let unknownTree: AnnotatedTree; + declare let stringStore: AnnotatedStore; + declare let unknownStore: AnnotatedStore; + + unknownTree = stringTree; + stringTree = unknownTree; // Error + ~~~~~~~~~~ +!!! error TS2322: Type 'AnnotatedTree' is not assignable to type 'AnnotatedTree'. +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. + unknownStore = stringStore; // Error + ~~~~~~~~~~~~ +!!! error TS2322: Type 'AnnotatedStore' is not assignable to type 'AnnotatedStore'. +!!! error TS2322: Types of property 'listener' are incompatible. +!!! error TS2322: Type '(batch: AnnotatedStore) => void' is not assignable to type '(batch: AnnotatedStore) => void'. +!!! error TS2322: Types of parameters 'batch' and 'batch' are incompatible. +!!! error TS2322: Type 'AnnotatedStore' is not assignable to type 'AnnotatedStore'. +!!! error TS2322: Types of property 'value' are incompatible. +!!! error TS2322: Type 'unknown[]' is not assignable to type 'string[]'. +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. + stringStore = unknownStore; // Error + ~~~~~~~~~~~ +!!! error TS2322: Type 'AnnotatedStore' is not assignable to type 'AnnotatedStore'. +!!! error TS2322: Types of property 'value' are incompatible. +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. + +==== structuralMeasurement.ts (1 errors) ==== + export {}; + + interface GenericMethod { + value: T; + next: (value: U) => GenericMethod; + } + interface Projected { + value: T["value"]; + next: Projected; + } + interface Method { + value: T; + accept(value: Method): void; + } + + declare let strings: GenericMethod; + declare let unknowns: GenericMethod; + declare let stringMethod: Method; + declare let unknownMethod: Method; + declare let projected: Projected<{ value: string; extra: number }>; + + unknowns = strings; + strings = unknowns; // Error + ~~~~~~~ +!!! error TS2322: Type 'GenericMethod' is not assignable to type 'GenericMethod'. +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. + unknownMethod = stringMethod; + const widened: Projected<{ value: string }> = projected; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/recursiveVarianceFixedPoint.symbols b/tsc/testdata/baselines/reference/compiler/recursiveVarianceFixedPoint.symbols new file mode 100644 index 0000000000000..5609297b7b09a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/recursiveVarianceFixedPoint.symbols @@ -0,0 +1,455 @@ +//// [tests/cases/compiler/recursiveVarianceFixedPoint.ts] //// + +=== storeFirst.ts === +export {}; + +interface Store { +>Store : Symbol(Store, Decl(storeFirst.ts, 0, 10)) +>T : Symbol(T, Decl(storeFirst.ts, 2, 16)) + + value: T; +>value : Symbol(Store.value, Decl(storeFirst.ts, 2, 20)) +>T : Symbol(T, Decl(storeFirst.ts, 2, 16)) + + listener: Listener; +>listener : Symbol(Store.listener, Decl(storeFirst.ts, 3, 13)) +>Listener : Symbol(Listener, Decl(storeFirst.ts, 5, 1)) +>T : Symbol(T, Decl(storeFirst.ts, 2, 16)) +} +type Listener = (batch: Store) => void; +>Listener : Symbol(Listener, Decl(storeFirst.ts, 5, 1)) +>T : Symbol(T, Decl(storeFirst.ts, 6, 14)) +>batch : Symbol(batch, Decl(storeFirst.ts, 6, 20)) +>Store : Symbol(Store, Decl(storeFirst.ts, 0, 10)) +>T : Symbol(T, Decl(storeFirst.ts, 6, 14)) + +declare let strings: Store; +>strings : Symbol(strings, Decl(storeFirst.ts, 8, 11)) +>Store : Symbol(Store, Decl(storeFirst.ts, 0, 10)) + +declare let unknowns: Store; +>unknowns : Symbol(unknowns, Decl(storeFirst.ts, 9, 11)) +>Store : Symbol(Store, Decl(storeFirst.ts, 0, 10)) + +declare let stringListener: Listener; +>stringListener : Symbol(stringListener, Decl(storeFirst.ts, 10, 11)) +>Listener : Symbol(Listener, Decl(storeFirst.ts, 5, 1)) + +declare let unknownListener: Listener; +>unknownListener : Symbol(unknownListener, Decl(storeFirst.ts, 11, 11)) +>Listener : Symbol(Listener, Decl(storeFirst.ts, 5, 1)) + +unknowns = strings; // Error +>unknowns : Symbol(unknowns, Decl(storeFirst.ts, 9, 11)) +>strings : Symbol(strings, Decl(storeFirst.ts, 8, 11)) + +unknownListener = stringListener; // Error +>unknownListener : Symbol(unknownListener, Decl(storeFirst.ts, 11, 11)) +>stringListener : Symbol(stringListener, Decl(storeFirst.ts, 10, 11)) + +=== listenerFirst.ts === +export {}; + +type Listener = (batch: Store) => void; +>Listener : Symbol(Listener, Decl(listenerFirst.ts, 0, 10)) +>T : Symbol(T, Decl(listenerFirst.ts, 2, 14)) +>batch : Symbol(batch, Decl(listenerFirst.ts, 2, 20)) +>Store : Symbol(Store, Decl(listenerFirst.ts, 2, 47)) +>T : Symbol(T, Decl(listenerFirst.ts, 2, 14)) + +interface Store { +>Store : Symbol(Store, Decl(listenerFirst.ts, 2, 47)) +>T : Symbol(T, Decl(listenerFirst.ts, 3, 16)) + + listener: Listener; +>listener : Symbol(Store.listener, Decl(listenerFirst.ts, 3, 20)) +>Listener : Symbol(Listener, Decl(listenerFirst.ts, 0, 10)) +>T : Symbol(T, Decl(listenerFirst.ts, 3, 16)) + + value: T; +>value : Symbol(Store.value, Decl(listenerFirst.ts, 4, 26)) +>T : Symbol(T, Decl(listenerFirst.ts, 3, 16)) +} + +declare let strings: Store; +>strings : Symbol(strings, Decl(listenerFirst.ts, 8, 11)) +>Store : Symbol(Store, Decl(listenerFirst.ts, 2, 47)) + +declare let unknowns: Store; +>unknowns : Symbol(unknowns, Decl(listenerFirst.ts, 9, 11)) +>Store : Symbol(Store, Decl(listenerFirst.ts, 2, 47)) + +declare let stringListener: Listener; +>stringListener : Symbol(stringListener, Decl(listenerFirst.ts, 10, 11)) +>Listener : Symbol(Listener, Decl(listenerFirst.ts, 0, 10)) + +declare let unknownListener: Listener; +>unknownListener : Symbol(unknownListener, Decl(listenerFirst.ts, 11, 11)) +>Listener : Symbol(Listener, Decl(listenerFirst.ts, 0, 10)) + +unknownListener = stringListener; // Error +>unknownListener : Symbol(unknownListener, Decl(listenerFirst.ts, 11, 11)) +>stringListener : Symbol(stringListener, Decl(listenerFirst.ts, 10, 11)) + +unknowns = strings; // Error +>unknowns : Symbol(unknowns, Decl(listenerFirst.ts, 9, 11)) +>strings : Symbol(strings, Decl(listenerFirst.ts, 8, 11)) + +=== columnDefFirst.ts === +export {}; + +interface ColumnDef { +>ColumnDef : Symbol(ColumnDef, Decl(columnDefFirst.ts, 0, 10)) +>Row : Symbol(Row, Decl(columnDefFirst.ts, 2, 20)) +>Value : Symbol(Value, Decl(columnDefFirst.ts, 2, 24)) + + cell?: (column: Column) => void; +>cell : Symbol(ColumnDef.cell, Decl(columnDefFirst.ts, 2, 43)) +>column : Symbol(column, Decl(columnDefFirst.ts, 3, 12)) +>Column : Symbol(Column, Decl(columnDefFirst.ts, 4, 1)) +>Row : Symbol(Row, Decl(columnDefFirst.ts, 2, 20)) +>Value : Symbol(Value, Decl(columnDefFirst.ts, 2, 24)) +} +interface Column { +>Column : Symbol(Column, Decl(columnDefFirst.ts, 4, 1)) +>Row : Symbol(Row, Decl(columnDefFirst.ts, 5, 17)) +>Value : Symbol(Value, Decl(columnDefFirst.ts, 5, 21)) + + accessorFn?: (row: Row) => Value; +>accessorFn : Symbol(Column.accessorFn, Decl(columnDefFirst.ts, 5, 40)) +>row : Symbol(row, Decl(columnDefFirst.ts, 6, 18)) +>Row : Symbol(Row, Decl(columnDefFirst.ts, 5, 17)) +>Value : Symbol(Value, Decl(columnDefFirst.ts, 5, 21)) + + columnDef: ColumnDef; +>columnDef : Symbol(Column.columnDef, Decl(columnDefFirst.ts, 6, 37)) +>ColumnDef : Symbol(ColumnDef, Decl(columnDefFirst.ts, 0, 10)) +>Row : Symbol(Row, Decl(columnDefFirst.ts, 5, 17)) +>Value : Symbol(Value, Decl(columnDefFirst.ts, 5, 21)) +} + +declare let stringColumn: ColumnDef<{ name: string }, string>; +>stringColumn : Symbol(stringColumn, Decl(columnDefFirst.ts, 10, 11)) +>ColumnDef : Symbol(ColumnDef, Decl(columnDefFirst.ts, 0, 10)) +>name : Symbol(name, Decl(columnDefFirst.ts, 10, 37)) + +declare let unknownColumn: ColumnDef<{ name: string }, unknown>; +>unknownColumn : Symbol(unknownColumn, Decl(columnDefFirst.ts, 11, 11)) +>ColumnDef : Symbol(ColumnDef, Decl(columnDefFirst.ts, 0, 10)) +>name : Symbol(name, Decl(columnDefFirst.ts, 11, 38)) + +unknownColumn = stringColumn; // Error +>unknownColumn : Symbol(unknownColumn, Decl(columnDefFirst.ts, 11, 11)) +>stringColumn : Symbol(stringColumn, Decl(columnDefFirst.ts, 10, 11)) + +stringColumn = unknownColumn; // Error +>stringColumn : Symbol(stringColumn, Decl(columnDefFirst.ts, 10, 11)) +>unknownColumn : Symbol(unknownColumn, Decl(columnDefFirst.ts, 11, 11)) + +=== columnFirst.ts === +export {}; + +interface Column { +>Column : Symbol(Column, Decl(columnFirst.ts, 0, 10)) +>Row : Symbol(Row, Decl(columnFirst.ts, 2, 17)) +>Value : Symbol(Value, Decl(columnFirst.ts, 2, 21)) + + columnDef: ColumnDef; +>columnDef : Symbol(Column.columnDef, Decl(columnFirst.ts, 2, 40)) +>ColumnDef : Symbol(ColumnDef, Decl(columnFirst.ts, 5, 1)) +>Row : Symbol(Row, Decl(columnFirst.ts, 2, 17)) +>Value : Symbol(Value, Decl(columnFirst.ts, 2, 21)) + + accessorFn?: (row: Row) => Value; +>accessorFn : Symbol(Column.accessorFn, Decl(columnFirst.ts, 3, 37)) +>row : Symbol(row, Decl(columnFirst.ts, 4, 18)) +>Row : Symbol(Row, Decl(columnFirst.ts, 2, 17)) +>Value : Symbol(Value, Decl(columnFirst.ts, 2, 21)) +} +interface ColumnDef { +>ColumnDef : Symbol(ColumnDef, Decl(columnFirst.ts, 5, 1)) +>Row : Symbol(Row, Decl(columnFirst.ts, 6, 20)) +>Value : Symbol(Value, Decl(columnFirst.ts, 6, 24)) + + cell?: (column: Column) => void; +>cell : Symbol(ColumnDef.cell, Decl(columnFirst.ts, 6, 43)) +>column : Symbol(column, Decl(columnFirst.ts, 7, 12)) +>Column : Symbol(Column, Decl(columnFirst.ts, 0, 10)) +>Row : Symbol(Row, Decl(columnFirst.ts, 6, 20)) +>Value : Symbol(Value, Decl(columnFirst.ts, 6, 24)) +} + +declare let stringColumn: ColumnDef<{ name: string }, string>; +>stringColumn : Symbol(stringColumn, Decl(columnFirst.ts, 10, 11)) +>ColumnDef : Symbol(ColumnDef, Decl(columnFirst.ts, 5, 1)) +>name : Symbol(name, Decl(columnFirst.ts, 10, 37)) + +declare let unknownColumn: ColumnDef<{ name: string }, unknown>; +>unknownColumn : Symbol(unknownColumn, Decl(columnFirst.ts, 11, 11)) +>ColumnDef : Symbol(ColumnDef, Decl(columnFirst.ts, 5, 1)) +>name : Symbol(name, Decl(columnFirst.ts, 11, 38)) + +unknownColumn = stringColumn; // Error +>unknownColumn : Symbol(unknownColumn, Decl(columnFirst.ts, 11, 11)) +>stringColumn : Symbol(stringColumn, Decl(columnFirst.ts, 10, 11)) + +stringColumn = unknownColumn; // Error +>stringColumn : Symbol(stringColumn, Decl(columnFirst.ts, 10, 11)) +>unknownColumn : Symbol(unknownColumn, Decl(columnFirst.ts, 11, 11)) + +=== positiveRecursion.ts === +export {}; + +interface Tree { +>Tree : Symbol(Tree, Decl(positiveRecursion.ts, 0, 10)) +>T : Symbol(T, Decl(positiveRecursion.ts, 2, 15)) + + readonly value: T; +>value : Symbol(Tree.value, Decl(positiveRecursion.ts, 2, 19)) +>T : Symbol(T, Decl(positiveRecursion.ts, 2, 15)) + + readonly children: readonly Tree[]; +>children : Symbol(Tree.children, Decl(positiveRecursion.ts, 3, 22)) +>Tree : Symbol(Tree, Decl(positiveRecursion.ts, 0, 10)) +>T : Symbol(T, Decl(positiveRecursion.ts, 2, 15)) + + readonly metadata: Map; +>metadata : Symbol(Tree.metadata, Decl(positiveRecursion.ts, 4, 42)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +} +interface Phantom { +>Phantom : Symbol(Phantom, Decl(positiveRecursion.ts, 6, 1)) +>T : Symbol(T, Decl(positiveRecursion.ts, 7, 18)) + + next: Phantom; +>next : Symbol(Phantom.next, Decl(positiveRecursion.ts, 7, 22)) +>Phantom : Symbol(Phantom, Decl(positiveRecursion.ts, 6, 1)) +>T : Symbol(T, Decl(positiveRecursion.ts, 7, 18)) +} + +declare let stringTree: Tree; +>stringTree : Symbol(stringTree, Decl(positiveRecursion.ts, 11, 11)) +>Tree : Symbol(Tree, Decl(positiveRecursion.ts, 0, 10)) + +declare let unknownTree: Tree; +>unknownTree : Symbol(unknownTree, Decl(positiveRecursion.ts, 12, 11)) +>Tree : Symbol(Tree, Decl(positiveRecursion.ts, 0, 10)) + +declare let stringPhantom: Phantom; +>stringPhantom : Symbol(stringPhantom, Decl(positiveRecursion.ts, 13, 11)) +>Phantom : Symbol(Phantom, Decl(positiveRecursion.ts, 6, 1)) + +declare let numberPhantom: Phantom; +>numberPhantom : Symbol(numberPhantom, Decl(positiveRecursion.ts, 14, 11)) +>Phantom : Symbol(Phantom, Decl(positiveRecursion.ts, 6, 1)) + +unknownTree = stringTree; +>unknownTree : Symbol(unknownTree, Decl(positiveRecursion.ts, 12, 11)) +>stringTree : Symbol(stringTree, Decl(positiveRecursion.ts, 11, 11)) + +stringTree = unknownTree; // Error +>stringTree : Symbol(stringTree, Decl(positiveRecursion.ts, 11, 11)) +>unknownTree : Symbol(unknownTree, Decl(positiveRecursion.ts, 12, 11)) + +stringPhantom = numberPhantom; +>stringPhantom : Symbol(stringPhantom, Decl(positiveRecursion.ts, 13, 11)) +>numberPhantom : Symbol(numberPhantom, Decl(positiveRecursion.ts, 14, 11)) + +numberPhantom = stringPhantom; +>numberPhantom : Symbol(numberPhantom, Decl(positiveRecursion.ts, 14, 11)) +>stringPhantom : Symbol(stringPhantom, Decl(positiveRecursion.ts, 13, 11)) + +=== nestedComposition.ts === +export {}; + +interface Outer { +>Outer : Symbol(Outer, Decl(nestedComposition.ts, 0, 10)) +>T : Symbol(T, Decl(nestedComposition.ts, 2, 16)) + + value: T; +>value : Symbol(Outer.value, Decl(nestedComposition.ts, 2, 20)) +>T : Symbol(T, Decl(nestedComposition.ts, 2, 16)) + + next: Inner>; +>next : Symbol(Outer.next, Decl(nestedComposition.ts, 3, 13)) +>Inner : Symbol(Inner, Decl(nestedComposition.ts, 5, 1)) +>Outer : Symbol(Outer, Decl(nestedComposition.ts, 0, 10)) +>T : Symbol(T, Decl(nestedComposition.ts, 2, 16)) +} +interface Inner { +>Inner : Symbol(Inner, Decl(nestedComposition.ts, 5, 1)) +>T : Symbol(T, Decl(nestedComposition.ts, 6, 16)) + + consume: (value: T) => void; +>consume : Symbol(Inner.consume, Decl(nestedComposition.ts, 6, 20)) +>value : Symbol(value, Decl(nestedComposition.ts, 7, 14)) +>T : Symbol(T, Decl(nestedComposition.ts, 6, 16)) +} + +declare let strings: Outer; +>strings : Symbol(strings, Decl(nestedComposition.ts, 10, 11)) +>Outer : Symbol(Outer, Decl(nestedComposition.ts, 0, 10)) + +declare let unknowns: Outer; +>unknowns : Symbol(unknowns, Decl(nestedComposition.ts, 11, 11)) +>Outer : Symbol(Outer, Decl(nestedComposition.ts, 0, 10)) + +unknowns = strings; // Error +>unknowns : Symbol(unknowns, Decl(nestedComposition.ts, 11, 11)) +>strings : Symbol(strings, Decl(nestedComposition.ts, 10, 11)) + +strings = unknowns; // Error +>strings : Symbol(strings, Decl(nestedComposition.ts, 10, 11)) +>unknowns : Symbol(unknowns, Decl(nestedComposition.ts, 11, 11)) + +=== annotations.ts === +export {}; + +interface AnnotatedTree { +>AnnotatedTree : Symbol(AnnotatedTree, Decl(annotations.ts, 0, 10)) +>T : Symbol(T, Decl(annotations.ts, 2, 24)) + + readonly value: T; +>value : Symbol(AnnotatedTree.value, Decl(annotations.ts, 2, 32)) +>T : Symbol(T, Decl(annotations.ts, 2, 24)) + + readonly children: AnnotatedTree[]; +>children : Symbol(AnnotatedTree.children, Decl(annotations.ts, 3, 22)) +>AnnotatedTree : Symbol(AnnotatedTree, Decl(annotations.ts, 0, 10)) +>T : Symbol(T, Decl(annotations.ts, 2, 24)) +} +interface AnnotatedStore { +>AnnotatedStore : Symbol(AnnotatedStore, Decl(annotations.ts, 5, 1)) +>T : Symbol(T, Decl(annotations.ts, 6, 25)) + + value: T; +>value : Symbol(AnnotatedStore.value, Decl(annotations.ts, 6, 36)) +>T : Symbol(T, Decl(annotations.ts, 6, 25)) + + listener: (batch: AnnotatedStore) => void; +>listener : Symbol(AnnotatedStore.listener, Decl(annotations.ts, 7, 13)) +>batch : Symbol(batch, Decl(annotations.ts, 8, 15)) +>AnnotatedStore : Symbol(AnnotatedStore, Decl(annotations.ts, 5, 1)) +>T : Symbol(T, Decl(annotations.ts, 6, 25)) +} + +declare let stringTree: AnnotatedTree; +>stringTree : Symbol(stringTree, Decl(annotations.ts, 11, 11)) +>AnnotatedTree : Symbol(AnnotatedTree, Decl(annotations.ts, 0, 10)) + +declare let unknownTree: AnnotatedTree; +>unknownTree : Symbol(unknownTree, Decl(annotations.ts, 12, 11)) +>AnnotatedTree : Symbol(AnnotatedTree, Decl(annotations.ts, 0, 10)) + +declare let stringStore: AnnotatedStore; +>stringStore : Symbol(stringStore, Decl(annotations.ts, 13, 11)) +>AnnotatedStore : Symbol(AnnotatedStore, Decl(annotations.ts, 5, 1)) + +declare let unknownStore: AnnotatedStore; +>unknownStore : Symbol(unknownStore, Decl(annotations.ts, 14, 11)) +>AnnotatedStore : Symbol(AnnotatedStore, Decl(annotations.ts, 5, 1)) + +unknownTree = stringTree; +>unknownTree : Symbol(unknownTree, Decl(annotations.ts, 12, 11)) +>stringTree : Symbol(stringTree, Decl(annotations.ts, 11, 11)) + +stringTree = unknownTree; // Error +>stringTree : Symbol(stringTree, Decl(annotations.ts, 11, 11)) +>unknownTree : Symbol(unknownTree, Decl(annotations.ts, 12, 11)) + +unknownStore = stringStore; // Error +>unknownStore : Symbol(unknownStore, Decl(annotations.ts, 14, 11)) +>stringStore : Symbol(stringStore, Decl(annotations.ts, 13, 11)) + +stringStore = unknownStore; // Error +>stringStore : Symbol(stringStore, Decl(annotations.ts, 13, 11)) +>unknownStore : Symbol(unknownStore, Decl(annotations.ts, 14, 11)) + +=== structuralMeasurement.ts === +export {}; + +interface GenericMethod { +>GenericMethod : Symbol(GenericMethod, Decl(structuralMeasurement.ts, 0, 10)) +>T : Symbol(T, Decl(structuralMeasurement.ts, 2, 24)) + + value: T; +>value : Symbol(GenericMethod.value, Decl(structuralMeasurement.ts, 2, 28)) +>T : Symbol(T, Decl(structuralMeasurement.ts, 2, 24)) + + next: (value: U) => GenericMethod; +>next : Symbol(GenericMethod.next, Decl(structuralMeasurement.ts, 3, 13)) +>U : Symbol(U, Decl(structuralMeasurement.ts, 4, 11)) +>value : Symbol(value, Decl(structuralMeasurement.ts, 4, 14)) +>U : Symbol(U, Decl(structuralMeasurement.ts, 4, 11)) +>GenericMethod : Symbol(GenericMethod, Decl(structuralMeasurement.ts, 0, 10)) +>T : Symbol(T, Decl(structuralMeasurement.ts, 2, 24)) +} +interface Projected { +>Projected : Symbol(Projected, Decl(structuralMeasurement.ts, 5, 1)) +>T : Symbol(T, Decl(structuralMeasurement.ts, 6, 20)) +>value : Symbol(value, Decl(structuralMeasurement.ts, 6, 31)) + + value: T["value"]; +>value : Symbol(Projected.value, Decl(structuralMeasurement.ts, 6, 51)) +>T : Symbol(T, Decl(structuralMeasurement.ts, 6, 20)) + + next: Projected; +>next : Symbol(Projected.next, Decl(structuralMeasurement.ts, 7, 22)) +>Projected : Symbol(Projected, Decl(structuralMeasurement.ts, 5, 1)) +>T : Symbol(T, Decl(structuralMeasurement.ts, 6, 20)) +} +interface Method { +>Method : Symbol(Method, Decl(structuralMeasurement.ts, 9, 1)) +>T : Symbol(T, Decl(structuralMeasurement.ts, 10, 17)) + + value: T; +>value : Symbol(Method.value, Decl(structuralMeasurement.ts, 10, 21)) +>T : Symbol(T, Decl(structuralMeasurement.ts, 10, 17)) + + accept(value: Method): void; +>accept : Symbol(Method.accept, Decl(structuralMeasurement.ts, 11, 13)) +>value : Symbol(value, Decl(structuralMeasurement.ts, 12, 11)) +>Method : Symbol(Method, Decl(structuralMeasurement.ts, 9, 1)) +>T : Symbol(T, Decl(structuralMeasurement.ts, 10, 17)) +} + +declare let strings: GenericMethod; +>strings : Symbol(strings, Decl(structuralMeasurement.ts, 15, 11)) +>GenericMethod : Symbol(GenericMethod, Decl(structuralMeasurement.ts, 0, 10)) + +declare let unknowns: GenericMethod; +>unknowns : Symbol(unknowns, Decl(structuralMeasurement.ts, 16, 11)) +>GenericMethod : Symbol(GenericMethod, Decl(structuralMeasurement.ts, 0, 10)) + +declare let stringMethod: Method; +>stringMethod : Symbol(stringMethod, Decl(structuralMeasurement.ts, 17, 11)) +>Method : Symbol(Method, Decl(structuralMeasurement.ts, 9, 1)) + +declare let unknownMethod: Method; +>unknownMethod : Symbol(unknownMethod, Decl(structuralMeasurement.ts, 18, 11)) +>Method : Symbol(Method, Decl(structuralMeasurement.ts, 9, 1)) + +declare let projected: Projected<{ value: string; extra: number }>; +>projected : Symbol(projected, Decl(structuralMeasurement.ts, 19, 11)) +>Projected : Symbol(Projected, Decl(structuralMeasurement.ts, 5, 1)) +>value : Symbol(value, Decl(structuralMeasurement.ts, 19, 34)) +>extra : Symbol(extra, Decl(structuralMeasurement.ts, 19, 49)) + +unknowns = strings; +>unknowns : Symbol(unknowns, Decl(structuralMeasurement.ts, 16, 11)) +>strings : Symbol(strings, Decl(structuralMeasurement.ts, 15, 11)) + +strings = unknowns; // Error +>strings : Symbol(strings, Decl(structuralMeasurement.ts, 15, 11)) +>unknowns : Symbol(unknowns, Decl(structuralMeasurement.ts, 16, 11)) + +unknownMethod = stringMethod; +>unknownMethod : Symbol(unknownMethod, Decl(structuralMeasurement.ts, 18, 11)) +>stringMethod : Symbol(stringMethod, Decl(structuralMeasurement.ts, 17, 11)) + +const widened: Projected<{ value: string }> = projected; +>widened : Symbol(widened, Decl(structuralMeasurement.ts, 24, 5)) +>Projected : Symbol(Projected, Decl(structuralMeasurement.ts, 5, 1)) +>value : Symbol(value, Decl(structuralMeasurement.ts, 24, 26)) +>projected : Symbol(projected, Decl(structuralMeasurement.ts, 19, 11)) + diff --git a/tsc/testdata/baselines/reference/compiler/recursiveVarianceFixedPoint.types b/tsc/testdata/baselines/reference/compiler/recursiveVarianceFixedPoint.types new file mode 100644 index 0000000000000..e26d435575c06 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/recursiveVarianceFixedPoint.types @@ -0,0 +1,344 @@ +//// [tests/cases/compiler/recursiveVarianceFixedPoint.ts] //// + +=== storeFirst.ts === +export {}; + +interface Store { + value: T; +>value : T + + listener: Listener; +>listener : Listener +} +type Listener = (batch: Store) => void; +>Listener : Listener +>batch : Store + +declare let strings: Store; +>strings : Store + +declare let unknowns: Store; +>unknowns : Store + +declare let stringListener: Listener; +>stringListener : Listener + +declare let unknownListener: Listener; +>unknownListener : Listener + +unknowns = strings; // Error +>unknowns = strings : Store +>unknowns : Store +>strings : Store + +unknownListener = stringListener; // Error +>unknownListener = stringListener : Listener +>unknownListener : Listener +>stringListener : Listener + +=== listenerFirst.ts === +export {}; + +type Listener = (batch: Store) => void; +>Listener : Listener +>batch : Store + +interface Store { + listener: Listener; +>listener : Listener + + value: T; +>value : T +} + +declare let strings: Store; +>strings : Store + +declare let unknowns: Store; +>unknowns : Store + +declare let stringListener: Listener; +>stringListener : Listener + +declare let unknownListener: Listener; +>unknownListener : Listener + +unknownListener = stringListener; // Error +>unknownListener = stringListener : Listener +>unknownListener : Listener +>stringListener : Listener + +unknowns = strings; // Error +>unknowns = strings : Store +>unknowns : Store +>strings : Store + +=== columnDefFirst.ts === +export {}; + +interface ColumnDef { + cell?: (column: Column) => void; +>cell : ((column: Column) => void) | undefined +>column : Column +} +interface Column { + accessorFn?: (row: Row) => Value; +>accessorFn : ((row: Row) => Value) | undefined +>row : Row + + columnDef: ColumnDef; +>columnDef : ColumnDef +} + +declare let stringColumn: ColumnDef<{ name: string }, string>; +>stringColumn : ColumnDef<{ name: string; }, string> +>name : string + +declare let unknownColumn: ColumnDef<{ name: string }, unknown>; +>unknownColumn : ColumnDef<{ name: string; }, unknown> +>name : string + +unknownColumn = stringColumn; // Error +>unknownColumn = stringColumn : ColumnDef<{ name: string; }, string> +>unknownColumn : ColumnDef<{ name: string; }, unknown> +>stringColumn : ColumnDef<{ name: string; }, string> + +stringColumn = unknownColumn; // Error +>stringColumn = unknownColumn : ColumnDef<{ name: string; }, unknown> +>stringColumn : ColumnDef<{ name: string; }, string> +>unknownColumn : ColumnDef<{ name: string; }, unknown> + +=== columnFirst.ts === +export {}; + +interface Column { + columnDef: ColumnDef; +>columnDef : ColumnDef + + accessorFn?: (row: Row) => Value; +>accessorFn : ((row: Row) => Value) | undefined +>row : Row +} +interface ColumnDef { + cell?: (column: Column) => void; +>cell : ((column: Column) => void) | undefined +>column : Column +} + +declare let stringColumn: ColumnDef<{ name: string }, string>; +>stringColumn : ColumnDef<{ name: string; }, string> +>name : string + +declare let unknownColumn: ColumnDef<{ name: string }, unknown>; +>unknownColumn : ColumnDef<{ name: string; }, unknown> +>name : string + +unknownColumn = stringColumn; // Error +>unknownColumn = stringColumn : ColumnDef<{ name: string; }, string> +>unknownColumn : ColumnDef<{ name: string; }, unknown> +>stringColumn : ColumnDef<{ name: string; }, string> + +stringColumn = unknownColumn; // Error +>stringColumn = unknownColumn : ColumnDef<{ name: string; }, unknown> +>stringColumn : ColumnDef<{ name: string; }, string> +>unknownColumn : ColumnDef<{ name: string; }, unknown> + +=== positiveRecursion.ts === +export {}; + +interface Tree { + readonly value: T; +>value : T + + readonly children: readonly Tree[]; +>children : readonly Tree[] + + readonly metadata: Map; +>metadata : Map +} +interface Phantom { + next: Phantom; +>next : Phantom +} + +declare let stringTree: Tree; +>stringTree : Tree + +declare let unknownTree: Tree; +>unknownTree : Tree + +declare let stringPhantom: Phantom; +>stringPhantom : Phantom + +declare let numberPhantom: Phantom; +>numberPhantom : Phantom + +unknownTree = stringTree; +>unknownTree = stringTree : Tree +>unknownTree : Tree +>stringTree : Tree + +stringTree = unknownTree; // Error +>stringTree = unknownTree : Tree +>stringTree : Tree +>unknownTree : Tree + +stringPhantom = numberPhantom; +>stringPhantom = numberPhantom : Phantom +>stringPhantom : Phantom +>numberPhantom : Phantom + +numberPhantom = stringPhantom; +>numberPhantom = stringPhantom : Phantom +>numberPhantom : Phantom +>stringPhantom : Phantom + +=== nestedComposition.ts === +export {}; + +interface Outer { + value: T; +>value : T + + next: Inner>; +>next : Inner> +} +interface Inner { + consume: (value: T) => void; +>consume : (value: T) => void +>value : T +} + +declare let strings: Outer; +>strings : Outer + +declare let unknowns: Outer; +>unknowns : Outer + +unknowns = strings; // Error +>unknowns = strings : Outer +>unknowns : Outer +>strings : Outer + +strings = unknowns; // Error +>strings = unknowns : Outer +>strings : Outer +>unknowns : Outer + +=== annotations.ts === +export {}; + +interface AnnotatedTree { + readonly value: T; +>value : T + + readonly children: AnnotatedTree[]; +>children : AnnotatedTree[] +} +interface AnnotatedStore { + value: T; +>value : T + + listener: (batch: AnnotatedStore) => void; +>listener : (batch: AnnotatedStore) => void +>batch : AnnotatedStore +} + +declare let stringTree: AnnotatedTree; +>stringTree : AnnotatedTree + +declare let unknownTree: AnnotatedTree; +>unknownTree : AnnotatedTree + +declare let stringStore: AnnotatedStore; +>stringStore : AnnotatedStore + +declare let unknownStore: AnnotatedStore; +>unknownStore : AnnotatedStore + +unknownTree = stringTree; +>unknownTree = stringTree : AnnotatedTree +>unknownTree : AnnotatedTree +>stringTree : AnnotatedTree + +stringTree = unknownTree; // Error +>stringTree = unknownTree : AnnotatedTree +>stringTree : AnnotatedTree +>unknownTree : AnnotatedTree + +unknownStore = stringStore; // Error +>unknownStore = stringStore : AnnotatedStore +>unknownStore : AnnotatedStore +>stringStore : AnnotatedStore + +stringStore = unknownStore; // Error +>stringStore = unknownStore : AnnotatedStore +>stringStore : AnnotatedStore +>unknownStore : AnnotatedStore + +=== structuralMeasurement.ts === +export {}; + +interface GenericMethod { + value: T; +>value : T + + next: (value: U) => GenericMethod; +>next : (value: U) => GenericMethod +>value : U +} +interface Projected { +>value : unknown + + value: T["value"]; +>value : T["value"] + + next: Projected; +>next : Projected +} +interface Method { + value: T; +>value : T + + accept(value: Method): void; +>accept : (value: Method) => void +>value : Method +} + +declare let strings: GenericMethod; +>strings : GenericMethod + +declare let unknowns: GenericMethod; +>unknowns : GenericMethod + +declare let stringMethod: Method; +>stringMethod : Method + +declare let unknownMethod: Method; +>unknownMethod : Method + +declare let projected: Projected<{ value: string; extra: number }>; +>projected : Projected<{ value: string; extra: number; }> +>value : string +>extra : number + +unknowns = strings; +>unknowns = strings : GenericMethod +>unknowns : GenericMethod +>strings : GenericMethod + +strings = unknowns; // Error +>strings = unknowns : GenericMethod +>strings : GenericMethod +>unknowns : GenericMethod + +unknownMethod = stringMethod; +>unknownMethod = stringMethod : Method +>unknownMethod : Method +>stringMethod : Method + +const widened: Projected<{ value: string }> = projected; +>widened : Projected<{ value: string; }> +>value : string +>projected : Projected<{ value: string; extra: number; }> + diff --git a/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=default).errors.txt new file mode 100644 index 0000000000000..e8f947ec283b1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=default).errors.txt @@ -0,0 +1,50 @@ +relationComplexityError.ts(10,5): error TS2859: Excessive complexity comparing types '{ p: T1 & T2; }' and '{ p: T1 | null; }'. +relationComplexityError.ts(10,5): error TS2859: Excessive complexity comparing types '{ p: T1 & T2; }' and '{ p: T1 | null; }'. +relationComplexityError.ts(18,5): error TS2859: Excessive complexity comparing types 'T1 & T2' and 'T1 | null'. +relationComplexityError.ts(22,5): error TS2859: Excessive complexity comparing types 'T1 & T2' and 'T1 | null'. +relationComplexityError.ts(26,5): error TS2322: Type '{ p: T1 & T2; }' is not assignable to type '{ p: T1 | null; }'. + Types of property 'p' are incompatible. + Excessive complexity comparing types 'T1 & T2' and 'T1 | null'. + + +==== relationComplexityError.ts (5 errors) ==== + // Repro from #55630 + // Every comparison that needs a comparison that is too complex is too complex + // itself, whether or not that comparison happened before. + + type Digits = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7'; + type T1 = `${Digits}${Digits}${Digits}${Digits}` | undefined; + type T2 = { a: string } | { b: number }; + + function f0(x: { p: T1 | null }, y: { p: T1 & T2 }) { + x = y; // Complexity error + ~ +!!! error TS2859: Excessive complexity comparing types '{ p: T1 & T2; }' and '{ p: T1 | null; }'. + ~~~~~ +!!! error TS2859: Excessive complexity comparing types '{ p: T1 & T2; }' and '{ p: T1 | null; }'. + } + + function f1(x: T1, y: T1 & T2) { + x = y; + } + + function f2(x: T1 | null, y: T1 & T2) { + x = y; // Complexity error + ~ +!!! error TS2859: Excessive complexity comparing types 'T1 & T2' and 'T1 | null'. + } + + function f3(x: T1 | null, y: T1 & T2) { + x = y; // Complexity error + ~ +!!! error TS2859: Excessive complexity comparing types 'T1 & T2' and 'T1 | null'. + } + + function f4(x: { p: T1 | null }, y: { p: T1 & T2 }) { + x = y; // Complexity error + ~ +!!! error TS2322: Type '{ p: T1 & T2; }' is not assignable to type '{ p: T1 | null; }'. +!!! error TS2322: Types of property 'p' are incompatible. +!!! error TS2322: Excessive complexity comparing types 'T1 & T2' and 'T1 | null'. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=default).symbols new file mode 100644 index 0000000000000..ea9543f81e755 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=default).symbols @@ -0,0 +1,91 @@ +//// [tests/cases/compiler/relationComplexityError.ts] //// + +=== relationComplexityError.ts === +// Repro from #55630 +// Every comparison that needs a comparison that is too complex is too complex +// itself, whether or not that comparison happened before. + +type Digits = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7'; +>Digits : Symbol(Digits, Decl(relationComplexityError.ts, 0, 0)) + +type T1 = `${Digits}${Digits}${Digits}${Digits}` | undefined; +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>Digits : Symbol(Digits, Decl(relationComplexityError.ts, 0, 0)) +>Digits : Symbol(Digits, Decl(relationComplexityError.ts, 0, 0)) +>Digits : Symbol(Digits, Decl(relationComplexityError.ts, 0, 0)) +>Digits : Symbol(Digits, Decl(relationComplexityError.ts, 0, 0)) + +type T2 = { a: string } | { b: number }; +>T2 : Symbol(T2, Decl(relationComplexityError.ts, 5, 61)) +>a : Symbol(a, Decl(relationComplexityError.ts, 6, 11)) +>b : Symbol(b, Decl(relationComplexityError.ts, 6, 27)) + +function f0(x: { p: T1 | null }, y: { p: T1 & T2 }) { +>f0 : Symbol(f0, Decl(relationComplexityError.ts, 6, 40)) +>x : Symbol(x, Decl(relationComplexityError.ts, 8, 12)) +>p : Symbol(p, Decl(relationComplexityError.ts, 8, 16)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>y : Symbol(y, Decl(relationComplexityError.ts, 8, 32)) +>p : Symbol(p, Decl(relationComplexityError.ts, 8, 37)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>T2 : Symbol(T2, Decl(relationComplexityError.ts, 5, 61)) + + x = y; // Complexity error +>x : Symbol(x, Decl(relationComplexityError.ts, 8, 12)) +>y : Symbol(y, Decl(relationComplexityError.ts, 8, 32)) +} + +function f1(x: T1, y: T1 & T2) { +>f1 : Symbol(f1, Decl(relationComplexityError.ts, 10, 1)) +>x : Symbol(x, Decl(relationComplexityError.ts, 12, 12)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>y : Symbol(y, Decl(relationComplexityError.ts, 12, 18)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>T2 : Symbol(T2, Decl(relationComplexityError.ts, 5, 61)) + + x = y; +>x : Symbol(x, Decl(relationComplexityError.ts, 12, 12)) +>y : Symbol(y, Decl(relationComplexityError.ts, 12, 18)) +} + +function f2(x: T1 | null, y: T1 & T2) { +>f2 : Symbol(f2, Decl(relationComplexityError.ts, 14, 1)) +>x : Symbol(x, Decl(relationComplexityError.ts, 16, 12)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>y : Symbol(y, Decl(relationComplexityError.ts, 16, 25)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>T2 : Symbol(T2, Decl(relationComplexityError.ts, 5, 61)) + + x = y; // Complexity error +>x : Symbol(x, Decl(relationComplexityError.ts, 16, 12)) +>y : Symbol(y, Decl(relationComplexityError.ts, 16, 25)) +} + +function f3(x: T1 | null, y: T1 & T2) { +>f3 : Symbol(f3, Decl(relationComplexityError.ts, 18, 1)) +>x : Symbol(x, Decl(relationComplexityError.ts, 20, 12)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>y : Symbol(y, Decl(relationComplexityError.ts, 20, 25)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>T2 : Symbol(T2, Decl(relationComplexityError.ts, 5, 61)) + + x = y; // Complexity error +>x : Symbol(x, Decl(relationComplexityError.ts, 20, 12)) +>y : Symbol(y, Decl(relationComplexityError.ts, 20, 25)) +} + +function f4(x: { p: T1 | null }, y: { p: T1 & T2 }) { +>f4 : Symbol(f4, Decl(relationComplexityError.ts, 22, 1)) +>x : Symbol(x, Decl(relationComplexityError.ts, 24, 12)) +>p : Symbol(p, Decl(relationComplexityError.ts, 24, 16)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>y : Symbol(y, Decl(relationComplexityError.ts, 24, 32)) +>p : Symbol(p, Decl(relationComplexityError.ts, 24, 37)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>T2 : Symbol(T2, Decl(relationComplexityError.ts, 5, 61)) + + x = y; // Complexity error +>x : Symbol(x, Decl(relationComplexityError.ts, 24, 12)) +>y : Symbol(y, Decl(relationComplexityError.ts, 24, 32)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=default).types new file mode 100644 index 0000000000000..a6085a90e7675 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=default).types @@ -0,0 +1,77 @@ +//// [tests/cases/compiler/relationComplexityError.ts] //// + +=== relationComplexityError.ts === +// Repro from #55630 +// Every comparison that needs a comparison that is too complex is too complex +// itself, whether or not that comparison happened before. + +type Digits = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7'; +>Digits : Digits + +type T1 = `${Digits}${Digits}${Digits}${Digits}` | undefined; +>T1 : T1 + +type T2 = { a: string } | { b: number }; +>T2 : T2 +>a : string +>b : number + +function f0(x: { p: T1 | null }, y: { p: T1 & T2 }) { +>f0 : (x: { p: T1 | null; }, y: { p: T1 & T2; }) => void +>x : { p: T1 | null; } +>p : T1 | null +>y : { p: T1 & T2; } +>p : T1 & T2 + + x = y; // Complexity error +>x = y : { p: T1 & T2; } +>x : { p: T1 | null; } +>y : { p: T1 & T2; } +} + +function f1(x: T1, y: T1 & T2) { +>f1 : (x: T1, y: T1 & T2) => void +>x : T1 +>y : T1 & T2 + + x = y; +>x = y : T1 & T2 +>x : T1 +>y : T1 & T2 +} + +function f2(x: T1 | null, y: T1 & T2) { +>f2 : (x: T1 | null, y: T1 & T2) => void +>x : T1 | null +>y : T1 & T2 + + x = y; // Complexity error +>x = y : T1 & T2 +>x : T1 | null +>y : T1 & T2 +} + +function f3(x: T1 | null, y: T1 & T2) { +>f3 : (x: T1 | null, y: T1 & T2) => void +>x : T1 | null +>y : T1 & T2 + + x = y; // Complexity error +>x = y : T1 & T2 +>x : T1 | null +>y : T1 & T2 +} + +function f4(x: { p: T1 | null }, y: { p: T1 & T2 }) { +>f4 : (x: { p: T1 | null; }, y: { p: T1 & T2; }) => void +>x : { p: T1 | null; } +>p : T1 | null +>y : { p: T1 & T2; } +>p : T1 & T2 + + x = y; // Complexity error +>x = y : { p: T1 & T2; } +>x : { p: T1 | null; } +>y : { p: T1 & T2; } +} + diff --git a/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..8a92179def8a5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=typesfirst).errors.txt @@ -0,0 +1,50 @@ +relationComplexityError.ts(10,5): error TS2322: Type '{ p: T1 & T2; }' is not assignable to type '{ p: T1 | null; }'. + Types of property 'p' are incompatible. + Excessive complexity comparing types 'T1 & T2' and 'T1 | null'. +relationComplexityError.ts(18,5): error TS2859: Excessive complexity comparing types 'T1 & T2' and 'T1 | null'. +relationComplexityError.ts(22,5): error TS2859: Excessive complexity comparing types 'T1 & T2' and 'T1 | null'. +relationComplexityError.ts(26,5): error TS2859: Excessive complexity comparing types '{ p: T1 & T2; }' and '{ p: T1 | null; }'. +relationComplexityError.ts(26,5): error TS2859: Excessive complexity comparing types '{ p: T1 & T2; }' and '{ p: T1 | null; }'. + + +==== relationComplexityError.ts (5 errors) ==== + // Repro from #55630 + // Every comparison that needs a comparison that is too complex is too complex + // itself, whether or not that comparison happened before. + + type Digits = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7'; + type T1 = `${Digits}${Digits}${Digits}${Digits}` | undefined; + type T2 = { a: string } | { b: number }; + + function f0(x: { p: T1 | null }, y: { p: T1 & T2 }) { + x = y; // Complexity error + ~ +!!! error TS2322: Type '{ p: T1 & T2; }' is not assignable to type '{ p: T1 | null; }'. +!!! error TS2322: Types of property 'p' are incompatible. +!!! error TS2322: Excessive complexity comparing types 'T1 & T2' and 'T1 | null'. + } + + function f1(x: T1, y: T1 & T2) { + x = y; + } + + function f2(x: T1 | null, y: T1 & T2) { + x = y; // Complexity error + ~ +!!! error TS2859: Excessive complexity comparing types 'T1 & T2' and 'T1 | null'. + } + + function f3(x: T1 | null, y: T1 & T2) { + x = y; // Complexity error + ~ +!!! error TS2859: Excessive complexity comparing types 'T1 & T2' and 'T1 | null'. + } + + function f4(x: { p: T1 | null }, y: { p: T1 & T2 }) { + x = y; // Complexity error + ~ +!!! error TS2859: Excessive complexity comparing types '{ p: T1 & T2; }' and '{ p: T1 | null; }'. + ~~~~~ +!!! error TS2859: Excessive complexity comparing types '{ p: T1 & T2; }' and '{ p: T1 | null; }'. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..ea9543f81e755 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=typesfirst).symbols @@ -0,0 +1,91 @@ +//// [tests/cases/compiler/relationComplexityError.ts] //// + +=== relationComplexityError.ts === +// Repro from #55630 +// Every comparison that needs a comparison that is too complex is too complex +// itself, whether or not that comparison happened before. + +type Digits = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7'; +>Digits : Symbol(Digits, Decl(relationComplexityError.ts, 0, 0)) + +type T1 = `${Digits}${Digits}${Digits}${Digits}` | undefined; +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>Digits : Symbol(Digits, Decl(relationComplexityError.ts, 0, 0)) +>Digits : Symbol(Digits, Decl(relationComplexityError.ts, 0, 0)) +>Digits : Symbol(Digits, Decl(relationComplexityError.ts, 0, 0)) +>Digits : Symbol(Digits, Decl(relationComplexityError.ts, 0, 0)) + +type T2 = { a: string } | { b: number }; +>T2 : Symbol(T2, Decl(relationComplexityError.ts, 5, 61)) +>a : Symbol(a, Decl(relationComplexityError.ts, 6, 11)) +>b : Symbol(b, Decl(relationComplexityError.ts, 6, 27)) + +function f0(x: { p: T1 | null }, y: { p: T1 & T2 }) { +>f0 : Symbol(f0, Decl(relationComplexityError.ts, 6, 40)) +>x : Symbol(x, Decl(relationComplexityError.ts, 8, 12)) +>p : Symbol(p, Decl(relationComplexityError.ts, 8, 16)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>y : Symbol(y, Decl(relationComplexityError.ts, 8, 32)) +>p : Symbol(p, Decl(relationComplexityError.ts, 8, 37)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>T2 : Symbol(T2, Decl(relationComplexityError.ts, 5, 61)) + + x = y; // Complexity error +>x : Symbol(x, Decl(relationComplexityError.ts, 8, 12)) +>y : Symbol(y, Decl(relationComplexityError.ts, 8, 32)) +} + +function f1(x: T1, y: T1 & T2) { +>f1 : Symbol(f1, Decl(relationComplexityError.ts, 10, 1)) +>x : Symbol(x, Decl(relationComplexityError.ts, 12, 12)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>y : Symbol(y, Decl(relationComplexityError.ts, 12, 18)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>T2 : Symbol(T2, Decl(relationComplexityError.ts, 5, 61)) + + x = y; +>x : Symbol(x, Decl(relationComplexityError.ts, 12, 12)) +>y : Symbol(y, Decl(relationComplexityError.ts, 12, 18)) +} + +function f2(x: T1 | null, y: T1 & T2) { +>f2 : Symbol(f2, Decl(relationComplexityError.ts, 14, 1)) +>x : Symbol(x, Decl(relationComplexityError.ts, 16, 12)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>y : Symbol(y, Decl(relationComplexityError.ts, 16, 25)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>T2 : Symbol(T2, Decl(relationComplexityError.ts, 5, 61)) + + x = y; // Complexity error +>x : Symbol(x, Decl(relationComplexityError.ts, 16, 12)) +>y : Symbol(y, Decl(relationComplexityError.ts, 16, 25)) +} + +function f3(x: T1 | null, y: T1 & T2) { +>f3 : Symbol(f3, Decl(relationComplexityError.ts, 18, 1)) +>x : Symbol(x, Decl(relationComplexityError.ts, 20, 12)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>y : Symbol(y, Decl(relationComplexityError.ts, 20, 25)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>T2 : Symbol(T2, Decl(relationComplexityError.ts, 5, 61)) + + x = y; // Complexity error +>x : Symbol(x, Decl(relationComplexityError.ts, 20, 12)) +>y : Symbol(y, Decl(relationComplexityError.ts, 20, 25)) +} + +function f4(x: { p: T1 | null }, y: { p: T1 & T2 }) { +>f4 : Symbol(f4, Decl(relationComplexityError.ts, 22, 1)) +>x : Symbol(x, Decl(relationComplexityError.ts, 24, 12)) +>p : Symbol(p, Decl(relationComplexityError.ts, 24, 16)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>y : Symbol(y, Decl(relationComplexityError.ts, 24, 32)) +>p : Symbol(p, Decl(relationComplexityError.ts, 24, 37)) +>T1 : Symbol(T1, Decl(relationComplexityError.ts, 4, 60)) +>T2 : Symbol(T2, Decl(relationComplexityError.ts, 5, 61)) + + x = y; // Complexity error +>x : Symbol(x, Decl(relationComplexityError.ts, 24, 12)) +>y : Symbol(y, Decl(relationComplexityError.ts, 24, 32)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=typesfirst).types new file mode 100644 index 0000000000000..a6085a90e7675 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationComplexityError(checkorder=typesfirst).types @@ -0,0 +1,77 @@ +//// [tests/cases/compiler/relationComplexityError.ts] //// + +=== relationComplexityError.ts === +// Repro from #55630 +// Every comparison that needs a comparison that is too complex is too complex +// itself, whether or not that comparison happened before. + +type Digits = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7'; +>Digits : Digits + +type T1 = `${Digits}${Digits}${Digits}${Digits}` | undefined; +>T1 : T1 + +type T2 = { a: string } | { b: number }; +>T2 : T2 +>a : string +>b : number + +function f0(x: { p: T1 | null }, y: { p: T1 & T2 }) { +>f0 : (x: { p: T1 | null; }, y: { p: T1 & T2; }) => void +>x : { p: T1 | null; } +>p : T1 | null +>y : { p: T1 & T2; } +>p : T1 & T2 + + x = y; // Complexity error +>x = y : { p: T1 & T2; } +>x : { p: T1 | null; } +>y : { p: T1 & T2; } +} + +function f1(x: T1, y: T1 & T2) { +>f1 : (x: T1, y: T1 & T2) => void +>x : T1 +>y : T1 & T2 + + x = y; +>x = y : T1 & T2 +>x : T1 +>y : T1 & T2 +} + +function f2(x: T1 | null, y: T1 & T2) { +>f2 : (x: T1 | null, y: T1 & T2) => void +>x : T1 | null +>y : T1 & T2 + + x = y; // Complexity error +>x = y : T1 & T2 +>x : T1 | null +>y : T1 & T2 +} + +function f3(x: T1 | null, y: T1 & T2) { +>f3 : (x: T1 | null, y: T1 & T2) => void +>x : T1 | null +>y : T1 & T2 + + x = y; // Complexity error +>x = y : T1 & T2 +>x : T1 | null +>y : T1 & T2 +} + +function f4(x: { p: T1 | null }, y: { p: T1 & T2 }) { +>f4 : (x: { p: T1 | null; }, y: { p: T1 & T2; }) => void +>x : { p: T1 | null; } +>p : T1 | null +>y : { p: T1 & T2; } +>p : T1 & T2 + + x = y; // Complexity error +>x = y : { p: T1 & T2; } +>x : { p: T1 | null; } +>y : { p: T1 & T2; } +} + diff --git a/tsc/testdata/baselines/reference/compiler/relationDeeplyNestedCheckOrder.symbols b/tsc/testdata/baselines/reference/compiler/relationDeeplyNestedCheckOrder.symbols new file mode 100644 index 0000000000000..cdf23cc04d684 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationDeeplyNestedCheckOrder.symbols @@ -0,0 +1,54 @@ +//// [tests/cases/compiler/relationDeeplyNestedCheckOrder.ts] //// + +=== relationDeeplyNestedCheckOrder.ts === +// Relating 'B<{ a: string }>' to 'B<{ a: "lit" }>' eventually relates 'string' +// to '"lit"' through 'm0.m1.a.m0.m1', but only after measuring the variances +// of 'A', which gives up on deeply nested types. TypeScript reports an error +// for the 'B' assignment only when it is checked before the 'A' assignment; +// the result must not depend on which is checked first. + +type A = { m0: (x: B) => void; m1: { [K in keyof T]: B } }; +>A : Symbol(A, Decl(relationDeeplyNestedCheckOrder.ts, 0, 0)) +>T : Symbol(T, Decl(relationDeeplyNestedCheckOrder.ts, 6, 7)) +>m0 : Symbol(m0, Decl(relationDeeplyNestedCheckOrder.ts, 6, 13)) +>x : Symbol(x, Decl(relationDeeplyNestedCheckOrder.ts, 6, 19)) +>B : Symbol(B, Decl(relationDeeplyNestedCheckOrder.ts, 6, 71)) +>T : Symbol(T, Decl(relationDeeplyNestedCheckOrder.ts, 6, 7)) +>m1 : Symbol(m1, Decl(relationDeeplyNestedCheckOrder.ts, 6, 36)) +>K : Symbol(K, Decl(relationDeeplyNestedCheckOrder.ts, 6, 44)) +>T : Symbol(T, Decl(relationDeeplyNestedCheckOrder.ts, 6, 7)) +>B : Symbol(B, Decl(relationDeeplyNestedCheckOrder.ts, 6, 71)) +>T : Symbol(T, Decl(relationDeeplyNestedCheckOrder.ts, 6, 7)) +>K : Symbol(K, Decl(relationDeeplyNestedCheckOrder.ts, 6, 44)) + +type B = { m0: A }; +>B : Symbol(B, Decl(relationDeeplyNestedCheckOrder.ts, 6, 71)) +>T : Symbol(T, Decl(relationDeeplyNestedCheckOrder.ts, 7, 7)) +>m0 : Symbol(m0, Decl(relationDeeplyNestedCheckOrder.ts, 7, 13)) +>A : Symbol(A, Decl(relationDeeplyNestedCheckOrder.ts, 0, 0)) +>T : Symbol(T, Decl(relationDeeplyNestedCheckOrder.ts, 7, 7)) + +declare let a1: A<{ a: string }>, a2: A<{ a: "lit" }>; +>a1 : Symbol(a1, Decl(relationDeeplyNestedCheckOrder.ts, 9, 11)) +>A : Symbol(A, Decl(relationDeeplyNestedCheckOrder.ts, 0, 0)) +>a : Symbol(a, Decl(relationDeeplyNestedCheckOrder.ts, 9, 19)) +>a2 : Symbol(a2, Decl(relationDeeplyNestedCheckOrder.ts, 9, 33)) +>A : Symbol(A, Decl(relationDeeplyNestedCheckOrder.ts, 0, 0)) +>a : Symbol(a, Decl(relationDeeplyNestedCheckOrder.ts, 9, 41)) + +declare let b1: B<{ a: string }>, b2: B<{ a: "lit" }>; +>b1 : Symbol(b1, Decl(relationDeeplyNestedCheckOrder.ts, 10, 11)) +>B : Symbol(B, Decl(relationDeeplyNestedCheckOrder.ts, 6, 71)) +>a : Symbol(a, Decl(relationDeeplyNestedCheckOrder.ts, 10, 19)) +>b2 : Symbol(b2, Decl(relationDeeplyNestedCheckOrder.ts, 10, 33)) +>B : Symbol(B, Decl(relationDeeplyNestedCheckOrder.ts, 6, 71)) +>a : Symbol(a, Decl(relationDeeplyNestedCheckOrder.ts, 10, 41)) + +a2 = a1; +>a2 : Symbol(a2, Decl(relationDeeplyNestedCheckOrder.ts, 9, 33)) +>a1 : Symbol(a1, Decl(relationDeeplyNestedCheckOrder.ts, 9, 11)) + +b2 = b1; +>b2 : Symbol(b2, Decl(relationDeeplyNestedCheckOrder.ts, 10, 33)) +>b1 : Symbol(b1, Decl(relationDeeplyNestedCheckOrder.ts, 10, 11)) + diff --git a/tsc/testdata/baselines/reference/compiler/relationDeeplyNestedCheckOrder.types b/tsc/testdata/baselines/reference/compiler/relationDeeplyNestedCheckOrder.types new file mode 100644 index 0000000000000..fedd3a84c64f9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationDeeplyNestedCheckOrder.types @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/relationDeeplyNestedCheckOrder.ts] //// + +=== relationDeeplyNestedCheckOrder.ts === +// Relating 'B<{ a: string }>' to 'B<{ a: "lit" }>' eventually relates 'string' +// to '"lit"' through 'm0.m1.a.m0.m1', but only after measuring the variances +// of 'A', which gives up on deeply nested types. TypeScript reports an error +// for the 'B' assignment only when it is checked before the 'A' assignment; +// the result must not depend on which is checked first. + +type A = { m0: (x: B) => void; m1: { [K in keyof T]: B } }; +>A : A +>m0 : (x: B) => void +>x : B +>m1 : { [K in keyof T]: B; } + +type B = { m0: A }; +>B : B +>m0 : A + +declare let a1: A<{ a: string }>, a2: A<{ a: "lit" }>; +>a1 : A<{ a: string; }> +>a : string +>a2 : A<{ a: "lit"; }> +>a : "lit" + +declare let b1: B<{ a: string }>, b2: B<{ a: "lit" }>; +>b1 : B<{ a: string; }> +>a : string +>b2 : B<{ a: "lit"; }> +>a : "lit" + +a2 = a1; +>a2 = a1 : A<{ a: string; }> +>a2 : A<{ a: "lit"; }> +>a1 : A<{ a: string; }> + +b2 = b1; +>b2 = b1 : B<{ a: string; }> +>b2 : B<{ a: "lit"; }> +>b1 : B<{ a: string; }> + diff --git a/tsc/testdata/baselines/reference/compiler/relationMaybeCheckOrder.errors.txt b/tsc/testdata/baselines/reference/compiler/relationMaybeCheckOrder.errors.txt new file mode 100644 index 0000000000000..88dee4e5a8f7e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationMaybeCheckOrder.errors.txt @@ -0,0 +1,31 @@ +relationMaybeCheckOrder.ts(8,32): error TS2322: Type 'B' is not assignable to type 'string | number | symbol'. +relationMaybeCheckOrder.ts(18,11): error TS2322: Type '2' is not assignable to type '1'. + + +==== relationMaybeCheckOrder.ts (2 errors) ==== + // Relating to 'keyof M' rejects keys that relate only by assuming a + // comparison still in progress. Relating 'A' to 'B' assumes only itself + // along 'next', so it completes on its own and must be accepted whether + // or not the call to 'h' related 'A' to 'B' first. + + interface A { next: A; v: "a" } + interface B { next: B; v: string } + type M = { [K in keyof T as B]: 1 }; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'string | number | symbol'. + + declare const a: A; + declare function h(x: B): 1; + declare function h(x: unknown): 2; + + function f() { + function g(x: keyof M): 1; + function g(x: unknown): 2; + function g(x: unknown) { return 1 as any; } + const r: 1 = g(a); + ~ +!!! error TS2322: Type '2' is not assignable to type '1'. + } + + const w: 1 = h(a); + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/relationMaybeCheckOrder.symbols b/tsc/testdata/baselines/reference/compiler/relationMaybeCheckOrder.symbols new file mode 100644 index 0000000000000..c577599a23c3c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationMaybeCheckOrder.symbols @@ -0,0 +1,69 @@ +//// [tests/cases/compiler/relationMaybeCheckOrder.ts] //// + +=== relationMaybeCheckOrder.ts === +// Relating to 'keyof M' rejects keys that relate only by assuming a +// comparison still in progress. Relating 'A' to 'B' assumes only itself +// along 'next', so it completes on its own and must be accepted whether +// or not the call to 'h' related 'A' to 'B' first. + +interface A { next: A; v: "a" } +>A : Symbol(A, Decl(relationMaybeCheckOrder.ts, 0, 0)) +>next : Symbol(A.next, Decl(relationMaybeCheckOrder.ts, 5, 13)) +>A : Symbol(A, Decl(relationMaybeCheckOrder.ts, 0, 0)) +>v : Symbol(A.v, Decl(relationMaybeCheckOrder.ts, 5, 22)) + +interface B { next: B; v: string } +>B : Symbol(B, Decl(relationMaybeCheckOrder.ts, 5, 31)) +>next : Symbol(B.next, Decl(relationMaybeCheckOrder.ts, 6, 13)) +>B : Symbol(B, Decl(relationMaybeCheckOrder.ts, 5, 31)) +>v : Symbol(B.v, Decl(relationMaybeCheckOrder.ts, 6, 22)) + +type M = { [K in keyof T as B]: 1 }; +>M : Symbol(M, Decl(relationMaybeCheckOrder.ts, 6, 34)) +>T : Symbol(T, Decl(relationMaybeCheckOrder.ts, 7, 7)) +>K : Symbol(K, Decl(relationMaybeCheckOrder.ts, 7, 15)) +>T : Symbol(T, Decl(relationMaybeCheckOrder.ts, 7, 7)) +>B : Symbol(B, Decl(relationMaybeCheckOrder.ts, 5, 31)) + +declare const a: A; +>a : Symbol(a, Decl(relationMaybeCheckOrder.ts, 9, 13)) +>A : Symbol(A, Decl(relationMaybeCheckOrder.ts, 0, 0)) + +declare function h(x: B): 1; +>h : Symbol(h, Decl(relationMaybeCheckOrder.ts, 9, 19), Decl(relationMaybeCheckOrder.ts, 10, 28)) +>x : Symbol(x, Decl(relationMaybeCheckOrder.ts, 10, 19)) +>B : Symbol(B, Decl(relationMaybeCheckOrder.ts, 5, 31)) + +declare function h(x: unknown): 2; +>h : Symbol(h, Decl(relationMaybeCheckOrder.ts, 9, 19), Decl(relationMaybeCheckOrder.ts, 10, 28)) +>x : Symbol(x, Decl(relationMaybeCheckOrder.ts, 11, 19)) + +function f() { +>f : Symbol(f, Decl(relationMaybeCheckOrder.ts, 11, 34)) +>T : Symbol(T, Decl(relationMaybeCheckOrder.ts, 13, 11)) + + function g(x: keyof M): 1; +>g : Symbol(g, Decl(relationMaybeCheckOrder.ts, 13, 17), Decl(relationMaybeCheckOrder.ts, 14, 33), Decl(relationMaybeCheckOrder.ts, 15, 30)) +>x : Symbol(x, Decl(relationMaybeCheckOrder.ts, 14, 15)) +>M : Symbol(M, Decl(relationMaybeCheckOrder.ts, 6, 34)) +>T : Symbol(T, Decl(relationMaybeCheckOrder.ts, 13, 11)) + + function g(x: unknown): 2; +>g : Symbol(g, Decl(relationMaybeCheckOrder.ts, 13, 17), Decl(relationMaybeCheckOrder.ts, 14, 33), Decl(relationMaybeCheckOrder.ts, 15, 30)) +>x : Symbol(x, Decl(relationMaybeCheckOrder.ts, 15, 15)) + + function g(x: unknown) { return 1 as any; } +>g : Symbol(g, Decl(relationMaybeCheckOrder.ts, 13, 17), Decl(relationMaybeCheckOrder.ts, 14, 33), Decl(relationMaybeCheckOrder.ts, 15, 30)) +>x : Symbol(x, Decl(relationMaybeCheckOrder.ts, 16, 15)) + + const r: 1 = g(a); +>r : Symbol(r, Decl(relationMaybeCheckOrder.ts, 17, 9)) +>g : Symbol(g, Decl(relationMaybeCheckOrder.ts, 13, 17), Decl(relationMaybeCheckOrder.ts, 14, 33), Decl(relationMaybeCheckOrder.ts, 15, 30)) +>a : Symbol(a, Decl(relationMaybeCheckOrder.ts, 9, 13)) +} + +const w: 1 = h(a); +>w : Symbol(w, Decl(relationMaybeCheckOrder.ts, 20, 5)) +>h : Symbol(h, Decl(relationMaybeCheckOrder.ts, 9, 19), Decl(relationMaybeCheckOrder.ts, 10, 28)) +>a : Symbol(a, Decl(relationMaybeCheckOrder.ts, 9, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/relationMaybeCheckOrder.types b/tsc/testdata/baselines/reference/compiler/relationMaybeCheckOrder.types new file mode 100644 index 0000000000000..ecbee15a795d4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationMaybeCheckOrder.types @@ -0,0 +1,60 @@ +//// [tests/cases/compiler/relationMaybeCheckOrder.ts] //// + +=== relationMaybeCheckOrder.ts === +// Relating to 'keyof M' rejects keys that relate only by assuming a +// comparison still in progress. Relating 'A' to 'B' assumes only itself +// along 'next', so it completes on its own and must be accepted whether +// or not the call to 'h' related 'A' to 'B' first. + +interface A { next: A; v: "a" } +>next : A +>v : "a" + +interface B { next: B; v: string } +>next : B +>v : string + +type M = { [K in keyof T as B]: 1 }; +>M : M + +declare const a: A; +>a : A + +declare function h(x: B): 1; +>h : { (x: B): 1; (x: unknown): 2; } +>x : B + +declare function h(x: unknown): 2; +>h : { (x: B): 1; (x: unknown): 2; } +>x : unknown + +function f() { +>f : () => void + + function g(x: keyof M): 1; +>g : { (x: keyof M): 1; (x: unknown): 2; } +>x : keyof M + + function g(x: unknown): 2; +>g : { (x: keyof M): 1; (x: unknown): 2; } +>x : unknown + + function g(x: unknown) { return 1 as any; } +>g : { (x: keyof M): 1; (x: unknown): 2; } +>x : unknown +>1 as any : any +>1 : 1 + + const r: 1 = g(a); +>r : 1 +>g(a) : 2 +>g : { (x: keyof M): 1; (x: unknown): 2; } +>a : A +} + +const w: 1 = h(a); +>w : 1 +>h(a) : 1 +>h : { (x: B): 1; (x: unknown): 2; } +>a : A + diff --git a/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=default).symbols new file mode 100644 index 0000000000000..1a917a7da7f9f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=default).symbols @@ -0,0 +1,48 @@ +//// [tests/cases/compiler/relationTruncatedCacheCheckOrder.ts] //// + +=== relationTruncatedCacheCheckOrder.ts === +// Relating 'S<[string]>' to 'R<[string]>' from scratch reaches 'next.leaf' +// before giving up on deeply nested types, and fails there. Inside the +// relation of 'S' to 'R' it is one level deeper and is cut +// short instead. That truncated result must not be cached, so the error for +// 'q = p' must be reported whether or not 'y = x' was checked first. + +type S = { next: S<[T]>; leaf: T extends [[unknown]] ? number : T }; +>S : Symbol(S, Decl(relationTruncatedCacheCheckOrder.ts, 0, 0)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 6, 7)) +>next : Symbol(next, Decl(relationTruncatedCacheCheckOrder.ts, 6, 13)) +>S : Symbol(S, Decl(relationTruncatedCacheCheckOrder.ts, 0, 0)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 6, 7)) +>leaf : Symbol(leaf, Decl(relationTruncatedCacheCheckOrder.ts, 6, 27)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 6, 7)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 6, 7)) + +type R = { next: R<[T]>; leaf: T }; +>R : Symbol(R, Decl(relationTruncatedCacheCheckOrder.ts, 6, 71)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 7, 7)) +>next : Symbol(next, Decl(relationTruncatedCacheCheckOrder.ts, 7, 13)) +>R : Symbol(R, Decl(relationTruncatedCacheCheckOrder.ts, 6, 71)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 7, 7)) +>leaf : Symbol(leaf, Decl(relationTruncatedCacheCheckOrder.ts, 7, 27)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 7, 7)) + +declare let x: S, y: R; +>x : Symbol(x, Decl(relationTruncatedCacheCheckOrder.ts, 9, 11)) +>S : Symbol(S, Decl(relationTruncatedCacheCheckOrder.ts, 0, 0)) +>y : Symbol(y, Decl(relationTruncatedCacheCheckOrder.ts, 9, 25)) +>R : Symbol(R, Decl(relationTruncatedCacheCheckOrder.ts, 6, 71)) + +declare let p: S<[string]>, q: R<[string]>; +>p : Symbol(p, Decl(relationTruncatedCacheCheckOrder.ts, 10, 11)) +>S : Symbol(S, Decl(relationTruncatedCacheCheckOrder.ts, 0, 0)) +>q : Symbol(q, Decl(relationTruncatedCacheCheckOrder.ts, 10, 27)) +>R : Symbol(R, Decl(relationTruncatedCacheCheckOrder.ts, 6, 71)) + +y = x; +>y : Symbol(y, Decl(relationTruncatedCacheCheckOrder.ts, 9, 25)) +>x : Symbol(x, Decl(relationTruncatedCacheCheckOrder.ts, 9, 11)) + +q = p; +>q : Symbol(q, Decl(relationTruncatedCacheCheckOrder.ts, 10, 27)) +>p : Symbol(p, Decl(relationTruncatedCacheCheckOrder.ts, 10, 11)) + diff --git a/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=default).types new file mode 100644 index 0000000000000..61db4cbc7e0c8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=default).types @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/relationTruncatedCacheCheckOrder.ts] //// + +=== relationTruncatedCacheCheckOrder.ts === +// Relating 'S<[string]>' to 'R<[string]>' from scratch reaches 'next.leaf' +// before giving up on deeply nested types, and fails there. Inside the +// relation of 'S' to 'R' it is one level deeper and is cut +// short instead. That truncated result must not be cached, so the error for +// 'q = p' must be reported whether or not 'y = x' was checked first. + +type S = { next: S<[T]>; leaf: T extends [[unknown]] ? number : T }; +>S : S +>next : S<[T]> +>leaf : T extends [[unknown]] ? number : T + +type R = { next: R<[T]>; leaf: T }; +>R : R +>next : R<[T]> +>leaf : T + +declare let x: S, y: R; +>x : S +>y : R + +declare let p: S<[string]>, q: R<[string]>; +>p : S<[string]> +>q : R<[string]> + +y = x; +>y = x : S +>y : R +>x : S + +q = p; +>q = p : S<[string]> +>q : R<[string]> +>p : S<[string]> + diff --git a/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..343f53694e8da --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=typesfirst).errors.txt @@ -0,0 +1,32 @@ +relationTruncatedCacheCheckOrder.ts(13,1): error TS2322: Type 'S' is not assignable to type 'R'. + The types of 'next.next.leaf' are incompatible between these types. + Type 'number' is not assignable to type '[[string]]'. +relationTruncatedCacheCheckOrder.ts(14,1): error TS2322: Type 'S<[string]>' is not assignable to type 'R<[string]>'. + The types of 'next.leaf' are incompatible between these types. + Type 'number' is not assignable to type '[[string]]'. + + +==== relationTruncatedCacheCheckOrder.ts (2 errors) ==== + // Relating 'S<[string]>' to 'R<[string]>' from scratch reaches 'next.leaf' + // before giving up on deeply nested types, and fails there. Inside the + // relation of 'S' to 'R' it is one level deeper and is cut + // short instead. That truncated result must not be cached, so the error for + // 'q = p' must be reported whether or not 'y = x' was checked first. + + type S = { next: S<[T]>; leaf: T extends [[unknown]] ? number : T }; + type R = { next: R<[T]>; leaf: T }; + + declare let x: S, y: R; + declare let p: S<[string]>, q: R<[string]>; + + y = x; + ~ +!!! error TS2322: Type 'S' is not assignable to type 'R'. +!!! error TS2322: The types of 'next.next.leaf' are incompatible between these types. +!!! error TS2322: Type 'number' is not assignable to type '[[string]]'. + q = p; + ~ +!!! error TS2322: Type 'S<[string]>' is not assignable to type 'R<[string]>'. +!!! error TS2322: The types of 'next.leaf' are incompatible between these types. +!!! error TS2322: Type 'number' is not assignable to type '[[string]]'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..1a917a7da7f9f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=typesfirst).symbols @@ -0,0 +1,48 @@ +//// [tests/cases/compiler/relationTruncatedCacheCheckOrder.ts] //// + +=== relationTruncatedCacheCheckOrder.ts === +// Relating 'S<[string]>' to 'R<[string]>' from scratch reaches 'next.leaf' +// before giving up on deeply nested types, and fails there. Inside the +// relation of 'S' to 'R' it is one level deeper and is cut +// short instead. That truncated result must not be cached, so the error for +// 'q = p' must be reported whether or not 'y = x' was checked first. + +type S = { next: S<[T]>; leaf: T extends [[unknown]] ? number : T }; +>S : Symbol(S, Decl(relationTruncatedCacheCheckOrder.ts, 0, 0)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 6, 7)) +>next : Symbol(next, Decl(relationTruncatedCacheCheckOrder.ts, 6, 13)) +>S : Symbol(S, Decl(relationTruncatedCacheCheckOrder.ts, 0, 0)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 6, 7)) +>leaf : Symbol(leaf, Decl(relationTruncatedCacheCheckOrder.ts, 6, 27)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 6, 7)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 6, 7)) + +type R = { next: R<[T]>; leaf: T }; +>R : Symbol(R, Decl(relationTruncatedCacheCheckOrder.ts, 6, 71)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 7, 7)) +>next : Symbol(next, Decl(relationTruncatedCacheCheckOrder.ts, 7, 13)) +>R : Symbol(R, Decl(relationTruncatedCacheCheckOrder.ts, 6, 71)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 7, 7)) +>leaf : Symbol(leaf, Decl(relationTruncatedCacheCheckOrder.ts, 7, 27)) +>T : Symbol(T, Decl(relationTruncatedCacheCheckOrder.ts, 7, 7)) + +declare let x: S, y: R; +>x : Symbol(x, Decl(relationTruncatedCacheCheckOrder.ts, 9, 11)) +>S : Symbol(S, Decl(relationTruncatedCacheCheckOrder.ts, 0, 0)) +>y : Symbol(y, Decl(relationTruncatedCacheCheckOrder.ts, 9, 25)) +>R : Symbol(R, Decl(relationTruncatedCacheCheckOrder.ts, 6, 71)) + +declare let p: S<[string]>, q: R<[string]>; +>p : Symbol(p, Decl(relationTruncatedCacheCheckOrder.ts, 10, 11)) +>S : Symbol(S, Decl(relationTruncatedCacheCheckOrder.ts, 0, 0)) +>q : Symbol(q, Decl(relationTruncatedCacheCheckOrder.ts, 10, 27)) +>R : Symbol(R, Decl(relationTruncatedCacheCheckOrder.ts, 6, 71)) + +y = x; +>y : Symbol(y, Decl(relationTruncatedCacheCheckOrder.ts, 9, 25)) +>x : Symbol(x, Decl(relationTruncatedCacheCheckOrder.ts, 9, 11)) + +q = p; +>q : Symbol(q, Decl(relationTruncatedCacheCheckOrder.ts, 10, 27)) +>p : Symbol(p, Decl(relationTruncatedCacheCheckOrder.ts, 10, 11)) + diff --git a/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=typesfirst).types new file mode 100644 index 0000000000000..61db4cbc7e0c8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/relationTruncatedCacheCheckOrder(checkorder=typesfirst).types @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/relationTruncatedCacheCheckOrder.ts] //// + +=== relationTruncatedCacheCheckOrder.ts === +// Relating 'S<[string]>' to 'R<[string]>' from scratch reaches 'next.leaf' +// before giving up on deeply nested types, and fails there. Inside the +// relation of 'S' to 'R' it is one level deeper and is cut +// short instead. That truncated result must not be cached, so the error for +// 'q = p' must be reported whether or not 'y = x' was checked first. + +type S = { next: S<[T]>; leaf: T extends [[unknown]] ? number : T }; +>S : S +>next : S<[T]> +>leaf : T extends [[unknown]] ? number : T + +type R = { next: R<[T]>; leaf: T }; +>R : R +>next : R<[T]> +>leaf : T + +declare let x: S, y: R; +>x : S +>y : R + +declare let p: S<[string]>, q: R<[string]>; +>p : S<[string]> +>q : R<[string]> + +y = x; +>y = x : S +>y : R +>x : S + +q = p; +>q = p : S<[string]> +>q : R<[string]> +>p : S<[string]> + diff --git a/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=default).js new file mode 100644 index 0000000000000..90085dfe2092f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=default).js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/returnTypeInferenceNotTooBroad.ts] //// + +//// [returnTypeInferenceNotTooBroad.ts] +type Signs = { kind: 'a'; a: 3; } | { kind: 'b'; b: 2; } | { kind: 'c'; c: 1; }; +interface Opts { + low?: number; + sign?: T +} +interface Wrapper { +} +declare function sepsis(opts: Opts): Wrapper; +declare function unwrap(w: Wrapper): T; +export const y = sepsis({ low: 1, sign: { kind: 'a', a: 3 }}); +// $ExpectType { kind: "a"; a: 3; } +export const yun = unwrap(y); +// $ExpectType { kind: "a"; a: 3; } +export const yone = unwrap(sepsis({ low: 1, sign: { kind: 'a', a: 3 }})); + +//// [returnTypeInferenceNotTooBroad.js] +export const y = sepsis({ low: 1, sign: { kind: 'a', a: 3 } }); +// $ExpectType { kind: "a"; a: 3; } +export const yun = unwrap(y); +// $ExpectType { kind: "a"; a: 3; } +export const yone = unwrap(sepsis({ low: 1, sign: { kind: 'a', a: 3 } })); diff --git a/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=default).symbols new file mode 100644 index 0000000000000..ad8e148932bab --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=default).symbols @@ -0,0 +1,69 @@ +//// [tests/cases/compiler/returnTypeInferenceNotTooBroad.ts] //// + +=== returnTypeInferenceNotTooBroad.ts === +type Signs = { kind: 'a'; a: 3; } | { kind: 'b'; b: 2; } | { kind: 'c'; c: 1; }; +>Signs : Symbol(Signs, Decl(returnTypeInferenceNotTooBroad.ts, 0, 0)) +>kind : Symbol(kind, Decl(returnTypeInferenceNotTooBroad.ts, 0, 14)) +>a : Symbol(a, Decl(returnTypeInferenceNotTooBroad.ts, 0, 25)) +>kind : Symbol(kind, Decl(returnTypeInferenceNotTooBroad.ts, 0, 37)) +>b : Symbol(b, Decl(returnTypeInferenceNotTooBroad.ts, 0, 48)) +>kind : Symbol(kind, Decl(returnTypeInferenceNotTooBroad.ts, 0, 60)) +>c : Symbol(c, Decl(returnTypeInferenceNotTooBroad.ts, 0, 71)) + +interface Opts { +>Opts : Symbol(Opts, Decl(returnTypeInferenceNotTooBroad.ts, 0, 80)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 1, 15)) + + low?: number; +>low : Symbol(Opts.low, Decl(returnTypeInferenceNotTooBroad.ts, 1, 19)) + + sign?: T +>sign : Symbol(Opts.sign, Decl(returnTypeInferenceNotTooBroad.ts, 2, 17)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 1, 15)) +} +interface Wrapper { +>Wrapper : Symbol(Wrapper, Decl(returnTypeInferenceNotTooBroad.ts, 4, 1)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 5, 18)) +} +declare function sepsis(opts: Opts): Wrapper; +>sepsis : Symbol(sepsis, Decl(returnTypeInferenceNotTooBroad.ts, 6, 1)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 7, 24)) +>Signs : Symbol(Signs, Decl(returnTypeInferenceNotTooBroad.ts, 0, 0)) +>opts : Symbol(opts, Decl(returnTypeInferenceNotTooBroad.ts, 7, 41)) +>Opts : Symbol(Opts, Decl(returnTypeInferenceNotTooBroad.ts, 0, 80)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 7, 24)) +>Wrapper : Symbol(Wrapper, Decl(returnTypeInferenceNotTooBroad.ts, 4, 1)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 7, 24)) + +declare function unwrap(w: Wrapper): T; +>unwrap : Symbol(unwrap, Decl(returnTypeInferenceNotTooBroad.ts, 7, 68)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 8, 24)) +>w : Symbol(w, Decl(returnTypeInferenceNotTooBroad.ts, 8, 27)) +>Wrapper : Symbol(Wrapper, Decl(returnTypeInferenceNotTooBroad.ts, 4, 1)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 8, 24)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 8, 24)) + +export const y = sepsis({ low: 1, sign: { kind: 'a', a: 3 }}); +>y : Symbol(y, Decl(returnTypeInferenceNotTooBroad.ts, 9, 12)) +>sepsis : Symbol(sepsis, Decl(returnTypeInferenceNotTooBroad.ts, 6, 1)) +>low : Symbol(low, Decl(returnTypeInferenceNotTooBroad.ts, 9, 25)) +>sign : Symbol(sign, Decl(returnTypeInferenceNotTooBroad.ts, 9, 33)) +>kind : Symbol(kind, Decl(returnTypeInferenceNotTooBroad.ts, 9, 41)) +>a : Symbol(a, Decl(returnTypeInferenceNotTooBroad.ts, 9, 52)) + +// $ExpectType { kind: "a"; a: 3; } +export const yun = unwrap(y); +>yun : Symbol(yun, Decl(returnTypeInferenceNotTooBroad.ts, 11, 12)) +>unwrap : Symbol(unwrap, Decl(returnTypeInferenceNotTooBroad.ts, 7, 68)) +>y : Symbol(y, Decl(returnTypeInferenceNotTooBroad.ts, 9, 12)) + +// $ExpectType { kind: "a"; a: 3; } +export const yone = unwrap(sepsis({ low: 1, sign: { kind: 'a', a: 3 }})); +>yone : Symbol(yone, Decl(returnTypeInferenceNotTooBroad.ts, 13, 12)) +>unwrap : Symbol(unwrap, Decl(returnTypeInferenceNotTooBroad.ts, 7, 68)) +>sepsis : Symbol(sepsis, Decl(returnTypeInferenceNotTooBroad.ts, 6, 1)) +>low : Symbol(low, Decl(returnTypeInferenceNotTooBroad.ts, 13, 35)) +>sign : Symbol(sign, Decl(returnTypeInferenceNotTooBroad.ts, 13, 43)) +>kind : Symbol(kind, Decl(returnTypeInferenceNotTooBroad.ts, 13, 51)) +>a : Symbol(a, Decl(returnTypeInferenceNotTooBroad.ts, 13, 62)) + diff --git a/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=default).types new file mode 100644 index 0000000000000..94962df020556 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=default).types @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/returnTypeInferenceNotTooBroad.ts] //// + +=== returnTypeInferenceNotTooBroad.ts === +type Signs = { kind: 'a'; a: 3; } | { kind: 'b'; b: 2; } | { kind: 'c'; c: 1; }; +>Signs : Signs +>kind : "a" +>a : 3 +>kind : "b" +>b : 2 +>kind : "c" +>c : 1 + +interface Opts { + low?: number; +>low : number | undefined + + sign?: T +>sign : T | undefined +} +interface Wrapper { +} +declare function sepsis(opts: Opts): Wrapper; +>sepsis : (opts: Opts) => Wrapper +>opts : Opts + +declare function unwrap(w: Wrapper): T; +>unwrap : (w: Wrapper) => T +>w : Wrapper + +export const y = sepsis({ low: 1, sign: { kind: 'a', a: 3 }}); +>y : Wrapper<{ kind: "a"; a: 3; }> +>sepsis({ low: 1, sign: { kind: 'a', a: 3 }}) : Wrapper<{ kind: "a"; a: 3; }> +>sepsis : (opts: Opts) => Wrapper +>{ low: 1, sign: { kind: 'a', a: 3 }} : { low: number; sign: { kind: "a"; a: 3; }; } +>low : number +>1 : 1 +>sign : { kind: "a"; a: 3; } +>{ kind: 'a', a: 3 } : { kind: "a"; a: 3; } +>kind : "a" +>'a' : "a" +>a : 3 +>3 : 3 + +// $ExpectType { kind: "a"; a: 3; } +export const yun = unwrap(y); +>yun : { kind: "a"; a: 3; } +>unwrap(y) : { kind: "a"; a: 3; } +>unwrap : (w: Wrapper) => T +>y : Wrapper<{ kind: "a"; a: 3; }> + +// $ExpectType { kind: "a"; a: 3; } +export const yone = unwrap(sepsis({ low: 1, sign: { kind: 'a', a: 3 }})); +>yone : { kind: "a"; a: 3; } +>unwrap(sepsis({ low: 1, sign: { kind: 'a', a: 3 }})) : { kind: "a"; a: 3; } +>unwrap : (w: Wrapper) => T +>sepsis({ low: 1, sign: { kind: 'a', a: 3 }}) : Wrapper<{ kind: "a"; a: 3; }> +>sepsis : (opts: Opts) => Wrapper +>{ low: 1, sign: { kind: 'a', a: 3 }} : { low: number; sign: { kind: "a"; a: 3; }; } +>low : number +>1 : 1 +>sign : { kind: "a"; a: 3; } +>{ kind: 'a', a: 3 } : { kind: "a"; a: 3; } +>kind : "a" +>'a' : "a" +>a : 3 +>3 : 3 + diff --git a/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=typesfirst).js new file mode 100644 index 0000000000000..90085dfe2092f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=typesfirst).js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/returnTypeInferenceNotTooBroad.ts] //// + +//// [returnTypeInferenceNotTooBroad.ts] +type Signs = { kind: 'a'; a: 3; } | { kind: 'b'; b: 2; } | { kind: 'c'; c: 1; }; +interface Opts { + low?: number; + sign?: T +} +interface Wrapper { +} +declare function sepsis(opts: Opts): Wrapper; +declare function unwrap(w: Wrapper): T; +export const y = sepsis({ low: 1, sign: { kind: 'a', a: 3 }}); +// $ExpectType { kind: "a"; a: 3; } +export const yun = unwrap(y); +// $ExpectType { kind: "a"; a: 3; } +export const yone = unwrap(sepsis({ low: 1, sign: { kind: 'a', a: 3 }})); + +//// [returnTypeInferenceNotTooBroad.js] +export const y = sepsis({ low: 1, sign: { kind: 'a', a: 3 } }); +// $ExpectType { kind: "a"; a: 3; } +export const yun = unwrap(y); +// $ExpectType { kind: "a"; a: 3; } +export const yone = unwrap(sepsis({ low: 1, sign: { kind: 'a', a: 3 } })); diff --git a/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..ad8e148932bab --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=typesfirst).symbols @@ -0,0 +1,69 @@ +//// [tests/cases/compiler/returnTypeInferenceNotTooBroad.ts] //// + +=== returnTypeInferenceNotTooBroad.ts === +type Signs = { kind: 'a'; a: 3; } | { kind: 'b'; b: 2; } | { kind: 'c'; c: 1; }; +>Signs : Symbol(Signs, Decl(returnTypeInferenceNotTooBroad.ts, 0, 0)) +>kind : Symbol(kind, Decl(returnTypeInferenceNotTooBroad.ts, 0, 14)) +>a : Symbol(a, Decl(returnTypeInferenceNotTooBroad.ts, 0, 25)) +>kind : Symbol(kind, Decl(returnTypeInferenceNotTooBroad.ts, 0, 37)) +>b : Symbol(b, Decl(returnTypeInferenceNotTooBroad.ts, 0, 48)) +>kind : Symbol(kind, Decl(returnTypeInferenceNotTooBroad.ts, 0, 60)) +>c : Symbol(c, Decl(returnTypeInferenceNotTooBroad.ts, 0, 71)) + +interface Opts { +>Opts : Symbol(Opts, Decl(returnTypeInferenceNotTooBroad.ts, 0, 80)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 1, 15)) + + low?: number; +>low : Symbol(Opts.low, Decl(returnTypeInferenceNotTooBroad.ts, 1, 19)) + + sign?: T +>sign : Symbol(Opts.sign, Decl(returnTypeInferenceNotTooBroad.ts, 2, 17)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 1, 15)) +} +interface Wrapper { +>Wrapper : Symbol(Wrapper, Decl(returnTypeInferenceNotTooBroad.ts, 4, 1)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 5, 18)) +} +declare function sepsis(opts: Opts): Wrapper; +>sepsis : Symbol(sepsis, Decl(returnTypeInferenceNotTooBroad.ts, 6, 1)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 7, 24)) +>Signs : Symbol(Signs, Decl(returnTypeInferenceNotTooBroad.ts, 0, 0)) +>opts : Symbol(opts, Decl(returnTypeInferenceNotTooBroad.ts, 7, 41)) +>Opts : Symbol(Opts, Decl(returnTypeInferenceNotTooBroad.ts, 0, 80)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 7, 24)) +>Wrapper : Symbol(Wrapper, Decl(returnTypeInferenceNotTooBroad.ts, 4, 1)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 7, 24)) + +declare function unwrap(w: Wrapper): T; +>unwrap : Symbol(unwrap, Decl(returnTypeInferenceNotTooBroad.ts, 7, 68)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 8, 24)) +>w : Symbol(w, Decl(returnTypeInferenceNotTooBroad.ts, 8, 27)) +>Wrapper : Symbol(Wrapper, Decl(returnTypeInferenceNotTooBroad.ts, 4, 1)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 8, 24)) +>T : Symbol(T, Decl(returnTypeInferenceNotTooBroad.ts, 8, 24)) + +export const y = sepsis({ low: 1, sign: { kind: 'a', a: 3 }}); +>y : Symbol(y, Decl(returnTypeInferenceNotTooBroad.ts, 9, 12)) +>sepsis : Symbol(sepsis, Decl(returnTypeInferenceNotTooBroad.ts, 6, 1)) +>low : Symbol(low, Decl(returnTypeInferenceNotTooBroad.ts, 9, 25)) +>sign : Symbol(sign, Decl(returnTypeInferenceNotTooBroad.ts, 9, 33)) +>kind : Symbol(kind, Decl(returnTypeInferenceNotTooBroad.ts, 9, 41)) +>a : Symbol(a, Decl(returnTypeInferenceNotTooBroad.ts, 9, 52)) + +// $ExpectType { kind: "a"; a: 3; } +export const yun = unwrap(y); +>yun : Symbol(yun, Decl(returnTypeInferenceNotTooBroad.ts, 11, 12)) +>unwrap : Symbol(unwrap, Decl(returnTypeInferenceNotTooBroad.ts, 7, 68)) +>y : Symbol(y, Decl(returnTypeInferenceNotTooBroad.ts, 9, 12)) + +// $ExpectType { kind: "a"; a: 3; } +export const yone = unwrap(sepsis({ low: 1, sign: { kind: 'a', a: 3 }})); +>yone : Symbol(yone, Decl(returnTypeInferenceNotTooBroad.ts, 13, 12)) +>unwrap : Symbol(unwrap, Decl(returnTypeInferenceNotTooBroad.ts, 7, 68)) +>sepsis : Symbol(sepsis, Decl(returnTypeInferenceNotTooBroad.ts, 6, 1)) +>low : Symbol(low, Decl(returnTypeInferenceNotTooBroad.ts, 13, 35)) +>sign : Symbol(sign, Decl(returnTypeInferenceNotTooBroad.ts, 13, 43)) +>kind : Symbol(kind, Decl(returnTypeInferenceNotTooBroad.ts, 13, 51)) +>a : Symbol(a, Decl(returnTypeInferenceNotTooBroad.ts, 13, 62)) + diff --git a/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=typesfirst).types new file mode 100644 index 0000000000000..1f07d04ed8463 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/returnTypeInferenceNotTooBroad(checkorder=typesfirst).types @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/returnTypeInferenceNotTooBroad.ts] //// + +=== returnTypeInferenceNotTooBroad.ts === +type Signs = { kind: 'a'; a: 3; } | { kind: 'b'; b: 2; } | { kind: 'c'; c: 1; }; +>Signs : Signs +>kind : "a" +>a : 3 +>kind : "b" +>b : 2 +>kind : "c" +>c : 1 + +interface Opts { + low?: number; +>low : number | undefined + + sign?: T +>sign : T | undefined +} +interface Wrapper { +} +declare function sepsis(opts: Opts): Wrapper; +>sepsis : (opts: Opts) => Wrapper +>opts : Opts + +declare function unwrap(w: Wrapper): T; +>unwrap : (w: Wrapper) => T +>w : Wrapper + +export const y = sepsis({ low: 1, sign: { kind: 'a', a: 3 }}); +>y : Wrapper<{ kind: "a"; a: 3; }> +>sepsis({ low: 1, sign: { kind: 'a', a: 3 }}) : Wrapper<{ kind: "a"; a: 3; }> +>sepsis : (opts: Opts) => Wrapper +>{ low: 1, sign: { kind: 'a', a: 3 }} : { low: number; sign: { kind: "a"; a: 3; }; } +>low : number +>1 : 1 +>sign : { kind: "a"; a: 3; } +>{ kind: 'a', a: 3 } : { kind: "a"; a: 3; } +>kind : "a" +>'a' : "a" +>a : 3 +>3 : 3 + +// $ExpectType { kind: "a"; a: 3; } +export const yun = unwrap(y); +>yun : { kind: "a"; a: 3; } +>unwrap(y) : { kind: "a"; a: 3; } +>unwrap : (w: Wrapper) => T +>y : Wrapper<{ kind: "a"; a: 3; }> + +// $ExpectType { kind: "a"; a: 3; } +export const yone = unwrap(sepsis({ low: 1, sign: { kind: 'a', a: 3 }})); +>yone : { kind: string; a: number; } +>unwrap(sepsis({ low: 1, sign: { kind: 'a', a: 3 }})) : { kind: string; a: number; } +>unwrap : (w: Wrapper) => T +>sepsis({ low: 1, sign: { kind: 'a', a: 3 }}) : Wrapper<{ kind: string; a: number; }> +>sepsis : (opts: Opts) => Wrapper +>{ low: 1, sign: { kind: 'a', a: 3 }} : { low: number; sign: { kind: string; a: number; }; } +>low : number +>1 : 1 +>sign : { kind: string; a: number; } +>{ kind: 'a', a: 3 } : { kind: string; a: number; } +>kind : string +>'a' : "a" +>a : number +>3 : 3 + diff --git a/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=default).errors.txt new file mode 100644 index 0000000000000..b56bf6531dd0a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=default).errors.txt @@ -0,0 +1,24 @@ +sharedMemberLayoutThisIntersectionBase.ts(7,3): error TS2339: Property 'm' does not exist on type 'D<"b">'. +sharedMemberLayoutThisIntersectionBase.ts(12,3): error TS2339: Property 'm' does not exist on type 'C<"b">'. + + +==== sharedMemberLayoutThisIntersectionBase.ts (2 errors) ==== + interface A { kind: string; m: this["kind"] } + interface B { m: "a" } + type AB = A & B; + + interface D extends AB { kind: T } + declare let d: D<"b">; + d.m; + ~ +!!! error TS2339: Property 'm' does not exist on type 'D<"b">'. + + declare const ABCtor: new () => AB; + class C extends ABCtor { declare kind: T } + declare let c: C<"b">; + c.m; + ~ +!!! error TS2339: Property 'm' does not exist on type 'C<"b">'. + + export {}; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=default).symbols new file mode 100644 index 0000000000000..793b38f82728b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=default).symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/sharedMemberLayoutThisIntersectionBase.ts] //// + +=== sharedMemberLayoutThisIntersectionBase.ts === +interface A { kind: string; m: this["kind"] } +>A : Symbol(A, Decl(sharedMemberLayoutThisIntersectionBase.ts, 0, 0)) +>kind : Symbol(A.kind, Decl(sharedMemberLayoutThisIntersectionBase.ts, 0, 13)) +>m : Symbol(A.m, Decl(sharedMemberLayoutThisIntersectionBase.ts, 0, 27)) + +interface B { m: "a" } +>B : Symbol(B, Decl(sharedMemberLayoutThisIntersectionBase.ts, 0, 45)) +>m : Symbol(B.m, Decl(sharedMemberLayoutThisIntersectionBase.ts, 1, 13)) + +type AB = A & B; +>AB : Symbol(AB, Decl(sharedMemberLayoutThisIntersectionBase.ts, 1, 22)) +>A : Symbol(A, Decl(sharedMemberLayoutThisIntersectionBase.ts, 0, 0)) +>B : Symbol(B, Decl(sharedMemberLayoutThisIntersectionBase.ts, 0, 45)) + +interface D extends AB { kind: T } +>D : Symbol(D, Decl(sharedMemberLayoutThisIntersectionBase.ts, 2, 16)) +>T : Symbol(T, Decl(sharedMemberLayoutThisIntersectionBase.ts, 4, 12)) +>AB : Symbol(AB, Decl(sharedMemberLayoutThisIntersectionBase.ts, 1, 22)) +>kind : Symbol(D.kind, Decl(sharedMemberLayoutThisIntersectionBase.ts, 4, 42)) +>T : Symbol(T, Decl(sharedMemberLayoutThisIntersectionBase.ts, 4, 12)) + +declare let d: D<"b">; +>d : Symbol(d, Decl(sharedMemberLayoutThisIntersectionBase.ts, 5, 11)) +>D : Symbol(D, Decl(sharedMemberLayoutThisIntersectionBase.ts, 2, 16)) + +d.m; +>d : Symbol(d, Decl(sharedMemberLayoutThisIntersectionBase.ts, 5, 11)) + +declare const ABCtor: new () => AB; +>ABCtor : Symbol(ABCtor, Decl(sharedMemberLayoutThisIntersectionBase.ts, 8, 13)) +>AB : Symbol(AB, Decl(sharedMemberLayoutThisIntersectionBase.ts, 1, 22)) + +class C extends ABCtor { declare kind: T } +>C : Symbol(C, Decl(sharedMemberLayoutThisIntersectionBase.ts, 8, 35)) +>T : Symbol(T, Decl(sharedMemberLayoutThisIntersectionBase.ts, 9, 8)) +>ABCtor : Symbol(ABCtor, Decl(sharedMemberLayoutThisIntersectionBase.ts, 8, 13)) +>kind : Symbol(C.kind, Decl(sharedMemberLayoutThisIntersectionBase.ts, 9, 42)) +>T : Symbol(T, Decl(sharedMemberLayoutThisIntersectionBase.ts, 9, 8)) + +declare let c: C<"b">; +>c : Symbol(c, Decl(sharedMemberLayoutThisIntersectionBase.ts, 10, 11)) +>C : Symbol(C, Decl(sharedMemberLayoutThisIntersectionBase.ts, 8, 35)) + +c.m; +>c : Symbol(c, Decl(sharedMemberLayoutThisIntersectionBase.ts, 10, 11)) + +export {}; + diff --git a/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=default).types new file mode 100644 index 0000000000000..41de65a71ea2f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=default).types @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/sharedMemberLayoutThisIntersectionBase.ts] //// + +=== sharedMemberLayoutThisIntersectionBase.ts === +interface A { kind: string; m: this["kind"] } +>kind : string +>m : this["kind"] + +interface B { m: "a" } +>m : "a" + +type AB = A & B; +>AB : AB + +interface D extends AB { kind: T } +>kind : T + +declare let d: D<"b">; +>d : D<"b"> + +d.m; +>d.m : any +>d : D<"b"> +>m : any + +declare const ABCtor: new () => AB; +>ABCtor : new () => AB + +class C extends ABCtor { declare kind: T } +>C : C +>ABCtor : A & B +>kind : T + +declare let c: C<"b">; +>c : C<"b"> + +c.m; +>c.m : any +>c : C<"b"> +>m : any + +export {}; + diff --git a/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..b56bf6531dd0a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=typesfirst).errors.txt @@ -0,0 +1,24 @@ +sharedMemberLayoutThisIntersectionBase.ts(7,3): error TS2339: Property 'm' does not exist on type 'D<"b">'. +sharedMemberLayoutThisIntersectionBase.ts(12,3): error TS2339: Property 'm' does not exist on type 'C<"b">'. + + +==== sharedMemberLayoutThisIntersectionBase.ts (2 errors) ==== + interface A { kind: string; m: this["kind"] } + interface B { m: "a" } + type AB = A & B; + + interface D extends AB { kind: T } + declare let d: D<"b">; + d.m; + ~ +!!! error TS2339: Property 'm' does not exist on type 'D<"b">'. + + declare const ABCtor: new () => AB; + class C extends ABCtor { declare kind: T } + declare let c: C<"b">; + c.m; + ~ +!!! error TS2339: Property 'm' does not exist on type 'C<"b">'. + + export {}; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..793b38f82728b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=typesfirst).symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/sharedMemberLayoutThisIntersectionBase.ts] //// + +=== sharedMemberLayoutThisIntersectionBase.ts === +interface A { kind: string; m: this["kind"] } +>A : Symbol(A, Decl(sharedMemberLayoutThisIntersectionBase.ts, 0, 0)) +>kind : Symbol(A.kind, Decl(sharedMemberLayoutThisIntersectionBase.ts, 0, 13)) +>m : Symbol(A.m, Decl(sharedMemberLayoutThisIntersectionBase.ts, 0, 27)) + +interface B { m: "a" } +>B : Symbol(B, Decl(sharedMemberLayoutThisIntersectionBase.ts, 0, 45)) +>m : Symbol(B.m, Decl(sharedMemberLayoutThisIntersectionBase.ts, 1, 13)) + +type AB = A & B; +>AB : Symbol(AB, Decl(sharedMemberLayoutThisIntersectionBase.ts, 1, 22)) +>A : Symbol(A, Decl(sharedMemberLayoutThisIntersectionBase.ts, 0, 0)) +>B : Symbol(B, Decl(sharedMemberLayoutThisIntersectionBase.ts, 0, 45)) + +interface D extends AB { kind: T } +>D : Symbol(D, Decl(sharedMemberLayoutThisIntersectionBase.ts, 2, 16)) +>T : Symbol(T, Decl(sharedMemberLayoutThisIntersectionBase.ts, 4, 12)) +>AB : Symbol(AB, Decl(sharedMemberLayoutThisIntersectionBase.ts, 1, 22)) +>kind : Symbol(D.kind, Decl(sharedMemberLayoutThisIntersectionBase.ts, 4, 42)) +>T : Symbol(T, Decl(sharedMemberLayoutThisIntersectionBase.ts, 4, 12)) + +declare let d: D<"b">; +>d : Symbol(d, Decl(sharedMemberLayoutThisIntersectionBase.ts, 5, 11)) +>D : Symbol(D, Decl(sharedMemberLayoutThisIntersectionBase.ts, 2, 16)) + +d.m; +>d : Symbol(d, Decl(sharedMemberLayoutThisIntersectionBase.ts, 5, 11)) + +declare const ABCtor: new () => AB; +>ABCtor : Symbol(ABCtor, Decl(sharedMemberLayoutThisIntersectionBase.ts, 8, 13)) +>AB : Symbol(AB, Decl(sharedMemberLayoutThisIntersectionBase.ts, 1, 22)) + +class C extends ABCtor { declare kind: T } +>C : Symbol(C, Decl(sharedMemberLayoutThisIntersectionBase.ts, 8, 35)) +>T : Symbol(T, Decl(sharedMemberLayoutThisIntersectionBase.ts, 9, 8)) +>ABCtor : Symbol(ABCtor, Decl(sharedMemberLayoutThisIntersectionBase.ts, 8, 13)) +>kind : Symbol(C.kind, Decl(sharedMemberLayoutThisIntersectionBase.ts, 9, 42)) +>T : Symbol(T, Decl(sharedMemberLayoutThisIntersectionBase.ts, 9, 8)) + +declare let c: C<"b">; +>c : Symbol(c, Decl(sharedMemberLayoutThisIntersectionBase.ts, 10, 11)) +>C : Symbol(C, Decl(sharedMemberLayoutThisIntersectionBase.ts, 8, 35)) + +c.m; +>c : Symbol(c, Decl(sharedMemberLayoutThisIntersectionBase.ts, 10, 11)) + +export {}; + diff --git a/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=typesfirst).types new file mode 100644 index 0000000000000..41de65a71ea2f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/sharedMemberLayoutThisIntersectionBase(checkorder=typesfirst).types @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/sharedMemberLayoutThisIntersectionBase.ts] //// + +=== sharedMemberLayoutThisIntersectionBase.ts === +interface A { kind: string; m: this["kind"] } +>kind : string +>m : this["kind"] + +interface B { m: "a" } +>m : "a" + +type AB = A & B; +>AB : AB + +interface D extends AB { kind: T } +>kind : T + +declare let d: D<"b">; +>d : D<"b"> + +d.m; +>d.m : any +>d : D<"b"> +>m : any + +declare const ABCtor: new () => AB; +>ABCtor : new () => AB + +class C extends ABCtor { declare kind: T } +>C : C +>ABCtor : A & B +>kind : T + +declare let c: C<"b">; +>c : C<"b"> + +c.m; +>c.m : any +>c : C<"b"> +>m : any + +export {}; + diff --git a/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=default).errors.txt new file mode 100644 index 0000000000000..2c10283c820ef --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=default).errors.txt @@ -0,0 +1,48 @@ +templateLiteralTypeExcessiveLength.ts(15,11): error TS2589: Type instantiation is excessively deep and possibly infinite. +templateLiteralTypeExcessiveLength.ts(20,11): error TS2589: Type instantiation is excessively deep and possibly infinite. +templateLiteralTypeExcessiveLength.ts(34,11): error TS2589: Type instantiation is excessively deep and possibly infinite. + + +==== templateLiteralTypeExcessiveLength.ts (3 errors) ==== + // Regression test for #63271: `Dec<2>` is `any`, so `Recur` produces both conditional branches and + // keeps tail-recursing forever. The checker must report an error instead of building an unbounded + // template literal type. + + type Dec = + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; + + type Recur = + N extends 0 ? S : Recur, `${S}_${S}`>; + + // The string literal doubles on every iteration. + type Explode = { + [P in Recur<5, "a"> as `${P}_key`]: any; + ~~~~~~~~~~~~~ +!!! error TS2589: Type instantiation is excessively deep and possibly infinite. + }; + + // The number of placeholders doubles on every iteration. + type ExplodeSpans = { + [P in Recur<5, string> as `${P}_key`]: any; + ~~~~~~~~~~~~~~~~ +!!! error TS2589: Type instantiation is excessively deep and possibly infinite. + }; + + // Every text segment stays small, but the number of segments doubles on every iteration, + // so the combined text length grows without bound. + type A16 = "aaaaaaaaaaaaaaaa"; + type A64 = `${A16}${A16}${A16}${A16}`; + type A256 = `${A64}${A64}${A64}${A64}`; + type A1024 = `${A256}${A256}${A256}${A256}`; + + type RecurSegments = + N extends 0 ? S : RecurSegments, `${S}${string}${S}`>; + + type ExplodeSegments = { + [P in RecurSegments<5, A1024> as `${P}_key`]: any; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2589: Type instantiation is excessively deep and possibly infinite. + }; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=default).js new file mode 100644 index 0000000000000..36fa92d4a5035 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=default).js @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/templateLiteralTypeExcessiveLength.ts] //// + +//// [templateLiteralTypeExcessiveLength.ts] +// Regression test for #63271: `Dec<2>` is `any`, so `Recur` produces both conditional branches and +// keeps tail-recursing forever. The checker must report an error instead of building an unbounded +// template literal type. + +type Dec = + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; + +type Recur = + N extends 0 ? S : Recur, `${S}_${S}`>; + +// The string literal doubles on every iteration. +type Explode = { + [P in Recur<5, "a"> as `${P}_key`]: any; +}; + +// The number of placeholders doubles on every iteration. +type ExplodeSpans = { + [P in Recur<5, string> as `${P}_key`]: any; +}; + +// Every text segment stays small, but the number of segments doubles on every iteration, +// so the combined text length grows without bound. +type A16 = "aaaaaaaaaaaaaaaa"; +type A64 = `${A16}${A16}${A16}${A16}`; +type A256 = `${A64}${A64}${A64}${A64}`; +type A1024 = `${A256}${A256}${A256}${A256}`; + +type RecurSegments = + N extends 0 ? S : RecurSegments, `${S}${string}${S}`>; + +type ExplodeSegments = { + [P in RecurSegments<5, A1024> as `${P}_key`]: any; +}; + + +//// [templateLiteralTypeExcessiveLength.js] +"use strict"; +// Regression test for #63271: `Dec<2>` is `any`, so `Recur` produces both conditional branches and +// keeps tail-recursing forever. The checker must report an error instead of building an unbounded +// template literal type. diff --git a/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=default).symbols new file mode 100644 index 0000000000000..2e85049b74921 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=default).symbols @@ -0,0 +1,109 @@ +//// [tests/cases/compiler/templateLiteralTypeExcessiveLength.ts] //// + +=== templateLiteralTypeExcessiveLength.ts === +// Regression test for #63271: `Dec<2>` is `any`, so `Recur` produces both conditional branches and +// keeps tail-recursing forever. The checker must report an error instead of building an unbounded +// template literal type. + +type Dec = +>Dec : Symbol(Dec, Decl(templateLiteralTypeExcessiveLength.ts, 0, 0)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 4, 9)) + + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 4, 9)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 4, 9)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 4, 9)) + + N extends 2 ? any : +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 4, 9)) + + N extends 1 ? 0 : 0; +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 4, 9)) + +type Recur = +>Recur : Symbol(Recur, Decl(templateLiteralTypeExcessiveLength.ts, 7, 24)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 9, 11)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 9, 28)) + + N extends 0 ? S : Recur, `${S}_${S}`>; +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 9, 11)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 9, 28)) +>Recur : Symbol(Recur, Decl(templateLiteralTypeExcessiveLength.ts, 7, 24)) +>Dec : Symbol(Dec, Decl(templateLiteralTypeExcessiveLength.ts, 0, 0)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 9, 11)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 9, 28)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 9, 28)) + +// The string literal doubles on every iteration. +type Explode = { +>Explode : Symbol(Explode, Decl(templateLiteralTypeExcessiveLength.ts, 10, 49)) + + [P in Recur<5, "a"> as `${P}_key`]: any; +>P : Symbol(P, Decl(templateLiteralTypeExcessiveLength.ts, 14, 5)) +>Recur : Symbol(Recur, Decl(templateLiteralTypeExcessiveLength.ts, 7, 24)) +>P : Symbol(P, Decl(templateLiteralTypeExcessiveLength.ts, 14, 5)) + +}; + +// The number of placeholders doubles on every iteration. +type ExplodeSpans = { +>ExplodeSpans : Symbol(ExplodeSpans, Decl(templateLiteralTypeExcessiveLength.ts, 15, 2)) + + [P in Recur<5, string> as `${P}_key`]: any; +>P : Symbol(P, Decl(templateLiteralTypeExcessiveLength.ts, 19, 5)) +>Recur : Symbol(Recur, Decl(templateLiteralTypeExcessiveLength.ts, 7, 24)) +>P : Symbol(P, Decl(templateLiteralTypeExcessiveLength.ts, 19, 5)) + +}; + +// Every text segment stays small, but the number of segments doubles on every iteration, +// so the combined text length grows without bound. +type A16 = "aaaaaaaaaaaaaaaa"; +>A16 : Symbol(A16, Decl(templateLiteralTypeExcessiveLength.ts, 20, 2)) + +type A64 = `${A16}${A16}${A16}${A16}`; +>A64 : Symbol(A64, Decl(templateLiteralTypeExcessiveLength.ts, 24, 30)) +>A16 : Symbol(A16, Decl(templateLiteralTypeExcessiveLength.ts, 20, 2)) +>A16 : Symbol(A16, Decl(templateLiteralTypeExcessiveLength.ts, 20, 2)) +>A16 : Symbol(A16, Decl(templateLiteralTypeExcessiveLength.ts, 20, 2)) +>A16 : Symbol(A16, Decl(templateLiteralTypeExcessiveLength.ts, 20, 2)) + +type A256 = `${A64}${A64}${A64}${A64}`; +>A256 : Symbol(A256, Decl(templateLiteralTypeExcessiveLength.ts, 25, 38)) +>A64 : Symbol(A64, Decl(templateLiteralTypeExcessiveLength.ts, 24, 30)) +>A64 : Symbol(A64, Decl(templateLiteralTypeExcessiveLength.ts, 24, 30)) +>A64 : Symbol(A64, Decl(templateLiteralTypeExcessiveLength.ts, 24, 30)) +>A64 : Symbol(A64, Decl(templateLiteralTypeExcessiveLength.ts, 24, 30)) + +type A1024 = `${A256}${A256}${A256}${A256}`; +>A1024 : Symbol(A1024, Decl(templateLiteralTypeExcessiveLength.ts, 26, 39)) +>A256 : Symbol(A256, Decl(templateLiteralTypeExcessiveLength.ts, 25, 38)) +>A256 : Symbol(A256, Decl(templateLiteralTypeExcessiveLength.ts, 25, 38)) +>A256 : Symbol(A256, Decl(templateLiteralTypeExcessiveLength.ts, 25, 38)) +>A256 : Symbol(A256, Decl(templateLiteralTypeExcessiveLength.ts, 25, 38)) + +type RecurSegments = +>RecurSegments : Symbol(RecurSegments, Decl(templateLiteralTypeExcessiveLength.ts, 27, 44)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 29, 19)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 29, 36)) + + N extends 0 ? S : RecurSegments, `${S}${string}${S}`>; +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 29, 19)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 29, 36)) +>RecurSegments : Symbol(RecurSegments, Decl(templateLiteralTypeExcessiveLength.ts, 27, 44)) +>Dec : Symbol(Dec, Decl(templateLiteralTypeExcessiveLength.ts, 0, 0)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 29, 19)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 29, 36)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 29, 36)) + +type ExplodeSegments = { +>ExplodeSegments : Symbol(ExplodeSegments, Decl(templateLiteralTypeExcessiveLength.ts, 30, 65)) + + [P in RecurSegments<5, A1024> as `${P}_key`]: any; +>P : Symbol(P, Decl(templateLiteralTypeExcessiveLength.ts, 33, 5)) +>RecurSegments : Symbol(RecurSegments, Decl(templateLiteralTypeExcessiveLength.ts, 27, 44)) +>A1024 : Symbol(A1024, Decl(templateLiteralTypeExcessiveLength.ts, 26, 39)) +>P : Symbol(P, Decl(templateLiteralTypeExcessiveLength.ts, 33, 5)) + +}; + diff --git a/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=default).types new file mode 100644 index 0000000000000..e882332afbf78 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=default).types @@ -0,0 +1,58 @@ +//// [tests/cases/compiler/templateLiteralTypeExcessiveLength.ts] //// + +=== templateLiteralTypeExcessiveLength.ts === +// Regression test for #63271: `Dec<2>` is `any`, so `Recur` produces both conditional branches and +// keeps tail-recursing forever. The checker must report an error instead of building an unbounded +// template literal type. + +type Dec = +>Dec : Dec + + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; + +type Recur = +>Recur : Recur + + N extends 0 ? S : Recur, `${S}_${S}`>; + +// The string literal doubles on every iteration. +type Explode = { +>Explode : Explode + + [P in Recur<5, "a"> as `${P}_key`]: any; +}; + +// The number of placeholders doubles on every iteration. +type ExplodeSpans = { +>ExplodeSpans : ExplodeSpans + + [P in Recur<5, string> as `${P}_key`]: any; +}; + +// Every text segment stays small, but the number of segments doubles on every iteration, +// so the combined text length grows without bound. +type A16 = "aaaaaaaaaaaaaaaa"; +>A16 : "aaaaaaaaaaaaaaaa" + +type A64 = `${A16}${A16}${A16}${A16}`; +>A64 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + +type A256 = `${A64}${A64}${A64}${A64}`; +>A256 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + +type A1024 = `${A256}${A256}${A256}${A256}`; +>A1024 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + +type RecurSegments = +>RecurSegments : RecurSegments + + N extends 0 ? S : RecurSegments, `${S}${string}${S}`>; + +type ExplodeSegments = { +>ExplodeSegments : ExplodeSegments + + [P in RecurSegments<5, A1024> as `${P}_key`]: any; +}; + diff --git a/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..a7a577d5080f1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=typesfirst).errors.txt @@ -0,0 +1,41 @@ +error TS2589: Type instantiation is excessively deep and possibly infinite. + + +!!! error TS2589: Type instantiation is excessively deep and possibly infinite. +==== templateLiteralTypeExcessiveLength.ts (0 errors) ==== + // Regression test for #63271: `Dec<2>` is `any`, so `Recur` produces both conditional branches and + // keeps tail-recursing forever. The checker must report an error instead of building an unbounded + // template literal type. + + type Dec = + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; + + type Recur = + N extends 0 ? S : Recur, `${S}_${S}`>; + + // The string literal doubles on every iteration. + type Explode = { + [P in Recur<5, "a"> as `${P}_key`]: any; + }; + + // The number of placeholders doubles on every iteration. + type ExplodeSpans = { + [P in Recur<5, string> as `${P}_key`]: any; + }; + + // Every text segment stays small, but the number of segments doubles on every iteration, + // so the combined text length grows without bound. + type A16 = "aaaaaaaaaaaaaaaa"; + type A64 = `${A16}${A16}${A16}${A16}`; + type A256 = `${A64}${A64}${A64}${A64}`; + type A1024 = `${A256}${A256}${A256}${A256}`; + + type RecurSegments = + N extends 0 ? S : RecurSegments, `${S}${string}${S}`>; + + type ExplodeSegments = { + [P in RecurSegments<5, A1024> as `${P}_key`]: any; + }; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=typesfirst).js new file mode 100644 index 0000000000000..36fa92d4a5035 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=typesfirst).js @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/templateLiteralTypeExcessiveLength.ts] //// + +//// [templateLiteralTypeExcessiveLength.ts] +// Regression test for #63271: `Dec<2>` is `any`, so `Recur` produces both conditional branches and +// keeps tail-recursing forever. The checker must report an error instead of building an unbounded +// template literal type. + +type Dec = + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; + +type Recur = + N extends 0 ? S : Recur, `${S}_${S}`>; + +// The string literal doubles on every iteration. +type Explode = { + [P in Recur<5, "a"> as `${P}_key`]: any; +}; + +// The number of placeholders doubles on every iteration. +type ExplodeSpans = { + [P in Recur<5, string> as `${P}_key`]: any; +}; + +// Every text segment stays small, but the number of segments doubles on every iteration, +// so the combined text length grows without bound. +type A16 = "aaaaaaaaaaaaaaaa"; +type A64 = `${A16}${A16}${A16}${A16}`; +type A256 = `${A64}${A64}${A64}${A64}`; +type A1024 = `${A256}${A256}${A256}${A256}`; + +type RecurSegments = + N extends 0 ? S : RecurSegments, `${S}${string}${S}`>; + +type ExplodeSegments = { + [P in RecurSegments<5, A1024> as `${P}_key`]: any; +}; + + +//// [templateLiteralTypeExcessiveLength.js] +"use strict"; +// Regression test for #63271: `Dec<2>` is `any`, so `Recur` produces both conditional branches and +// keeps tail-recursing forever. The checker must report an error instead of building an unbounded +// template literal type. diff --git a/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..2e85049b74921 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=typesfirst).symbols @@ -0,0 +1,109 @@ +//// [tests/cases/compiler/templateLiteralTypeExcessiveLength.ts] //// + +=== templateLiteralTypeExcessiveLength.ts === +// Regression test for #63271: `Dec<2>` is `any`, so `Recur` produces both conditional branches and +// keeps tail-recursing forever. The checker must report an error instead of building an unbounded +// template literal type. + +type Dec = +>Dec : Symbol(Dec, Decl(templateLiteralTypeExcessiveLength.ts, 0, 0)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 4, 9)) + + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 4, 9)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 4, 9)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 4, 9)) + + N extends 2 ? any : +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 4, 9)) + + N extends 1 ? 0 : 0; +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 4, 9)) + +type Recur = +>Recur : Symbol(Recur, Decl(templateLiteralTypeExcessiveLength.ts, 7, 24)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 9, 11)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 9, 28)) + + N extends 0 ? S : Recur, `${S}_${S}`>; +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 9, 11)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 9, 28)) +>Recur : Symbol(Recur, Decl(templateLiteralTypeExcessiveLength.ts, 7, 24)) +>Dec : Symbol(Dec, Decl(templateLiteralTypeExcessiveLength.ts, 0, 0)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 9, 11)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 9, 28)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 9, 28)) + +// The string literal doubles on every iteration. +type Explode = { +>Explode : Symbol(Explode, Decl(templateLiteralTypeExcessiveLength.ts, 10, 49)) + + [P in Recur<5, "a"> as `${P}_key`]: any; +>P : Symbol(P, Decl(templateLiteralTypeExcessiveLength.ts, 14, 5)) +>Recur : Symbol(Recur, Decl(templateLiteralTypeExcessiveLength.ts, 7, 24)) +>P : Symbol(P, Decl(templateLiteralTypeExcessiveLength.ts, 14, 5)) + +}; + +// The number of placeholders doubles on every iteration. +type ExplodeSpans = { +>ExplodeSpans : Symbol(ExplodeSpans, Decl(templateLiteralTypeExcessiveLength.ts, 15, 2)) + + [P in Recur<5, string> as `${P}_key`]: any; +>P : Symbol(P, Decl(templateLiteralTypeExcessiveLength.ts, 19, 5)) +>Recur : Symbol(Recur, Decl(templateLiteralTypeExcessiveLength.ts, 7, 24)) +>P : Symbol(P, Decl(templateLiteralTypeExcessiveLength.ts, 19, 5)) + +}; + +// Every text segment stays small, but the number of segments doubles on every iteration, +// so the combined text length grows without bound. +type A16 = "aaaaaaaaaaaaaaaa"; +>A16 : Symbol(A16, Decl(templateLiteralTypeExcessiveLength.ts, 20, 2)) + +type A64 = `${A16}${A16}${A16}${A16}`; +>A64 : Symbol(A64, Decl(templateLiteralTypeExcessiveLength.ts, 24, 30)) +>A16 : Symbol(A16, Decl(templateLiteralTypeExcessiveLength.ts, 20, 2)) +>A16 : Symbol(A16, Decl(templateLiteralTypeExcessiveLength.ts, 20, 2)) +>A16 : Symbol(A16, Decl(templateLiteralTypeExcessiveLength.ts, 20, 2)) +>A16 : Symbol(A16, Decl(templateLiteralTypeExcessiveLength.ts, 20, 2)) + +type A256 = `${A64}${A64}${A64}${A64}`; +>A256 : Symbol(A256, Decl(templateLiteralTypeExcessiveLength.ts, 25, 38)) +>A64 : Symbol(A64, Decl(templateLiteralTypeExcessiveLength.ts, 24, 30)) +>A64 : Symbol(A64, Decl(templateLiteralTypeExcessiveLength.ts, 24, 30)) +>A64 : Symbol(A64, Decl(templateLiteralTypeExcessiveLength.ts, 24, 30)) +>A64 : Symbol(A64, Decl(templateLiteralTypeExcessiveLength.ts, 24, 30)) + +type A1024 = `${A256}${A256}${A256}${A256}`; +>A1024 : Symbol(A1024, Decl(templateLiteralTypeExcessiveLength.ts, 26, 39)) +>A256 : Symbol(A256, Decl(templateLiteralTypeExcessiveLength.ts, 25, 38)) +>A256 : Symbol(A256, Decl(templateLiteralTypeExcessiveLength.ts, 25, 38)) +>A256 : Symbol(A256, Decl(templateLiteralTypeExcessiveLength.ts, 25, 38)) +>A256 : Symbol(A256, Decl(templateLiteralTypeExcessiveLength.ts, 25, 38)) + +type RecurSegments = +>RecurSegments : Symbol(RecurSegments, Decl(templateLiteralTypeExcessiveLength.ts, 27, 44)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 29, 19)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 29, 36)) + + N extends 0 ? S : RecurSegments, `${S}${string}${S}`>; +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 29, 19)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 29, 36)) +>RecurSegments : Symbol(RecurSegments, Decl(templateLiteralTypeExcessiveLength.ts, 27, 44)) +>Dec : Symbol(Dec, Decl(templateLiteralTypeExcessiveLength.ts, 0, 0)) +>N : Symbol(N, Decl(templateLiteralTypeExcessiveLength.ts, 29, 19)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 29, 36)) +>S : Symbol(S, Decl(templateLiteralTypeExcessiveLength.ts, 29, 36)) + +type ExplodeSegments = { +>ExplodeSegments : Symbol(ExplodeSegments, Decl(templateLiteralTypeExcessiveLength.ts, 30, 65)) + + [P in RecurSegments<5, A1024> as `${P}_key`]: any; +>P : Symbol(P, Decl(templateLiteralTypeExcessiveLength.ts, 33, 5)) +>RecurSegments : Symbol(RecurSegments, Decl(templateLiteralTypeExcessiveLength.ts, 27, 44)) +>A1024 : Symbol(A1024, Decl(templateLiteralTypeExcessiveLength.ts, 26, 39)) +>P : Symbol(P, Decl(templateLiteralTypeExcessiveLength.ts, 33, 5)) + +}; + diff --git a/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=typesfirst).types new file mode 100644 index 0000000000000..e882332afbf78 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/templateLiteralTypeExcessiveLength(checkorder=typesfirst).types @@ -0,0 +1,58 @@ +//// [tests/cases/compiler/templateLiteralTypeExcessiveLength.ts] //// + +=== templateLiteralTypeExcessiveLength.ts === +// Regression test for #63271: `Dec<2>` is `any`, so `Recur` produces both conditional branches and +// keeps tail-recursing forever. The checker must report an error instead of building an unbounded +// template literal type. + +type Dec = +>Dec : Dec + + N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : + N extends 2 ? any : + N extends 1 ? 0 : 0; + +type Recur = +>Recur : Recur + + N extends 0 ? S : Recur, `${S}_${S}`>; + +// The string literal doubles on every iteration. +type Explode = { +>Explode : Explode + + [P in Recur<5, "a"> as `${P}_key`]: any; +}; + +// The number of placeholders doubles on every iteration. +type ExplodeSpans = { +>ExplodeSpans : ExplodeSpans + + [P in Recur<5, string> as `${P}_key`]: any; +}; + +// Every text segment stays small, but the number of segments doubles on every iteration, +// so the combined text length grows without bound. +type A16 = "aaaaaaaaaaaaaaaa"; +>A16 : "aaaaaaaaaaaaaaaa" + +type A64 = `${A16}${A16}${A16}${A16}`; +>A64 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + +type A256 = `${A64}${A64}${A64}${A64}`; +>A256 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + +type A1024 = `${A256}${A256}${A256}${A256}`; +>A1024 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + +type RecurSegments = +>RecurSegments : RecurSegments + + N extends 0 ? S : RecurSegments, `${S}${string}${S}`>; + +type ExplodeSegments = { +>ExplodeSegments : ExplodeSegments + + [P in RecurSegments<5, A1024> as `${P}_key`]: any; +}; + diff --git a/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=default).errors.txt new file mode 100644 index 0000000000000..b7a0b982aceb6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=default).errors.txt @@ -0,0 +1,15 @@ +typeParameterHasSelfAsConstraint.ts(1,24): error TS2313: Type parameter 'T' has a circular constraint. +typeParameterHasSelfAsConstraint.ts(2,5): error TS2322: Type 'T' is not assignable to type 'number'. + + +==== typeParameterHasSelfAsConstraint.ts (2 errors) ==== + function foo(x: T): number { + ~ +!!! error TS2313: Type parameter 'T' has a circular constraint. + return x; + ~~~~~~ +!!! error TS2322: Type 'T' is not assignable to type 'number'. +!!! related TS2208 typeParameterHasSelfAsConstraint.ts:1:14: This type parameter might need an `extends number` constraint. + } + + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=default).js new file mode 100644 index 0000000000000..2b6ae7f2bca3f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=default).js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/typeParameterHasSelfAsConstraint.ts] //// + +//// [typeParameterHasSelfAsConstraint.ts] +function foo(x: T): number { + return x; +} + + + +//// [typeParameterHasSelfAsConstraint.js] +"use strict"; +function foo(x) { + return x; +} diff --git a/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=default).symbols new file mode 100644 index 0000000000000..e8a52432a83dc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=default).symbols @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/typeParameterHasSelfAsConstraint.ts] //// + +=== typeParameterHasSelfAsConstraint.ts === +function foo(x: T): number { +>foo : Symbol(foo, Decl(typeParameterHasSelfAsConstraint.ts, 0, 0)) +>T : Symbol(T, Decl(typeParameterHasSelfAsConstraint.ts, 0, 13)) +>T : Symbol(T, Decl(typeParameterHasSelfAsConstraint.ts, 0, 13)) +>x : Symbol(x, Decl(typeParameterHasSelfAsConstraint.ts, 0, 26)) +>T : Symbol(T, Decl(typeParameterHasSelfAsConstraint.ts, 0, 13)) + + return x; +>x : Symbol(x, Decl(typeParameterHasSelfAsConstraint.ts, 0, 26)) +} + + diff --git a/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=default).types new file mode 100644 index 0000000000000..dd8af60e8c209 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=default).types @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/typeParameterHasSelfAsConstraint.ts] //// + +=== typeParameterHasSelfAsConstraint.ts === +function foo(x: T): number { +>foo : (x: T) => number +>x : T + + return x; +>x : T +} + + diff --git a/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..83997ce99f298 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=typesfirst).errors.txt @@ -0,0 +1,16 @@ +typeParameterHasSelfAsConstraint.ts(1,24): error TS2313: Type parameter 'T' has a circular constraint. +typeParameterHasSelfAsConstraint.ts(2,5): error TS2322: Type 'T' is not assignable to type 'number'. + + +==== typeParameterHasSelfAsConstraint.ts (2 errors) ==== + function foo(x: T): number { + ~ +!!! error TS2313: Type parameter 'T' has a circular constraint. +!!! related TS2751 typeParameterHasSelfAsConstraint.ts:2:12: Circularity originates in type at this location. + return x; + ~~~~~~ +!!! error TS2322: Type 'T' is not assignable to type 'number'. +!!! related TS2208 typeParameterHasSelfAsConstraint.ts:1:14: This type parameter might need an `extends number` constraint. + } + + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=typesfirst).js new file mode 100644 index 0000000000000..2b6ae7f2bca3f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=typesfirst).js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/typeParameterHasSelfAsConstraint.ts] //// + +//// [typeParameterHasSelfAsConstraint.ts] +function foo(x: T): number { + return x; +} + + + +//// [typeParameterHasSelfAsConstraint.js] +"use strict"; +function foo(x) { + return x; +} diff --git a/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..e8a52432a83dc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=typesfirst).symbols @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/typeParameterHasSelfAsConstraint.ts] //// + +=== typeParameterHasSelfAsConstraint.ts === +function foo(x: T): number { +>foo : Symbol(foo, Decl(typeParameterHasSelfAsConstraint.ts, 0, 0)) +>T : Symbol(T, Decl(typeParameterHasSelfAsConstraint.ts, 0, 13)) +>T : Symbol(T, Decl(typeParameterHasSelfAsConstraint.ts, 0, 13)) +>x : Symbol(x, Decl(typeParameterHasSelfAsConstraint.ts, 0, 26)) +>T : Symbol(T, Decl(typeParameterHasSelfAsConstraint.ts, 0, 13)) + + return x; +>x : Symbol(x, Decl(typeParameterHasSelfAsConstraint.ts, 0, 26)) +} + + diff --git a/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=typesfirst).types new file mode 100644 index 0000000000000..dd8af60e8c209 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/typeParameterHasSelfAsConstraint(checkorder=typesfirst).types @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/typeParameterHasSelfAsConstraint.ts] //// + +=== typeParameterHasSelfAsConstraint.ts === +function foo(x: T): number { +>foo : (x: T) => number +>x : T + + return x; +>x : T +} + + diff --git a/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=default).errors.txt b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=default).errors.txt new file mode 100644 index 0000000000000..f2bff262ffc44 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=default).errors.txt @@ -0,0 +1,28 @@ +unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(1,18): error TS6133: 'person' is declared but its value is never read. +unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(1,34): error TS6133: 'person2' is declared but its value is never read. +unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,14): error TS6133: 'maker' is declared but its value is never read. +unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,20): error TS6133: 'child' is declared but its value is never read. +unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. + + +==== unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts (6 errors) ==== + function greeter(person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but its value is never read. + function maker(child: string): void { + ~~~~~ +!!! error TS6133: 'maker' is declared but its value is never read. + ~~~~~ +!!! error TS6133: 'child' is declared but its value is never read. + var unused2 = 22; + ~~~~~~~ +!!! error TS6133: 'unused2' is declared but its value is never read. + } + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=default).js b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=default).js new file mode 100644 index 0000000000000..9457d5135a002 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=default).js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts] //// + +//// [unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts] +function greeter(person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} + +//// [unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.js] +"use strict"; +function greeter(person, person2) { + var unused = 20; + function maker(child) { + var unused2 = 22; + } + person2 = "dummy value"; +} diff --git a/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=default).symbols b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=default).symbols new file mode 100644 index 0000000000000..7f6c7e03b1461 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=default).symbols @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts] //// + +=== unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts === +function greeter(person: string, person2: string) { +>greeter : Symbol(greeter, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 0, 0)) +>person : Symbol(person, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 0, 17)) +>person2 : Symbol(person2, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 0, 32)) + + var unused = 20; +>unused : Symbol(unused, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 1, 7)) + + function maker(child: string): void { +>maker : Symbol(maker, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 1, 20)) +>child : Symbol(child, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 2, 19)) + + var unused2 = 22; +>unused2 : Symbol(unused2, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 3, 11)) + } + person2 = "dummy value"; +>person2 : Symbol(person2, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 0, 32)) +} diff --git a/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=default).types b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=default).types new file mode 100644 index 0000000000000..0a0c9a1359a5f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=default).types @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts] //// + +=== unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts === +function greeter(person: string, person2: string) { +>greeter : (person: string, person2: string) => void +>person : string +>person2 : string + + var unused = 20; +>unused : number +>20 : 20 + + function maker(child: string): void { +>maker : (child: string) => void +>child : string + + var unused2 = 22; +>unused2 : number +>22 : 22 + } + person2 = "dummy value"; +>person2 = "dummy value" : "dummy value" +>person2 : string +>"dummy value" : "dummy value" +} diff --git a/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=typesfirst).errors.txt b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=typesfirst).errors.txt new file mode 100644 index 0000000000000..387fe2f14d0be --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=typesfirst).errors.txt @@ -0,0 +1,25 @@ +unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(1,18): error TS6133: 'person' is declared but its value is never read. +unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,14): error TS6133: 'maker' is declared but its value is never read. +unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,20): error TS6133: 'child' is declared but its value is never read. +unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. + + +==== unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts (5 errors) ==== + function greeter(person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but its value is never read. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but its value is never read. + function maker(child: string): void { + ~~~~~ +!!! error TS6133: 'maker' is declared but its value is never read. + ~~~~~ +!!! error TS6133: 'child' is declared but its value is never read. + var unused2 = 22; + ~~~~~~~ +!!! error TS6133: 'unused2' is declared but its value is never read. + } + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=typesfirst).js b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=typesfirst).js new file mode 100644 index 0000000000000..9457d5135a002 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=typesfirst).js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts] //// + +//// [unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts] +function greeter(person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} + +//// [unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.js] +"use strict"; +function greeter(person, person2) { + var unused = 20; + function maker(child) { + var unused2 = 22; + } + person2 = "dummy value"; +} diff --git a/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=typesfirst).symbols b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=typesfirst).symbols new file mode 100644 index 0000000000000..7f6c7e03b1461 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=typesfirst).symbols @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts] //// + +=== unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts === +function greeter(person: string, person2: string) { +>greeter : Symbol(greeter, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 0, 0)) +>person : Symbol(person, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 0, 17)) +>person2 : Symbol(person2, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 0, 32)) + + var unused = 20; +>unused : Symbol(unused, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 1, 7)) + + function maker(child: string): void { +>maker : Symbol(maker, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 1, 20)) +>child : Symbol(child, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 2, 19)) + + var unused2 = 22; +>unused2 : Symbol(unused2, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 3, 11)) + } + person2 = "dummy value"; +>person2 : Symbol(person2, Decl(unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts, 0, 32)) +} diff --git a/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=typesfirst).types b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=typesfirst).types new file mode 100644 index 0000000000000..0a0c9a1359a5f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1(checkorder=typesfirst).types @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts] //// + +=== unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts === +function greeter(person: string, person2: string) { +>greeter : (person: string, person2: string) => void +>person : string +>person2 : string + + var unused = 20; +>unused : number +>20 : 20 + + function maker(child: string): void { +>maker : (child: string) => void +>child : string + + var unused2 = 22; +>unused2 : number +>22 : 22 + } + person2 = "dummy value"; +>person2 = "dummy value" : "dummy value" +>person2 : string +>"dummy value" : "dummy value" +} diff --git a/tsc/testdata/baselines/reference/compiler/varianceCircularConsistency.errors.txt b/tsc/testdata/baselines/reference/compiler/varianceCircularConsistency.errors.txt new file mode 100644 index 0000000000000..a4725d41bf2bf --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/varianceCircularConsistency.errors.txt @@ -0,0 +1,48 @@ +varianceCircularConsistency.ts(26,7): error TS2322: Type 'Ref>' is not assignable to type 'Ref, never, never, {}>>'. + Type 'EntryPointComponent<{ q: { readonly variables: { slug: string; }; }; }, never, never, {}>' is not assignable to type 'EntryPointComponent, never, never, {}>'. + Type '(props: Props<{ q: { readonly variables: { slug: string; }; }; }, never, never, {}>) => void' is not assignable to type 'EntryPointComponent, never, never, {}>'. + Type '(props: Props<{ q: { readonly variables: { slug: string; }; }; }, never, never, {}>) => void' is not assignable to type '(props: Props, never, never, {}>) => void'. + Types of parameters 'props' and 'props' are incompatible. + Type 'Props, never, never, {}>' is not assignable to type 'Props<{ q: { readonly variables: { slug: string; }; }; }, never, never, {}>'. + Types of property 'queries' are incompatible. + Property 'q' is missing in type 'Record' but required in type '{ q: { readonly variables: { slug: string; }; }; }'. + + +==== varianceCircularConsistency.ts (1 errors) ==== + // Variances of these mutually recursive generics must not depend on values + // measured mid-cycle. Assigning `e` to `EntryPoint` must agree with + // assigning `e.root` to `EntryPoint["root"]`. + + interface Query {} + type Component