Skip to content

Support libraries using auto decorators in tspd - #11813

Draft
Timothee Guerin (timotheeguerin) wants to merge 2 commits into
microsoft:mainfrom
timotheeguerin:tspd-auto-decorator-support
Draft

Support libraries using auto decorators in tspd#11813
Timothee Guerin (timotheeguerin) wants to merge 2 commits into
microsoft:mainfrom
timotheeguerin:tspd-auto-decorator-support

Conversation

@timotheeguerin

@timotheeguerin Timothee Guerin (timotheeguerin) commented Sep 2, 2026

Copy link
Copy Markdown
Member

Two things stand in the way of a library shipping auto dec in its public API.

tspd never loads the library's own tspconfig.yaml. Every compile() call site passes only
parseOptions, so any compiler feature the library opts into is invisible. @typespec/graphql shows
the symptom today — its regen-docs prints one error per auto decorator:

error auto-decorator-disabled: Auto decorators are experimental. Enable the `auto-decorators` feature...

Fixed by running the library's entrypoint through the existing resolveCompilerOptions and handing
the result to compile(), with noEmit: true since tspd only ever inspects a library.

Generated accessors carried no doc comment, so a library re-exporting one failed api-extractor's
ae-undocumented rule. They now inherit the description of the decorator they read or write, which
is already the source of truth in the .tsp:

/**
 * Mark a field, operation, or type as nullable in the emitted GraphQL schema.
 *
 * Applied automatically by the mutation engine when it strips `| null` from
 * union types, and can also be applied directly in TypeSpec source.
 */
export function isNullable(program: Program, target: ModelProperty | Operation | Union | Model): boolean

Only the description is carried over; the decorator's @param tags describe its TypeSpec parameters,
which do not line up with the accessor signatures. A decorator with no doc still generates no doc.

One detail worth knowing for anyone touching this later: the doc is emitted as a standalone comment
rather than through alloy's doc prop, because that prop also emits @param {Type} tags whose type
references count as value usages — which turns this file's type-only imports into value imports and
breaks verbatimModuleSyntax.

The only output change is @typespec/graphql's regenerated signatures.

@pkg-pr-new

pkg-pr-new Bot commented Sep 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/graphql@11813
npm i https://pkg.pr.new/@typespec/tspd@11813

commit: d989d8b

@microsoft-github-policy-service microsoft-github-policy-service Bot added the tspd Issues for the tspd tool label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/graphql
  • @typespec/tspd
Show changes

@typespec/graphql - internal ✏️

Regenerate the decorator signatures to pick up the doc comments now emitted for auto decorator,> accessors.

@typespec/tspd - fix ✏️

Document the generated auto decorator accessors with the description of the decorator they read or,> write, so libraries re-exporting them satisfy api-extractor's ae-undocumented rule.,> ,> ts,> /** Mark a model as a GraphQL input type in the emitted schema. */,> export function isInputType(program: Program, target: Model): boolean {,> return hasAutoDecorator(program, "TypeSpec.GraphQL.inputType", target);,> },>

@typespec/tspd - fix ✏️

Honor the library's own tspconfig.yaml when generating signatures and reference documentation, so,> libraries that opt into a compiler feature (such as auto-decorators) no longer report errors during,> gen-extern-signature and doc.

@timotheeguerin Timothee Guerin (timotheeguerin) changed the title Honor the library's tspconfig.yaml in tspd Support libraries using auto decorators in tspd Sep 2, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:graphql Issues for @typespec/graphql emitter label Sep 2, 2026
Load the config file when compiling a library for signature generation and
reference docs, so features it opts into (such as auto-decorators) apply.
Use the decorator's own description so libraries re-exporting the accessors
satisfy api-extractor.
@azure-sdk-automation

azure-sdk-automation Bot commented Sep 2, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:graphql Issues for @typespec/graphql emitter tspd Issues for the tspd tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant