convert this as3 into typescript:

package com.playsaurus.model
{
   import by.blooddy.crypto.Base64;
   import com.adobe.serialization.json.JSONDecoder;
   import com.adobe.serialization.json.JSONEncoder;
   import com.bigDecimal.com.BigDecimal;
   import com.doogog.utils.MiscUtils;
   import com.maccherone.json.JSONEncoder;
   import com.playsaurus.numbers.BigNumber;
   import com.playsaurus.staticData.StaticData;
   import flash.utils.ByteArray;
   import flash.utils.getQualifiedClassName;
   
   public class Model
   {
      
      private static var _cache:Object = new Object();
      
      private static var _enableCaching:Boolean = true;
      
      private static var _reusableByteArray:ByteArray = new ByteArray();
      
      public static const DYNAMIC_STRING:int = 0;
      
      public static const DYNAMIC_NUMBER:int = 1;
      
      public static const DYNAMIC_BOOLEAN:int = 2;
      
      public static const DYNAMIC_OBJECT:int = 3;
      
      public static const DYNAMIC_CHILD:int = 4;
      
      public static const DYNAMIC_COLLECTION:int = 5;
      
      public static const DYNAMIC_BIG_DECIMAL:int = 6;
      
      public static const DYNAMIC_BIG_NUMBER:int = 7;
      
      public static const DYNAMIC_BYTE_ARRAY:int = 8;
      
      public static const STATIC_STRING:int = 10;
      
      public static const STATIC_INTEGER:int = 11;
      
      public static const STATIC_FLOAT:int = 12;
      
      public static const STATIC_FOREIGN_KEY:int = 13;
      
      public static const STATIC_COLLECTION:int = 14;
      
      public static const STATIC_M2M_COLLECTION:int = 15;
      
      public static const STATIC_BIG_DECIMAL:int = 16;
      
      public static const STATIC_BIG_NUMBER:int = 17;
      
      protected static const PARENT:int = 0;
      
      protected static const VAR_NAME:int = 1;
      
      protected static const COLLECTION_KEY:int = 2;
       
      
      private var _staticFields:Array;
      
      private var _dynamicFields:Object;
      
      private var _childClasses:Array;
      
      private var _staticTable:String = null;
      
      private var _staticPrimaryKey:String = null;
      
      private var _staticForeignKeys:Array;
      
      private var _staticCollections:Array;
      
      private var _staticM2MCollections:Array;
      
      protected var _dynamicParentReference:Array;
      
      private var _dynamicRoot:Model = null;
      
      public function Model()
      {
         this._staticFields = new Array();
         this._dynamicFields = new Object();
         this._childClasses = new Array();
         this._staticForeignKeys = new Array();
         this._staticCollections = new Array();
         this._staticM2MCollections = new Array();
         this._dynamicParentReference = new Array();
         super();
      }
      
      public function get staticTable() : String
      {
         return this._staticTable;
      }
      
      public function get staticPrimaryKey() : String
      {
         return this._staticPrimaryKey;
      }
      
      public function rowsInTable() : int
      {
         return MiscUtils.lengthOfObject(StaticData.instance.getAll(Object(this).constructor as Class));
      }
      
      public function sizeOfTable() : int
      {
         return this.rowsInTable();
      }
      
      public function dispose() : void
      {
      }
      
      protected function getStatic(param1:String) : *
      {
         var _loc2_:Class = null;
         var _loc3_:String = null;
         var _loc4_:String = null;
         var _loc5_:Model = null;
         var _loc6_:Object = null;
         var _loc7_:String = null;
         var _loc8_:String = null;
         var _loc9_:Object = null;
         var _loc10_:String = null;
         var _loc11_:String = null;
         var _loc12_:String = null;
         var _loc13_:Array = null;
         var _loc14_:BigDecimal = null;
         var _loc15_:BigNumber = null;
         var _loc16_:Object = null;
         if(!this._staticFields.hasOwnProperty(param1))
         {
            throw new Error("Unregistered static property \'" + param1 + "\' in \'" + this + "\' model");
         }
         if(this._staticTable)
         {
            if(!(_loc9_ = StaticData.instance.getTable(this._staticTable)).hasOwnProperty(this[this._staticPrimaryKey]))
            {
               throw new Error("Key \'" + this[this._staticPrimaryKey] + "\' does not exist in table \'" + this._staticTable + "\'.");
            }
         }
         switch(this._staticFields[param1])
         {
            case Model.STATIC_STRING:
               return _loc9_[this[this._staticPrimaryKey]][param1];
            case Model.STATIC_INTEGER:
            case Model.STATIC_FLOAT:
               return Number(_loc9_[this[this._staticPrimaryKey]][param1]);
            case Model.STATIC_FOREIGN_KEY:
               _loc2_ = this._staticForeignKeys[param1][0];
               _loc3_ = String(this._staticForeignKeys[param1][1]);
               if(!this[_loc3_])
               {
                  return null;
               }
               _loc5_ = new _loc2_();
               _loc5_[_loc5_._staticPrimaryKey] = this[_loc3_];
               return _loc5_;
               break;
            case Model.STATIC_COLLECTION:
               _loc2_ = this._staticCollections[param1][0];
               _loc4_ = String(this._staticCollections[param1][1]);
               _loc7_ = "1:M:" + _loc4_ + ":" + this[this._staticPrimaryKey];
               if(_cache.hasOwnProperty(_loc2_) && _cache[_loc2_].hasOwnProperty(_loc7_) && _enableCaching)
               {
                  return _cache[_loc2_][_loc7_];
               }
               _loc5_ = new _loc2_();
               _loc6_ = new Object();
               if(_loc9_[this[this._staticPrimaryKey]].hasOwnProperty("_" + param1 + "Index"))
               {
                  for each(_loc8_ in _loc9_[this[this._staticPrimaryKey]]["_" + param1 + "Index"])
                  {
                     _loc5_ = new _loc2_();
                     _loc5_[_loc5_._staticPrimaryKey] = _loc8_;
                     _loc6_[_loc8_] = _loc5_;
                  }
               }
               else
               {
                  _loc9_ = StaticData.instance.getTable(_loc5_._staticTable);
                  for(_loc8_ in _loc9_)
                  {
                     if(_loc9_[_loc8_][_loc4_] == this[this._staticPrimaryKey])
                     {
                        _loc5_ = new _loc2_();
                        _loc5_[_loc5_._staticPrimaryKey] = _loc8_;
                        _loc6_[_loc8_] = _loc5_;
                     }
                  }
               }
               if(_enableCaching)
               {
                  if(!_cache.hasOwnProperty(_loc2_))
                  {
                     _cache[_loc2_] = new Object();
                  }
                  _cache[_loc2_][_loc7_] = _loc6_;
               }
               return _loc6_;
               break;
            case Model.STATIC_M2M_COLLECTION:
               _loc2_ = this._staticM2MCollections[param1][0];
               _loc10_ = String(this._staticM2MCollections[param1][1]);
               _loc11_ = String(this._staticM2MCollections[param1][2]);
               _loc12_ = String(this._staticM2MCollections[param1][3]);
               _loc7_ = "M:M:" + _loc10_ + "-" + _loc11_ + "-" + _loc12_ + ":" + this[this._staticPrimaryKey];
               _loc5_ = new _loc2_();
               _loc13_ = [];
               if(_loc9_[this[this._staticPrimaryKey]].hasOwnProperty("_" + param1 + "Index"))
               {
                  _loc13_ = _loc9_[this[this._staticPrimaryKey]]["_" + param1 + "Index"];
               }
               else
               {
                  _loc16_ = StaticData.instance.getTable(_loc11_);
                  for(_loc8_ in _loc16_)
                  {
                     if(_loc16_[_loc8_][_loc10_] == this[this._staticPrimaryKey])
                     {
                        _loc13_.push(_loc16_[_loc8_][_loc12_]);
                     }
                  }
               }
               _loc6_ = new Object();
               for each(_loc8_ in _loc13_)
               {
                  _loc5_ = new _loc2_();
                  _loc5_[_loc5_._staticPrimaryKey] = _loc8_;
                  _loc6_[_loc8_] = _loc5_;
               }
               return _loc6_;
            case Model.STATIC_BIG_DECIMAL:
               return new BigDecimal(_loc9_[this[this._staticPrimaryKey]][param1]);
            case Model.STATIC_BIG_NUMBER:
               return new BigNumber(_loc9_[this[this._staticPrimaryKey]][param1]);
            default:
               throw new ModelException("Unknown static data type.");
         }
      }