Using satisfies with keyof and typeof in TypeScript
We're back to the configurations
object that includes development
, production
, and staging
. Each of these members contains specific settings relevant to its environment:
const configurations = { development: { apiBaseUrl: "http://localhost:8080", timeout: 5000, }, prod
Transcript
00:00 Here, we're back with our configurations object, which has development, production, and staging members of that object. We are basically saying type environment is key of type of configurations. We have development and production and staging being inferred from this. But we're expecting an error when we pass
00:18 something to this configurations object, which is not supposed to be there. Your job is to try to figure out how we can annotate configurations so that we still get environment properly inferred, but we get errors on this not allowed member on this value. Good luck.