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 🙏

© 2024 – Pkg Stats / Ryan Hefner

unified-types-declarator

v1.4.2

Published

The Unified Type Declarator is a utility designed for generating global TypeScript type declarations from project files.

Downloads

45

Readme

Unified Type Declarator

Description

The Unified Type Declarator is a utility designed for generating global TypeScript type declarations from project files. This tool automates the creation of detailed type definitions, ensuring consistency and accuracy across large TypeScript projects. It's particularly useful for applications with complex or frequently changing data models, as it helps maintain type safety and improve developer productivity by reducing manual type declaration overhead.

Motivation

The Unified Type Declarator was developed to address the complexities associated with managing TypeScript type declarations, especially in large-scale projects or those organized as monorepos. In environments where multiple packages coexist within a single repository, maintaining a single source of truth for type definitions is crucial. This tool facilitates the integration and reuse of types across different parts of a project, streamlining development and enhancing maintainability.

Features

  • Automatic Generation: Creates global TypeScript type declarations automatically.
  • Configuration: Fully configurable through standard tsconfig.json files.
  • Support: Handles Enums, Interfaces, Types, Functions, Variable Declarations and Classes seamlessly.
  • Integration: Easily integrates into existing TypeScript projects.

Installation

To install the Unified Type Declarator, run the following command:

npm install unified-types-generator
# or globally
npm install -g unified-types-generator

Usage

Here's how you can use the Unified Type Declarator in your project:

Setup Configuration:

Ensure your tsconfig.declaration.json or a custom configuration file specifies the root directory, include paths, exclude paths, and the output file name.

Generating Types:

By default, the Unified Type Declarator uses tsconfig.declaration.json to generate type declarations. To run the Declarator with the default configuration file, use:

npx ut-declarator

If you need to specify an alternative configuration file, you can pass the path to the executable as follows:

Integrate Generated Types:

Include the generated type declaration file in your project to enhance type checking and IntelliSense across your IDE.

npx ut-declarator tsconfig.otherFile.json

This flexibility allows you to customize the generation process based on different configurations within the same project or across projects.

Integration

After generating the type declarations, include the generated type declaration file in your project to enhance type safety and IntelliSense support across your IDE.

Example Workflow
  1. Set up your configuration: Adjust your tsconfig.declaration.json or another config file to include all necessary model files.

  2. Generate types: Use the default or a specified configuration file to run the declarator.

  3. Integrate the types: Include the output file in your project for improved type checking. Here is a simple tsconfig example that the declarator could use:

{
	"compilerOptions": {
		"outFile": "types/index.d.ts",
		"rootDir": "./src"
	},
	"include": ["./src/**/*.entity.ts", "./src/**/*.fixtures.ts"],
	"exclude": ["./src/**/*.service.ts"]
}

License

This project is licensed under the MIT License - see the LICENSE.md file for details. The MIT License is a permissive license that is short and to the point. It lets people do almost anything they want with your project, like making and distributing closed source versions.