Say I have a typescript file containing the following:
// my-ts-file.ts
const inner = {
hello: "world",
};
export const value = {
prop1: "hello",
prop2: "world",
prop3: 42,
prop4: inner,
}
When I hover over this code in vscode, typescript correctly infers the type of the value
variable as the following:
const value: {
prop1: string;
prop2: string;
prop3: number;
prop4: {
hello: string;
};
}
Now, assume I want to write a separate program that reads the contents of my-ts-file.ts
above and parses + returns / converts the type of the exported const value
as a JSON such as the following:
{
"prop1": "string",
"prop2": "string",
"prop3": "number",
"prop4": {
"hello": "string"
}
}
Is this possible? And how would I go about doing this? What libraries / packages would make this possible.