Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote state-accessor functions from experimental to supported #5699

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

steverice
Copy link
Contributor

These reusable state accessors were added in 3eed298 under the experimental namespace. They are now considered ready to be promoted out to the @typespec/compiler package exports (and to have their unsafe_ prefixes removed).

In this commit, we move state-accessor into utils and add it to the module index so that its functions can be imported from @typespec/compiler/utils.

For usages inside @typespec/compiler, we are replacing the wrapper functions in lib/utils with direct imports of the newly-exposed accessor functions. Because the wrapper functions previously created a symbol with the TypeSpec. prefix when given a string, we preserve this behavior by introducing the simple createStateSymbol function in files that previously used the wrapper functions.

createStateSymbol could be trivially refactored into a shared utility function rather than duplicated, but here we are simply following the pattern already established where there are already several copies of this function. Indeed, while one of these was exported in 050139d, that export was never used.

These reusable state accessors were added in 3eed298 under the `experimental` namespace. They are now considered ready to be promoted out to the `@typespec/compiler` package exports (and to have their `unsafe_` prefixes removed).

In this commit, we move `state-accessor` into `utils` and add it to the module index so that its functions can be imported from `@typespec/compiler/utils`.

For usages inside `@typespec/compiler`, we are replacing the wrapper functions in `lib/utils` with direct imports of the newly-exposed accessor functions. Because the wrapper functions previously created a symbol with the `TypeSpec.` prefix when given a string, we preserve this behavior by introducing the simple `createStateSymbol` function in files that previously used the wrapper functions.

 `createStateSymbol` could be trivially refactored into a shared utility function rather than duplicated, but here we are simply following the pattern already established where there are already several copies of this function. Indeed, while one of these was exported in 050139d, that export was never used.
To smooth the transition for any packages relying on these exports.
@steverice steverice force-pushed the promote-state-accessor branch from baa8542 to 951ba9e Compare January 23, 2025 00:21
Comment on lines +3 to +4
mutateSubgraph as unsafe_mutateSubgraph,
mutateSubgraphWithNamespace as unsafe_mutateSubgraphWithNamespace,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prettier made this change — I can try reverting it if need be.

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.

2 participants