Skip to content

chore: refactor types#2769

Merged
tatomyr merged 2 commits intomainfrom
chore/refactor-types
Apr 23, 2026
Merged

chore: refactor types#2769
tatomyr merged 2 commits intomainfrom
chore/refactor-types

Conversation

@tatomyr
Copy link
Copy Markdown
Collaborator

@tatomyr tatomyr commented Apr 23, 2026

What/Why/How?

Refactored types for better readability and fixed wrong ones.

Needed for https://github.com/Redocly/redocly/pull/22749.

Pipeline, E2E and integration tests passed here and here.

Check yourself

  • This PR follows the contributing guide
  • All new/updated code is covered by tests
  • Core code changed? - Tested with other Redocly products (internal contributions only)
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update has been considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

Note

Medium Risk
Medium risk because it changes the shape/typing of directResolveAs and array items in the core type-normalization pipeline, which can affect how config/YAML nodes are resolved at runtime. The rest are typing-only tweaks plus a small utility boolean change and stricter test coverage thresholds.

Overview
Refactors core schema type normalization to use fully normalized nested types: NormalizedScalarSchema.items now recursively uses NormalizedScalarSchema, and NormalizedNodeType.directResolveAs is typed as a NormalizedNodeType (with resolveType updated to handle functions, named types, and directResolveAs more explicitly).

Fixes a typing issue in redocly-yaml’s extends schema builder by removing an incorrect cast and aligning directResolveAs with the new normalized node type expectations. Separately tightens OpenAPI/Swagger typings (Record<string, …> and unknown), makes isNotEmptyArray check explicit, and raises Vitest coverage thresholds slightly.

Reviewed by Cursor Bugbot for commit 2c0d4e7. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 23, 2026

⚠️ No Changeset found

Latest commit: 2c0d4e7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 80.04% (🎯 80%) 7100 / 8870
🔵 Statements 79.45% (🎯 79%) 7379 / 9287
🔵 Functions 83.45% (🎯 83%) 1428 / 1711
🔵 Branches 71.5% (🎯 71%) 4799 / 6711
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/types/index.ts 97.29% 88.46% 100% 97.29% 140
packages/core/src/types/redocly-yaml.ts 92.53% 82.85% 100% 92.18% 390-397, 399, 544-549, 552-557, 560-565
packages/core/src/utils/is-not-empty-array.ts 100% 100% 100% 100%
Generated in workflow #9581 for commit 2c0d4e7 by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2026

CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 3.320s ± 0.056s ▓ 1.01x
cli-next 3.286s ± 0.017s ▓ 1.00x (Fastest)

@tatomyr tatomyr force-pushed the chore/refactor-types branch from b9f2ef0 to 87da7f5 Compare April 23, 2026 08:54
@tatomyr tatomyr self-assigned this Apr 23, 2026
@tatomyr tatomyr marked this pull request as ready for review April 23, 2026 09:11
@tatomyr tatomyr requested a review from a team as a code owner April 23, 2026 09:11
name?: never;
type?: 'string' | 'boolean' | 'number' | 'integer' | 'object' | 'array';
items?: ScalarSchema;
items?: NormalizedScalarSchema;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check with snapshot on monorepo.

@tatomyr tatomyr added the snapshot Create experimental release PR label Apr 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1776935776 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1776935776
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1776935776
# or
npm install @redocly/respect-core@0.0.0-snapshot.1776935776

⚠️ Note: This is a development build and may contain unstable features.

@tatomyr tatomyr merged commit b25cc39 into main Apr 23, 2026
72 of 73 checks passed
@tatomyr tatomyr deleted the chore/refactor-types branch April 23, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changeset needed snapshot Create experimental release PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants