Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Error "TS2300: Duplicate identifier 'Promise'" after installing in a SPFx project #221

Closed
pranavmmodi opened this issue Oct 12, 2016 · 20 comments
Milestone

Comments

@pranavmmodi
Copy link

Category

[ ] Enhancement

[+ ] Bug

[ ] Question

Getting some typings while running application.

error

Looks like postscript is not running while installing sp-pnp-js module. it use to work fine till yesterday and today something goes wrong.

@patrick-rodgers
Copy link
Contributor

What version of the library? If you have updated to 1.0.5 it is targeted to TypeScript 2.0. Did you get a chance to review the release notes post or the updated app setup post?

@pranavmmodi
Copy link
Author

pranavmmodi commented Oct 13, 2016

I am using typescript 2.0 and Tried both version 1.0.5 and 1.0.4 , same issue. It install library correctly but do not perform post installation step i guess.

image

@patrick-rodgers
Copy link
Contributor

There is no longer a post install step, it was removed. We now depend on some of the @types libraries to do the typings where we used to use typings. In what context are you trying to use the library? You haven't given us much to go on in terms of helping you - so the more info you can share the more we can try and help.

@pranavmmodi
Copy link
Author

pranavmmodi commented Oct 13, 2016

I understand. I am trying to run this library with share point client side framework (SPFX) http://dev.office.com/sharepoint/docs/spfx/web-parts/get-started/build-a-hello-world-web-part

This project is with React, Typescript and Gulp all provided in initial setup by Microsoft.

Everything use to work fine until yesterday untill I take latest of sp-pnp-js. Task Typescript start throwing error. Just tried to import pnp library , nothing else.
image

This is structure of my node-module sp-pnp-js folder .. It use to add few other folder previously (typings and some typingtheme or something)

image

@pranavmmodi
Copy link
Author

Ok so Its look like reference syntax create problem in my project.

Error on line /// and issue is getting fixed after I remove one / from reference. // just work fine

image

@patrick-rodgers
Copy link
Contributor

Hmmm...ok, very strange. The change yesterday was definitely the release of 1.0.5 which did change the definition files. Let me grab the very latest of SPFx and see if I can duplicate and I'll get back to you on this. Sorry for the difficulties but thanks for reporting it. We'll see if we can get you sorted out.

@patrick-rodgers
Copy link
Contributor

Interesting - so when I pulled latest SPFx it turns out it is still using TypeScript 1.8.* and I was able to duplicate this. Let me see if I can get some clarity on when they will drop the version which uses TS2. I thought we timed this well but seems like not the case.

@patrick-rodgers
Copy link
Contributor

Quick update - drop 5 of SPFx has been released and includes TypeScript 2.0, which resolves the above issues. However I am keeping this open as there are now errors related to duplicate definitions. Working with SP Engineering on best approach to make it all work together and will report back when I have something. So still working on it.

@patrick-rodgers
Copy link
Contributor

Had a look at this first thing this morning and don't have a perfect fix yet, but if you edit the tsd.d.ts file under "typings" folder in your project and remove/comment out these two lines things start working again as expected:

/// <reference path="whatwg-fetch/whatwg-fetch.d.ts" />
/// <reference path="es6-promise/es6-promise.d.ts" />

Will keep this open until we can firm up the entire experience but still working with PG on that. Thanks!

@patrick-rodgers
Copy link
Contributor

Tracking: SharePoint/sp-dev-docs#265

@patrick-rodgers patrick-rodgers changed the title PreInstall script not running while npm install -sp-pnp-js and not installing required typings Error "TS2300: Duplicate identifier 'Promise'" after installing in a SPFx project Nov 21, 2016
@biste5
Copy link
Contributor

biste5 commented Nov 23, 2016

Hi Patrick,

I'm encountering the same error, when trying to include PnP-JS in an existing TS project (it's NOT an SPFx project) where I was previously already using ES6-Promise package, but not PnP-JS.

In the screenshot below you can see as soon as I install PnP-JS, I get that error during build.
Further, in my case, I can't apply the workaround above as I'm not using typings, but trying to use only @types package

Let me know in case you need more details, or is better if I create a separate issue for this

tspnperror

@patrick-rodgers
Copy link
Contributor

@biste5 - I am currently working on dropping the reference to core-js in @types but am blocked as discussed in this thread. I am honestly considering just removing all type information from the npm package and forcing folks to install the typings using whatever system they want. I think that is less than ideal experience but this is turning into a circular problem that fixing one part breaks something for someone else. Had hoped @types was the solution but does not seem to be.

@patrick-rodgers patrick-rodgers added this to the 2.0.0 milestone Dec 30, 2016
@celerity12
Copy link

I am having similar issue, please see #287

i am using tsc v 2.1.4

@joelfmrodrigues
Copy link

Hi @patrick-rodgers,
same problem here using the latest version of package with latest version of SharePoint Framework (RC0). This package is amazing :) is there something I can help with to get this resolved?

Joel

@patrick-rodgers
Copy link
Contributor

@joelfmrodrigues - thanks for the kind words. I haven't had a chance to work with our latest with RC0 yet - been working on work + refactoring the provisioning library and getting it up in the new repo. So busy days. If you want to test out removing all the @types from sp-pnp-js and see if that builds with RC0 give it a go. My feeling currently is to not package any typing info with the library and document that folks may need to add some depending on their project. There are too many variables it seems to make it all work, so doing nothing might be best.

@joelfmrodrigues
Copy link

Hi @patrick-rodgers I will do my best to give it a try an let you know in case it worked 👍 I'm also super busy at work, but I'm trying to promote SPFx adoption within the team and this package is definitely a must have 🥇

@patrick-rodgers
Copy link
Contributor

Things should now be working fully with RC0 release of SPFx. You will need to pull latest dev branch and ensure you have RC0 installed. If someone could verify it works somewhere other than my machine that would be great. Thanks!

@joelfmrodrigues
Copy link

joelfmrodrigues commented Jan 13, 2017

@patrick-rodgers that was a quick fix! It's working for me 👍 By working I mean that the project compiles without errors. Will try to test better later

@patrick-rodgers
Copy link
Contributor

Awesome - thanks @joelfmrodrigues for confirming. Will close this as the last issue before 2.0.0!

@joelfmrodrigues
Copy link

I'm getting this error when trying to run the SPFx project locally. Not sure if it's related
node_modules@microsoft\sp-build-core-tasks\node_modules\source-map-loader-web-loader doesn't exist

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants