chore: harden TypeScript types across codebase#7
Merged
Conversation
Extract ErrorCode from ERROR_CODES const, narrow EncodingError.code from string to ErrorCode, add never-typed exhaustive default in getErrorMessage, and add missing cases for ENCODE_FAILED, EMPTY_INPUT, INPUT_TOO_LARGE.
…rrors Tighten formatFieldErrors, FieldMetaLike.errors, and FieldErrorMessage meta.errors from unknown[] to StandardSchemaIssue[], removing the unsafe cast in formatFieldErrors.
…union Define ConverterMode = 'encode' | 'decode', update ConverterFormBase, FieldConfig callbacks, and ConverterConfig function signatures. Update ConverterPage to use ConverterMode annotation on useStore result.
Split FieldConfig into SelectFieldConfig and TextAreaFieldConfig extending a shared FieldConfigBase. Use `string & keyof T` for field names. Update ConverterPage to narrow via field.type before accessing type-specific props.
Link schema output type to the config's generic T parameter so mismatched schemas produce a compile error. ZodEffects (from superRefine) extends ZodType, so all 4 converter schemas satisfy the constraint.
…assName, never guards Move placeholder and className up to FieldConfigBase so both select and textarea variants share them. Add rows?: never on SelectFieldConfig and options?: never on TextAreaFieldConfig as mutual exclusion guards.
✅ Deploy Preview for devkit-app ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Owner
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
- Move placeholder/className from FieldConfigBase to TextAreaFieldConfig (selects never use these — adding them was silently ignored) - Add placeholder?: never and className?: never to SelectFieldConfig for compile-time enforcement - Narrow conditionalInputValidation mode param from string to literal union - Use shared modeSchema in urlEncoderSchema instead of inline z.enum
Owner
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
- Align StandardSchemaIssue.path with Standard Schema V1 spec
(ReadonlyArray<PropertyKey | {key: PropertyKey}> instead of (string | number)[])
- Pin ZodType Input parameter: ZodType<T, ZodTypeDef, T> prevents
transform schemas from silently satisfying the constraint
- Collapse EMPTY_INPUT/INPUT_TOO_LARGE switch cases to return
error.message directly (avoids potential message duplication)
- Add @internal JSDoc to never-typed guard properties explaining their role as discriminated-union sentinels - Add discriminant JSDoc to type: 'select' and type: 'textarea' - Clarify ConverterPage comment to describe property resolution intent
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
neverswitch ingetErrorMessage— compiler catches unhandled error codesStandardSchemaIssuereplacesunknown[]for form errors, withpathaligned to Standard Schema V1 specConverterMode = 'encode' | 'decode'literal union replacesstringfor mode across all config signaturesFieldConfig<T>discriminated union —SelectFieldConfig<T> | TextAreaFieldConfig<T>withname: string & keyof Tfor compile-time field name validation andneverguards for mutual exclusion;placeholder/classNameonly onTextAreaFieldConfigConverterConfig.schema: ZodType<T, ZodTypeDef, T>— pins both Output and Input types, preventing transform schemas from silently satisfying the constraintTest plan
npm run buildpasses (zero type errors)npm run lintpasses (zero warnings)as anyoras unknown ascasts introduced