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

Error: An accessor cannot be declared in an ambient context #308

Closed
paupizaru opened this issue Jan 6, 2020 · 7 comments
Closed

Error: An accessor cannot be declared in an ambient context #308

paupizaru opened this issue Jan 6, 2020 · 7 comments

Comments

@paupizaru
Copy link

paupizaru commented Jan 6, 2020

Hello,
I'm having an issue when compiling my project:

Error

error

I deleted the node_modules folder to do a "clean" npm install and then I installed
-> npm i pdf-lib@1.2.0 (we were using 1.2.1 so we tried using 1.2.0 and "it worked" but then we couldn't login into our project even with the server running).

Then one of our teammates upgraded the Angular version from 7 to 8 and the error was still there.

@Hopding
Copy link
Owner

Hopding commented Jan 6, 2020

This seems to be due to microsoft/TypeScript#33939.

@Hopding
Copy link
Owner

Hopding commented Jan 7, 2020

Looks like other libraries have run into this issue as well, e.g. nest:

@madmansn0w
Copy link

madmansn0w commented Jan 7, 2020

Any solution to this? Dealing with it as well.
Edit:
So I went ahead and upgraded Typescript to ^3.7.4 (Angular Compiler ~8.2.3) which meant that I needed to ignore the typescript version. Doesn't seem to have made any breaking changes.
I also had to update @types/nodes in the process.
Followed this thread starting with this comment and then this comment
It's a workaround, but I'm not certain if things will break just yet.

@Hopding
Copy link
Owner

Hopding commented Jan 12, 2020

It seems the best solution at the moment is to update your version of TypeScript to 3.7.x. But it would be ideal if pdf-lib didn't require you to do this. It looks like it may be possible to produce backwards compatible .d.ts files using https://github.com/sandersn/downlevel-dts (per microsoft/TypeScript#33939 (comment)). Otherwise we'll have to downgrade our version of typescript from 3.7 to 3.6.

@paupizaru
Copy link
Author

Hi, thanks for answering you all, I haven't upgraded my Angular compiler version yet, it is still ~7.1.0, so I can only use Typescript ~3.2.4, my teammates tell me that in order to use Typescript 3.7.x I have to upgrade Angular from 7 to 8 first, I will let you know If by doing so my problem is solved.

@paupizaru
Copy link
Author

Hello again, It seems that as you both said the real solution is to upgrade Typescript version.
We can't upgrade Angular at this moment so we decided to freeze the pdf-lib version in 1.2.0 which is working for us (the login bug I mentioned when I opened the issue had nothing to do with this, so we fixed it and know works with pdf-lib 1.2.0 but not with 1.2.1).

Thank you everyone

@Hopding
Copy link
Owner

Hopding commented Feb 29, 2020

Version 1.4.0 is now published. It contains additional TypeScript declarations for older version of TypeScript that should resolve this issue. The full release notes are available here.

You can install this new version with npm:

npm install pdf-lib@1.4.0

It's also available on unpkg:

As well as jsDelivr:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants