Skip to content

Commit

Permalink
Use exported filterModelPropertiesInPlace from utils (#5756)
Browse files Browse the repository at this point in the history
  • Loading branch information
steverice authored Jan 29, 2025
1 parent 6d4e89c commit 74cd815
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/steverice-dry-filter-2025-0-26-1-0-45.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/compiler"
---

Use exported `filterModelPropertiesInPlace` from `utils` in `decorators.ts`
2 changes: 1 addition & 1 deletion .github/workflows/consistency.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- uses: ./.github/actions/setup

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

- run: pnpm install
Expand Down
13 changes: 1 addition & 12 deletions packages/compiler/src/lib/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ import {
} from "../core/types.js";
import { useStateMap, useStateSet } from "../utils/index.js";
import { setKey } from "./key.js";
import { createStateSymbol } from "./utils.js";
import { createStateSymbol, filterModelPropertiesInPlace } from "./utils.js";

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

export { getEncode };

export function filterModelPropertiesInPlace(
model: Model,
filter: (prop: ModelProperty) => boolean,
) {
for (const [key, prop] of model.properties) {
if (!filter(prop)) {
model.properties.delete(key);
}
}
}

// -- @withOptionalProperties decorator ---------------------

export const $withOptionalProperties: WithOptionalPropertiesDecorator = (
Expand Down

0 comments on commit 74cd815

Please sign in to comment.