From 74cd815808b935dd6174bdb40919b7f328456a0d Mon Sep 17 00:00:00 2001 From: Steve Rice Date: Wed, 29 Jan 2025 15:03:41 -0800 Subject: [PATCH] Use exported `filterModelPropertiesInPlace` from `utils` (#5756) --- .../steverice-dry-filter-2025-0-26-1-0-45.md | 7 +++++++ .github/workflows/consistency.yml | 2 +- packages/compiler/src/lib/decorators.ts | 13 +------------ 3 files changed, 9 insertions(+), 13 deletions(-) create mode 100644 .chronus/changes/steverice-dry-filter-2025-0-26-1-0-45.md diff --git a/.chronus/changes/steverice-dry-filter-2025-0-26-1-0-45.md b/.chronus/changes/steverice-dry-filter-2025-0-26-1-0-45.md new file mode 100644 index 0000000000..7d73a8b91a --- /dev/null +++ b/.chronus/changes/steverice-dry-filter-2025-0-26-1-0-45.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/compiler" +--- + +Use exported `filterModelPropertiesInPlace` from `utils` in `decorators.ts` \ No newline at end of file diff --git a/.github/workflows/consistency.yml b/.github/workflows/consistency.yml index 05421262ea..4c3131ec56 100644 --- a/.github/workflows/consistency.yml +++ b/.github/workflows/consistency.yml @@ -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 diff --git a/packages/compiler/src/lib/decorators.ts b/packages/compiler/src/lib/decorators.ts index d65f8f2ae6..ab9c72a10b 100644 --- a/packages/compiler/src/lib/decorators.ts +++ b/packages/compiler/src/lib/decorators.ts @@ -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"; @@ -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 = (