Skip to content

Conversation

@bterlson
Copy link
Member

@bterlson bterlson commented Jan 13, 2026

The declaration provider is an abstraction that allows for the emitter framework to discover types it needs to emit, storing discovered types in a reactive array. This array is stored in context, allowing emitters to create multiple declarations for the same typespec type in different areas of their output. It also allows for emitter authors to control the logic of "what is a declaration" which is often emitter-specific. For more details, see this gist.

Suffix refkeys have been removed, the concept seemed not very useful since consumers could just provide the actual refkey to use instead (using a suffix approach if they feel like it).

This adopts declaration provider in the TypeScript emitter framework and updates http-client-js to take advantage of it. The changes required in http-client-js are mostly just to use the declaration provider instead of assuming the refkey convention EF used. Also fixed up some things I considered to be bugs (see the test changes).

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:js Issue for the JS client emitter: @typespec/http-client-js label Jan 13, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 13, 2026

Open in StackBlitz

npm i https://pkg.pr.new/microsoft/typespec/@typespec/emitter-framework@9352
npm i https://pkg.pr.new/microsoft/typespec/@typespec/http@9352
npm i https://pkg.pr.new/microsoft/typespec/@typespec/http-client@9352
npm i https://pkg.pr.new/microsoft/typespec/@typespec/http-client-js@9352

commit: 17ec28d

@github-actions
Copy link
Contributor

github-actions bot commented Jan 13, 2026

All changed packages have been documented.

  • @typespec/emitter-framework
  • @typespec/http-client-js
Show changes

@typespec/emitter-framework - feature ✏️

Add DeclarationProvider, a mechanism to reactively track declarations discovered as they are emitted.

@typespec/emitter-framework - breaking ✏️

TypeScript: Adopt DeclarationProvider, which changes how refkeys to declarations are assigned and referenced. The current provider vends fresh refkeys when needed, so refkey(type) is no longer a viable way to refer to declarations created by the emitter framework. Replace all forms of refkey(type) with dp.getRefkey(type).

@typespec/http-client-js - internal ✏️

Adopt EF changes.

@typespec/http-client-js - fix ✏️

Don't emit types for built-ins like floats and such (which were unused anyway).

@typespec/http-client-js - fix ✏️

Emit types for model is Record<T>.

@typespec/emitter-framework - breaking ✏️

TypeScript: remove notion of suffix refkey. Since its purpose is to create a unique refkey based on the suffix, users can just provide such a refkey instead of providing the suffix.

@typespec/emitter-framework - feature ✏️

Add refkey option to buildParameterDescriptor.

@azure-sdk
Copy link
Collaborator

azure-sdk commented Jan 13, 2026

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@bterlson bterlson enabled auto-merge January 16, 2026 00:14
@bterlson bterlson changed the title [WIP] Add declaration provider Add declaration provider Jan 16, 2026
@bterlson
Copy link
Member Author

Ok this is ready

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

Labels

emitter:client:js Issue for the JS client emitter: @typespec/http-client-js

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants