Skip to content

A collection of TypeScript utilities and examples for use cases

License

Notifications You must be signed in to change notification settings

Omer-Shahar/TypeScript-Dreams

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript Dreams

This is a collection of TypeScript utilities and examples for use cases, including:

Installation

In order to use context.ts, run npm install zod. In order to use decorators.ts, enable decorators in your tsconfig.json file:

{
    "compilerOptions": {
        "experimentalDecorators": true
    }
}

Behind the Scenes

Functions

  • getContext - returns the current context.
  • getZodContext - returns the current context if it fits the received schema, otherwise throws an error.
  • runWithContext - runs a function with a new context.

Types

  • Func<Return> - a function that returns Return.
  • MethodDesc<Return> - a descriptor for a method that returns Return.
  • MethodDecorator - a decorator for a method.
  • ClassDecorator - a decorator for a class.
  • MethodDescValueGetter - a function that receives a method descriptor and the original method, and returns a new method.
  • ExistingMethodDesc - a method descriptor with an existing method.

Functions

  • getMethodsDescriptors - receives a class prototype and returns an array of existing method descriptors.
  • getClassName - receives a class prototype and returns the class name.

Disclaimer

The code in this repository serves as a proof of concept and might not work in all cases. It is recommended to test it thoroughly before using it in a production environment. I encourage you to experiment with it and adjust it to your needs. If you find any issues or have suggestions for improvements, please let me know.

About

A collection of TypeScript utilities and examples for use cases

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published