These are all of the steps I took up to the issue arising. Starting from creation of the project.
ng new calendar-test
cd calendar-test
npm install --save angular-calendar
At this point I noticed NPM gave me the warning UNMET PEER DEPENDENCY @angular/animations@^4.0.0, so I ran npm install --save @angular/animations
Then I added
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CalendarModule } from 'angular-calendar';
...
imports: [ BrowserAnimationsModule, CalendarModule.forRoot() ]
to my app.module.ts and then ran ng serve.
Upon running ng serve I get a failure to compile with the following error:
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/calendar-utils/dist/calendarUtils.d.ts (20,41): ',' expected.
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/calendar-utils/dist/calendarUtils.d.ts (17,16): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/calendar-utils/dist/calendarUtils.d.ts (20,43): Type parameter name cannot be 'any'
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/calendar-utils/dist/calendarUtils.d.ts (36,12): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/calendar-utils/dist/calendarUtils.d.ts (47,13): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/calendar-utils/dist/calendarUtils.d.ts (58,12): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/calendar-utils/dist/calendarUtils.d.ts (69,19): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/calendar-utils/dist/calendarUtils.d.ts (80,12): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/calendar-utils/dist/calendarUtils.d.ts (92,14): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/calendar-utils/dist/calendarUtils.d.ts (101,14): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/calendar-utils/dist/calendarUtils.d.ts (110,14): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/providers/calendarEventTitleFormatter.provider.d.ts (27,18): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/providers/calendarEventTitleFormatter.provider.d.ts (31,25): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/providers/calendarEventTitleFormatter.provider.d.ts (35,17): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/providers/calendarEventTitleFormatter.provider.d.ts (39,24): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/providers/calendarEventTitleFormatter.provider.d.ts (43,16): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/providers/calendarEventTitleFormatter.provider.d.ts (47,23): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/interfaces/calendarEventTimesChangedEvent.interface.d.ts (6,12): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/components/day/calendarDayView.component.d.ts (28,13): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/components/day/calendarDayView.component.d.ts (90,16): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/components/day/calendarDayView.component.d.ts (152,21): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/components/month/calendarMonthView.component.d.ts (27,13): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/components/month/calendarMonthView.component.d.ts (79,16): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/components/month/calendarMonthView.component.d.ts (124,31): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/components/month/calendarMonthView.component.d.ts (128,44): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/components/week/calendarWeekView.component.d.ts (28,13): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in C:/Users/Matt/dev/tests/calendar-test/node_modules/angular-calendar/dist/esm/src/components/week/calendarWeekView.component.d.ts (76,16): Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
ERROR in multi ./src/styles.css ./src/~/angular-calendar/dist/css/angular-calendar.css
Module not found: Error: Can't resolve 'C:\Users\Matt\dev\tests\calendar-test\src\node_modules\angular-calendar\dist\css\angular-calendar.css' in 'C:\Users\Matt\dev\tests\calendar-test'
@ multi ./src/styles.css ./src/~/angular-calendar/dist/css/angular-calendar.css
Is a plunkr necessary for an issue that arises so early in the bootstrapping process? If so, please let me know and I will try to provide one.
Angular: 4.1.3
Calendar library: 0.17.0
Browser name and version: N/A
This relates to https://github.com/mattlewis92/angular-calendar/issues/218 and it only happens to you because you upgraded to the latest version.
Im not sure if we continue with the generic approach or not. /cc @mattlewis92 ?
Anyway the required second generic type (any) is wrong indeed.
To make it work again, downgrade to Version 0.16.0 or specify the required generic type CalendarEvent<Type>
Ah, it seems like generic defaults are only for TS 2.3, IIRC the cli ships with 2.2 by default. If you upgrade typescript to 2.3.x does the problem go away?
Upgrading the typescript dependency from "~2.2.0" to "~2.3.0" did seem to solve it.
Just a note:
By upgrading the typescript version to 2.3.x, the code will compile, but my Atom typescript package (and probably a lot of other tooling as well) will complain about it with: Generic type 'CalendarEvent<MetaType, any>' requires 2 type argument(s).
Ah it seems like atom-typescript has a hard dependency on an older nightly version of typescript that doesn't have generic defaults. I think it might just be best to revert this for now and give it a few months for tooling to catch up.
I also needed upgrade @angular/cli to version ^1.1.0 to get rid of the errors.
Upgraded @angular/cli and typescript as mentioned above don't seem to work in my cases.
npm install --save-dev typescript@latest
This fixed the error for me.
Changed my mind on this, I've added an explicit peer dependency on typescript 2.3 so folks should get warned when they're using an older version when updating the package. I also sent a PR to the atom typescript package to update its TS dependency: https://github.com/TypeStrong/atom-typescript/pull/1272
It seems like it's not a Atom thing only. I am using PHPStorm I have literally just installed the package, and updated typescript and angular/cli to final version. Both in global and locally. Could it be happening in phpStorm too? It doesn't recognize the use of generic defaults. Is there something I can do to make it work until all technology catch up?
thanks!
It works ok for me in webstorm, I didn't think that php storm even supported typescript?
It does but if generics are not supported in general, it seems to be related to your configuration. There is a bundled typescript version in PHPStorm (have you checked this in preferences -> languages & frameworks -> typescript -> typescript version ?). Try using the version from node_modules instead? You need at least 2.3 version configured
I just typed again _yarn remove angular-calendar_ && _yarn add angular-calendar_, and now it seems to recognize the default generics!
Well I guess that was the last step missing, even though, it didn't make sense to me, that I had typescript 2.3.4, globally installed and locally but phpStorm wasn't applying the right typescript version in compilaiton...
I am still getting the below error with my ts dependencies : "^2.5.3"
Build:Generic type 'CalendarEvent
Most helpful comment
Ah, it seems like generic defaults are only for TS 2.3, IIRC the cli ships with 2.2 by default. If you upgrade typescript to 2.3.x does the problem go away?