Skip to content

Instantly share code, notes, and snippets.

@dioxmio
Created November 12, 2022 20:17
Show Gist options
  • Save dioxmio/2f878a5221dd2d48e7a98cb48f43ee19 to your computer and use it in GitHub Desktop.
Save dioxmio/2f878a5221dd2d48e7a98cb48f43ee19 to your computer and use it in GitHub Desktop.
const foo = {
a: 255,
b: 255,
c: 255,
// ❌ We get the error Type 'string' is not assignable to type 'number'
d: 'bar'
} satisfies Record<string, number>;
// ✅ We are not loosing any type inferance information
// typeof foo is
// const foo: {
// a: number;
// b: number;
// c: number;
// d: string;
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment