microsoft / microsoft/TypeScript
Ghost error in a circular situation
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
🔎 Search Terms
ghost error circular error mapped type
🕗 Version & Regression Information
- This changed in commit or PR https://github.com/microsoft/TypeScript/pull/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 https://github.com/microsoft/TypeScript/issues/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([]);
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
埋め込まれた fourslash.ts の再現コードから始め、verify.quickInfoAt("1", (getter) parent: any) の有無で診断を比較してください。PR 58337 で導入された循環 mapped type のケースを追跡し、失敗する verify.getSemanticDiagnostics([]) アサーションを確認に使用してください。完了条件は、両方のバリアントでエラー数が同じになり、報告される quick info が正しいままであることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100