microsoft / microsoft/TypeScript
Ghost error in a circular situation
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
### 🔎 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([]);
```
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con la reproducción integrada de fourslash.ts y compara los diagnósticos con y sin verify.quickInfoAt("1", `(getter) parent: any`). Rastrea el caso de tipo mapeado circular introducido por PR 58337, usando como comprobación la aserción fallida verify.getSemanticDiagnostics([]). Se considera terminado cuando ambas variantes producen el mismo número de errores y la información rápida reportada sigue siendo correcta.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100