@blynx/strict-types
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

blynx-strict-types

Decorate a method for strict types

Example

class MyCustomClass {}

export class Test {
    @StrictTypes(Function, Boolean, Nullable(String), Arguments(Nullable(Number)))
    public TestMethod(func, bool, str) { }

    @StrictTypes(MyCustomClass, Boolean)
    public Custom(cust, boolean) { }
}
var t = new Test();

t.TestMethod(null, true, '', 1); // Throws at argument index 0
t.TestMethod(function() {}, true, null); // Does not throw
t.TestMethod(function() {}, true, null, 1, 2, 3, false); // Throws at argument index 6

t.Custom(new MyCustomClass(), true); // Does not throw

Package Sidebar

Install

npm i @blynx/strict-types

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

16.1 kB

Total Files

39

Last publish

Collaborators

  • blynx