TypeError: Class constructor CommonStringsService cannot be invoked without 'new' #4094
Comments
The current Clarity 3.0.0-next.4 will work with Angular 8.x until we finish upgrading to Angular 9. This should be working currently and looks like a bug. What version of the Angular CLI is your project running? |
I will come back to you on Monday. |
Hi. I have the same issue. My package.json {
"name": "web",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:ssr": "ng run web:server:dev",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular-devkit/architect": "^0.803.20",
"@angular-devkit/core": "^8.3.20",
"@angular-devkit/schematics": "^8.3.20",
"@angular/animations": "8.2.12",
"@angular/common": "8.2.12",
"@angular/compiler": "8.2.12",
"@angular/core": "8.2.12",
"@angular/forms": "8.2.12",
"@angular/platform-browser": "8.2.12",
"@angular/platform-browser-dynamic": "8.2.12",
"@angular/platform-server": "8.2.12",
"@angular/router": "8.2.12",
"@clr/icons": "next",
"@clr/ui": "next",
"@clr/angular": "next",
"@clr/core": "next",
"@nguniversal/module-map-ngfactory-loader": "8.1.1",
"@webcomponents/custom-elements": "^1.0.0",
"aspnet-prerendering": "^3.0.1",
"core-js": "^3.3.3",
"oidc-client": "^1.9.1",
"popper.js": "^1.16.0",
"rxjs": "^6.5.3",
"zone.js": "0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.20",
"@angular/cli": "8.3.20",
"@angular/compiler-cli": "8.2.12",
"@angular/language-service": "8.2.12",
"@types/jasmine": "~3.4.4",
"@types/jasminewd2": "~2.0.8",
"@types/node": "~12.11.6",
"codelyzer": "^5.2.0",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"typescript": "3.5.3"
},
"optionalDependencies": {
"node-sass": "^4.12.0",
"protractor": "~5.4.2",
"ts-node": "~8.4.1",
"tslint": "~5.20.0"
}
} |
|
Thanks for the details, I am looking into this and will try to get a fix in for our next 3.x-next release. |
Just a note, we haven't confirmed that Clarity v3 can work with Angular v8, we are still working through issues with v9 update. |
After investigation the latest CLI/Angular works with the latest 3.x Clarity but the error can occur in scenarios for misconfigured older projects. Make sure in the |
@coryrylan Your absolutely right. I changed the target from es5 to es2015 and it worked. Thanks! |
I would say misconfigured is the wrong word here. It is a totally valid configuration, as sown here. It is the easiest configuration option to opt out of differential loading. |
Thanks for the link, agree that it is a valid configuration. It looks like when using It also looks like even after using the default differential loading ie11 support is broken in the latest v9 for me. Looks like its possibly due to a zone issue angular/angular#31678 Going to mark as has tentative workaround when using differential loading and will look into the zone issue. I'll keep this issue open to see if we can get ES5 target working with |
Blocking on the zone issue angular/angular#31678 |
Same issue running Angular 9 with ivy and Clarity 3.0.0-next8. But I use target="es5".
This is really blocking me, any know workaround for this? The zone.js trick did not work:
and I don't want differential loading to be enabled. Really struggeling here.
|
@alexej-strelzow to better understand the use cases could you describe why you would not want to have differential loading for your project? |
@coryrylan thank's for getting back to me so quickly. A couple of month ago I investigated the differential loading behavior on the major 4 browsers + IE 11 (I know...) and I saw that some browsers load both bundles, but in the end execute only 1 (of course). That's the main reason - seems like only Chrome fully benefits from it. Also, yesterday I tried target="es2015", but was not successful. I believe that it has sth to do with the Tab-Component I am using. I will try to provide you a repro scenario tmw. Thank you (and all the contributors) for putting your time and passion into this project, really appreciate it! :) |
A repro would be excellent! I'd be happy to take a look. I do remember, at one point, when differential loading first came out, I had a similar issue where all the bundles would get loaded. I believe this has been fixed now in the latest Angular CLI but I will double-check to be sure that is the case with the latest Clarity release. We want to be able to help teams be able to take advantage of differential loading as well as many of the under the hood perf improvements coming soon in Clarity. I also don't want to block people on upgrading because of this issue either so I am watching this closely and still investigating. |
UPDATE: OLD:
then this error: does not occur anymore. And sometimes (with the clr-tabs) I get this error, after I played around with it for a long time: Idk if this hint is enough for you. For now a workaround for me would be to write an own tabs-component I guess. I saw that there is now an own TabsModule - "ClrTabsModule", using this in addition to "ClarityModule" does not help. The module where the tx-list is declared looks like this:
|
@alexej-strelzow fantastic! I'll be leaving this open and continue to closely monitor for similar issues. |
@coryrylan I'm stuck at the same problem. After upgrading Angular & Clarity in Nx workspace the Jest tests were failing according to #4196.
All my targets are already configured for es2015, can you provide another hint for a solution? |
Have you checked to see if the angular bundle is included in your |
I ignored clarity completely:
|
I was with the same problem when trying to use the datepicker. |
Getting this same error.
tsConfig.json's target is set to we have temporarily switched off ivy compiler ( |
@aravindh-nagarajan I may be able to point you in the right direction if I have a better understanding of what shape you're in. |
@mathisscott Thank you, Here it is.
Some more details: ours is a hybrid application (AngularV9 and AngularJS 1.7) and we dont use angular cli. |
@aravindh-nagarajan |
• crossing the streams with a service shared b/w core and angular was causing nx and jest to lose their minds • much of the problem was due to when typescript or jest would decide to compile an import down to ES5 or not • recent discussions have uncovered the potential for more significant divergence in the scope of what we previously felt would be shared services • in the future, a shared resource may need to be pulled into angular proper – as opposed to being brought in as a dependency • i verified this approach solves breakages in previously breaking apps • users still need to use `transformIgnorePatterns` in their jest config to allow babel to compile core, lit, and ramada • users will NOT need to override ClrCommonStrings in their spec configs • that was a band-aid that was going to break again soon in any case Tested in: ✔︎ Chrome Fixes: vmware-archive#4094 Signed-off-by: Scott Mathis <smathis@vmware.com>
• crossing the streams with a service shared b/w core and angular was causing nx and jest to lose their minds • much of the problem was due to when typescript or jest would decide to compile an import down to ES5 or not • recent discussions have uncovered the potential for more significant divergence in the scope of what we previously felt would be shared services • in the future, a shared resource may need to be pulled into angular proper – as opposed to being brought in as a dependency • i verified this approach solves breakages in previously breaking apps • users still need to use `transformIgnorePatterns` in their jest config to allow babel to compile core, lit, and ramada • users will NOT need to override ClrCommonStrings in their spec configs • that was a band-aid that was going to break again soon in any case Tested in: ✔︎ Chrome Fixes: #4094 Signed-off-by: Scott Mathis <smathis@vmware.com>
go to tsconfig.json file and change your target to es5 (ECMAScript 5) like this : { |
since my error started when i first install Material, i have relized that the fix should be somewhere around material.
after compilation the issue got fixed! |
Describe the bug
After updating to version
3.0.0-next.4
just runningng serve
will result in no compile errors. But you get a runtime error with CommonStringsService.Is clarity
3.x
intended to work with angular versions pre9.x
, e.g.8.2.0
?How to reproduce
Run
ng serve
and and open browser console.Expected behavior
It should just work?
Versions
App
The text was updated successfully, but these errors were encountered: