Skip to content

refactor: remove ts-toolbelt dependency#53

Open
regevbr wants to merge 1 commit into
masterfrom
remove-ts-toolbelt-dependency
Open

refactor: remove ts-toolbelt dependency#53
regevbr wants to merge 1 commit into
masterfrom
remove-ts-toolbelt-dependency

Conversation

@regevbr
Copy link
Copy Markdown
Owner

@regevbr regevbr commented Feb 1, 2026

Summary

  • Remove ts-toolbelt dependency by replacing all utilities with native TypeScript built-ins and custom implementations
  • Maintain 100% type safety with no runtime behavior changes
  • Reduce bundle size by eliminating the only runtime dependency

Changes

New file: src/types/utils.ts

Custom type utilities replacing ts-toolbelt:

  • Primitive, BuiltIn - Type categories
  • List, Cast, Keys, Compute - Any/list utilities
  • Split, Join - String utilities
  • Path, FilterNever, NonNullableFlat - Object utilities
  • RequireOnlyOne - Replacement for Object.Either

Modified files

File Changes
src/types/paths.ts Replace ts-toolbelt imports with ./utils
src/types/required.ts Replace Misc.BuiltInBuiltIn
src/types/evaluator.ts Replace ts-toolbelt imports, re-export RequireOnlyOne
src/types/expressionParts.ts Replace imports, use native Parameters
src/lib/helpers.ts Replace Any.KeyPropertyKey
src/lib/engine.ts Add type assertion for RuleDefinition narrowing
src/test/types/expressionParts.ts Replace Any.ComputeCompute
package.json Remove ts-toolbelt dependency

Test plan

  • All 166 unit tests pass
  • 100% code coverage maintained
  • All TypeScript definition tests pass
  • Linting passes
  • Full CI pipeline passes (pnpm run ci)

🤖 Generated with Claude Code

Replace all ts-toolbelt utilities with native TypeScript built-ins and
custom implementations while maintaining 100% type safety.

Changes:
- Create src/types/utils.ts with custom type utilities (Primitive,
  BuiltIn, List, Cast, Keys, Compute, Split, Join, Path, FilterNever,
  NonNullableFlat, RequireOnlyOne)
- Replace ts-toolbelt imports in paths.ts, required.ts, evaluator.ts,
  and expressionParts.ts
- Replace Any.Key with PropertyKey in helpers.ts
- Add type assertion in engine.ts for RuleDefinition narrowing
- Update test file to use custom Compute type
- Remove ts-toolbelt from dependencies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@qltysh
Copy link
Copy Markdown

qltysh Bot commented Feb 1, 2026

❌ 4 blocking issues (4 total)

Tool Category Rule Count
radarlint-js Lint Remove this type without members or change this type intersection. 3
radarlint-js Lint 'unknown' is overridden by other types in this intersection type. 1

Comment thread src/types/utils.ts
? Exclude<keyof A, keyof any[]> | number
: keyof A;
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export type Compute<A> = A extends Function ? A : { [K in keyof A]: A[K] } & unknown;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'unknown' is overridden by other types in this intersection type. [radarlint-js:typescript:S6571]

Comment thread src/types/utils.ts
// NonNullableFlat - makes properties non-nullable at top level
export type NonNullableFlat<O> = {
[K in keyof O]: NonNullable<O[K]>;
} & {};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove this type without members or change this type intersection. [radarlint-js:typescript:S4335]

Comment thread src/types/utils.ts
// Pick helper - matches ts-toolbelt's _Pick
type _Pick<O extends object, K extends PropertyKey> = {
[P in keyof O & K]: O[P];
} & {};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove this type without members or change this type intersection. [radarlint-js:typescript:S4335]

Comment thread src/types/utils.ts
// OptionalFlat - matches ts-toolbelt's OptionalFlat
type OptionalFlat<O> = {
[K in keyof O]?: O[K];
} & {};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove this type without members or change this type intersection. [radarlint-js:typescript:S4335]

@qltysh
Copy link
Copy Markdown

qltysh Bot commented Feb 1, 2026

Qlty

Coverage Impact

This PR will not change total coverage.

Modified Files with Diff Coverage (2)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
src/lib/helpers.ts100.0%
Coverage rating: A Coverage rating: A
src/lib/engine.ts100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

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