Definitelytyped: [@types/googlemaps] Property 'setFields()' does not exist on type 'Autocomplete'

Created on 12 Jul 2018  路  2Comments  路  Source: DefinitelyTyped/DefinitelyTyped

If you know how to fix the issue, make a pull request instead.

  • [x] I tried using the @types/xxxx package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [ ] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @cgwrench, @nertzy, @xaolas, @mrmcnerd, @martincostello, @svenkreiss, @bolatovumar

If you do not mention the authors the issue will be ignored.

Problem description:

Trying to make an Autocomplete request explicitly without Places Details like that:

this.autocomplete = new google.maps.places.Autocomplete(autocompleteInput, {
  types: ['address']
});
this.autocomplete.setFields(['formatted_address']);

And recieve an error:

Typescript Error
Property 'setFields' does not exist on type 'Autocomplete'.

Possible solution

Please, add the new functionality according to sku mapping changes. Link

Most helpful comment

Ping - any word on this? Given that it's directly related to how much we're charged for using the API, this seems like something that should be important enough to have some time allotted to it.

Update:
Looks like you can also set it through the options object
https://developers.google.com/maps/documentation/javascript/reference/places-widget#AutocompleteOptions.fields

All 2 comments

Ping - any word on this? Given that it's directly related to how much we're charged for using the API, this seems like something that should be important enough to have some time allotted to it.

Update:
Looks like you can also set it through the options object
https://developers.google.com/maps/documentation/javascript/reference/places-widget#AutocompleteOptions.fields

is not a mistake, just tell to the compiler that the autocomplete is type of any
const autocomplete:any = new google.maps.places.Autocomplete(
autocompleteInput, {
types: ['address']
});

Was this page helpful?
0 / 5 - 0 ratings