Skip to content

Ghost error in a circular situation #62181

Description

🔎 Search Terms

ghost error circular error mapped type

🕗 Version & Regression Information

⏯ Playground Link

No response

💻 Code

/// <reference path="fourslash.ts" />// @strict: true// @target: esnext// @lib: esnext//// interface ZodType<T> {//// optional: "true" | "false";//// output: T;//// }//////// interface ZodString extends ZodType<string> {//// optional: "false";//// }//////// type ZodShape = Record<string, any>;//// type Prettify<T> = { [K in keyof T]: T[K] } & {};//// type InferObjectType<Shape extends ZodShape> = 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<T extends ZodShape> extends ZodType<InferObjectType<T>> {//// optional: "false";//// }//////// interface ZodOptional<T extends ZodType<any>>//// extends ZodType<T["output"] | undefined> {//// optional: "true";//// }//////// declare function object<T extends ZodShape>(shape: T): ZodObject<T>;//// declare function string(): ZodString;//// declare function optional<T extends ZodType<any>>(schema: T): ZodOptional<T>;//////// const Category = object({//// name: string(),//// get parent/*1*/() {//// return optional(Category);//// },//// });//////// export const output = Category.output;verify.quickInfoAt("1",`(getter) parent: any`);verify.getSemanticDiagnostics([]);

🙁 Actual behavior

Depending on the presence of verify.quickInfoAt("1", (getter) parent: any); the compiler produces 1 or 2 errors (observable in the expected output of the failing verify.getSemanticDiagnostics([]) assertion).

🙂 Expected behavior

I'd expect the error count to be the same.

Additional information about the issue

Relates to #62180

An extra test case that currently works OK but that suffered from a similar issue in the past:

an extra test case
/// <reference path="fourslash.ts" />// @strict: true// @target: esnext// @lib: esnext//// interface ZodType {//// optional: "true" | "false";//// output: any;//// }//////// interface ZodString extends ZodType {//// optional: "false";//// output: string;//// }//////// type ZodShape = Record<string, any>;//// type Prettify<T> = { [K in keyof T]: T[K] } & {};//// type InferObjectType<Shape extends ZodShape> = 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<T extends ZodShape> extends ZodType {//// optional: "false";//// output: InferObjectType<T>;//// }//////// interface ZodOptional<T extends ZodType> extends ZodType {//// optional: "true";//// output: T["output"] | undefined;//// }//////// declare function object<T extends ZodShape>(shape: T): ZodObject<T>;//// declare function string(): ZodString;//// declare function optional<T extends ZodType>(schema: T): ZodOptional<T>;//////// const Category = object({//// name: string(),//// get parent/*1*/() {//// return optional(Category);//// },//// });//////// export const output = Category.outputverify.quickInfoAt("1",`(getter) parent: ZodOptional<ZodObject<{ name: ZodString; readonly parent: ZodOptional<ZodObject<...>>;}>>`);verify.getSemanticDiagnostics([]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: check: Error InstabilityErrors appear or disappear based on order of checker operations, e.g. LS / tsc discrepanciesHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions