Tuesday, 18 April 2017

TS - Only a void function can be called with the 'new' keyword

I am getting this weird error from TypeScript:

"Only a void function can be called with the 'new' keyword."

What?

enter image description here

The constructor function, just looks like:

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;

}

I have no idea what the problem is. I tried adding and removing the return type (void) but that did nothing.



via Alexander Mills

No comments:

Post a Comment