Is there any equivalent in TypeScript to the following code snippet?
type TypeA = { x: number };
printType(TypeA);
I have found a method that consistently enables TypeScript to provide a type description.
const y = {
x: 1,
z: 'hello',
};
const z: never = y;
Whenever attempting to assign to a never
type, an error message is generated which includes details about the type of the value being assigned.
Type '{ x: number; z: string; }' is not assignable to type 'never'.
This technique does have limitations as it necessitates the use of a tangible variable.
Are there any alternative methods available?