SPFx – Using PnPjs version 3 : Resolving error – Error – [tsc] node_modules/@pnp/queryable/queryable.d.ts(10,115): error TS1005: ‘,’ expected.

SPFx component - error while using spfi member from module "@pnp/sp" from PnPjs version 3
SPFx component - error while using spfi member from module "@pnp/sp" from PnPjs version 3

Hi All,

Greetings for the day ! New issue and solution !! Exploring SPFx continues !

Background / Details :

import { spfi, SPFx } from "@pnp/sp";

  • But as I build the project using gulp command, getting an error

gulp build

Error / Issue :

Error – [tsc] node_modules/@pnp/queryable/queryable.d.ts(10,115): error TS1005: ‘,’ expected. #2126

Error – [tsc] node_modules/@pnp/queryable/queryable.d.ts(10,155): error TS1005: ‘;’ expected

Error – [tsc] node_modules/@pnp/queryable/queryable.d.ts(10,156): error TS1131: Property or signature expected.

SPFx component - error while using spfi member from module "@pnp/sp" version 3
fig : SPFx component – error while using spfi member from module “@pnp/sp” from PnPjs version 3

SPFx component - error while using spfi member from module "@pnp/sp" from PnPjs version 3
fig : SPFx component – error while using spfi member from module “@pnp/sp” from PnPjs version 3

Solution / Cause:

  • This error is caused since current version of @microsoft/generator-sharepoint defaults to TypeScript 3.7
  • Because of this when we use newer version of PnPjs it breaks the build and shows the respective above errors
  • To solve this issue we need upgrade the Microsoft rush stack compiler with latest version and update tsconfig file
fig : SPFx component – tsconfig.json file – old version of “rush stack compiler” referred
  • Upgrading Microsoft rush stack compiler : As shown in above fig, in tsconfig.json file – old version of “Microsoft rush stack compiler” is mentioned – 3.9, we need to upgrade it to latest version 4.2 as

npm uninstall @microsoft/rush-stack-compiler-3.9

npm i @microsoft/rush-stack-compiler-4.2

SPFx component - removing / uninstalling old version of "rush stack compiler"
fig : SPFx component – removing / uninstalling old version of “rush stack compiler”

SPFx component - installing updated version of "rush stack compiler" - 4.2
fig : SPFx component – installing updated version of “rush stack compiler” – 4.2

  • Once we have latest version of “Microsoft rush stack compiler” we need to update our tsconfig.json file to use it as
SPFx component - Updated tsconfig.json file for referring latest "Microsoft rush stack compiler"
fig : SPFx component – Updated tsconfig.json file for referring latest “Microsoft rush stack compiler”

Try to build again. Build will be successful.

Thanks for reading! Please feel free to discuss in case any issue / suggestions / thoughts

HAVE A GREAT TIME AHEAD!

Prasham Sabadra

LIFE IS VERY BEAUTIFUL. ENJOY THE WHOLE JOURNEY :) Founder of Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

You may also like...

1 Response

  1. April 9, 2022

    […] one of our SPFx last article – SPFx – Using PnPjs version 3 : Resolving error – Error – [tsc] node_modules/@pnp/query… we discussed about Microsoft rush stack compiler and updated the latest version of […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Microsoft 365

Subscribe now to keep reading and get access to the full archive.

Continue reading