How to extend js class from outside library in TypeScript / Using mojs in TypeScript


i know how to declare library ( example usage mojs):

declare var mojs:any;

but i have problem with extending from it:

class MyObject extends mojs.CustomShape { getShape () { return '..path' } };

i get error:


Type 'any' is not constructor object type


I tried something like this:

declare var mojs:Object{ CustomShape:any };

but no luck - it is wrong code.

So how can I extend js library class in typescript?


Ok, i managed this by setting type as <strong>ObjectConstructor</strong>

My code for mojs:

declare var mojs: { CustomShape:ObjectConstructor, //here usage addShape:any, Burst:any, Timeline:any, Shape:any, ShapeSwirl:any };

So with ObjectConstructor i can extend this class without errors like:

class MyObject extends mojs.CustomShape { getShape () { return '..path' } };


  • Generic collection in generic class
  • Performance of System.IO.ReadAllxxx / WriteAllxxx methods
  • getUserMedia results in TrackStartError in Chrome
  • How do I find out what tables have data in a file in SQL Server?
  • Treetop basic parsing and regular expression usage
  • TensorFlow C++, runtime issue
  • ng-repeat not working with table but works with list
  • How to debug Shell command after customization
  • Pythons argparse default value doesn't work
  • Detection of framework usage on Mac system?
  • Memory error in python- how to use more memory
  • Spring boot 2.0.0.M4 required a bean named 'entityManagerFactory' that could not be found
  • How can I set a binding to a Combox in a UserControl?
  • Sort List of Strings By Version
  • Create DicomImage from scratch using Dcmtk
  • Highlight and Bold text in JTextPane
  • how to do an event when i swipe from fragment to the other
  • script to move all files from one location to another location
  • ILMerge & Keep Assembly Name
  • Symfony2: How to get request parameter
  • Akka Routing: Reply's send to router ends up as dead letters
  • AT Commands to Send SMS not working in Windows 8.1
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Hits per day in Google Big Query
  • Angular 2 constructor injection vs direct access
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How do I configure my settings file to work with unit tests?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Linking SubReports Without LinkChild/LinkMaster
  • Is it possible to post an object from jquery to bottle.py?
  • unknown Exception android
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Django query for large number of relationships
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • How can I use `wmic` in a Windows PE script?
  • How to push additional view controllers onto NavigationController but keep the TabBar?