0.2.0 • Published 5 years ago

ewk-ts v0.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

ewk-ts

TypeScript compiler extensions

Features

  • Getting the fields of an interface
  • Getting the name of the interface

Install

yarn add ewk-ts to install the package

Usage

Simple pass extensionTransformerBuilder to the before category of your custom transformers

By calling __fieldsOf<InterfaceOrTypeName>() we get a string[] with the names of all fields.

interface User {
    id: number;
    email: string;
}
__fieldsOf<User>();

transforms into

["id", "email"]

and than it gets transformed by the TypeScript compiler to JavaScript.

By calling __nameOf<InterfaceOrTypeName>() you get the name of the interface

interface SuperUser {
    id: number;
    email: string;
}

__nameOf<SuperUser>();

will be transformed into

"SuperUser"

Notes

  • Inheritance is supported
  • A discriminated union will contain only the fields shared by all types.
  • An intersection will contain all types. Warning, duplicates are not removed

Author

Ruslan Cisa

cisa.ruslan@gmail.com

License

MIT

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago