Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serviceScope={serviceScope from AppContext} Does not pass typescript in SPFx 1.15 #1253

Closed
Ofer-Gal opened this issue Jul 5, 2022 · 9 comments

Comments

@Ofer-Gal
Copy link

Ofer-Gal commented Jul 5, 2022

Category

[ ] Enhancement

[? ] Bug

[ ?] Question

Version 3.8.1

Using

    const { wpContext } = React.useContext(AppContext);
    const sp:ServiceScope = wpContext.serviceScope;

I get TS error:

TS2322: Type 'import("C:/DATA/Sources/Repos/SPFx15/DpcAllJobsScreen/node_modules/@microsoft/sp-core-library/dist/index-internal").ServiceScope' is not assignable to type 'import("C:/DATA/Sources/Repos/SPFx15/DpcAllJobsScreen/node_modules/@pnp/spfx-property-controls/node_modules/@microsoft/sp-core-library/dist/index-internal").ServiceScope'.
  Types have separate declarations of a private property '_registrations'.
    163 |     const sp:ServiceScope = wpContext.serviceScope;
    164 |     return (
  > 165 |         <LivePersona upn={params.data.RequestFor.Email}  serviceScope={sp}
        |                                                          ^^^^^^^^^^^^

How can I use "LivePersona" with hooks deep in child component?
what is "private property '_registrations"

Thanks

@ghost
Copy link

ghost commented Jul 5, 2022

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

@ghost ghost added the Needs: Triage 🔍 label Jul 5, 2022
@AJIXuMuK
Copy link
Collaborator

AJIXuMuK commented Jul 5, 2022

@Ofer-Gal - the library hasn't been updated to SPFx 1.15.0 yet.
You should cast the property to any to pass it in.
Or, potentially, do double casting like as unknown as ServiceScope where ServiceScope is imported as type from @pnp/spfx-property-controls/node_modules/@microsoft/sp-core-library (not sure though it will work)

@Ofer-Gal
Copy link
Author

Ofer-Gal commented Jul 6, 2022

@AJIXuMuK - Thank you. Both your suggestions worked for TS but the run time failed with error:

SPLoaderError.loadComponentError]:
Failed to load component "ee96f3dd-120e-4983-b269-ac5da936bad1" (DpcAllJobsScreenWebPart). Original error: The entry point for component "ee96f3dd-120e-4983-b269-ac5da936bad1" (DpcAllJobsScreenWebPart) has a dependency on "@microsoft/sp-loader" that is not declared in the manifest.

INNERERROR:
The entry point for component "ee96f3dd-120e-4983-b269-ac5da936bad1" (DpcAllJobsScreenWebPart) has a dependency on "@microsoft/sp-loader" that is not declared in the manifest.
CALLSTACK:
Error
    at t [as constructor] (https://res-1.cdn.office.net/files/sp-client/sp-webpart-workbench-assembly_en-us_d773573f7d35b6f7a679f16c44d839ae.js:70:214899)
    at new t (https://res-1.cdn.office.net/files/sp-client/sp-webpart-workbench-assembly_en-us_d773573f7d35b6f7a679f16c44d839ae.js:72:7680)
    at e.buildErrorWithVerboseLog (https://res-1.cdn.office.net/files/sp-client/sp-webpart-workbench-assembly_en-us_d773573f7d35b6f7a679f16c44d839ae.js:72:44944)
    at e.buildLoadComponentError (https://res-1.cdn.office.net/files/sp-client/sp-webpart-workbench-assembly_en-us_d773573f7d35b6f7a679f16c44d839ae.js:72:41035)
    at https://res-1.cdn.office.net/files/sp-client/chunk.systemjs-component-loader_en-us_dc58eaaa7aaff14eda18.js:1:6012

So I will wait for you to add SPFx 1.15 support. I will use MGT for now.
Any idea when you will do it?

@AJIXuMuK
Copy link
Collaborator

AJIXuMuK commented Jul 6, 2022

@Ofer-Gal the issue doesn't seem to be related to 1.15. Have you tried the same with 1.14? Is it working?

@fonbrauzen
Copy link

fonbrauzen commented Jul 15, 2022

@Ofer-Gal 2 workarounds:

  1. @microsoft/sp-loader add to dependencies
  2. (a bit of hardcore, which I use when this library behind SPFX) clone this repo, get your control from there, copy to your repo with dependencies and try to get it work, when later on this library catches up with SPFX version you could switch it back to library one.

@fonbrauzen
Copy link

@AJIXuMuK any plans, or estimations about when 1.15 will be integrated?

@michaelmaillot
Copy link
Collaborator

Hi everyone,

Latest version (3.15.0) is based on SPFx 1.17.3.

Did anyone of you had the chance to test again with this one? Does the problem still occur?

@ghost
Copy link

ghost commented Aug 28, 2023

This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within next 7 days of this comment. Thank you for your contributions to SharePoint Developer activities.

@ghost ghost closed this as completed Sep 4, 2023
@ghost
Copy link

ghost commented Sep 4, 2023

Closing issue due no response from original author. If this issue is still occurring, please open a new issue with additional details. Notice that if you have included another related issue as additional comment on this, please open that also as separate issue, so that we can track it independently.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants