npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@thalesrc/extra-ts-types

v1.4.0

Published

Extra TypeScript types

Downloads

225

Readme

@thalesrc/extra-ts-types

npm version

Extra TypeScript utility types for advanced type manipulation and better type safety.

Installation

npm install @thalesrc/extra-ts-types
yarn add @thalesrc/extra-ts-types
pnpm add @thalesrc/extra-ts-types

Usage

import { AnyFunction, PartialSome, Join, Tail } from '@thalesrc/extra-ts-types';

// For polyfills (like URLPattern)
import '@thalesrc/extra-ts-types/polyfills';

API

AnyFunction

A utility type that represents any function with any number of arguments and any return type.

// Example usage
function callFunction(fn: AnyFunction) {
  return fn();
}

const myFunction = (a: number, b: string) => `${a}: ${b}`;
callFunction(myFunction); // Works with any function

ConstructorType<T>

Extracts the constructor type from an interface or class type.

// Example usage
class MyClass {
  constructor(public value: string) {}
}

type MyConstructor = ConstructorType<typeof MyClass>;
// MyConstructor is: new (value: string) => MyClass

DeepestValue<T, K>

Gets the deepest type of a nested object by following a specific key path.

// Example usage
type NestedObject = {
  data: {
    data: {
      data: string;
    };
  };
};

type Result = DeepestValue<NestedObject, 'data'>;
// Result is: string

DeepestObject<T, K>

Gets the deepest object of a nested object by following a specific key path.

// Example usage
type NestedObject = {
  data: {
    data: {
      value: string;
      other: number;
    };
  };
};

type Result = DeepestObject<NestedObject, 'data'>;
// Result is: { value: string; other: number; }

Join<T, Sep>

Joins a union of strings with a separator, creating all possible combinations.

// Example usage
type Colors = 'red' | 'blue' | 'green';
type ColorCombinations = Join<Colors, '-'>;
// Result includes: "red" | "blue" | "green" | "red-blue" | "red-green" | "blue-red" | "blue-green" | "green-red" | "green-blue" | ...

type SimpleJoin = Join<'x' | 'y'>;
// Result: "x" | "y" | "x,y" | "y,x"

PartialSome<T, K>

Makes some properties of an object optional while keeping others required.

// Example usage
interface User {
  id: number;
  name: string;
  email: string;
  age: number;
}

type UserWithOptionalContact = PartialSome<User, 'email' | 'age'>;
// Result: { id: number; name: string; email?: string; age?: number; }

Tail<X>

Omits the first element of a tuple type, returning the rest.

// Example usage
type Numbers = [1, 2, 3, 4, 5];
type RestNumbers = Tail<Numbers>;
// Result: [2, 3, 4, 5]

type Args = [string, number, boolean];
type RestArgs = Tail<Args>;
// Result: [number, boolean]

Polyfills

URLPattern (Global Type)

TypeScript type definitions for the URLPattern Web API, which provides pattern matching for URLs.

// Import all polyfills
import '@thalesrc/extra-ts-types/polyfills';

// Or import URLPattern specifically
import '@thalesrc/extra-ts-types/polyfills/url-pattern';

// Now URLPattern is available in the global scope
const pattern = new URLPattern({ pathname: '/books/:id' });
const result = pattern.exec('https://example.com/books/123');
console.log(result?.pathname.groups.id); // '123'

// Test if a URL matches
if (pattern.test('https://example.com/books/456')) {
  console.log('URL matches!');
}

Interfaces:

  • URLPattern - Main interface with test() and exec() methods
  • URLPatternInit - Initialization options for creating patterns
  • URLPatternResult - Match results including all URL components and captured groups
  • URLPatternComponentResult - Matched text and groups for individual URL components

Use Cases

  • Function Type Safety: Use AnyFunction for generic function parameters
  • Constructor Patterns: Extract constructor types with ConstructorType
  • Deep Object Navigation: Work with nested structures using DeepestValue and DeepestObject
  • String Combinations: Generate all possible string combinations with Join
  • Flexible Interfaces: Create partially optional interfaces with PartialSome
  • Tuple Manipulation: Work with tuple types using Tail
  • URL Pattern Matching: Use URLPattern polyfill types for type-safe URL routing and matching

Contributing

This package is part of the Thalesrc monorepo. Contributions are welcome!

License

MIT © Thalesrc

Homepage

Visit extra-ts-types.thalesrc.com for more information and examples.