When we want to see variable's value, we just do console.log(someVar)
What about if we want to see what is there behind a type?
Example:
type SomeUnion = 'foo' | 'bar' | 'baz'
console.log(SomeUnion)
// of course above will not work, but what will do?
// is there any TS tool that I am missing?
P.S. For those who might not understand why would one need this, here is much more complex type (from TS docs):
type FunctionPropertyNames<T> = { [K in keyof T]:
T[K] extends Function ? K : never }[keyof T];
interface Part {
id: number;
name: string;
subparts: Part[];
updatePart(newName: string): void;
}
type T40 = FunctionPropertyNames<Part>; // "updatePart"
The last line has comment with what the type looks like. Currently what am I doing to find out if it really looks like this is something like:
let foo: T40 = 'bar' // gives error: type "bar" is not assignable to type "updatePart"
In other words, the only way to know what is hidden behind the type identifier is to generate a type error, which should not be the only way to do it.