wellyshen / use-places-autocomplete

😎 📍 React hook for Google Maps Places Autocomplete.

Home Page:https://use-places-autocomplete.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type Expected in index.d.ts

chrissx520 opened this issue · comments

Bug Report

Describe the Bug

Trying to bundle fails on line 21

export type Status = ${google.maps.places.PlacesServiceStatus} | "";

How to Reproduce

react-app-rewired build

Steps to reproduce the behavior, please provide code snippets or a repository:

Just compiling a project with the library.

TypeScript error in /home/christopher/tango/admin/node_modules/use-places-autocomplete/dist/index.d.ts(21,24):
Type expected.  TS1110

    19 |   export type Suggestion = google.maps.places.AutocompletePrediction;
    20 | 
  > 21 |   export type Status = `${google.maps.places.PlacesServiceStatus}` | "";
       |                        ^
    22 | 
    23 |   export interface Suggestions {
    24 |     readonly loading: boolean;

Expected Behavior

Clean compilation.

Additional Information

When switching to export type Status = google.maps.places.PlacesServiceStatus;

the build succeeds

@chrissx520 I have tried to reproduce this issue through this repo and I can pass the build. This library uses the template literal to convert the Enum's values of @types/google-maps for the Status type. So, please ensure you are using TypeScript v4.1+