diff --git a/packages/typescript/src/enums/objectFlags.enum.ts b/packages/typescript/src/enums/objectFlags.enum.ts index 63ed4e4d3c93f..d6bf418f148ff 100644 --- a/packages/typescript/src/enums/objectFlags.enum.ts +++ b/packages/typescript/src/enums/objectFlags.enum.ts @@ -36,8 +36,7 @@ export enum ObjectFlags { IsClassInstanceClone = 1 << 26, IdenticalBaseTypeCalculated = 1 << 27, IdenticalBaseTypeExists = 1 << 28, - UnresolvedMembers = 1 << 29, - FromTypeNode = 1 << 30, + FromTypeNode = 1 << 29, IsGenericTypeComputed = 1 << 22, IsGenericObjectType = 1 << 23, IsGenericIndexType = 1 << 24, diff --git a/packages/typescript/src/enums/objectFlags.ts b/packages/typescript/src/enums/objectFlags.ts index 1c17a70d5f797..71d0b8b008110 100644 --- a/packages/typescript/src/enums/objectFlags.ts +++ b/packages/typescript/src/enums/objectFlags.ts @@ -36,8 +36,7 @@ export var ObjectFlags: any; ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 67108864] = "IsClassInstanceClone"; ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 134217728] = "IdenticalBaseTypeCalculated"; ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 268435456] = "IdenticalBaseTypeExists"; - ObjectFlags[ObjectFlags["UnresolvedMembers"] = 536870912] = "UnresolvedMembers"; - ObjectFlags[ObjectFlags["FromTypeNode"] = 1073741824] = "FromTypeNode"; + ObjectFlags[ObjectFlags["FromTypeNode"] = 536870912] = "FromTypeNode"; ObjectFlags[ObjectFlags["IsGenericTypeComputed"] = 4194304] = "IsGenericTypeComputed"; ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; ObjectFlags[ObjectFlags["IsGenericIndexType"] = 16777216] = "IsGenericIndexType"; diff --git a/tsc/internal/api/enum_values_generated.go b/tsc/internal/api/enum_values_generated.go index 678051b687573..3859fabba4411 100644 --- a/tsc/internal/api/enum_values_generated.go +++ b/tsc/internal/api/enum_values_generated.go @@ -237,7 +237,6 @@ func main() { "IsClassInstanceClone": toInt32(checker.ObjectFlagsIsClassInstanceClone), "IdenticalBaseTypeCalculated": toInt32(checker.ObjectFlagsIdenticalBaseTypeCalculated), "IdenticalBaseTypeExists": toInt32(checker.ObjectFlagsIdenticalBaseTypeExists), - "UnresolvedMembers": toInt32(checker.ObjectFlagsUnresolvedMembers), "FromTypeNode": toInt32(checker.ObjectFlagsFromTypeNode), "IsGenericTypeComputed": toInt32(checker.ObjectFlagsIsGenericTypeComputed), "IsGenericObjectType": toInt32(checker.ObjectFlagsIsGenericObjectType), diff --git a/tsc/internal/checker/checker.go b/tsc/internal/checker/checker.go index 8aec6df21d7af..37765dd836ea8 100644 --- a/tsc/internal/checker/checker.go +++ b/tsc/internal/checker/checker.go @@ -234,10 +234,9 @@ type IterationTypesKey struct { // PropertiesTypesKey type PropertiesTypesKey struct { - typeId TypeId - include TypeFlags - includeOrigin bool - unresolvedMembers bool + typeId TypeId + include TypeFlags + includeOrigin bool } // NonExistentPropertyKey @@ -596,7 +595,7 @@ type Checker struct { SignatureCount uint32 TotalInstantiationCount uint32 instantiationCount uint32 - instantiationDepth uint32 + instantiationStack []*Type conditionalConstraintDepth uint32 inlineLevel int serializationLevel int @@ -4720,7 +4719,7 @@ basePropertyCheck: c.error(errorNode, diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, memberInfo.typeName, missedProperty, memberInfo.baseTypeName) } case len(memberInfo.missedProperties) > 5: - missedProperties := strings.Join(core.Map(memberInfo.missedProperties[:4], func(prop string) string { return "'" + prop + "'" }), ", ") + missedProperties := quotedAndCommaSeparated(memberInfo.missedProperties[:4]) remainingMissedProperties := len(memberInfo.missedProperties) - 4 if ast.IsClassExpression(errorNode) { c.error(errorNode, diagnostics.Non_abstract_class_expression_is_missing_implementations_for_the_following_members_of_0_Colon_1_and_2_more, memberInfo.baseTypeName, missedProperties, remainingMissedProperties) @@ -4728,7 +4727,7 @@ basePropertyCheck: c.error(errorNode, diagnostics.Non_abstract_class_0_is_missing_implementations_for_the_following_members_of_1_Colon_2_and_3_more, memberInfo.typeName, memberInfo.baseTypeName, missedProperties, remainingMissedProperties) } default: - missedProperties := strings.Join(core.Map(memberInfo.missedProperties, func(prop string) string { return "'" + prop + "'" }), ", ") + missedProperties := quotedAndCommaSeparated(memberInfo.missedProperties) if ast.IsClassExpression(errorNode) { c.error(errorNode, diagnostics.Non_abstract_class_expression_is_missing_implementations_for_the_following_members_of_0_Colon_1, memberInfo.baseTypeName, missedProperties) } else { @@ -19461,9 +19460,7 @@ func (c *Checker) resolveObjectTypeMembers(t *Type, source *Type, typeParameters if !instantiated { members = maps.Clone(members) } - c.setStructuredTypeMembers(t, members, callSignatures, constructSignatures, indexInfos) thisArgument := core.LastOrNil(typeArguments) - t.objectFlags |= ObjectFlagsUnresolvedMembers for _, baseType := range baseTypes { instantiatedBaseType := baseType if thisArgument != nil { @@ -19482,7 +19479,6 @@ func (c *Checker) resolveObjectTypeMembers(t *Type, source *Type, typeParameters return findIndexInfo(indexInfos, info.keyType) == nil })) } - t.objectFlags &^= ObjectFlagsUnresolvedMembers } c.setStructuredTypeMembers(t, members, callSignatures, constructSignatures, indexInfos) } @@ -22461,14 +22457,22 @@ func (c *Checker) instantiateTypeWithAlias(t *Type, m *TypeMapper, alias *TypeAl if t == nil || m == nil || !(c.couldContainTypeVariables(t) || (t.alias != nil && len(t.alias.typeArguments) > 0 && core.Some(t.alias.typeArguments, c.couldContainTypeVariables))) { return t } - if c.instantiationDepth == 100 || c.instantiationCount >= 5_000_000 { + if len(c.instantiationStack) == 100 || c.instantiationCount >= 5_000_000 { // We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement // or expression. There is a very high likelihood we're dealing with a combination of infinite generic types // that perpetually generate new type identities, so we stop the recursion here by yielding the error type. if tr := c.tracer; tr != nil { - tr.Instant(tracing.PhaseCheckTypes, "instantiateType_DepthLimit", map[string]any{"typeId": t.id, "instantiationDepth": c.instantiationDepth, "instantiationCount": c.instantiationCount}) + tr.Instant(tracing.PhaseCheckTypes, "instantiateType_DepthLimit", map[string]any{"typeId": t.id, "instantiationDepth": len(c.instantiationStack), "instantiationCount": c.instantiationCount}) + } + circularTypeNames := c.getCircularTypeNames() + switch { + case len(circularTypeNames) == 1: + c.error(c.currentNode, diagnostics.Instantiations_of_type_0_appear_infinitely_circular, circularTypeNames[0]) + case len(circularTypeNames) > 1: + c.error(c.currentNode, diagnostics.Instantiations_of_the_following_types_appear_infinitely_circular_Colon_0, quotedAndCommaSeparated(circularTypeNames)) + default: + c.error(c.currentNode, diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite) } - c.error(c.currentNode, diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite) return c.errorType } index := c.findActiveMapper(m) @@ -22485,17 +22489,38 @@ func (c *Checker) instantiateTypeWithAlias(t *Type, m *TypeMapper, alias *TypeAl } c.TotalInstantiationCount++ c.instantiationCount++ - c.instantiationDepth++ + c.instantiationStack = append(c.instantiationStack, t) result := c.instantiateTypeWorker(t, m, alias) if index == -1 { c.popActiveMapper() } else { cache[key] = result } - c.instantiationDepth-- + c.instantiationStack[len(c.instantiationStack)-1] = nil + c.instantiationStack = c.instantiationStack[:len(c.instantiationStack)-1] return result } +func (c *Checker) getCircularTypeNames() []string { + typeCounts := make(map[*Type]int) + var circularTypeNames []string + for _, t := range c.instantiationStack { + typeCounts[t] = typeCounts[t] + 1 + if typeCounts[t] == 3 { + symbol := t.symbol + if t.alias != nil { + symbol = t.alias.symbol + } + if symbol != nil && len(symbol.Name) != 0 && symbol.Name[0] != '\xFE' { + if name := c.SymbolToString(symbol); !slices.Contains(circularTypeNames, name) { + circularTypeNames = append(circularTypeNames, name) + } + } + } + } + return circularTypeNames +} + func (c *Checker) pushActiveMapper(mapper *TypeMapper) { c.activeMappers = append(c.activeMappers, mapper) @@ -27113,7 +27138,7 @@ func (c *Checker) getExtractStringType(t *Type) *Type { } func (c *Checker) getLiteralTypeFromProperties(t *Type, include TypeFlags, includeOrigin bool) *Type { - key := PropertiesTypesKey{typeId: t.id, include: include, includeOrigin: includeOrigin, unresolvedMembers: t.objectFlags&ObjectFlagsUnresolvedMembers != 0} + key := PropertiesTypesKey{typeId: t.id, include: include, includeOrigin: includeOrigin} if cached, ok := c.propertiesTypes[key]; ok { return cached } diff --git a/tsc/internal/checker/types.go b/tsc/internal/checker/types.go index 1ec80b0a26f62..bd4e3e0f3657a 100644 --- a/tsc/internal/checker/types.go +++ b/tsc/internal/checker/types.go @@ -642,8 +642,7 @@ const ( // Flags that require TypeFlags.Object and ObjectFlags.Reference ObjectFlagsIdenticalBaseTypeCalculated = 1 << 27 // has had `getSingleBaseForNonAugmentingSubtype` invoked on it already ObjectFlagsIdenticalBaseTypeExists = 1 << 28 // has a defined cachedEquivalentBaseType member - ObjectFlagsUnresolvedMembers = 1 << 29 // Member resolution in process - ObjectFlagsFromTypeNode = 1 << 30 // Originates in resolution of AST type node + ObjectFlagsFromTypeNode = 1 << 29 // Originates in resolution of AST type node // Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution ObjectFlagsIsGenericTypeComputed = 1 << 22 // IsGenericObjectType flag has been computed ObjectFlagsIsGenericObjectType = 1 << 23 // Union or intersection contains generic object type diff --git a/tsc/internal/checker/utilities.go b/tsc/internal/checker/utilities.go index 0a68372fcef3c..19b8416edf4b6 100644 --- a/tsc/internal/checker/utilities.go +++ b/tsc/internal/checker/utilities.go @@ -1908,3 +1908,7 @@ func GetSetAccessorValueParameter(accessor *ast.Node) *ast.Node { } return nil } + +func quotedAndCommaSeparated(items []string) string { + return strings.Join(core.Map(items, func(item string) string { return "'" + item + "'" }), ", ") +} diff --git a/tsc/internal/diagnostics/diagnosticMessages.json b/tsc/internal/diagnostics/diagnosticMessages.json index 8fef6d37ff389..ef39bc97661ff 100644 --- a/tsc/internal/diagnostics/diagnosticMessages.json +++ b/tsc/internal/diagnostics/diagnosticMessages.json @@ -4772,6 +4772,14 @@ "category": "Error", "code": 5113 }, + "Instantiations of type '{0}' appear infinitely circular.": { + "category": "Error", + "code": 5114 + }, + "Instantiations of the following types appear infinitely circular: {0}.": { + "category": "Error", + "code": 5115 + }, "Generates a sourcemap for each corresponding '.d.ts' file.": { "category": "Message", diff --git a/tsc/internal/diagnostics/diagnostics_generated.go b/tsc/internal/diagnostics/diagnostics_generated.go index abab44d7a6fab..7a0085d1c157b 100644 --- a/tsc/internal/diagnostics/diagnostics_generated.go +++ b/tsc/internal/diagnostics/diagnostics_generated.go @@ -2388,6 +2388,10 @@ var X_tsconfig_json_is_present_but_will_not_be_loaded_if_files_are_specified_on_ var X_0_is_only_assignable_to_the_non_distributed_1_but_1_has_been_distributed_here = &Message{code: 5113, category: CategoryError, key: "_0_is_only_assignable_to_the_non_distributed_1_but_1_has_been_distributed_here_5113", text: "'{0}' is only assignable to the non-distributed '{1}', but '{1}' has been distributed here."} +var Instantiations_of_type_0_appear_infinitely_circular = &Message{code: 5114, category: CategoryError, key: "Instantiations_of_type_0_appear_infinitely_circular_5114", text: "Instantiations of type '{0}' appear infinitely circular."} + +var Instantiations_of_the_following_types_appear_infinitely_circular_Colon_0 = &Message{code: 5115, category: CategoryError, key: "Instantiations_of_the_following_types_appear_infinitely_circular_Colon_0_5115", text: "Instantiations of the following types appear infinitely circular: {0}."} + var Generates_a_sourcemap_for_each_corresponding_d_ts_file = &Message{code: 6000, category: CategoryMessage, key: "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", text: "Generates a sourcemap for each corresponding '.d.ts' file."} var Concatenate_and_emit_output_to_single_file = &Message{code: 6001, category: CategoryMessage, key: "Concatenate_and_emit_output_to_single_file_6001", text: "Concatenate and emit output to single file."} @@ -6816,6 +6820,10 @@ func keyToMessage(key Key) *Message { return X_tsconfig_json_is_present_but_will_not_be_loaded_if_files_are_specified_on_commandline_Use_ignoreConfig_to_skip_this_error case "_0_is_only_assignable_to_the_non_distributed_1_but_1_has_been_distributed_here_5113": return X_0_is_only_assignable_to_the_non_distributed_1_but_1_has_been_distributed_here + case "Instantiations_of_type_0_appear_infinitely_circular_5114": + return Instantiations_of_type_0_appear_infinitely_circular + case "Instantiations_of_the_following_types_appear_infinitely_circular_Colon_0_5115": + return Instantiations_of_the_following_types_appear_infinitely_circular_Colon_0 case "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000": return Generates_a_sourcemap_for_each_corresponding_d_ts_file case "Concatenate_and_emit_output_to_single_file_6001": diff --git a/tsc/internal/fourslash/tests/noGhostErrors_test.go b/tsc/internal/fourslash/tests/noGhostErrors_test.go new file mode 100644 index 0000000000000..01a8303a8e72b --- /dev/null +++ b/tsc/internal/fourslash/tests/noGhostErrors_test.go @@ -0,0 +1,61 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/TypeScript/tsc/internal/fourslash" + "github.com/microsoft/TypeScript/tsc/internal/testutil" +) + +func TestNoGhostErrors(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` +interface ZodType { + optional: "true" | "false"; + output: T; +} + +interface ZodString extends ZodType { + optional: "false"; +} + +type ZodShape = Record; +type Prettify = { [K in keyof T]: T[K] } & {}; +type InferObjectType = Prettify< + { + [k in keyof Shape as Shape[k] extends { optional: "true" } + ? k + : never]?: Shape[k]["output"]; + } & { + [k in keyof Shape as Shape[k] extends { optional: "true" } + ? never + : k]: Shape[k]["output"]; + } +>; +interface ZodObject extends ZodType> { + optional: "false"; +} + +interface ZodOptional> + extends ZodType { + optional: "true"; +} + +declare function object(shape: T): ZodObject; +declare function string(): ZodString; +declare function optional>(schema: T): ZodOptional; + +const Category = object({ + name: string(), + get parent/*1*/() { + return optional(Category); + }, +}); + +export const output = Category.output;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "1", "(accessor) parent: ZodOptional>;\n}>>", "") + f.VerifyDiagnostics(t, nil) +} diff --git a/tsc/testdata/baselines/reference/compiler/keyofGenericExtendingClassDoubleLayer.errors.txt b/tsc/testdata/baselines/reference/compiler/keyofGenericExtendingClassDoubleLayer.errors.txt index fcd3ce0adb0da..9808b4f1f9122 100644 --- a/tsc/testdata/baselines/reference/compiler/keyofGenericExtendingClassDoubleLayer.errors.txt +++ b/tsc/testdata/baselines/reference/compiler/keyofGenericExtendingClassDoubleLayer.errors.txt @@ -1,8 +1,9 @@ keyofGenericExtendingClassDoubleLayer.ts(2,12): error TS2564: Property 'createdAt' has no initializer and is not definitely assigned in the constructor. +keyofGenericExtendingClassDoubleLayer.ts(9,7): error TS5115: Instantiations of the following types appear infinitely circular: 'Model', 'ModelAttributes', 'Exclude'. keyofGenericExtendingClassDoubleLayer.ts(10,12): error TS2564: Property 'age' has no initializer and is not definitely assigned in the constructor. -==== keyofGenericExtendingClassDoubleLayer.ts (2 errors) ==== +==== keyofGenericExtendingClassDoubleLayer.ts (3 errors) ==== class Model { public createdAt: Date; ~~~~~~~~~ @@ -14,6 +15,8 @@ keyofGenericExtendingClassDoubleLayer.ts(10,12): error TS2564: Property 'age' ha class AutoModel extends Model> {} class PersonModel extends AutoModel { + ~~~~~~~~~~~ +!!! error TS5115: Instantiations of the following types appear infinitely circular: 'Model', 'ModelAttributes', 'Exclude'. public age: number; ~~~ !!! error TS2564: Property 'age' has no initializer and is not definitely assigned in the constructor. diff --git a/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations.errors.txt b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations.errors.txt index ff15ecc04b6f7..a1b033edf54ba 100644 --- a/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations.errors.txt +++ b/tsc/testdata/baselines/reference/compiler/limitDeepInstantiations.errors.txt @@ -1,4 +1,4 @@ -limitDeepInstantiations.ts(4,9): error TS2589: Type instantiation is excessively deep and possibly infinite. +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"'. @@ -8,7 +8,7 @@ limitDeepInstantiations.ts(5,13): error TS2344: Type '"false"' does not satisfy type Foo = { "true": Foo> }[T]; let f1: Foo<"true", {}>; ~~~~~~~~~~~~~~~ -!!! error TS2589: Type instantiation is excessively deep and possibly infinite. +!!! error TS5114: Instantiations of type 'Foo' appear infinitely circular. let f2: Foo<"false", {}>; ~~~~~~~ !!! error TS2344: Type '"false"' does not satisfy the constraint '"true"'. diff --git a/tsc/testdata/baselines/reference/compiler/mutuallyRecursiveInference.errors.txt b/tsc/testdata/baselines/reference/compiler/mutuallyRecursiveInference.errors.txt index 5b6b3f6f75a76..f267690f34e18 100644 --- a/tsc/testdata/baselines/reference/compiler/mutuallyRecursiveInference.errors.txt +++ b/tsc/testdata/baselines/reference/compiler/mutuallyRecursiveInference.errors.txt @@ -1,9 +1,10 @@ mutuallyRecursiveInference.ts(2,5): error TS2564: Property 'a' has no initializer and is not definitely assigned in the constructor. mutuallyRecursiveInference.ts(9,5): error TS2564: Property 'a' has no initializer and is not definitely assigned in the constructor. mutuallyRecursiveInference.ts(10,5): error TS2564: Property 'b' has no initializer and is not definitely assigned in the constructor. +mutuallyRecursiveInference.ts(12,9): error TS5114: Instantiations of type 'T' appear infinitely circular. -==== mutuallyRecursiveInference.ts (3 errors) ==== +==== mutuallyRecursiveInference.ts (4 errors) ==== class T { a: A; ~ @@ -22,6 +23,8 @@ mutuallyRecursiveInference.ts(10,5): error TS2564: Property 'b' has no initializ !!! error TS2564: Property 'b' has no initializer and is not definitely assigned in the constructor. m2() { this.a + ~~~~~~ +!!! error TS5114: Instantiations of type 'T' appear infinitely circular. } } \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/recursiveConditionalCrash4.errors.txt b/tsc/testdata/baselines/reference/compiler/recursiveConditionalCrash4.errors.txt index 9a55044866b75..b119a342d2de9 100644 --- a/tsc/testdata/baselines/reference/compiler/recursiveConditionalCrash4.errors.txt +++ b/tsc/testdata/baselines/reference/compiler/recursiveConditionalCrash4.errors.txt @@ -2,9 +2,9 @@ recursiveConditionalCrash4.ts(7,16): error TS2503: Cannot find namespace 'StrIte recursiveConditionalCrash4.ts(8,5): error TS2503: Cannot find namespace 'StrIter'. recursiveConditionalCrash4.ts(9,25): error TS2304: Cannot find name 'Add'. recursiveConditionalCrash4.ts(9,37): error TS2503: Cannot find namespace 'StrIter'. -recursiveConditionalCrash4.ts(10,7): error TS2589: Type instantiation is excessively deep and possibly infinite. +recursiveConditionalCrash4.ts(10,7): error TS5114: Instantiations of type 'LengthDown' appear infinitely circular. recursiveConditionalCrash4.ts(10,31): error TS2503: Cannot find namespace 'StrIter'. -recursiveConditionalCrash4.ts(16,7): error TS2589: Type instantiation is excessively deep and possibly infinite. +recursiveConditionalCrash4.ts(16,7): error TS5114: Instantiations of type 'Foo' appear infinitely circular. ==== recursiveConditionalCrash4.ts (7 errors) ==== @@ -27,7 +27,7 @@ recursiveConditionalCrash4.ts(16,7): error TS2589: Type instantiation is excessi !!! error TS2503: Cannot find namespace 'StrIter'. : LengthDown> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2589: Type instantiation is excessively deep and possibly infinite. +!!! error TS5114: Instantiations of type 'LengthDown' appear infinitely circular. ~~~~~~~ !!! error TS2503: Cannot find namespace 'StrIter'. : Length; @@ -37,6 +37,6 @@ recursiveConditionalCrash4.ts(16,7): error TS2589: Type instantiation is excessi ? Foo : Foo ~~~~~~~~~~~~ -!!! error TS2589: Type instantiation is excessively deep and possibly infinite. +!!! error TS5114: Instantiations of type 'Foo' appear infinitely circular. : unknown; \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/recursiveTypeInference.types b/tsc/testdata/baselines/reference/compiler/recursiveTypeInference.types index 914b8260ed821..ac57dc4d96cea 100644 --- a/tsc/testdata/baselines/reference/compiler/recursiveTypeInference.types +++ b/tsc/testdata/baselines/reference/compiler/recursiveTypeInference.types @@ -315,7 +315,7 @@ const Activity = z.object({ }, }); export type ActivityT = output; ->ActivityT : { name: string; subactivities: unknown; } +>ActivityT : { name: string; subactivities: { name: string; subactivities: any[] | null; }[] | null; } >Activity : $ZodObject<{ name: $ZodString; readonly subactivities: $ZodNullable<$ZodArray<$ZodObject>>; }> // (4) reference through a separately-declared const @@ -355,6 +355,6 @@ const NodeArray = z.array(Node1); >Node1 : $ZodObject<{ name: $ZodString; readonly children: $ZodOptional<$ZodArray<$ZodObject>>; }> export type Node1T = output; ->Node1T : { name: string; children?: unknown; } +>Node1T : { name: string; children?: { name: string; children?: any[] | undefined; }[] | undefined; } >Node1 : $ZodObject<{ name: $ZodString; readonly children: $ZodOptional<$ZodArray<$ZodObject>>; }> diff --git a/tsc/testdata/baselines/reference/conformance/recursiveMappedTypes.errors.txt b/tsc/testdata/baselines/reference/conformance/recursiveMappedTypes.errors.txt index 2d62cc6d80ce3..5d6e45f1ffa2e 100644 --- a/tsc/testdata/baselines/reference/conformance/recursiveMappedTypes.errors.txt +++ b/tsc/testdata/baselines/reference/conformance/recursiveMappedTypes.errors.txt @@ -4,7 +4,7 @@ recursiveMappedTypes.ts(7,6): error TS2456: Type alias 'Recurse1' circularly ref recursiveMappedTypes.ts(8,11): error TS2313: Type parameter 'K' has a circular constraint. recursiveMappedTypes.ts(11,6): error TS2456: Type alias 'Recurse2' circularly references itself. recursiveMappedTypes.ts(12,11): error TS2313: Type parameter 'K' has a circular constraint. -recursiveMappedTypes.ts(20,19): error TS2589: Type instantiation is excessively deep and possibly infinite. +recursiveMappedTypes.ts(20,19): error TS5114: Instantiations of type 'Circular' appear infinitely circular. recursiveMappedTypes.ts(73,5): error TS2502: '"each"' is referenced directly or indirectly in its own type annotation. recursiveMappedTypes.ts(79,1): error TS2615: Type of property '"each"' circularly references itself in mapped type '{ [P in keyof ListWidget]: undefined extends ListWidget[P] ? never : P; }'. @@ -44,7 +44,7 @@ recursiveMappedTypes.ts(79,1): error TS2615: Type of property '"each"' circularl function foo(arg: Circular): tup { ~~~~~~~~~~~~~ -!!! error TS2589: Type instantiation is excessively deep and possibly infinite. +!!! error TS5114: Instantiations of type 'Circular' appear infinitely circular. return arg; }