-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Error InstabilityErrors appear or disappear based on order of checker operations, e.g. LS / tsc discrepanciesErrors appear or disappear based on order of checker operations, e.g. LS / tsc discrepanciesHelp WantedYou can do thisYou can do this
Milestone
Description
π Search Terms
ghost error circular error mapped type
π Version & Regression Information
- This changed in commit or PR Fix ghost errors resulting from out-of-order type checkingΒ #58337
β― 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.output
verify.quickInfoAt("1", `(getter) parent: ZodOptional<ZodObject<{
name: ZodString;
readonly parent: ZodOptional<ZodObject<...>>;
}>>`);
verify.getSemanticDiagnostics([]);Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Error InstabilityErrors appear or disappear based on order of checker operations, e.g. LS / tsc discrepanciesErrors appear or disappear based on order of checker operations, e.g. LS / tsc discrepanciesHelp WantedYou can do thisYou can do this