Skip to content

Class constructor h cannot be invoked without 'new' #10805

@jacksonv1lle

Description

@jacksonv1lle

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Developer environment

None

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

  • SPFx version: 1.20.2
  • Node.js version: 18.19.1

Describe the bug / error

We are seeing a tenant-specific regression affecting an SPFx library compiled with TypeScript target es5.

The bug presents with the following console error:
TypeError: Class constructor h cannot be invoked without 'new'
And causes the components that use custom extended versions of SPFx HTTP clients fail when they indirectly use MSGraphClientFactory or SPHttpClient.

For example we are implementing a custom class extending SPHttpClient like this:

export class SPHttpClientWithAuth extends SPHttpClient {
    constructor(serviceScope) {
        super(serviceScope);
    }
}

This is compiled as es5 and has been integrating fine with the SPHttpClient runtime code as that was also es5.
Now that the runtime is es6, this class extend is failing.

Recompiling the library with target: es2015 resolves the issue.

We cannot find Microsoft documentation stating that ES5-compiled SPFx components are no longer supported, nor a published 2026 cutoff date for ES5 in SPFx.

Microsoft documentation still presents MSGraphClientV3 and SPHttpClient as supported SPFx APIs.

Steps to reproduce

  1. Configure an SPFx webpart with "target": "es5" in the tsconfig.json

  2. In the web part src directory, create a class which extends SPHttpClient

     export class CustomSPHttpClient extends SPHttpClient {
         public static serviceKey = ServiceKey.create<SPHttpClient>("CustomSPHttpClientService", this);
    
         constructor(serviceScope: ServiceScope){
             super(serviceScope);
         }
    
         protected async _fetch(url: string, configuration: SPHttpClientConfiguration, options: ISPHttpClientOptions): Promise<SPHttpClientResponse> {
             console.log("Fetch: ", url);
             return await super._fetch(url, configuration, options);
         }
     }
    
  3. Consume the CustomSPHttpClient service from the webpart.

  4. Deploy the web part on a tenant which uses es6 runtime

  5. Observe the error: TypeError: Class constructor h cannot be invoked without 'new'

Expected behavior

Please confirm whether Microsoft has recently changed the SharePoint Online/SPFx runtime, @microsoft/sp-http, MSGraphClientFactory, SPHttpClient, or related Graph client dependencies to require ES2015+ output. If this is intentional, please provide the official support/deprecation statement. If not, please treat this as a tenant-specific regression.

Metadata

Metadata

Assignees

Labels

area:spfxCategory: SharePoint Framework (not extensions related)sharepoint-developer-supportsharepoint-developer-supporttype:bug-suspectedSuspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions