When utilizing TypeScript, the following code:
const x = 1;
Typically infers the type of x as number. Is it possible to specify that TypeScript infer the type as 1
? (Restricting it to only be assigned the value 1).
Similarly, with this code block:
const x: {
name: 'Name',
age: 0,
}
Is there a way to have TypeScript infer the type of x as:
{
name: 'Name',
age: 0,
}
I recall seeing a keyword for this functionality before, but I'm unable to locate it now.