microsoft / microsoft/TypeScript
Ghost error in a circular situation
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
### 🔎 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([]);
```
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con il repro fourslash.ts incorporato e confronta le diagnostiche con e senza verify.quickInfoAt("1", `(getter) parent: any`). Traccia il caso di mapped type circolare introdotto da PR 58337, usando come verifica l’asserzione fallita verify.getSemanticDiagnostics([]). Il lavoro è completato quando entrambe le varianti producono lo stesso numero di errori e le quick info riportate rimangono corrette.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100