sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

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

Open tarcisiocorte opened this issue 9 years ago • 42 comments

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

tarcisiocorte avatar Jan 27 '17 22:01 tarcisiocorte

I'm receiving this same error. Works fine if I choose react for a framework. Is there any resolution yet?

mrackley avatar Jan 28 '17 23:01 mrackley

Me too.

ozippy avatar Jan 29 '17 01:01 ozippy

received the same error...

terry8023 avatar Jan 29 '17 04:01 terry8023

I am able to repro this error in a fresh Windows machine.

@nickpape-msft @iclanton any ideas whats going on? I tried reinstalling lodash types but that doesn't seem to help.

chakkaradeep avatar Jan 29 '17 05:01 chakkaradeep

I am also getting this problem. I can also get it to work fine if I choose react for a framework.

Build target: DEBUG [16:57:16] Using gulpfile ~\OneDrive\Documents\SPFx\Projects\helloworld-webpart-RC0\gulpfile.js [16:57:16] Starting gulp [16:57:16] Starting 'serve'... [16:57:16] Starting subtask 'pre-copy'... [16:57:16] Finished subtask 'pre-copy' after 21 ms [16:57:16] Starting subtask 'copyStaticAssets'... [16:57:16] Starting subtask 'sass'... [16:57:18] Finished subtask 'sass' after 1.3 s [16:57:18] Starting subtask 'tslint'... [16:57:18] Starting subtask 'typescript'... [16:57:18] [typescript] Using custom version: 2.0.10 [16:57:18] Finished subtask 'copyStaticAssets' after 1.4 s [16:57:23] Error - typescript - node_modules@types\lodash\index.d.ts(245,25): error TS2304: Cannot find name 'Partial'. [16:57:23] Finished subtask 'tslint' after 5.12 s [16:57:23] Error - 'typescript' sub task errored after 5.13 s "TypeScript error(s) occurred." [16:57:23] 'serve' errored after 6.51 s [16:57:23] [16:57:23] ==================[ Finished ]================== Error - typescript - node_modules@types\lodash\index.d.ts(245,25): error TS2304: Cannot find name 'Partial'. Error - 'typescript' sub task errored after 5.13 s "TypeScript error(s) occurred." [16:57:24] Project helloworld-webpart-rc-0 version: 0.0.1 [16:57:24] Build tools version: 1.1.0 [16:57:24] Node version: v4.5.0 [16:57:24] Total duration: 12 s [16:57:24] Task errors: 2

NPrice99 avatar Jan 29 '17 17:01 NPrice99

This is a regression introduced by DefinitelyTyped PR 13994.

As a workaround, you can run this command:

npm install @types/[email protected]

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

octogonz avatar Jan 29 '17 21:01 octogonz

Does SPFX support TypeScript 2.1 ?

NPrice99 avatar Jan 29 '17 21:01 NPrice99

We just finished migrating to TypeScript 2.1 a week ago, but it hasn't been released yet. We're still testing. The 2.0 -> 2.1 migration was actually fairly involved compared to your normal intuition for a "minor" version increment. We'll explain this in more detail when the next release is published.

octogonz avatar Jan 29 '17 22:01 octogonz

So unless PR13994 is reverted, the only way forward is to use npm install @types/[email protected]

NPrice99 avatar Jan 29 '17 22:01 NPrice99

I can confirm that the workaround detailed by pgonzal works successfully with the "Build Your Own WebPart" instructions.

NPrice99 avatar Jan 29 '17 23:01 NPrice99

hi. I am getting the same error even after trying the workaround suggested by pgonzal. I am trying to refer jquery file in my type script file for helloworld webpart using below import syntax. I get the same exception when tried to import moduleloader class using "@microsoft/sp-module-loader".

import * as jQuery from 'jquery';

anishetty avatar Jan 30 '17 05:01 anishetty

I am also receiving this error. Fresh install, first time through the demo.

The workaround solves the issue, but wanted to make known that it is still happening.

adamrkerr avatar Feb 02 '17 21:02 adamrkerr

see @pgonzal item above As a workaround, you can run this command: npm install @types/[email protected]

NPrice99 avatar Feb 02 '17 21:02 NPrice99

Hey all,

I made the same as Mark, I choose to react for a framework then it works

On 28 January 2017 at 23:05, Mark Rackley [email protected] wrote:

I'm receiving this same error. Works fine if I choose react for a framework. Is there any resolution yet?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SharePoint/sp-dev-docs/issues/394#issuecomment-275881155, or mute the thread https://github.com/notifications/unsubscribe-auth/AAUHiY5bMTPxTWbhQHtA-bAq-r6lm2Lkks5rW8mwgaJpZM4LwS1Q .

-- Tarcísio Costa Corte e-mail: [email protected] [email protected] Skype: tarcisiocorte Phone: +55 (11) 9 7786 4190

tarcisiocorte avatar Feb 02 '17 21:02 tarcisiocorte

@anishetty when loading the jQuery lib in an RC0 webpart, you also have to load the jQuery typeScript types like so:

npm install @types/jquery

this should fix you issue.

hope this helps

dcu-sharepoint avatar Feb 12 '17 16:02 dcu-sharepoint

This is sorted in GA.

patmill avatar Feb 25 '17 02:02 patmill

I was just going through the process of creating a hello world client web part and ran into the same problem that everyone else seems to be having.

There seem to be a number of workarounds for this issue, none of which appear to work for me.

I did npm install @types/[email protected], but now getting:

Error - typescript - node_modules@types\es6-collections\index.d.ts(78,29): error TS2304: Cannot find name 'object'. Error - typescript - node_modules@types\es6-collections\index.d.ts(87,20): error TS2304: Cannot find name 'object'. Error - typescript - node_modules@types\es6-collections\index.d.ts(88,20): error TS2304: Cannot find name 'object'. Error - typescript - node_modules@types\lodash\index.d.ts(19417,15): error TS2428: All declarations of 'WeakMap' must have identical type parameters.

These errors on a basic project have got to be a huge impediment to the adoption of Spfx.

Can someone outline in layman terms what is going on here?

muirgus avatar Apr 19 '17 15:04 muirgus

@muirgus Looks like you have an older version of typescript installed. Try updating to at least 2.2.

ghost avatar Apr 19 '17 15:04 ghost

Not sure what's happening here: Trying to install v.2.2.2, but comes back with earlier version.

λ npm install -g [email protected]
C:\Program Files\nodejs\tsc -> C:\Program Files\nodejs\node_modules\typescript\bin\tsc
C:\Program Files\nodejs\tsserver -> C:\Program Files\nodejs\node_modules\typescript\bin\tsserver
C:\Program Files\nodejs
`-- [email protected]

c:\dev\helloVue
λ tsc -v
message TS6029: Version 1.7.2

muirgus avatar Apr 19 '17 16:04 muirgus

Check the output of get-command tsc?

ghost avatar Apr 19 '17 16:04 ghost