Is there a way to extract specific type information directly from the TypeScript compiler using an API method? Here's an example:
interface User {
id: number
name: string
}
type NameOnly = Pick<User, 'name'>
type NameOnlyAliased = NameOnly
When hovering over NameOnlyAliased
in VSCode, it displays as:
type NameOnlyAliased = {
name: string;
}
My inquiry is whether there is a function available in the compiler API (or any other straightforward method without diving into aliases, Pick
, etc.) to retrieve the details on the right side of the =
shown above, potentially as structured data instead of just a string, like so:
{
NameAliasedOnly: {
properties: {
name: {
type: 'string'
}
}
}
}
The purpose here is to automatically generate code for creating fast-check
arbitraries based on type definitions (if such functionality already exists, that would be great). I've experimented with using ts-json-schema-generator
for this task, but it doesn't handle certain type definitions.