Open utterances-bot opened 1 year ago
While the tuple
helper still has its place, TypeScript 4.9's satisfies
operator has made the last two examples obsolete.
Instead of withValueType<T>
, you can use satisfies Record<string, T>
:
const capitals = {
ny: [-73.7562, 42.6526],
ca: [-121.4944, 38.5816],
ak: [-134.4197, 58.3019],
} satisfies Record<string, Point>;
~Instead of withValueTypesFrom
, you can use satisfies Partial<T>
:~ This doesn't quite do the same thing!
Progress!
Use typed identity functions to guide type inference
Effective TypeScript: Use typed identity functions to guide type inference
https://effectivetypescript.com/2020/06/16/typed-identity-functions/