Skip to content

refactor!: use type aliases and replace any with exact types - #3

Merged
devCrossNet merged 1 commit into
mainfrom
refactor/types
Oct 8, 2026
Merged

devCrossNet merged 1 commit into
mainfrom
refactor/types

Conversation

@devCrossNet

Copy link
Copy Markdown
Owner

What is accomplished by your PR?

Interfaces → type aliases

  • All interfaces in src and examples are now type aliases
  • src/interfaces.ts is renamed to src/types.ts
  • Generic parameters IItem, IQuestion, INavigationItem are renamed to Item, Question, NavigationItem

any → exact types (27 of 32 replaced)

  • Inputs (saveAnswer, answer parameters, QuaireOptions.result, QuaireItem.defaultValue) use unknown
  • getByPath is generic, isNil is a type guard
  • as any casts are replaced: objects are built as QuaireQuestion / QuaireNavigationItem and then cast to the generic type
  • 5 outputs stay any on purpose (getResult(), _result, QuaireQuestion.value, QuaireQuestion.defaultValue, QuaireNavigationItem.value), because consumers read them directly

Types fixed to match runtime values

Type Before After
QuaireNavigationItem.value string any (arrays, booleans, null)
QuaireNavigationItem.componentType no null | null (parents without question)
QuaireQuestion.navigationItemId required optional
QuaireQuestion.selectOptions / rangeOption / inputOption no null | null

ESLint rules

  • @typescript-eslint/consistent-type-definitions: type
  • @typescript-eslint/naming-convention: no I prefix for types
  • @typescript-eslint/no-explicit-any enabled, the 5 exceptions are documented inline

Is there something controversial in your PR?

Breaking changes for TypeScript consumers:

  • Declaration merging of Quaire types is no longer possible
  • null must be handled for the fixed types listed above with strict mode
  • Direct imports from quaire/dist/interfaces break (now dist/types)

Normal imports from quaire and interface X extends QuaireItem in consumer code still work.

Checklist

  • Run unit tests to ensure all existing tests are still passing
  • Add new passing unit tests to cover the code introduced by your PR
  • Change documentation for the code introduced by your PR

🤖 Generated with Claude Code

- replace all interfaces with type aliases and rename interfaces.ts to types.ts
- remove I prefix from generic type parameters
- replace any with unknown for inputs and remove as any casts
- fix types that did not match runtime values
- enforce type aliases, no I prefix and no explicit any via eslint

BREAKING CHANGE: types can no longer be extended via declaration merging.
QuaireQuestion.navigationItemId is optional, selectOptions, rangeOption
and inputOption can be null, QuaireNavigationItem.componentType can be
null and QuaireNavigationItem.value is any instead of string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devCrossNet
devCrossNet merged commit dfc8437 into main Oct 8, 2026
2 checks passed
@devCrossNet
devCrossNet deleted the refactor/types branch October 8, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant