tiberiuzuld / angular-gridster2

Angular gridster 2
https://tiberiuzuld.github.io/angular-gridster2
MIT License
1.28k stars 377 forks source link

An accessor cannot be declared in an ambient context. #601

Open RowlandShaw opened 4 years ago

RowlandShaw commented 4 years ago

When building my Angular app with --prod flag, it now fails with:

ERROR in ../node_modules/angular-gridster2/lib/gridsterItem.component.d.ts (22,9): - error TS1086: An accessor cannot be declared in an ambient context.

This was working with 9.0.1, but has started failing with 9.1.0

tiberiuzuld commented 4 years ago

Hi @RowlandShaw , Seems the issue is with typescript in 3.7 https://github.com/microsoft/TypeScript/issues/33939

We introduced a get in 9.1.0 and that is root of the issue. https://github.com/tiberiuzuld/angular-gridster2/blob/master/projects/angular-gridster2/src/lib/gridsterItem.component.ts#L42 I will try have a fix for it today.

Also I think upgrading your TS to 3.7 will fix the issue.

tiberiuzuld commented 4 years ago

So after reading some more on the internet there are to options for you:

  1. Update to TS 3.7
  2. Add option skipLibCheck: true in tsconfig.json
  3. I downgrade the library to use TS 3.6 -> which is not really an option right now, and is not worth it since the first 2 options are more simple to do.
adrianwerle commented 4 years ago

Hi. On line 22 of file gridsterItem.component.d.ts there is a statement: get zIndex(): number; Replacing it with zIndex(): number; allows compilation. In previous versions there was no "get" instruction.

dannykoshy commented 4 years ago

So after reading some more on the internet there are to options for you:

  1. Update to TS 3.7
  2. Add option skipLibCheck: true in tsconfig.json
  3. I downgrade the library to use TS 3.6 -> which is not really an option right now, and is not worth it since the first 2 options are more simple to do.

Following the above step i get the following error

ERROR in The Angular Compiler requires TypeScript >=3.4.0 and <3.6.0 but 3.6.5 was found instead.

My angular CLI is already "@angular/cli": "^8.3.24"

HighSoftWare96 commented 4 years ago

Is there any workaround for this?

anthony-bt commented 4 years ago

Upgrade to TypeScript 3.7 works fine. However, at the first level of the tsconfig.json file, you must add the following configuration:

"angularCompilerOptions": {
  "disableTypeScriptVersionCheck": true
}
crissdev commented 4 years ago

@tiberiuzuld Not everyone develops with the latest version of typescript. The change basically forces developers working on projects with Angular 8, for example, to "hack" into typescript configuration or give up on type checking.