我從打字稿得到這個奇怪的錯誤被稱爲:TS - 只有一個void函數可以用「新」關鍵字
"Only a void function can be called with the 'new' keyword."
什麼?
的構造函數,只是看起來像:
function Suman(obj: ISumanInputs): void {
const projectRoot = _suman.projectRoot;
// via options
this.fileName = obj.fileName;
this.slicedFileName = obj.fileName.slice(projectRoot.length);
this.networkLog = obj.networkLog;
this.outputPath = obj.outputPath;
this.timestamp = obj.timestamp;
this.sumanId = ++sumanId;
// initialize
this.allDescribeBlocks = [];
this.describeOnlyIsTriggered = false;
this.deps = null;
this.numHooksSkipped = 0;
this.numHooksStubbed = 0;
this.numBlocksSkipped = 0;
}
我不知道是什麼問題。我嘗試添加和刪除返回類型(void),但是什麼也沒做。
'new(function Class(){})()'引發警告。 – Cody