Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One solution is to not use the typescript class system , but just the systeme of types and interfaces, in addition to the keyword 'new'.</p> <pre><code> //the function that create class function Class(construct : Function, proto : Object, ...mixins : Function[]) : Function { //... return function(){}; } module Test { //the type of A export interface IA { a(str1 : string) : void; } //the class A //&lt;new () =&gt; IA&gt; === cast to an anonyme function constructor that create an object of type IA, // the signature of the constructor is placed here, but refactoring should not work //Class(&lt;IA&gt; { === cast an anonyme object with the signature of IA (for refactoring, but the rename IDE method not work ) export var A = &lt;new () =&gt; IA&gt; Class( //the constructor with the same signature that the cast just above function() { } , &lt;IA&gt; { //!! the IDE does not check that the object implement all members of the interface, but create an error if an membre is not in the interface a : function(str : string){} } ); //the type of B export interface IB { b() : void; } //the implementation of IB export class B implements IB { b() { } } //the type of C export interface IC extends IA, IB{ c() : void; mystring: string; } //the implementation of IC export var C = &lt;new (mystring : string) =&gt; IC&gt; Class( //public key word not work function(mystring : string) { //problem with 'this', doesn't reference an object of type IC, why?? //but google compiler replace self by this !! var self = (&lt;IC&gt; this); self.mystring = mystring; } , &lt;IC&gt; { c : function (){}, //override a , and call the inherited method a: function (str: string) { (&lt;IA&gt; A.prototype).a.call(null, 5);//problem with call and apply, signature of call and apply are static, but should be dynamic //so, the 'Class' function must create an method for that (&lt;IA&gt; this.$super(A)).a(''); } }, //mixins A, B ); } var c = new Test.C(''); c.a(''); c.b(); c.c(); c.d();//ok error ! </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload