microsoft / microsoft/TypeScript

Ghost error in a circular situation

Đang mở
#62,181 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Bug Domain: check: Error Instability Help Wanted
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

### 🔎 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

```ts
///

// @strict: true
// @target: esnext
// @lib: esnext

//// 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;

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

```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;
//// 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";
//// output: InferObjectType;
//// }
////
//// interface ZodOptional extends ZodType {
//// optional: "true";
//// output: T["output"] | undefined;
//// }
////
//// 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

verify.quickInfoAt("1", `(getter) parent: ZodOptional>;
}>>`);
verify.getSemanticDiagnostics([]);
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với repro fourslash.ts được nhúng và so sánh các chẩn đoán có và không có verify.quickInfoAt("1", `(getter) parent: any`). Theo dõi trường hợp mapped type vòng được giới thiệu bởi PR 58337, sử dụng assertion verify.getSemanticDiagnostics([]) bị lỗi làm bước kiểm tra. Được coi là hoàn tất khi cả hai biến thể tạo ra cùng số lượng lỗi và quick info được báo cáo vẫn chính xác.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
typescript
Lĩnh vực
compilers
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.