Suggestion
π Search Terms
- getEmitResolver
- transform API
β
Viability Checklist
My suggestion meets these guidelines:
β Suggestion
transform API is quite nice and convenient because using this API doesn't need to invoke Program to compile ts to js to use custom AST transformers. However, it doesn't allow the case which requires to access to EmitResolver. It would be nice if transform API can allow users to pass getEmitResolver into the TransformationContext.
Currently, getEmitResolver isn't exposed for both TransformationContext as well as Program interfaces.
π Motivating Example
An ideal example would be like this
export function constructorParametersDownlevelTransform(program: ts.Program): ts.TransformerFactory<ts.SourceFile> {
const typeChecker = program.getTypeChecker();
const reflectionHost = new TypeScriptReflectionHost(typeChecker);
return (ctx: ts.TransformationContext) => {
return getDownlevelDecoratorsTransform(
typeChecker,
reflectionHost,
[],
false,
false,
true,
)({
...ctx,
getEmitResolver: ctx.getEmitResolver()
? ctx.getEmitResolver
: program.getDiagnosticsProducingTypeChecker().getEmitResolver,
});
};
}
π» Use Cases
I am trying to experiment the idea:
As far as I can tell, process AST with transform API is pretty fast. If I can process AST without using Program to do the full compilation step but use swc or esbuild to compile, that would help me to achieve the goal that: fast compilation + source is processed in such a way I want (Jest hoisting, Angular downlevel constructor etc...)
Suggestion
π Search Terms
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
transformAPI is quite nice and convenient because using this API doesn't need to invokeProgramto compiletstojsto use custom AST transformers. However, it doesn't allow the case which requires to access toEmitResolver. It would be nice iftransformAPI can allow users to passgetEmitResolverinto theTransformationContext.Currently,
getEmitResolverisn't exposed for bothTransformationContextas well asPrograminterfaces.π Motivating Example
An ideal example would be like this
π» Use Cases
I am trying to experiment the idea:
Use
transformAPI to process AST of TypeScript source codes with some custom AST transformers.Use
swcoresbuildto compiletstojswith the newly transformed source.As far as I can tell, process AST with
transformAPI is pretty fast. If I can process AST without usingProgramto do the full compilation step but useswcoresbuildto compile, that would help me to achieve the goal that: fast compilation + source is processed in such a way I want (Jest hoisting, Angular downlevel constructor etc...)