An RTTI and generics system for JavaScript.
npm install typings.jsmain.js in your HTML.html
...
...
`
The
typings object
The namespace for typings.js is called typings. It has the following interface:
`WebIDL
namespace typings {
//TypeName is a string or a constructor.
//BasicConstructor is a constructor.
//ClassProtoConstructor is a function that takes in an object of generic types with string keys and TypeName values and returns an ES6 class.
callback Observable = T?(optional T? val);
Observable createTypedVar(TypeName tipe, T value);
any createGenericClass(sequence genArgs, ClassProtoConstructor proto);
boolean typeCheck(TypeName tipe, T obj);
T instantiate(TypeName tipe);
}
`
Tutorial
Now that you've gotten Typings.js set up, let's go through a tutorial. This assumes that you are using JavaScript.
You can see the full source code at demo.html.
This tutorial uses the TemplateElement library.
First, create an HTML file. I chose "Typings.js Tutorial", but you can choose your own title.
`html
...
...
...
``