feat: add type-safe infix parameter validation & separate test TypeScript config#290
Merged
jasonbosco merged 2 commits intotypesense:masterfrom May 22, 2025
Merged
feat: add type-safe infix parameter validation & separate test TypeScript config#290jasonbosco merged 2 commits intotypesense:masterfrom
jasonbosco merged 2 commits intotypesense:masterfrom
Conversation
- add generic `Infix` parameter to search-related interfaces - implement `CommaSeparated` utility type for validating comma-separated values - update `SearchParams`, `MultiSearch`, and related types to support typed infix validation - add `TrimString` helper type for whitespace handling - add tests for infix type validation with edge cases - ensure `infix` parameter validates against `OperationMode` values at compile time
- add `tsconfig.test.json` extending base configuration - include both source and test files in test config - add `typecheck` script to validate test files without emit
Member
|
Released in v2.1.0-6 |
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.
TLDR
Added compile-time validation for infix parameters and separate TypeScript config for tests.
Change Summary
Added Features:
New Type Utilities in
Types.ts:CommaSeparated<T, ToExtend>: Validates comma-separated strings against allowed values at compile timeTrimString<S>: Helper type for handling whitespace in string validationType-Safe Infix Parameter in Search APIs:
SearchParams<TDoc, Infix>with genericInfixparameter for compile-time validationSeparate Test Configuration:
tsconfig.test.json: Extends base config to include both source and test filestypecheckscript: Validates test files without emitting outputCode Changes:
In
Types.ts:CommaSeparatedutility type that recursively validates comma-separated operation modesSearchParamsinterface to accept genericInfixparameter with compile-time validationIn
Utils.ts:normalizeArrayableParamsfunction to handle the new genericInfixparameterIn Search-Related Classes:
SearchOnlyDocuments.ts: Added genericInfixparameter to search methodMultiSearch.ts: Updated all perform method overloads with type-safe infix supportKeys.ts: Enhanced scoped search key generation with infix validationPresets.ts: Updated preset creation to support typed infix parametersIn
package.json:typecheckscript for validating TypeScript without compilationTests :
test/infix.type.test.ts:CommaSeparatedutility