3 ms·
Simple example: keyof allows you to safely describe objects which only partially fit an interface. interface Values { foo: string, // etc... } l
by ng12 10y ago
Simple example: keyof allows you to safely describe objects which only partially fit an interface.
interface Values {
foo: string,
// etc...
}
let keys: keyOf Values
function initialize(defaults: {[key: keys]: string}) {...}
Now the defaults object can only contain valid keys from Values.