To use the constructor function from the Underscore library in TypeScript, you can import it as a module like this:
index.ts40 chars2 lines
Then you can use it to create new instances of a class as follows:
index.ts160 chars7 lines
In this example, we're using the construct
function to create a new instance of MyClass
and passing in the constructor arguments as an array. The result is a new instance of MyClass
with the name
property set to 'John Doe'
.
Note that you'll need to have Underscore.js installed as a dependency in your project for this to work.
gistlibby LogSnag