Skip to content

JavaScript runtime decorator that enforces types in class methods

License

Notifications You must be signed in to change notification settings

Kawyn/unholy-types

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript runtime decorator that enforces types in class methods

Setup

To decorate Your functions with type checkers just inherit after UnholyTypes:

class YourSuperbClass extends UnholyTypes { }

Due to some heresy, Unholy Types ensures that when calling a function, parameters are of the type given in the JSDoc (currently only works for primitives), e.g.:

class LoremIpsum extends UnholyTypes {

    /**
     * 
     * @param {string|number} str 
     * @param {number} num 
     */
    test(str, num) {

        console.log(str, num);
    }
}

let x = new LoremIpsum();

x.test(3, 2); // pasess
x.test('a', 'b'); // throws error

About

JavaScript runtime decorator that enforces types in class methods

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published