Skip to content

Conversation

@glecaros
Copy link

This pull request introduces the initial implementation of the TypeSpec built-in library for Alloy, providing core TypeSpec types, decorators, and supporting infrastructure for symbol creation, scoping, and global namespace management. The changes establish a system for describing TypeSpec libraries and their members, enable dynamic symbol creation, and add comprehensive tests for library creation and symbol resolution.

The most important changes are:

TypeSpec Built-in Library Implementation

  • Added the TypeSpec built-in library, including core TypeSpec data types and decorators, with descriptors for models, enums, scalars, and decorators in data-types.ts and decorators.ts. The library is exported via index.ts for consumption. [1] [2] [3] [4]

Library Creation and Symbol Management

  • Implemented the createLibrary function and supporting types in create-library.ts to allow dynamic creation of TypeSpec libraries and their symbols, with support for nested namespaces, lazy member initialization, and reference resolution.

Global Namespace and Context Management

  • Added global namespace management utilities in contexts/global-namespace.ts, including functions to get, use, and reset the global namespace, and exported these via contexts/index.ts. [1] [2]

Scoping Infrastructure

  • Introduced scope classes for organizing symbols and output: DirectoryScope, NamespaceScope, NamedTypeScope, and SourceFileScope, supporting hierarchical organization and tracking of used namespaces. [1] [2] [3] [4] [5]

Testing and Exports

  • Added comprehensive tests for library creation, symbol resolution, nested namespaces, and reference handling in create-library.test.ts. Updated exports to expose new modules and symbols. [1] [2] [3]

These changes lay the foundation for Alloy's TypeSpec support, enabling extensible type libraries, symbol referencing, and organized output generation.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 18, 2026

Open in StackBlitz

npm i https://pkg.pr.new/alloy-framework/alloy/@alloy-js/typespec@352

commit: cc021cd

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant