please see code sample below- i'd like some typesafety around the type of array entries that resetHistory takes in, but it's not creating a type error where i'd like it to! appreciate any tips.
type Params = {
profile: { userId: string };
homepage: undefined;
settings: { tab: "password" | "profile" };
};
// naive attempt at typing the history arg
function resetHistory<K extends keyof Params>(
history: { name: K; params: Params[K] }[]
) {
// ...
}
resetHistory([
{ name: "homepage", params: undefined },
{ name: "profile", params: { userId: "1234" } },
{ name: "settings", params: { userId: "xxx" } }, // <-- i want this to be a typeerror, and only accept { tab: "password" | "profile" }
]);