Skip to content

Commit

Permalink
add default import for typescript (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErrorPro authored Apr 22, 2021
1 parent d16fec1 commit b98ab54
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,12 @@ const autocompleteRef = useRef(null);

### Typescript

We are planning on adding full support for TS and Flow in the later releases.
We are planning on rewritting the library with TS/Flow in the later releases but you can already use it with TypeScript.

```ts
import Autocomplete, {
ReactGoogleAutocomplete,
} from "react-google-autocomplete";

const AutocompleteTS: FC<ReactGoogleAutocomplete> = Autocomplete as FC<ReactGoogleAutocomplete>;
import Autocomplete from "react-google-autocomplete";

<AutocompleteTS apiKey="123" />;
<Autocomplete apiKey="123" />;
```

More examples(dynamic props, MaterialUI) how to use the lib could be found in `docs/examples.js`
Expand Down
13 changes: 7 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ export type OptionType = {
types?: string[];
};

export interface ReactGoogleAutocomplete<
T = { current: null },
B = { current: null }
> extends HTMLProps<HTMLInputElement> {
export interface ReactGoogleAutocompleteProps<T = { current: null }>
extends HTMLProps<HTMLInputElement> {
onPlaceSelected?: (
places: Record<string, unknown>,
ref: HTMLInputElement
) => void;
inputAutocompleteValue?: string;
options?: OptionType;
apiKey?: string;
ref?: T;
autocompleteRef?: B;
autocompleteRef?: T;
}

export default function ReactGoogleAutocomplete(
props: ReactGoogleAutocompleteProps
): JSX.Element;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-google-autocomplete",
"version": "2.0.1",
"version": "2.0.2",
"description": "React component for google autocomplete.",
"main": "index.js",
"types": "index.d.ts",
Expand Down

0 comments on commit b98ab54

Please sign in to comment.