Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@alwatr/type-helper

Alwatr2kMPL-2.06.1.5TypeScript support: included

Collection of useful typescript type helpers.

alwatr, nanolib, type, type-helper, types, typescript, util, utility, utils

readme

TypeScript Type Helpers

A collection of useful TypeScript type helpers.

Installation

yarn add -D @alwatr/type-helper

Then import the type helpers to one of your file

import type {} from '@alwatr/type-helper';

Usage Example

const obj: JSONObject = {
  foo: 'bar',
  baz: {
    qux: 1,
    arr: [1, 2, 3],
  },
  qux: true,
};

Read the source code for more details.

Sponsors

The following companies, organizations, and individuals support Nanolib ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.

Contributing

Contributions are welcome! Please read our contribution guidelines before submitting a pull request.

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

6.1.5 (2025-10-06)

🔗 Dependencies update

  • bump the npm-dependencies group with 4 updates (9825815)

6.1.4 (2025-09-27)

🧹 Miscellaneous Chores

  • exclude test files from package distribution (86f4f2f)

6.1.3 (2025-09-22)

🐛 Bug Fixes

  • remove unnecessary method from JsonValue type definition (d18847c)

6.1.2 (2025-09-22)

🐛 Bug Fixes

  • extend JsonValue type to include objects with toJSON method (13e8315)

6.1.1 (2025-09-20)

🐛 Bug Fixes

  • add sideEffects property to package.json files for better tree-shaking (c7b9e74)
  • add sideEffects property to package.json files for better tree-shaking (e8402c4)

🧹 Miscellaneous Chores

  • remove duplicate sideEffects property from multiple package.json files (b123f86)

6.1.0 (2025-09-19)

✨ Features

  • add SingleOrReadonlyArray type for flexible item handling (4b65513)

6.0.2 (2025-09-13)

🧹 Miscellaneous Chores

  • add utility types for function manipulation and event listener interface (b2ca24d)

6.0.1 (2025-09-09)

Note: Version bump only for package @alwatr/type-helper

6.0.0 (2025-09-06)

⚠ BREAKING CHANGES

  • The JSON types completely refactored for better consistency and clarity. Use new JsonPrimitive, JsonValue, JsonArray, JsonObject and powerful Jsonify util.
  • The type alias Merge has been renamed to Overwrite to avoid confusion with deep merging. The new name better describes its functionality: properties of N overwrite properties of M.
  • The type ArrayItems has been renamed to ArrayItem for better consistency and clarity. The logic has been updated to return never if the input is not an array. Additionally, it now supports readonly arrays using `readonly (infer U)[]
  • The type alias Values has been renamed to ObjectValues for better alignment with the TypeScript ecosystem. Update all references
  • The type alias Immutable<T> has been removed. Use internal Readonly<T> for better alignment with the TypeScript ecosystem. Update all references
  • The type alias MaybePromise has been renamed to Awaitable for better alignment with the TypeScript ecosystem. Update all references
  • Import separate types not supported anymore, please just use global usage.

🔨 Code Refactoring

  • enhance Class type definition to include constructor argument types (698b3d0)
  • enhance DeepReadonly, DeepRequired, and DeepPartial types for improved type safety (76c905f)
  • enhance documentation for RequiredKeys, OptionalKeys, and Prop types (1bb1ec4)
  • improve JSON type definitions and enhance documentation (0928233)
  • improve type documentation (f16d032)
  • improve type documentation and add Simplify type definition (33ffdcf)
  • improve type documentation and formatting in type definitions (e856018)
  • improve type documentation and organization in type declarations (695979b)
  • redefine all types as just global and remove exported each types (c4ac67a)
  • remove export from HasAddEventListener interface for consistency (8aaaba2)
  • remove Immutable type definition from global types (a154220)
  • rename ArrayItems to ArrayItem and fix its logic (9a63a3f)
  • rename MaybePromise to Awaitable and update documentation (35bf339)
  • rename Merge to Overwrite for clarity (25e4f02)
  • rename Values type to ObjectValues and update documentation (368de42)
  • reorganize global type declarations and improve documentation (e91a459)
  • update DictionaryOpt and DictionaryReq documents (8be1955)

5.4.4 (2025-08-23)

Note: Version bump only for package @alwatr/type-helper

5.4.3 (2025-08-23)

🐛 Bug Fixes

  • update license from AGPL-3.0-only to MPL-2.0 (d20968e)
  • update package versions in multiple package.json files (7638b1c)

🔨 Code Refactoring

  • Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. (db6a4f7)

🧹 Miscellaneous Chores

  • reformat all package.json files (ceda45d)

🔗 Dependencies update

  • update TypeScript and Jest versions across all packages to improve compatibility and performance (31baf36)

5.4.2 (2025-08-23)

Code Refactoring

  • Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. (db6a4f7) by @alimd

5.4.1 (2025-04-15)

Note: Version bump only for package @alwatr/type-helper

5.4.0 (2025-03-06)

Features

  • types: allow undefined in JsonValue type definition (7f25f3f) by @
  • types: simplify JsonObject type definition (a119d66) by @

Miscellaneous Chores

  • update username casing in changelog entries (9722ac9) by @

Dependencies update

  • bump the development-dependencies group across 1 directory with 11 updates (720c395) by @dependabot[bot]

5.3.0 (2025-02-03)

Miscellaneous Chores

Dependencies update

  • bump the development-dependencies group across 1 directory with 11 updates (cb79d07) by @
  • update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages (ddab05b) by @

5.0.0 (2024-11-02)

⚠ BREAKING CHANGES

  • To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.

Code Refactoring

  • use the same version as @alwatr/nanolib (60eb860) by @

5.3.0 (2025-02-03)

Miscellaneous Chores

  • edit README (3860b3d) by @ArmanAsadian

Dependencies update

  • bump the development-dependencies group across 1 directory with 11 updates (cb79d07) by @dependabot[bot]
  • update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages (ddab05b) by @alimd

5.0.0 (2024-11-02)

⚠ BREAKING CHANGES

  • To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
  • type-helper: Update the type definitions for the Dictionary type in the type-helper package. Introduce two new types: DictionaryOpt and DictionaryReq, representing dictionaries with optional and required values respectively. This change improves the clarity and flexibility of the type system.
  • type-helper: make values as optional

Features

  • ty-helper: Update type definitions and add new interfaces for JSON serialization (7df0b07) by @
  • type-helper: add HasAddEventListener (ba2b6fa) by @
  • type-helper: Add Mutable and Immutable types (bd57df7) by @
  • type-helper: add StrictlyRequired type (6d2831e) by @
  • type-helper: make types available globally! (69bcb97) by @
  • type-helper: new package for ts types (4d81aaf) by @
  • type-helper: Update type definitions for Dictionary and Json (0e3d56f) by @
  • type-helper: update type-helper to declare global types (f7b6f95) by @
  • type: add number key to dictionary (e6cae47) by @

Bug Fixes

  • type-helper: convert interface to type (c9e6970) by @

Code Refactoring

  • type-helper: update Dictionary type definitions (fa4c56d) by @
  • use the same version as @alwatr/nanolib (60eb860) by @

Miscellaneous Chores

  • include LICENSE and LEGAL files to publish (09f366f) by @
  • rename logger env (38443ad) by @
  • type-helper: change the license to AGPL-3.0 (5f1264d) by @
  • type-helper: fix package version (6b5374f) by @
  • type-helper: make lint happy (8e43a6a) by @
  • type-helper: remove version beta suffix (2222a51) by @
  • Update build and lint scripts (392d0b7) by @
  • Update debug command in package.json (be8403d) by @

Dependencies update

  • bump the development-dependencies group across 1 directory with 10 updates (9ed98ff) by @
  • bump the development-dependencies group with 10 updates (fa4aaf0) by @
  • upd (451d025) by @
  • update all dependencies (1e0c30e) by @
  • update all dependencies (0e908b4) by @

2.0.3 (2024-10-25)

Note: Version bump only for package @alwatr/type-helper

2.0.2 (2024-10-11)

Miscellaneous Chores

  • include LICENSE and LEGAL files to publish (09f366f) by @alimd

2.0.1 (2024-10-10)

Dependencies update

  • bump the development-dependencies group with 10 updates (fa4aaf0) by @dependabot[bot]

2.0.0 (2024-09-29)

⚠ BREAKING CHANGES

  • type-helper: Update the type definitions for the Dictionary type in the type-helper package. Introduce two new types: DictionaryOpt and DictionaryReq, representing dictionaries with optional and required values respectively. This change improves the clarity and flexibility of the type system.
  • type-helper: make values as optional

Features

  • type-helper: add StrictlyRequired type (6d2831e) by @alimd
  • type-helper: make types available globally! (69bcb97) by @alimd
  • type-helper: update type-helper to declare global types (f7b6f95) by @alimd

Bug Fixes

  • type-helper: convert interface to type (c9e6970) by @mohammadhonarvar

Code Refactoring

  • type-helper: update Dictionary type definitions (fa4c56d) by @alimd

Miscellaneous Chores

  • type-helper: change the license to AGPL-3.0 (5f1264d) by @ArmanAsadian
  • Update build and lint scripts (392d0b7) by @alimd

1.2.6 (2024-09-15)

Dependencies update

  • bump the development-dependencies group across 1 directory with 10 updates (9ed98ff) by @dependabot[bot]

1.2.5 (2024-08-31)

Dependencies update

  • update all dependencies (1e0c30e) by @alimd

1.2.4 (2024-07-04)

Dependencies update

  • update all dependencies (0e908b4) by @

1.2.3 (2024-04-25)

Note: Version bump only for package @alwatr/type-helper

1.2.2 (2024-03-28)

Note: Version bump only for package @alwatr/type-helper

1.2.1 (2024-01-31)

Note: Version bump only for package @alwatr/type-helper

1.2.0 (2024-01-24)

Features

  • ty-helper: Update type definitions and add new interfaces for JSON serialization (7df0b07) by @alimd
  • type-helper: Add Mutable and Immutable types (bd57df7) by @
  • type-helper: Update type definitions for Dictionary and Json (0e3d56f) by @

1.1.0 (2024-01-16)

Features

  • type-helper: Add Mutable and Immutable types (bd57df7) by @alimd
  • type-helper: Update type definitions for Dictionary and Json (0e3d56f) by @alimd

1.0.3 (2024-01-03)

Note: Version bump only for package @alwatr/type-helper

1.0.2 (2024-01-03)

Note: Version bump only for package @alwatr/type-helper

1.0.1 (2023-12-27)

Note: Version bump only for package @alwatr/type-helper

1.0.0-beta.2 (2023-12-27)

Features

  • type-helper: add HasAddEventListener (ba2b6fa) by @alimd

1.0.0-beta.1 (2023-12-26)

Features

  • type: add number key to dictionary (e6cae47) by @njfamirm

1.0.0-beta.0 (2023-12-26)

Features

  • type-helper: new package for ts types (4d81aaf) by @alimd