Closed tyh77 closed 3 years ago
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
You say you want to use TypeScript 3.7, but this line:
"@microsoft/rush-stack-compiler-3.3": "0.3.5",
... in your package.json is using TypeScript v3.3. The ability to use different versions of TypeScript from what is included in the OOTB project was added in SPFx v1.8.2. Refer to the release notes on how it works as well as this post by Elio.
With that being said, there hasn't been a recommended version of the Rush TS compiler project to use TS v3.7 with SPFx 1.11, the current release. You can try different versions of the 3.7 Rush TS compiler package to see if one works, but AFAIK, there's no recommended/supported version.
Thanks @andrewconnell
I targeted the 3.7 Rush TS Compiler to see if it would work.
I'm encountering errors loading the web part I developed, but am not sure what the issue is (doesn't seem like the component is even entering Render()
)
[SPLoaderError.loadComponentError]:
***Failed to load component "cf2dde94-4dbc-4dfe-9d48-907d9f0a7280" (NgxTestConsoleWebPart). Original error: ***Failed to load entry point from component "cf2dde94-4dbc-4dfe-9d48-907d9f0a7280" (NgxTestConsoleWebPart). Original error: Error loading https://component-id.invalid/cf2dde94-4dbc-4dfe-9d48-907d9f0a7280_1.0.2
https://component-id.invalid/cf2dde94-4dbc-4dfe-9d48-907d9f0a7280_1.0.2 did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support.
***INNERERROR:
***Failed to load entry point from component "cf2dde94-4dbc-4dfe-9d48-907d9f0a7280" (NgxTestConsoleWebPart). Original error: Error loading https://component-id.invalid/cf2dde94-4dbc-4dfe-9d48-907d9f0a7280_1.0.2
https://component-id.invalid/cf2dde94-4dbc-4dfe-9d48-907d9f0a7280_1.0.2 did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support.
***CALLSTACK:
Error
at SPLoaderError.SPError [as constructor] (https://localhost:4321/temp/workbench-packages/@microsoft_sp-webpart-workbench/local-workbench/sp-webpart-workbench-assembly_default.js:24453:24)
at new SPLoaderError (https://localhost:4321/temp/workbench-packages/@microsoft_sp-webpart-workbench/local-workbench/sp-webpart-workbench-assembly_default.js:42171:28)
at Function../sp-loader.js.__WEBPACK_AMD_DEFINE_RESULT__.ff4n.ErrorBuilder.buildErrorWithVerboseLog (https://localhost:4321/temp/workbench-packages/@microsoft_sp-webpart-workbench/local-workbench/sp-webpart-workbench-assembly_default.js:46165:21)
at Function../sp-loader.js.__WEBPACK_AMD_DEFINE_RESULT__.ff4n.ErrorBuilder.buildLoadComponentError (https://localhost:4321/temp/workbench-packages/@microsoft_sp-webpart-workbench/local-workbench/sp-webpart-workbench-assembly_default.js:46034:21)
at https://localhost:4321/temp/workbench-packages/@microsoft_sp-webpart-workbench/local-workbench/sp-webpart-workbench-assembly_default.js:45372:75
Do you have any recommendations for debugging this? I'm not sure if this is related to the Rush TS Compiler
You don't just target the package, you have to get the specific version that is supported by the SPFx team. As you can see, there are quite a few options: https://www.npmjs.com/package/@microsoft/rush-stack-compiler-3.7
That's why I said above, TS 3.7 is not officially supported by the SPFx team. You can see what is supported here: https://docs.microsoft.com/en-us/sharepoint/dev/spfx/release-1.8.0#support-for-typescript-27-29-and-3x-general-availability
Of course, you could try one of the many different versions of the RSC-3.7 package to see if any work with SPFx v1.11, but you're not just having to consider it working with your code, but also with the SPFx engine & dependencies. That's the problem you're hitting in the error before.
But... IMHO... SPFx v1.11 is supported at TS v3.3, and that's it for now. TypeScript 3.7 released no November 5, 2020 while the most recent version of SPFx (v1.11) released on July 16, 2020. It's no surprise you're having issues with TS 3.7.
Closing this issue as "answered". If you encounter a similar issue(s), please open up a new issue. See our wiki for more details: Issue-List: Our approach to closed issues
@tyh77 Might find this useful... https://www.voitanos.io/blog/use-different-typescript-versions-in-sharepoint-framework-projects/#typescript-v37
Category
Describe the bug
Our Web Part uses a particular dependency
@paperbits/common v0.1.357
that uses TypeScript Optional Chaining (?.
operator), introduced in TypeScript v3.7 (https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html)During
tsc
, the following error is encountered:Steps to reproduce
yo @microsoft/sharepoint
npm i @paperbits/common
import { GridHelper } from '@paperbits/common/editing';
gulp serve
package.json:
Expected behavior
Successful compilation of Web Part and serving into local SP workbench
Environment details (development & target environment)
Additional context
Our dependency: @paperbits/common uses a the Optional Chaining operator like so
By Default the SPFx solution generator uses
@microsoft/rush-stack-compiler-3.3
, which targets TypeScript v3.3. However, a newer Rush Stack compiler exists that targets TypeScript v3.7. I'm wondering if I can upgrade the dependency tree to use 3.7 as opposed to 3.3?Would this break anything? How can I specify a different TypeScript compiler when scaffolding a new project using the SP Yeoman generator?