-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
Problem
The OnAfterGeneration hook and the Generate result provides a list of the output files but does not provide the metadata about the generation. Namely:
- Which types were included in the generation
- Metadata such as the name of the class/interface that was generated for the type
Reasoning
My use case is that after generating the TypeScript models, I would like to generate additional code manually.
Consider this case:
/**
* This is a TypeGen auto-generated file.
* Any changes made to this file can be lost when this file is regenerated.
*/
export interface Message1 {
text: string;
}
/**
* This is a TypeGen auto-generated file.
* Any changes made to this file can be lost when this file is regenerated.
*/
export interface Message2 {
text: string;
}
/**
* This is a TypeGen auto-generated file.
* Any changes made to this file can be lost when this file is regenerated.
*/
export * from './message1';
export * from './message2';Now I would like to reflect on the types that were included and manually produce another file:
import { Message1, Message2 } from "./index";
type MessageType = 'message-type-1' | 'message-type-2'
type MessageBase<T extends MessageType> = {
type: T;
};
type MessageType1 = Message1 & MessageBase<'message-type-1'>;
type MessageType2 = Message2 & MessageBase<'message-type-2'>;
type Message<T extends MessageType> =
// prettier-ignore
T extends 'message-type-1' ? MessageType1 :
T extends 'message-type-2' ? MessageType2 :
neverThe FileContentGenerated is close, but it only contains the fully rendered file contents and not the parts that may be relevant like the name of the class (which may have been customized with an attribute). It would be great to be able to access this metadata for additional file generation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels