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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@pixielity/ts-types

v1.0.4

Published

A powerful TypeScript types library with full type safety, decorator support, and flexible configuration

Readme

TS Types

npm version License: MIT Build Status Coverage Status

A powerful TypeScript types library with full type safety, decorator support, and flexible configuration.

Features

  • 🔒 Type-safe: Full TypeScript support with proper type inference
  • 🧩 Flexible: Mix any number of classes with different strategies
  • 🎭 Decorator support: Inherit decorators from constituent classes
  • ⚙️ Configurable: Choose between different typesg strategies
  • 🔍 Tracking: Track and detect types at runtime
  • 🏗️ Abstract class support: Mix abstract classes with concrete implementations

Installation


# npm

npm install ts-types

# yarn

yarn add ts-types

# pnpm

pnpm add ts-types

Basic Usage

import { Mixin } from 'ts-types';

// Define your classes
class Logger {
log(message: string) {
console.log(`[LOG]: ${message}`);
}
}

class Serializable {
serialize() {
return JSON.stringify(this);
}
}

// Create a mixed class
const LoggableSerializable = Mixin(Logger, Serializable);

// Use the mixed class
const instance = new LoggableSerializable();
instance.log('Hello, world!'); // [LOG]: Hello, world!
console.log(instance.serialize()); // {"message":"Hello, world!"}

Using the Decorator

import { Mix } from 'ts-types';

class Logger {
log(message: string) {
console.log(`[LOG]: ${message}`);
}
}

class Serializable {
serialize() {
return JSON.stringify(this);
}
}

@Mix(Logger, Serializable)
class User {
name: string;

constructor(name: string) {
this.name = name;
}
}

const user = new User('John');
user.log('User created'); // [LOG]: User created
console.log(user.serialize()); // {"name":"John"}

Configuration

TS Types provides several configuration options to customize its behavior:

import { settings } from 'ts-types';

// Configure initialization function
settings.initFunction = 'initialize';

// Configure prototype strategy
settings.prototypeStrategy = 'proxy'; // 'copy' (default) or 'proxy'

// Configure statics strategy
settings.staticsStrategy = 'proxy'; // 'copy' (default) or 'proxy'

// Configure decorator inheritance
settings.decoratorInheritance = 'direct'; // 'deep' (default), 'direct', or 'none'

Configuration Options

| Option | Description | Default | Values | | ---------------------- | -------------------------------------------------------- | -------- | --------------------------------- | | initFunction | Name of the initialization function to call after typesg | null | string or null | | prototypeStrategy | Strategy for handling prototype properties | 'copy' | 'copy' or 'proxy' | | staticsStrategy | Strategy for handling static properties | 'copy' | 'copy' or 'proxy' | | decoratorInheritance | Strategy for inheriting decorators | 'deep' | 'deep', 'direct', or 'none' |

Advanced Usage

Working with Abstract Classes

import { Mixin } from 'ts-types';

abstract class Entity {
id: string;

constructor(id: string) {
this.id = id;
}

abstract getType(): string;
}

class Product {
name: string;
price: number;

constructor(name: string, price: number) {
this.name = name;
this.price = price;
}

getType(): string {
return 'Product';
}
}

const EntityProduct = Mixin(Entity, Product);

const product = new EntityProduct('abc123', 'Laptop', 999);
console.log(product.id); // abc123
console.log(product.name); // Laptop
console.log(product.getType()); // Product

Tracking Mixins

import { Mixin, hasMixin, getMixinsForClass } from 'ts-types';

class A {
methodA() { return 'A'; }
}

class B {
methodB() { return 'B'; }
}

const AB = Mixin(A, B);
const instance = new AB();

// Check if an instance has a specific types
console.log(hasMixin(instance, A)); // true
console.log(hasMixin(instance, B)); // true

// Get all types for a class
const types = getMixinsForClass(AB);
console.log(types); // [A, B]

Decorator Inheritance

import { Mixin, Decorate } from 'ts-types';

function LogClass(target: any) {
console.log(`Class ${target.name} was decorated`);
return target;
}

function LogProperty(target: any, propertyKey: string) {
console.log(`Property ${propertyKey} was decorated`);
}

@Decorate(LogClass)
class A {
@Decorate(LogProperty)
propertyA = 'A';
}

class B {
propertyB = 'B';
}

// The mixed class will inherit the decorators from A
const AB = Mixin(A, B);

API Reference

For detailed API documentation, please see the API Reference.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please make sure to update tests as appropriate and adhere to the code style of the project.

License

This project is licensed under the MIT License - see the LICENSE file for details.