Promote state-accessor
functions from experimental to supported
#5699
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.
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 theirunsafe_
prefixes removed).In this commit, we move
state-accessor
intoutils
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 inlib/utils
with direct imports of the newly-exposed accessor functions. Because the wrapper functions previously created a symbol with theTypeSpec.
prefix when given a string, we preserve this behavior by introducing the simplecreateStateSymbol
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.