Solvedsp dev docs SPFx Yeoman template broken by TypeScript 2.1 definition in @types/lodash

Thank you for reporting an issue or suggesting an enhancement. We appreciate your feedback - to help the team to understand your needs, please complete the below template to ensure we have the necessary details to assist you.

Category

  • Question
  • Typo
  • [ x] Bug
  • Enhancement / Suggestion
  • Additional article idea

Expected or Desired Behavior

I was just creating a Hellow world with SharePoint Framework

Step 1
yo @microsoft/sharepoint

step 2
lp trust-dev-cert

step 3
gulp serve
----the error showed up

Observed Behavior

Steps to Reproduce

I create a helloworld folder (Windows 10)
open cmdlet and typed
yo @microsoft/sharepoint
lp trust-dev-cert
gulp serve

Build target: DEBUG
[22:33:22] Using gulpfile c:\dev\helloworld_2\gulpfile.js
[22:33:22] Starting gulp
[22:33:22] Starting 'default'...
[22:33:22] Starting subtask 'pre-copy'...
[22:33:22] Finished subtask 'pre-copy' after 14 ms
[22:33:22] Starting subtask 'copyStaticAssets'...
[22:33:22] Starting subtask 'sass'...
[22:33:23] Finished subtask 'sass' after 720 ms
[22:33:23] Starting subtask 'tslint'...
[22:33:23] Starting subtask 'typescript'...
[22:33:23] [typescript] Using custom version: 2.0.10
[22:33:23] Finished subtask 'copyStaticAssets' after 810 ms
[22:33:26] Error - typescript - node_modules@types\lodash\index.d.ts(245,25): error TS2304: Cannot find name 'Partial'.
[22:33:26] Finished subtask 'tslint' after 3.15 s
[22:33:26] Error - 'typescript' sub task errored after 3.15 s
"TypeScript error(s) occurred."
[22:33:26] 'default' errored after 3.93 s
[22:33:26]
[22:33:27] ==================[ Finished ]==================
Error - typescript - node_modules@types\lodash\index.d.ts(245,25): error TS2304: Cannot find name 'Partial'.
Error - 'typescript' sub task errored after 3.15 s
"TypeScript error(s) occurred."
[22:33:27] Project helloworld-2 version: 0.0.1
[22:33:27] Build tools version: 1.1.0
[22:33:27] Node version: v6.4.0
[22:33:27] Total duration: 7.25 s
[22:33:27] Task errors: 2

43 Answers

✔️Accepted Answer

This is a regression introduced by DefinitelyTyped PR 13994.

As a workaround, you can run this command:

npm install @types/lodash@4.14.50

However, IMO it is inappropriate for the upstream PR to introduce a patch-level SemVer change that forces all consumers to immediately upgrade to the TypeScript 2.1 compiler. The PR even failed its Travis build for this reason, but was merged anyway.

@mhegazy @lukas-zech-software @andy-ms

Other Answers:

The SPFx toolchain ships with a specific version of the TypeScript compiler. There are ways to override it (e.g. via TypeScriptConfiguration.setTypescriptCompiler() in your Gulpfile), however we generally recommend against that, because it will put you in an untested state. For small projects, the compiler doesn't matter that much, but for large code bases pretty much every single compiler upgrade causes some kind of regression or break (in our experience). The best workaround is to downgrade to a version of your typings that is compatible with your compiler. Since @types projects don't follow SemVer and specify their indirect dependencies using a wildcard, in some cases you may need to add an indirect dependency to your package.json file as well.

BTW our core toolchain already upgraded to TypeScript 2.4. This will ship in the next release of SPFx, which is right around the corner.

Related Issues:

24
sp dev docs SPFX Field Customizer Extension not loading
I was able to workaround the issue by replacing &loadSPFX=true in the url opened by gulp serve with ...
19
sp dev docs SPFX Local workbench not loading
@nickpape-msft @andrewconnell I found the issue Port 5432 is the default port value used by PostgreS...
12
sp dev docs SPFx Yeoman template broken by TypeScript 2.1 definition in @types/lodash
This is a regression introduced by DefinitelyTyped PR 13994 As a workaround you can run this command...
11
sp dev docs Breaking change on creating content types using CSOM - Value cannot be null
Thanks everyone for confirming that the workaround fix in the PnP PowerShell and NuGet package side ...
3
sp dev docs environment missing on WebPartContext for O365 hosted SPFx/workbench
So we are refactoring APIs for the next drop and the lack of API documentation has lead to this conf...