You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow string enums for error code in router/errors.ts to support the purpose stated in the PR title
This change updates error schema typing to accept string enums in addition to string literals and extends tests to cover enum-based error codes and unions. It modifies BaseErrorSchemaType and union flattening logic and adds test coverage for enum-based error schemas in the TypeScript stress suite.
Update BaseErrorSchemaType in router/errors.ts so code accepts TEnum via a new TStringCode type
Adjust Flatten<T> union handling in router/errors.ts to return TUnion<Array<U>> when U extends BaseErrorSchemaType
Add TestErrorCodes enum and expand allowed error schema cases in tests/typescript-stress.test.ts to include enum-based schemas, mixed unions, and flattenErrorType with nested unions
📍Where to Start
Start with the updated BaseErrorSchemaType and TStringCode definitions in router/errors.ts, then review the Flatten<T> conditional type changes before verifying coverage in tests/typescript-stress.test.ts.
Accept string enums for error code fields in router/errors.ts to allow string enum-based error schemas
This change updates the error schema typing to accept string enums for the code property and adjusts union flattening behavior, with accompanying tests and a version bump. • Modify BaseErrorSchemaType in router/errors.ts to use a new TStringCode type that includes TLiteral<string> and TEnum, and update Flatten<T> to preserve unions of BaseErrorSchemaType as TUnion<Array<U>> while continuing recursive flattening for other members. • Add tests in tests/typescript-stress.test.ts validating Type.Enum-based error codes, unions combining enum-based schemas, and flattenErrorType with unions containing enum-based schemas. • Bump package version from 0.209.8 to 0.210.0 in package.json.
📍Where to Start
Start with the updated BaseErrorSchemaType and TStringCode definitions and the Flatten<T> conditional logic in router/errors.ts.
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
to provide better type safety and developer experience when defining error schemas.
What changed
BaseErrorSchemaTypeFlattentype helper to properly handle unions containing enum-based error schemasVersioning