stephenh / ts-poet

A code generator DSL for typescript
Apache License 2.0
103 stars 13 forks source link

Add optional structure top of code blocks #20

Open stephenh opened 2 years ago

stephenh commented 2 years ago

I.e. to enable plugins/approaches like:

function myPlugin(output: TsProtoOutput) {
  const file = output.getFile("./simple.ts");
  const foo = file.getClass("FooRpcService");
  const getFoo = foo.getMethod("getFoo");
  foo.setMethod("getFoo", code`
    ...my customization...
    ${getFoo}
    ...my customization...
  `);
  return output;
}

Not sure if it's best to have full-fledged File / Class / Function / Method types, or if something as simple as object hashes would be good enough.