-
Notifications
You must be signed in to change notification settings - Fork 232
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
steverice
wants to merge
4
commits into
microsoft:main
Choose a base branch
from
pinterest:promote-state-accessor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
steverice
requested review from
bterlson,
markcowl,
allenjzhang,
timotheeguerin and
witemple-msft
as code owners
January 22, 2025 06:36
steverice
force-pushed
the
promote-state-accessor
branch
from
January 23, 2025 00:21
baa8542
to
951ba9e
Compare
steverice
commented
Jan 23, 2025
timotheeguerin
approved these changes
Jan 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, just missing the changelog and seems like a lint issue
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
force-pushed
the
promote-state-accessor
branch
from
January 23, 2025 17:51
951ba9e
to
8e2656f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.