microsoft / microsoft/TypeScript
unused type declaration causes totally unrelated error (Index signatures are incompatible)
Offen
@armanio123 arbeitet bereits daran.
Seit 02.8.2021.
Bug
Domain: check: Error Instability
Rescheduled
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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);
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.
Bewertung
Dieses Issue wurde noch nicht bewertet.