0

So I ran npm install @microsoft/generator-sharepoint@latest -g

Now I have a bunch of errors in my WebPart.ts files

spfxContext is highlighted and the error is ...

(property) ILibraryConfiguration.spfxContext?: ISPFXContext Used to supply the current context from an SPFx webpart to the library

Type 'WebPartContext' is not assignable to type 'ISPFXContext'.ts(2322)

protected onInit(): Promise {

sp.setup({

spfxContext: this.context

});

return super.onInit();

}

thanks P

Nikolay
  • 10,752
  • 2
  • 23
  • 51
Pete Whelan
  • 85
  • 11

1 Answers1

0

You seem to be using pnpjs library (the line that gives the error is the initialization of the pnpjs library), try updating the pnpjs library to the latest version. Please note that pnpjs is a separate library (is not a part of the SPFx framework).

More info: https://github.com/pnp/pnpjs/issues/2329

Alternatively, just could simply cast the spfx context like this:

sp.setup({
  spfxContext: this.context as any
});
Nikolay
  • 10,752
  • 2
  • 23
  • 51