-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Promote
state-accessor
functions from experimental to supported (#5699
) 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.
- Loading branch information
Showing
18 changed files
with
108 additions
and
81 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
.chronus/changes/promote-state-accessor-2025-0-23-9-50-42.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
changeKind: deprecation | ||
packages: | ||
- "@typespec/compiler" | ||
- "@typespec/events" | ||
- "@typespec/json-schema" | ||
- "@typespec/openapi" | ||
- "@typespec/sse" | ||
- "@typespec/streams" | ||
--- | ||
|
||
Deprecate `unsafe_useStateMap` and `unsafe_useStateSet`, export `useStateMap` and `useStateSet` |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
export { | ||
MutableType as unsafe_MutableType, | ||
mutateSubgraph as unsafe_mutateSubgraph, | ||
mutateSubgraphWithNamespace as unsafe_mutateSubgraphWithNamespace, | ||
Mutator as unsafe_Mutator, | ||
MutatorFilterFn as unsafe_MutatorFilterFn, | ||
MutatorFlow as unsafe_MutatorFlow, | ||
MutatorFn as unsafe_MutatorFn, | ||
MutatorRecord as unsafe_MutatorRecord, | ||
MutatorReplaceFn as unsafe_MutatorReplaceFn, | ||
MutatorWithNamespace as unsafe_MutatorWithNamespace, | ||
mutateSubgraph as unsafe_mutateSubgraph, | ||
mutateSubgraphWithNamespace as unsafe_mutateSubgraphWithNamespace, | ||
} from "./mutators.js"; | ||
export { Realm as unsafe_Realm } from "./realm.js"; | ||
export { unsafe_useStateMap, unsafe_useStateSet } from "./state-accessor.js"; | ||
export { $ as unsafe_$ } from "./typekit/index.js"; | ||
|
||
import { useStateMap, useStateSet } from "../utils/state-accessor.js"; | ||
|
||
/** @deprecated use `useStateMap` from `@typespec/compiler/utils` instead */ | ||
export const unsafe_useStateMap = useStateMap; | ||
/** @deprecated use `useStateSet` from `@typespec/compiler/utils` instead */ | ||
export const unsafe_useStateSet = useStateSet; |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.