Typescript errors occur when I try to integrate React Framework based Target Audience functionality into SPFx solution having multiple SPFx Web Parts that have no Javascript Framework

Vivek Gupta 126 Reputation points
2020-08-19T16:14:47.357+00:00

Hi,

I have created a SPFx solution & added multiple SPFx Web Parts having no Javascript Framework.

For implementing the Target Audience functionality, I have created a React Framework based SPFx Web Part in this SPFx solution & have integrated the changes from https://github.com/rabwill/generic-target-audience

However, I am getting compilation errors when I execute gulp build.

For example:

Error - typescript - node_modules/@types/prop-types/index.d.ts(52,53): error TS1005: ';' expected.

Error - typescript - node_modules/@types/prop-types/index.d.ts(52,56): error TS1109: Expression expected.

Error - typescript - src/webparts/sampleTargetedComponent/SampleTargetedComponentWebPart.ts(19,21): error TS2415: Class 'SampleTargetedComponentWebPart' incorrectly extends base class 'BaseClientSideWebPart<ISampleTargetedComponentWebPartProps>'.

Kindly let me know the solution for the above errors.

Thanks.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,819 questions
0 comments No comments
{count} votes

Accepted answer
  1. Baker Kong-MSFT 3,791 Reputation points
    2020-08-20T03:03:24.883+00:00

    Hi anonymous user-9563,

    I understand you want to add 'target-audience-generic-component' web part (React) to an existing web part solution (No JS Framework). Please take a reference of below demo:

    This demo contains a 'helloword' webpart (no framework) and 'SampleTargetedComponentWebPart'.

    Test Result:

    18973-image.png

    19002-1.jpg

    More reference:

    Best Regards,
    Baker Kong

    0 comments No comments

0 additional answers

Sort by: Most helpful