Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An accessor cannot be declared in an ambient context - @aws-amplify - 1.2.5-unstable.5 #4389

Closed
iamishver opened this issue Nov 13, 2019 · 11 comments · Fixed by #4452
Closed
Labels
Angular Related to Angular 2+ bug Something isn't working Build Related to build issues TypeScript Related to TypeScript issues

Comments

@iamishver
Copy link

ERROR in ·[96m../node_modules/@aws-amplify/core/lib-esm/ServiceWorker/ServiceWorker.d.ts·[0m:·[93m23·[0m:·[93m9·[0m - ·[91merror·[0m·[90m TS1086: ·[0mAn accessor cannot be declared in an ambient context.

·[7m23·[0m get serviceWorker(): ServiceWorker;
·[7m ·[0m ·[91m ~~~~~~~~~~~~~·[0m
·[96m../node_modules/@aws-amplify/pubsub/lib-esm/PubSub.d.ts·[0m:·[93m13·[0m:·[93m17·[0m - ·[91merror·[0m·[90m TS1086: ·[0mAn accessor cannot be declared in an ambient context.

·[7m13·[0m private get awsAppSyncProvider();
·[7m ·[0m ·[91m ~~~~~~~~~~~~~~~~~~·[0m
·[96m../node_modules/@aws-amplify/pubsub/lib-esm/Providers/PubSubProvider.d.ts·[0m:·[93m9·[0m:·[93m19·[0m - ·[91merror·[0m·[90m TS1086: ·[0mAn accessor cannot be declared in an ambient context.

·[7m9·[0m protected get options(): ProvidertOptions;
·[7m ·[0m ·[91m ~~~~~~~·[0m
·[96m../node_modules/@aws-amplify/pubsub/lib-esm/Providers/MqttOverWSProvider.d.ts·[0m:·[93m12·[0m:·[93m9·[0m - ·[91merror·[0m·[90m TS1086: ·[0mAn accessor cannot be declared in an ambient context.

·[7m12·[0m get allClients(): string[];
·[7m ·[0m ·[91m ~~~~~~~~~~·[0m
·[96m../node_modules/@aws-amplify/pubsub/lib-esm/Providers/MqttOverWSProvider.d.ts·[0m:·[93m18·[0m:·[93m19·[0m - ·[91merror·[0m·[90m TS1086: ·[0mAn accessor cannot be declared in an ambient context.

·[7m18·[0m protected get clientId(): any;
·[7m ·[0m ·[91m ~~~~~~~~·[0m
·[96m../node_modules/@aws-amplify/pubsub/lib-esm/Providers/MqttOverWSProvider.d.ts·[0m:·[93m19·[0m:·[93m19·[0m - ·[91merror·[0m·[90m TS1086: ·[0mAn accessor cannot be declared in an ambient context.

·[7m19·[0m protected get endpoint(): any;
·[7m ·[0m ·[91m ~~~~~~~~·[0m
·[96m../node_modules/@aws-amplify/pubsub/lib-esm/Providers/MqttOverWSProvider.d.ts·[0m:·[93m20·[0m:·[93m19·[0m - ·[91merror·[0m·[90m TS1086: ·[0mAn accessor cannot be declared in an ambient context.

·[7m20·[0m protected get clientsQueue(): ClientsQueue;
·[7m ·[0m ·[91m ~~~~~~~~~~~~·[0m
·[96m../node_modules/@aws-amplify/pubsub/lib-esm/Providers/MqttOverWSProvider.d.ts·[0m:·[93m21·[0m:·[93m19·[0m - ·[91merror·[0m·[90m TS1086: ·[0mAn accessor cannot be declared in an ambient context.

·[7m21·[0m protected get isSSLEnabled(): boolean;
·[7m ·[0m ·[91m ~~~~~~~~~~~~·[0m
·[96m../node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSIotProvider.d.ts·[0m:·[93m3·[0m:·[93m19·[0m - ·[91merror·[0m·[90m TS1086: ·[0mAn accessor cannot be declared in an ambient context.

·[7m3·[0m protected get region(): any;
·[7m ·[0m ·[91m ~~~~~~·[0m
·[96m../node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSIotProvider.d.ts·[0m:·[93m5·[0m:·[93m19·[0m - ·[91merror·[0m·[90m TS1086: ·[0mAn accessor cannot be declared in an ambient context.

·[7m5·[0m protected get endpoint(): Promise;
·[7m ·[0m ·[91m ~~~~~~~~·[0m
·[96m../node_modules/@aws-amplify/interactions/lib-esm/Providers/InteractionsProvider.d.ts·[0m:·[93m8·[0m:·[93m19·[0m - ·[91merror·[0m·[90m TS1086: ·[0mAn accessor cannot be declared in an ambient context.

·[7m8·[0m protected get options(): InteractionsOptions;
·[7m ·[0m ·[91m ~~~~~~~·[0m
·[96m../node_modules/@aws-amplify/xr/lib-esm/Providers/XRProvider.d.ts·[0m:·[93m8·[0m:·[93m19·[0m - ·[91merror·[0m·[90m TS1086: ·[0mAn accessor cannot be declared in an ambient context.

·[7m8·[0m protected get options(): ProviderOptions;
·[7m ·[0m ·[91m ~~~~~~~·[0m

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vivanco@0.0.0 build:client-and-server-bundles: ng build --prod && ng run vivanco:server:production
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vivanco@0.0.0 build:client-and-server-bundles script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-11-13T07_27_56_230Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vivanco@0.0.0 build:ssr: npm run build:client-and-server-bundles && npm run compile:server
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vivanco@0.0.0 build:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-11-13T07_27_56_243Z-debug.log

[Container] 2019/11/13 07:27:56 Command did not exit successfully npm run build:ssr exit status 1
[Container] 2019/11/13 07:27:56 Phase complete: POST_BUILD State: FAILED
[Container] 2019/11/13 07:27:56 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm run build:ssr. Reason: exit status 1
[Container] 2019/11/13 07:27:56 Expanding base directory path: .
[Container] 2019/11/13 07:27:56 Assembling file list
[Container] 2019/11/13 07:27:56 Expanding .
[Container] 2019/11/13 07:27:56 Expanding file paths for base directory .
[Container] 2019/11/13 07:27:56 Assembling file list
[Container] 2019/11/13 07:27:56 Expanding template.yml
[Container] 2019/11/13 07:27:56 Expanding README.md
[Container] 2019/11/13 07:27:56 Expanding package.json
[Container] 2019/11/13 07:27:56 Expanding appspec.yml
[Container] 2019/11/13 07:27:56 Expanding scripts/*
[Container] 2019/11/13 07:27:56 Expanding node_modules//*
[Container] 2019/11/13 07:27:56 Expanding dist/
/*
[Container] 2019/11/13 07:27:56 Expanding template-configuration.json
[Container] 2019/11/13 07:27:56 Found 75714 file(s)
[Container] 2019/11/13 07:28:15 Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED
[Container] 2019/11/13 07:28:15 Phase context status code: Message:

@iamishver iamishver added the question General question label Nov 13, 2019
@iartemiev
Copy link
Member

Can you please provide some context?

  • What feature of Amplify are you using and what is the action that led to the error?
  • Please share a code sample

@iamishver
Copy link
Author

I am using "aws-amplify": "^1.2.5-unstable.11" for login purpose in angular 8 universal.

On stable version gives "WINDOW NOT DEFINED" error and I add the unstable version "1.2.5-unstable.5" and on that time it works fine.

But as now, it won't allow me deploy as well as run on local machine with "ng serve".

ng serve
10% building 3/3 modules 0 activei 「wds」: Project is running at http://localhost:4200/webpack-dev-server/
i 「wds」: webpack output is served from /
i 「wds」: 404s will fallback to //index.html

chunk {main} main.js, main.js.map (main) 2.02 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 149 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 1.75 MB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 340 kB [initial] [rendered]
Date: 2019-11-14T05:50:24.986Z - Hash: 1333d03a06133d940f40 - Time: 13440ms

ERROR in ../node_modules/@aws-amplify/core/lib-esm/ServiceWorker/ServiceWorker.d.ts:23:9 - error TS1086: An accessor cannot be declared in an ambient context.

23 get serviceWorker(): ServiceWorker;
~~~~~~~~~~~~~
../node_modules/@aws-amplify/interactions/lib-esm/Providers/InteractionsProvider.d.ts:8:19 - error TS1086: An accessor cannot be declared in an ambient context.

8 protected get options(): InteractionsOptions;
~~~~~~~
../node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSIotProvider.d.ts:3:19 - error TS1086: An accessor cannot be declared in an ambient context.

3 protected get region(): any;
~~~~~~
../node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSIotProvider.d.ts:5:19 - error TS1086: An accessor cannot be declared in an ambient context.

5 protected get endpoint(): Promise;
~~~~~~~~
../node_modules/@aws-amplify/pubsub/lib-esm/Providers/MqttOverWSProvider.d.ts:12:9 - error TS1086: An accessor cannot be declared in an ambient context.

12 get allClients(): string[];
~~~~~~~~~~
../node_modules/@aws-amplify/pubsub/lib-esm/Providers/MqttOverWSProvider.d.ts:18:19 - error TS1086: An accessor cannot be declared in an ambient context.

18 protected get clientId(): any;
~~~~~~~~
../node_modules/@aws-amplify/pubsub/lib-esm/Providers/MqttOverWSProvider.d.ts:19:19 - error TS1086: An accessor cannot be declared in an ambient context.

19 protected get endpoint(): any;
~~~~~~~~
../node_modules/@aws-amplify/pubsub/lib-esm/Providers/MqttOverWSProvider.d.ts:20:19 - error TS1086: An accessor cannot be declared in an ambient context.

20 protected get clientsQueue(): ClientsQueue;
~~~~~~~~~~~~
../node_modules/@aws-amplify/pubsub/lib-esm/Providers/MqttOverWSProvider.d.ts:21:19 - error TS1086: An accessor cannot be declared in an ambient context.

21 protected get isSSLEnabled(): boolean;
~~~~~~~~~~~~
../node_modules/@aws-amplify/pubsub/lib-esm/Providers/PubSubProvider.d.ts:9:19 - error TS1086: An accessor cannot be declared in an ambient context.

9 protected get options(): ProvidertOptions;
~~~~~~~
../node_modules/@aws-amplify/pubsub/lib-esm/PubSub.d.ts:13:17 - error TS1086: An accessor cannot be declared in an ambient context.

13 private get awsAppSyncProvider();
~~~~~~~~~~~~~~~~~~
../node_modules/@aws-amplify/xr/lib-esm/Providers/XRProvider.d.ts:8:19 - error TS1086: An accessor cannot be declared in an ambient context.

8 protected get options(): ProviderOptions;
~~~~~~~

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
i 「wdm」: Failed to compile.

@ekzGuille
Copy link

I'm having the same problem using @aws-cdk

 > tsc
node_modules/@aws-cdk/core/lib/cfn-element.d.ts:52:9 - error TS1086: An accessor cannot be declared in an ambient context.

52     get creationStack(): string[];
           ~~~~~~~~~~~~~

node_modules/@aws-cdk/core/lib/cfn-element.d.ts:77:9 - error TS1086: An accessor cannot be declared in an ambient context.

77     get ref(): string;
           ~~~

node_modules/@aws-cdk/core/lib/cfn-parameter.d.ts:100:9 - error TS1086: An accessor cannot be declared in an ambient context.

100     get noEcho(): boolean;
            ~~~~~~

node_modules/@aws-cdk/core/lib/cfn-parameter.d.ts:104:9 - error TS1086: An accessor cannot be declared in an ambient context.

104     get value(): IResolvable;
            ~~~~~

node_modules/@aws-cdk/core/lib/cfn-parameter.d.ts:108:9 - error TS1086: An accessor cannot be declared in an ambient context.

@feldmarv
Copy link

We are facing the same issue in AWS CodeBuild pipeline with Angular universal 8 and "aws-amplify": "^2.1.0"

@iamishver
Copy link
Author

I had try with "aws-amplify": "^2.1.1-unstable.0" , but it can't work with latest unstable version.

ERROR in ../node_modules/@aws-amplify/core/lib-esm/ServiceWorker/ServiceWorker.d.ts:23:9 - error TS1086: An accessor cannot be declared in an ambient context.

23 get serviceWorker(): ServiceWorker;
~~~~~~~~~~~~~

@ekzGuille
Copy link

I found out that this error was because last version of aws-cdk (v. 1.16.0) had breaking changes on Stack generation.
Previously we were using v. 1.15.0.

  • 1.15.0:

node_modules/@aws-cdk/core/lib/cfn-element.d.ts

52    readonly creationStack: string[];
  • 1.16.3:

node_modules/@aws-cdk/core/lib/cfn-element.d.ts

52     get creationStack(): string[];

This getter (and all new ones in other files) is what is crashing the Stack generation.

@iartemiev iartemiev added Angular Related to Angular 2+ bug Something isn't working Build Related to build issues TypeScript Related to TypeScript issues and removed question General question labels Nov 22, 2019
@iartemiev
Copy link
Member

@vc-ishver Thank you for the additional info. PR with the fix is up. Will update this issue once it's merged

@iartemiev
Copy link
Member

This issue was caused by changes to declaration files generated by TypeScript 3.7+, which are incompatible with the versions of TypeScript supported by current versions of Angular Compiler. Building aws-amplify with TypeScript 3.6.4 resolves the issue.

@ekzGuille
Copy link

@iartemiev Thank you.
I will check in my project if updating to latest version also updates Typescript to 3.7+ version. If so, I will downgrade to a working version.

@iartemiev
Copy link
Member

@vc-ishver @ekzGuille please try the latest unstable version of aws-amplify (2.1.1-unstable.5
or later)

socram8888 added a commit to socram8888/saph-browser that referenced this issue Nov 25, 2019
TypeScript 3.7 generates a .d.ts with setter and getter incompatible with old versions of
TS, such as the ones Angular 7 and 8 depend on.

See aws-amplify/amplify-js#4389 (comment)
socram8888 added a commit to socram8888/saph-browser that referenced this issue Nov 25, 2019
TypeScript 3.7 generates a .d.ts with setter and getter incompatible with old versions of
TS, such as the ones Angular 7 and 8 depend on.

See aws-amplify/amplify-js#4389 (comment)
@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Angular Related to Angular 2+ bug Something isn't working Build Related to build issues TypeScript Related to TypeScript issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants