Angular-gridster2: An accessor cannot be declared in an ambient context.

Created on 2 Mar 2020  路  7Comments  路  Source: tiberiuzuld/angular-gridster2

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

wontfix

Most helpful comment

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.

All 7 comments

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.

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.

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.

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"

Is there any workaround for this?

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
}

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matpag picture matpag  路  3Comments

leandro-ali-elel picture leandro-ali-elel  路  4Comments

ddegasperi picture ddegasperi  路  4Comments

dnbo picture dnbo  路  4Comments

klemenoslaj picture klemenoslaj  路  4Comments