Comment

Comment by planede

I don't follow how this parameter works then in Record:

  const taskCounts = { work: 10, home: 5, personal: 3 };

  const what : Record<string, number> = taskCounts; // OK, covariance?
  const the : Record<"work" | "home", number> = taskCounts; // Also OK, contravariance?
  const hell : Record<"work" | "home" | "personal" | "hello", number> = taskCounts; // This is an error
https://www.typescriptlang.org/play?#code/MYewdgzgLgBFCGEDWB...
parent planede 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton