1
votes

I am importing Algolia's places.js with the following line:

import * as places from 'places.js';

And further down:

const placesAutocomplete = places({
    appId: 'plTI5MDAXXXX',
    apiKey: '7d055eac95a6c48eb4939d2d5edXXXX',
    container: document.querySelector('#address-input')
});

And I am getting the following error:

error TS2349: Cannot invoke an expression whose type lacks a call signature.

Type `typeof import("ionic/XXXX/node_modules/places.js/typings")' has no compatible call signatures.

I already tried installing DefinitelyTyped/DefinitelyTyped to no avail.

1

1 Answers

1
votes

Changing the import line to:

import places from 'places.js';

worked on the latest update of the places.js bundle.

FYI: I also had to fix an issue related to types, after faffing around with types for long. This error was popping up, once the aforementioned error was fixed:

Type 'Element' is not assignable to type 'string | HTMLInputElement'. [ng] Type 'Element' is not assignable to type 'HTMLInputElement'.

This was fixed by explicitly casting onto the container:

const placesAutocomplete = places({
    appId: 'plTI5MDAXXXX',
    apiKey: '7d055eac95a6c48eb4939d2d5edXXXX',
    // The following change: <HTMLInputElement>
    container: <HTMLInputElement>document.querySelector('#address-input')
});