Skip to content

Commit 74cd815

Browse files
authored
Use exported filterModelPropertiesInPlace from utils (#5756)
1 parent 6d4e89c commit 74cd815

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
changeKind: internal
3+
packages:
4+
- "@typespec/compiler"
5+
---
6+
7+
Use exported `filterModelPropertiesInPlace` from `utils` in `decorators.ts`

.github/workflows/consistency.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
- uses: ./.github/actions/setup
2626

27-
- run: git pull --force --no-tags origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}
27+
- run: git fetch --force --no-tags origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}
2828
name: Get ${{ github.event.pull_request.base.ref }} ref for ${{ github.ref}}, evt ${{ github.event_name }}
2929

3030
- run: pnpm install

packages/compiler/src/lib/decorators.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ import {
100100
} from "../core/types.js";
101101
import { useStateMap, useStateSet } from "../utils/index.js";
102102
import { setKey } from "./key.js";
103-
import { createStateSymbol } from "./utils.js";
103+
import { createStateSymbol, filterModelPropertiesInPlace } from "./utils.js";
104104

105105
export { $encodedName, resolveEncodedName } from "./encoded-names.js";
106106
export { serializeValueAsJson } from "./examples.js";
@@ -811,17 +811,6 @@ function validateEncodeData(context: DecoratorContext, target: Type, encodeData:
811811

812812
export { getEncode };
813813

814-
export function filterModelPropertiesInPlace(
815-
model: Model,
816-
filter: (prop: ModelProperty) => boolean,
817-
) {
818-
for (const [key, prop] of model.properties) {
819-
if (!filter(prop)) {
820-
model.properties.delete(key);
821-
}
822-
}
823-
}
824-
825814
// -- @withOptionalProperties decorator ---------------------
826815

827816
export const $withOptionalProperties: WithOptionalPropertiesDecorator = (

0 commit comments

Comments
 (0)