microsoft / microsoft/TypeScript
Ghost error in a circular situation
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
### 🔎 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([]);
```
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem eingebetteten fourslash.ts-Repro und vergleiche die Diagnosen mit und ohne verify.quickInfoAt("1", `(getter) parent: any`). Verfolge den zirkulären Mapped-Type-Fall, der durch PR 58337 eingeführt wurde, und verwende die fehlschlagende verify.getSemanticDiagnostics([])-Assertion als Prüfung. Fertig ist die Arbeit, wenn beide Varianten dieselbe Fehleranzahl erzeugen und die gemeldeten Quick-Info-Daten weiterhin korrekt sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100