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 #85

Open
minicatsCB opened this issue Jul 15, 2020 · 1 comment
Open

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

minicatsCB opened this issue Jul 15, 2020 · 1 comment

Comments

@minicatsCB
Copy link

Hi, I just started using this library with Vue and TypeScript.

Versions:
Node: v12.7.0
Vue: 2.6.11
TypeScript: 3.5.3

Following the instructions in the README.md, I installed (from package.json):
"geodesy": "^2.2.1"
"@types/geodesy": "^2.2.2"
"esm": "^3.2.25"

In one of my Vue components I did:

import LatLon from 'geodesy/latlon-spherical.js';

...

const p1 = new LatLon(50.06632, -5.71475);
const p2 = new LatLon(58.64402, -3.07009);

const d = p1.distanceTo(p2);
console.assert(d.toFixed(3) == '968874.704');

Which works OK. But when I took a look at the console there were many errors like this:

ERROR in /path//node_modules/@types/geodesy/latlon-spherical.d.ts(18,9):
18:9 An accessor cannot be declared in an ambient context.
    16 |     get lng(): number;
    17 |     set lng(lon: number);
  > 18 |     get longitude(): number;
       |         ^
    19 |     set longitude(lon: number);
    20 |     static get metresToKm(): number;
    21 |     static get metresToMiles(): number;

What can be happening? Could I be missing any step?

@chrisveness
Copy link
Owner

I'm not a TypeScript user, but this appears to be a widespread issue after TypeScript introduced a breaking change in a semver-minor release(!).

From what I can see, it may be resolved by changing the declaration for getters/setters in latlon-spherical.d.ts; e.g. (perhaps)

readonly longitude: number;

in place of

get longitude(): number;

– but as I'm not a TypeScript user, I can't be sure!

I suggest you approach the maintainers of the DefinitelyTyped geodesy types.

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

2 participants