rushstack
rushstack copied to clipboard
[api-extractor] Generate .d.ts with fully compiled and inlined types
Summary
I would like to be able to generate a fully compiled and inlined .d.ts with only the exported types of the main file.
Details
Let's say I have an input file of:
export type { ResponseBodyType as ResultResBodyType } from '../result/index.js';
export type { BodyType as ResultReqBodyType } from '../result/modules/eventParser.js';
And want simply just:
// Just an example
export type ResultResBodyType =
| { issues: {message: string, fatal: boolean}[]; message?: undefined; result?: undefined }
| { message: string; issues?: undefined; result?: undefined }
export type ResultReqBodyType = { example: string };
Without any external libraries being put inside the declaration file. I want all the external things to be compiled.
The above would contain compiled types like usage of zod for example.
Currently instead I get a copy of the actual code.. Example:
import type { APIGatewayProxyEvent } from 'aws-lambda';
import type { Image } from '@aws-sdk/client-rekognition';
import { z } from './lib';
declare const handlerBodyZod = z.object({
accountNumber: z
.string()
.regex(ACCOUNT_REGEX, { message: 'Invalid AccountNumber Format' }),
});
declare const main = async (event: APIGatewayProxyEvent) => {
// Code of the whole main function
};
export declare type ResultReqBodyType = z.infer<typeof handlerBodyZod>;
export declare type ResultResBodyType = Awaited<ReturnType<typeof main>>['body'];
export { }
Thank you and really appreciate the work on the tool! 🙇