I'm trying to generate some type declarations for a project. The main idea here is that I got to a point where I am able to generate something like this:
type T = typeof import("somepath").default
Where default is a function.
The code that does this is:
ts.createTypeAliasDeclaration(
undefined,
undefined,
ts.createIdentifier("T"),
undefined,
ts.createTypeOf(
ts.createPropertyAccess(
ts.createCall(
ts.createToken(ts.SyntaxKind.ImportKeyword),
undefined,
[ts.createStringLiteral("somepath")]
),
ts.createIdentifier("default"))
),
undefined,
true
);
After printing that to the console I can see the output of that is indeed:
type T = typeof import("somepath").default
Now I have a variable, say t that holds the node of that type alias declaration, but when I try to extract the type with the type checker I keep getting any.
So far I've tried checker.getTypeAtLocation and checker.getTypeFromTypeNode but I keep getting any no matter what I try (I checked manually and vscode can indeed verify the type is not any).
Any help would be much appreciated, Thanks!