sp-dev-fx-controls-react icon indicating copy to clipboard operation
sp-dev-fx-controls-react copied to clipboard

package version conflict regarding LivePersona

Open kongmengfei opened this issue 2 years ago • 8 comments

Hello,

I am trying to use pnp control LivePersona in my spfx project. this control needs a prop 'serviceScope' , when I pass webpart context to it, it will prompt an error:

image

Error:

Type 'import("C:/nline_1.15/node_modules/@microsoft/sp-core-library/dist/index-internal").ServiceScope' is not assignable to type 'import("C:/nline_1.15/node_modules/@pnp/spfx-controls-react/node_modules/@microsoft/sp-core-library/dist/index-internal").ServiceScope'. Types have separate declarations of a private property '_registrations'.

it seems that PNP control uses spfx 1.14 while my project uses 1.15. there're 2 "@microsoft/sp-core-library", one is spfx (1.15), other is 1.14.

please help me! I need the below hover card while fluent UI does not have

image

Category

[ ] Enhancement

[ ] Bug

[x ] Question

Environment

Node: v14.20.0 Spfx: lastest, 1.15

Thanks!

kongmengfei avatar Aug 24 '22 07:08 kongmengfei

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ghost avatar Aug 24 '22 07:08 ghost

Thank you for submitting your first issue to this project.

github-actions[bot] avatar Aug 24 '22 07:08 github-actions[bot]

Hi @kongmengfei ,

The beta version of the controls is already updated to SPFx 1.15.2 so you can install the beta version until the main release is out. Or as a temporary workaround, can you try to pass your object as any:

serviceScope={this.context.serviceScope as any}

Please let us know if you were able to resolve the issue

joelfmrodrigues avatar Aug 24 '22 08:08 joelfmrodrigues

We have just updated our projects to SPFx 1.17.4 and observed the same error, even with the latest 3.16.0-beta.5586495.
Passing serviceScope as any, like you suggested, was useful for mitigation though.

mzietlow avatar Jul 31 '23 10:07 mzietlow

Hi @mzietlow,

I've just tested the LivePersona control in a webpart built on 1.17.3 of SPFx and 3.15.0 of PnP Controls and it's working without having to cast the ServiceScope.

Would you mind giving a try on a fresh new webpart and tell us if it's working or not?

Can you share your package.json file, or at least the packages dependancies installed?

michaelmaillot avatar Aug 08 '23 08:08 michaelmaillot

Hi @mzietlow,

Did you have the chance to test with latest version (3.15.0) and version 1.17.x of SPFx?

michaelmaillot avatar Aug 08 '23 08:08 michaelmaillot

Hi @michaelmaillot, I don't have a minimal working example by hand, but in my project, casting to any was required. ServiceScope comes from another project (I'll name it MyOnlineLibs). MyOnlineLibs was also updated to SPFx v1.17.4:

Type 'import("D:/MyOnlineLibs/node_modules/@microsoft/sp-core-library/dist/index-internal").ServiceScope' is not assignable
to type 'import("d:/MyProject/node_modules/@pnp/spfx-controls-react/node_modules/@microsoft/sp-core-library/dist/index-internal").ServiceScope'.
  Types have separate declarations of a private property '_registrations'.ts(2322)


ILivePersonaProps.d.ts(7, 5): The expected type comes from property 'serviceScope' which is declared here on type 'IntrinsicAttributes & ILivePersonatProps & { children?: ReactNode; }'

My deps:

...
  "dependencies": {
    "tslib": "2.3.1",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "office-ui-fabric-react": "^7.199.1",
    "@microsoft/sp-core-library": "1.17.4",
    "@microsoft/sp-property-pane": "1.17.4",
    "@microsoft/sp-webpart-base": "1.17.4",
    "@microsoft/sp-lodash-subset": "1.17.4",
    "@microsoft/sp-office-ui-fabric-core": "1.17.4",
    "@pnp/spfx-controls-react": "^3.15.0",
    ...
  },
...

mzietlow avatar Aug 08 '23 10:08 mzietlow

Ok so I've tested with a SPFx 1.17.4 webpart and I repro the issue.

I've had a look at the ServiceScope.js file (in @microsoft/sp-core-library node_modules) which contains the _registrations property in both version 1.17.3 & 1.17.4 and I don't see any difference between them.

For now, version 3.15.0 of PnP Controls relies on SPFx version 1.17.3 so you can keep casting like like suggests @joelfmrodrigues or downgrade your project to SPFx version 1.17.3 if you can (I would understand that you can't / don't want to).

Maybe there could be some investigation around this one, to know if there's a real difference between ServiceScope file versions or if the PnP Controls could be updated with some flexibility around this one.

michaelmaillot avatar Aug 08 '23 15:08 michaelmaillot