Skip to content

Commit b98ab54

Browse files
authored
add default import for typescript (#97)
1 parent d16fec1 commit b98ab54

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,12 @@ const autocompleteRef = useRef(null);
121121

122122
### Typescript
123123

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

126126
```ts
127-
import Autocomplete, {
128-
ReactGoogleAutocomplete,
129-
} from "react-google-autocomplete";
130-
131-
const AutocompleteTS: FC<ReactGoogleAutocomplete> = Autocomplete as FC<ReactGoogleAutocomplete>;
127+
import Autocomplete from "react-google-autocomplete";
132128

133-
<AutocompleteTS apiKey="123" />;
129+
<Autocomplete apiKey="123" />;
134130
```
135131

136132
More examples(dynamic props, MaterialUI) how to use the lib could be found in `docs/examples.js`

index.d.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@ export type OptionType = {
1111
types?: string[];
1212
};
1313

14-
export interface ReactGoogleAutocomplete<
15-
T = { current: null },
16-
B = { current: null }
17-
> extends HTMLProps<HTMLInputElement> {
14+
export interface ReactGoogleAutocompleteProps<T = { current: null }>
15+
extends HTMLProps<HTMLInputElement> {
1816
onPlaceSelected?: (
1917
places: Record<string, unknown>,
2018
ref: HTMLInputElement
2119
) => void;
2220
inputAutocompleteValue?: string;
2321
options?: OptionType;
2422
apiKey?: string;
25-
ref?: T;
26-
autocompleteRef?: B;
23+
autocompleteRef?: T;
2724
}
25+
26+
export default function ReactGoogleAutocomplete(
27+
props: ReactGoogleAutocompleteProps
28+
): JSX.Element;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-google-autocomplete",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "React component for google autocomplete.",
55
"main": "index.js",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)