Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsc errors with SPFx 1.7 unchanged scaffolded project #2934

Closed
1 of 4 tasks
sbrown-fc opened this issue Nov 12, 2018 · 21 comments
Closed
1 of 4 tasks

tsc errors with SPFx 1.7 unchanged scaffolded project #2934

sbrown-fc opened this issue Nov 12, 2018 · 21 comments
Labels
area:tooling Category: Development tooling status:tracked Currently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed) type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Comments

@sbrown-fc
Copy link

sbrown-fc commented Nov 12, 2018

Category

  • Question
  • Typo
  • Bug
  • Additional article idea

Expected or Desired Behavior

Workbench page launches with ability to add web part.

Observed Behavior

Workbench page is blank. Console shows error messages:

Build target: DEBUG
[12:40:38] Using gulpfile ~\Documents\SharePoint\playground\spfx17\gulpfile.js
[12:40:38] Starting gulp
[12:40:38] Starting 'serve'...
[12:40:38] Starting subtask 'configure-sp-build-rig'...
[12:40:38] Finished subtask 'configure-sp-build-rig' after 7.67 ms
[12:40:38] Starting subtask 'spfx-serve'...
[12:40:39] Starting server...
Starting api server on port 5432.
Registring api: /workbench
Registring api: */*
[12:40:39] Finished subtask 'spfx-serve' after 692 ms
[12:40:39] Starting subtask 'pre-copy'...
[12:40:39] Finished subtask 'pre-copy' after 25 ms
[12:40:39] Starting subtask 'copy-static-assets'...
[12:40:39] Starting subtask 'sass'...
[12:40:39] Server started https://localhost:4321
[12:40:39] LiveReload started on port 35729
[12:40:39] Running server
[12:40:39] Opening https://localhost:5432/workbench using the default OS app
[12:40:39] Finished subtask 'copy-static-assets' after 81 ms
[12:40:39] Finished subtask 'sass' after 326 ms
[12:40:39] Starting subtask 'tslint'...
[12:40:39] [tslint] tslint version: 5.9.1
[12:40:40] Starting subtask 'tsc'...
[12:40:40] [tsc] typescript version: 2.4.2
  Request: [::1] '/workbench'
  Request: '/temp/workbench.html'
  Request: '/temp/manifests.js'
  Request: '/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js'
  Request: '/temp/workbench-packages/@microsoft_sp-webpart-workbench/lib/api/workbenchInit.js'
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(27,38): error TS1005: '=' expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(29,46): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(29,75): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(29,99): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,54): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,78): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,81): error TS1109: Expression expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,97): error TS1109: Expression expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,122): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,130): error TS1128: Declaration or statement expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,138): error TS1005: ',' expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(44,48): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(44,49): error TS1109: Expression expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(44,50): error TS1109: Expression expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(44,68): error TS1005: '(' expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(44,69): error TS1005: ')' expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(46,30): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(46,54): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/prop-types/index.d.ts(46,57): error TS1109: Expression expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(672,11): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(672,39): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(672,42): error TS1109: Expression expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(674,11): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(674,40): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(675,13): error TS1109: Expression expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(676,13): error TS1005: '(' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(676,17): error TS1005: ',' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(676,35): error TS1005: ',' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(677,17): error TS1109: Expression expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(678,21): error TS1005: ')' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2597,27): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2598,14): error TS1005: ':' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2598,28): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2599,9): error TS1109: Expression expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2600,9): error TS1005: '(' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2601,9): error TS1005: '(' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2602,5): error TS1005: '(' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2602,12): error TS1005: ')' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2604,39): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2604,66): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2604,89): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2605,5): error TS1128: Declaration or statement
expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2606,5): error TS1005: '(' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2606,9): error TS1005: ',' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2606,36): error TS1005: ',' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2606,37): error TS1005: ':' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2608,9): error TS1005: '(' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2608,13): error TS1005: ',' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2608,43): error TS1005: ',' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2608,44): error TS1005: ':' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2610,13): error TS1005: '(' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2610,16): error TS1005: ')' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2624,49): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2624,89): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2624,92): error TS1109: Expression expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2624,126): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2625,13): error TS1109: Expression expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2625,17): error TS1005: ':' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2625,57): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2625,60): error TS1109: Expression expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2625,94): error TS1005: ';' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2626,17): error TS1109: Expression expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2627,17): error TS1005: '(' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2628,13): error TS1005: '(' expected.
[12:40:43] Error - [tsc] node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2628,43): error TS1005: '(' expected.
[12:40:43] Error - 'tsc' sub task errored after 3.52 s
 exited with code 2
[12:40:44] Finished subtask 'tslint' after 4.21 s

Steps to Reproduce

mkdir spfx17
cd spfx17
yo @microsoft/sharepoint --package-manager yarn

Accept all the defaults from yo but include React as a library.

gulp trust-dev-cert
gulp serve

EDIT: Seems to work when using pnpm as package manager.

@Seiyasu Seiyasu added type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. area:tooling Category: Development tooling labels Nov 13, 2018
@Seiyasu
Copy link
Contributor

Seiyasu commented Nov 14, 2018

Both yarn and pnpm for SPFx 1.7 have issues on my side, but not the same to you.

@VesaJuvonen
Copy link
Contributor

Most likely this is related on an inconsistent node and/or npm version. We currently support only node v8 LTS version and not yet v10 with SPFx. Can you share the versions which you are using, so that we can build a consistent repro. Thanks.

@sbrown-fc
Copy link
Author

Version details:

Node: 8.12.0
NPM: 6.4.1
Yarn: 1.12.3
PNPM: 2.18.2

I can get it working using NPM (in other words, with no --package-manager switch), using PNPM there is a tslint error (Could not find custom rule directory: tslint-microsoft-contrib) but otherwise it works. Yarn gives the errors in my original post and the workbench doesn't load.

My usual dev box is Windows but I've also tried NPM and Yarn on Linux and the same results happen there too.

@patmill
Copy link
Contributor

patmill commented Nov 15, 2018

It's an issue specifically with Yarn (not necessarily in Yarn, just with using Yarn and SPFx). We are sorting out the pnpm issue first, which appears to be an underlying issue with tslint ( pnpm/pnpm#1487 ). We'll look at Yarn next to see what's going on.

@nickpape
Copy link

FYI, for the PNPM issue, I filed a workaround here: #2916

And opened an issue with tslint: palantir/tslint#4294

Investigating the yarn issue now.

@nickpape
Copy link

For this yarn issue, the best way to work around it is to add a resolution to your package.json:

"resolutions": {
  "@types/react": "16.4.2"
}

This seems to be a bug with Yarn. It is not deduping the dependencies in the same way as NPM or PNPM would.

I filed an issue there: yarnpkg/yarn#6695

@VesaJuvonen VesaJuvonen added the status:tracked Currently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed) label Jan 8, 2019
@DanyalKhawaja
Copy link

This issue was appearing since I tried to use any UI React library which requires a higher version of typescript. Then I upgraded typescript with the latest and added some code in gulp.js. But then it does not creating production build ie --ship.

@andrewconnell
Copy link
Collaborator

@DanyalKhawaja which React lib were you using?

The SharePoint team has said that the build toolchain SPFx is based on will rev to TypeScript v3.x (and webpack v4.x) in an upcoming release, which should address part of that...

@DanyalKhawaja
Copy link

I had tried Material-UI, Ant Design 2.x and finally Fabric ( which got installed with generator "@microsoft/sp-office-ui-fabric-core": "1.7.1").

I am trying to create Application Customizer in react. My solution works with my own react components, but as soon I start using components from any of the above react library, it starts generating errors after gulp serve or bundle.

[16:43:28] Starting subtask 'tsc'...
[16:43:28] [tsc] typescript version: 2.4.2
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(27,38): error TS1005: '=' expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(29,46): error TS1005: ';' expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(29,75): error TS1005: ';' expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(29,99): error TS1005: ';' expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(31,54): error TS1005: ';' expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(31,78): error TS1005: ';' expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(31,81): error TS1109: Expression expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(31,97): error TS1109: Expression expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(31,122): error TS1005: ';' expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(31,130): error TS1128: Declaration or statement expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(31,138): error TS1005: ',' expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(44,48): error TS1005: ';' expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(44,49): error TS1109: Expression expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(44,50): error TS1109: Expression expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(44,68): error TS1005: '(' expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(44,69): error TS1005: ')' expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(46,30): error TS1005: ';' expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(46,54): error TS1005: ';' expected.
[16:43:34] Error - [tsc] ../node_modules/@types/prop-types/index.d.ts(46,57): error TS1109: Expression expected.
[16:43:34] Error - 'tsc' sub task errored after 5.69 s
exited with code 2
[16:43:35] Finished subtask 'tslint' after 7.17 s

@andrewconnell
Copy link
Collaborator

I can't speak for Material / Ant, but the Fabric React components included with the React project include shouldn't need any special type declarations. I see the props-types type declarations were updated 2mo ago... unsure if they introduced an issue...

@DanyalKhawaja
Copy link

You are right, after I reinstalled Node, Fabric UI was working fine.

@tarjeieo
Copy link
Contributor

tarjeieo commented Mar 3, 2019

Got this same error, but was able to resolve it by

  • Make sure typescript is 2.4.2 in package.json
  • Installed @types/prop-types to match typescript 2.4.2: npm install -D @types/[email protected]

@andrewconnell
Copy link
Collaborator

@tarjeieo shouldn't be necessary to do that. Are you running SPFx v1.7 or 1.7.1? The latter had a fix for resolving some type declarations.

@tarjeieo
Copy link
Contributor

tarjeieo commented Mar 4, 2019

@andrewconnell I'm running 1.7.1. Do note that this was on my home computer and I've successfully built it earlier on my primary work machine. Might be some other factors in play here...

What should be the correct typescript-version in package.json? I can try without the @types/prop-types specified.

@andrewconnell
Copy link
Collaborator

You shouldn't have TypeScript listed in your package.json... it's added to the dep tree by other deps...

@tarjeieo
Copy link
Contributor

tarjeieo commented Mar 5, 2019

Removing typescript and @prop-types from package.json causes this error to appear again during gulp....

This is how my package.json looks like, see anything stinky?

{
  "name": "lmv-pp-spfx",
  "version": "0.6.0",
  "private": true,
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "serve": "gulp serve",
    "package": "gulp clean && gulp default --ship && gulp package-solution --ship",
    "deploy": "gulp uploadAppPkg && gulp deploySppkg",
    "package-deploy": " npm run package &&  npm run deploy",
    "package-deploy-patch": " npm version patch &&  npm run deploy",
    "package-deploy-minor": " npm version minor &&  npm run deploy",
    "package-deploy-major": " npm version major &&  npm run deploy",
    "postversion": "gulp version-sync && npm run package",
    "patch-version": "npm version patch",
    "minor-version": "npm version minor",
    "major-version": "npm version major"
  },
  "dependencies": {
    "@microsoft/sp-core-library": "1.7.1",
    "@microsoft/sp-lodash-subset": "1.7.1",
    "@microsoft/sp-office-ui-fabric-core": "1.7.1",
    "@microsoft/sp-webpart-base": "1.7.1",
    "@pnp/common": "^1.2.9",
    "@pnp/logging": "^1.2.9",
    "@pnp/odata": "^1.2.9",
    "@pnp/sp": "^1.2.9",
    "@types/es6-promise": "0.0.33",
    "@types/react": "16.4.2",
    "@types/react-dom": "16.0.5",
    "@types/webpack-env": "1.13.1",
    "office-ui-fabric-react": "^5.38.1",
    "react": "16.4.2",
    "react-dom": "16.3.2"
  },
  "devDependencies": {
    "@microsoft/sp-build-web": "1.7.1",
    "@microsoft/sp-module-interfaces": "1.7.1",
    "@microsoft/sp-tslint-rules": "^1.7.1",
    "@microsoft/sp-webpart-workbench": "1.7.1",
    "@types/chai": "3.4.34",
    "@types/mocha": "2.2.38",
    "ajv": "~5.2.2",
    "bluebird": "^3.5.3",
    "gulp": "~3.9.1",
    "gulp-connect": "5.7.0",
    "gulp-spsync-creds": "^2.3.8",
    "node-fetch": "^2.3.0",
    "node-sppkg-deploy": "^1.2.1",
    "slash": "2.0.0",
    "spfx-pkgdeploy": "^0.2.1",
    "through2": "^3.0.1",
    "tslint": "5.9.1",
    "tslint-microsoft-contrib": "5.0.0"
  },
  "resolutions": {
    "@types/react": "16.4.2"
  }
}

@andrewconnell
Copy link
Collaborator

@tarjeieo This is forking from the OP's issue... can you open a new issue as it's hard to follow what the error is that you're having now. Having a repro'd project (linked to in a public repo) would be helpful.

@tarjeieo
Copy link
Contributor

tarjeieo commented Mar 6, 2019

I'm just trying to add more context to this issue, since I'm getting the exact same errors as OP as far as I can tell. But as mentioned earlier, I cannot reproduce on my work computer so it looks like an env. issue of some sort.

@warmjaijai
Copy link

I am having the same error too where I didn't set any package manager and simply did yo @microsoft/sharepoint and the following error shows when I tried gulp serve:

Error - 'tsc' sub task errored after 3.28 s
exited with code 2

@andrewconnell
Copy link
Collaborator

@warmjaijai Please create a new issue & provide additional information on your context (versions of things installed)... the issue appears resolved from the OP.

@msft-github-bot
Copy link
Collaborator

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

@SharePoint SharePoint locked as resolved and limited conversation to collaborators Jan 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:tooling Category: Development tooling status:tracked Currently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed) type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
Projects
None yet
Development

No branches or pull requests

10 participants