[tsp] Adding symbols, scopes, createLibrary and some builtin types. #352
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
TypeSpecbuilt-in library, including core TypeSpec data types and decorators, with descriptors for models, enums, scalars, and decorators indata-types.tsanddecorators.ts. The library is exported viaindex.tsfor consumption. [1] [2] [3] [4]Library Creation and Symbol Management
createLibraryfunction and supporting types increate-library.tsto 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
contexts/global-namespace.ts, including functions to get, use, and reset the global namespace, and exported these viacontexts/index.ts. [1] [2]Scoping Infrastructure
DirectoryScope,NamespaceScope,NamedTypeScope, andSourceFileScope, supporting hierarchical organization and tracking of used namespaces. [1] [2] [3] [4] [5]Testing and Exports
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.