调用我的打字稿对象的新实例时,非法的构造函数

时间:2019-01-07 18:24:00

标签: javascript typescript indexeddb

我有一个自定义的打字稿类对象:

class IndexedDBManager {
 constructor(autoCreateDatabaseAndTable : boolean = false, databaseName : string = null, tableName : string = null, primaryKey : string = null, obtrusiveError: boolean = false) {
      if (!this.VerifyIndexDB()) {
            console.error("IndexedDB is not supported on this browser.");
            if (obtrusiveError) {
                 alert("IndexedDB is not supported on this browser.");
                 return;
            }
      }
      if (autoCreateDatabaseAndTable) {
            this.SetAndCreateDatabase(databaseName, obtrusiveError);
            this.SetAndCreateTable(tableName, primaryKey, obtrusiveError);
      }
 }
...
}

当尝试使用实例化此类的新实例时

var myTest = new IndexedDBManager(true, "myTestDB", "myTestTable", "key", true);

在浏览器控制台中,出现以下控制台错误:

TypeError: Illegal constructor.

这是怎么回事,我该如何解决?

编辑:如注释中所述,从构造函数中删除所有代码并不能解决问题。

0 个答案:

没有答案
相关问题