Error TS2350 when create a new Promise in certain situations #117

Closed
opened 2025-08-09 17:15:04 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @QuinntyneBrown on 3/26/2018

Using the .NET Core 2.1 Template when creating a new Promise in certain situation, you get a TS2350 error.

It looks like there is another Promise type definition that Visual Studio is getting confused with, Q.IPromise.

The following code inside a HubClient Service will raise an error as the compiler thinks I'm trying to use Q.IPromise and not the native promise.

public connect(): Promise {
if (this._connect) return this._connect;

this._connect = new Promise((resolve) => {
  this._connection = this._connection || new HubConnection("/signalrDemoHub");
  this._connection.start().then(() => resolve());
});

return this._connect;

}

*Originally created by @QuinntyneBrown on 3/26/2018* Using the .NET Core 2.1 Template when creating a new Promise in certain situation, you get a TS2350 error. It looks like there is another Promise type definition that Visual Studio is getting confused with, Q.IPromise. The following code inside a HubClient Service will raise an error as the compiler thinks I'm trying to use Q.IPromise and not the native promise. public connect(): Promise<any> { if (this._connect) return this._connect; this._connect = new Promise((resolve) => { this._connection = this._connection || new HubConnection("/signalrDemoHub"); this._connection.start().then(() => resolve()); }); return this._connect; }
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#117
No description provided.