Skip to content

feat(compiler): add setAutoDecorator API and generate auto-decorator setters in tspd - #11247

Merged
timotheeguerin merged 1 commit into
mainfrom
feature/auto-decorator-setter
Jul 14, 2026
Merged

feat(compiler): add setAutoDecorator API and generate auto-decorator setters in tspd#11247
timotheeguerin merged 1 commit into
mainfrom
feature/auto-decorator-setter

Conversation

@timotheeguerin

Copy link
Copy Markdown
Member

Summary

Infrastructure for programmatically applying auto decorators, extracted from the GraphQL emitter work.

  • @typespec/compiler: Add a public setAutoDecorator(program, decoratorFqn, target, value?) API that programmatically applies an auto decorator to a target, storing its argument values the same way the synthesized auto dec implementation does when the decorator is written in source. This lets emitters and mutators mark synthetic types without reaching into the program state map directly.

    import { setAutoDecorator } from "@typespec/compiler";
    
    setAutoDecorator(program, "MyLib.myFlag", target);
  • @typespec/tspd: gen-extern-signature now generates a typed set* setter (e.g. setMyFlag, setMyLabel) for each auto decorator, alongside the existing is*/get* readers. Single-arg setters accept the bare value (parity with the get* reader); multi-arg setters accept the { paramName: value } record.

  • @typespec/compiler (testing): createTester now mounts each discovered library's tspconfig.yaml into the virtual file system, so experimental features a library opts into (e.g. auto-decorators) are honored when compiling against the tester.

Testing

  • Added a unit test for setAutoDecorator (decorators.test.ts).
  • Updated tspd gen-extern-signature golden tests to cover the generated setters (no-arg, single-arg, rest-arg, multi-arg).
  • Added a createTester test verifying a library's tspconfig.yaml features are honored (fails without the mount fix).

…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.
@microsoft-github-policy-service microsoft-github-policy-service Bot added compiler:core Issues for @typespec/compiler tspd Issues for the tspd tool labels Jul 14, 2026
@timotheeguerin
timotheeguerin marked this pull request as ready for review July 14, 2026 15:14
@pkg-pr-new

pkg-pr-new Bot commented Jul 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/compiler@11247
npm i https://pkg.pr.new/@typespec/tspd@11247

commit: 6c0f023

@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/compiler
  • @typespec/tspd
Show changes

@typespec/compiler - feature ✏️

Add setAutoDecorator API to programmatically apply an auto decorator to a target, mirroring what the synthesized auto dec implementation does when the decorator is written in source. This lets emitters and mutators mark synthetic types without reaching into the program state map directly.,> ,> ts,> import { setAutoDecorator } from "@typespec/compiler";,> ,> setAutoDecorator(program, "MyLib.myFlag", target);,>

@typespec/compiler - feature ✏️

createTester now mounts each discovered library's tspconfig.yaml into the virtual file system, so experimental features a library opts into (e.g. auto-decorators) are honored when compiling against the tester.

@typespec/tspd - feature ✏️

tspd gen-extern-signature now also generates a typed setter (e.g. setMyFlag, setMyLabel) for each auto decorator, alongside the existing is*/get* readers.

@azure-sdk-automation

azure-sdk-automation Bot commented Jul 14, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@timotheeguerin
timotheeguerin enabled auto-merge July 14, 2026 15:57
@timotheeguerin
timotheeguerin disabled auto-merge July 14, 2026 16:04
@timotheeguerin
timotheeguerin merged commit dc88474 into main Jul 14, 2026
33 checks passed
@timotheeguerin
timotheeguerin deleted the feature/auto-decorator-setter branch July 14, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler tspd Issues for the tspd tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant