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

Kept on getting error message for @types/sharepoint

Open jonathanhotono opened this issue 9 years ago • 10 comments

Category

  • [x] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

Just changed my PC, installed the latest generator-sharepoint, performed a git clone on my repository and on some projects this error messages kept on coming up when I'm trying to build(gulp serve) the project and I'm not sure on what's causing this issue. The project is on GA release. I tried to upgrade it to June release and the error still persists. Typescript version on tslint is 2.1.6. Any idea on what's going on?

Update: I have managed to fix it by checking the version of @types/sharepoint on my old computer (2013.1.6) and the current version is (2013.1.9), I rolled back the version to 2013.1.6 and it works fine on my GA release project. I'm not exactly sure whether this way of changing to old version is actually right, but it works.

[09:00:22] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3604,17): error TS1005: ',' expected.

[09:00:22] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3823,17): error TS1005: ',' expected.

[09:00:22] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3825,19): error TS1005: ',' expected.

[09:00:22] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3827,21): error TS1005: ',' expected.
[09:00:22] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3829,18): error TS1005: ',' expected.
[09:00:22] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3896,21): error TS1005: ',' expected.
[09:00:22] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3944,31): error TS1005: ',' expected.
[09:00:24] Error - typescript - node_modules\@types\sharepoint\index.d.ts(70,42): error TS2314: Generic type 'ListItem<T, any>' requires 2 type
argument(s).

[09:00:24] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3098,31): error TS2314: Generic type 'ListItem<T, any>' requires 2 typ
e argument(s).
[09:00:24] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3362,33): error TS2314: Generic type 'ListItem<T, any>' requires 2 typ
e argument(s).
[09:00:24] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3468,33): error TS2314: Generic type 'ListItem<T, any>' requires 2 typ
e argument(s).
[09:00:24] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3604,19): error TS2368: Type parameter name cannot be 'any'
[09:00:24] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3606,33): error TS2314: Generic type 'ListItem<T, any>' requires 2 typ
e argument(s).
[09:00:24] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3816,39): error TS2314: Generic type 'ListItemCollection<T, any>' requ
ires 2 type argument(s).
[09:00:24] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3818,61): error TS2314: Generic type 'ListItem<T, any>' requires 2 typ
e argument(s).
[09:00:24] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3821,59): error TS2314: Generic type 'List<T, any>' requires 2 type ar
gument(s).
[09:00:24] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3823,19): error TS2368: Type parameter name cannot be 'any'
[09:00:24] Error - typescript - node_modules\@types\sharepoint\index.d.ts(3823,40): error TS2314: Generic type 'List<T, any>' requires 2 type ar
gument(s).
```


jonathanhotono avatar Jun 23 '17 01:06 jonathanhotono

Same for me...

stijnbrouwers avatar Jun 26 '17 07:06 stijnbrouwers

Sounds like the latest version of @types/sharepoint is expecting a newer version of the TypeScript compiler. We will be releasing a new drop of the build tools supporting a newer version of the compiler soon, but for now the best workaround is to stay on the older (2013.1.6) version.

iclanton avatar Jun 26 '17 23:06 iclanton

Encountered same issue.

Fix: If you already have installed the latest version, uninstall the version from the solution: npm uninstall @types/sharepoint

Use the last working version (2013.1.6): npm install @types/[email protected] --save-dev

AnupamRanku avatar Jul 14 '17 04:07 AnupamRanku

I have encountered similar issue. As per your suggestion used 2013.1.6 version.

But now in browser I get error "ERROR ReferenceError: SP is not defined"

I have defined types in tsconfig.json

shashanknigade avatar Oct 31 '17 12:10 shashanknigade

@nigadeshshank are you loading SP JSOM yourself? While it is present on classic SharePoint pages, it's not available by default on modern pages and in the workbench and you have to load it yourself before you can use it.

waldekmastykarz avatar Nov 01 '17 08:11 waldekmastykarz

@waldekmastykarz ohh ok.. Thanks. This makes sense. But yesterday I was going through MS documentation and it seems JSOM is not on their agenda anymore but REST is. So I will try to move away from JSOM anyway. But let me give a try for it. Thanks again

shashanknigade avatar Nov 01 '17 10:11 shashanknigade

REST is definitely the recommended approach as newer APIs are not included in JSOM.

waldekmastykarz avatar Nov 01 '17 10:11 waldekmastykarz

hey any update with this? we're still having to revert our version.

kmartindale avatar Feb 05 '18 20:02 kmartindale

Which version of the SharePoint Framework are you using @kmartindale?

waldekmastykarz avatar Feb 06 '18 08:02 waldekmastykarz

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

msft-github-bot avatar Jan 29 '20 06:01 msft-github-bot