microsoft / microsoft/TypeScript
unused type declaration causes totally unrelated error (Index signatures are incompatible)
Abierto
@armanio123 ya está trabajando en esto.
Desde el 2/8/2021.
Bug
Domain: check: Error Instability
Rescheduled
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
Bug Report
🕗 Version & Regression Information
Getting same error on all versions I tried.
⏯ Playground Link
Playground link with relevant code
💻 Code
interface Ref<Prefix extends string> {
$ref: string;
prefix: Prefix;
}
type FFF = { faa: number };
// if you comment this line out the error will disappear
// NOTE THIS TYPE IS NOT USED AT ALL 😱
type KAMIKADZE = { asdasdasd: Record<string, FFF>; }
declare const x: {
responses: Record<string, number>;
fff: Record<string, FFF>;
};
// if you comment out first declaration of `KAMIKADZE` and uncomment this one
// THE ERROR WILL disappear 😱
// type KAMIKADZE = { asdasdasd: Record<string, FFF>; }
mustResolveRef({ $ref: "", prefix: "responses" }, x);
// ___^^^___
// Argument of type '{ responses: Record<string, number>; fff: Record<string, FFF>; }' is not assignable to parameter of type 'Record<"responses", Record<string, FFF>>'.
// Types of property 'responses' are incompatible.
// Type 'Record<string, number>' is not assignable to type 'Record<string, FFF>'.
// Index signatures are incompatible.
// Type 'number' is not assignable to type 'FFF'.
declare function mustResolveRef<T extends string, V>(
ref: Ref<T>,
components: Record<T, Record<string, V>>
): V | undefined
🙁 Actual behavior
Actual behavior is super strange. tried to express this in code comments.
🙂 Expected behavior
It's expected that, having some type declaration, that's not used and is not in conflict with anything, to not cause totally unrelated error.
Plus the error itself shouldn't be thrown as if I do this, all works fine:
const y: Pick<typeof x,"responses"> = x
mustResolveRef({ $ref: "", prefix: "responses" }, y);
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.
Evaluación
Este issue todavía no se ha evaluado.