feat(compiler): add setAutoDecorator API and generate auto-decorator setters in tspd - #11247
Conversation
…setters - Add public `setAutoDecorator` to programmatically apply an auto decorator to a target, mirroring the synthesized `auto dec` implementation. - `tspd gen-extern-signature` now generates a typed `set*` setter for each auto decorator alongside the existing `is*`/`get*` readers. - `createTester` mounts each discovered library's `tspconfig.yaml` so library-opted-in experimental features (e.g. auto-decorators) are honored.
commit: |
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
Summary
Infrastructure for programmatically applying
autodecorators, extracted from the GraphQL emitter work.@typespec/compiler: Add a publicsetAutoDecorator(program, decoratorFqn, target, value?)API that programmatically applies anautodecorator to a target, storing its argument values the same way the synthesizedauto decimplementation does when the decorator is written in source. This lets emitters and mutators mark synthetic types without reaching into the program state map directly.@typespec/tspd:gen-extern-signaturenow generates a typedset*setter (e.g.setMyFlag,setMyLabel) for eachautodecorator, alongside the existingis*/get*readers. Single-arg setters accept the bare value (parity with theget*reader); multi-arg setters accept the{ paramName: value }record.@typespec/compiler(testing):createTesternow mounts each discovered library'stspconfig.yamlinto the virtual file system, so experimental features a library opts into (e.g.auto-decorators) are honored when compiling against the tester.Testing
setAutoDecorator(decorators.test.ts).gen-extern-signaturegolden tests to cover the generated setters (no-arg, single-arg, rest-arg, multi-arg).createTestertest verifying a library'stspconfig.yamlfeatures are honored (fails without the mount fix).