microsoft / microsoft/TypeScript
unused type declaration causes totally unrelated error (Index signatures are incompatible)
Aperta
@armanio123 ci sta già lavorando.
Dal 2/8/2021.
Bug
Domain: check: Error Instability
Rescheduled
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
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);
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.
Valutazione
Questa issue non è ancora stata valutata.