Skip to content
/ typeg Public

Typeg generates type definitions for TypeScript using decorators using Prettier

Notifications You must be signed in to change notification settings

suguru03/typeg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Typeg

Typeg generates type definitions for TypeScript using decorators using Prettier.

@Times creates similar type definitions such as Promise.all easily.

Currently, It will only work where you can define TypeScript decorators.

class Promise {
  @Times(10, 'T', { args: { values: 'arrayMulti' }, returnType: 'arrayMulti' })
  all<T>(values: [T | PromiseLike<T>]): Promise<[T]>;
}
yarn typeg promise.d.ts --out _promise.d.ts
class Promise {
  all<T1>(values: [T1 | PromiseLike<T1>]): Promise<[T1]>;
  all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
  all<T1, T2, T3>(
    values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>],
  ): Promise<[T1, T2, T3]>;
  all<T1, T2, T3, T4>(
    values: [
      T1 | PromiseLike<T1>,
      T2 | PromiseLike<T2>,
      T3 | PromiseLike<T3>,
      T4 | PromiseLike<T4>
    ],
  ): Promise<[T1, T2, T3, T4]>;
  ...
}

Other examples are here!

Usage

npm install -D prettier typeg
// or
yarn add -D prettier typeg
npx typeg <filepath> --out <dirpath>
// or
yarn typeg <filepath> --out <dirpath>

Use case

About

Typeg generates type definitions for TypeScript using decorators using Prettier

Resources

Stars

Watchers

Forks

Packages

No packages published