Reputation: 5279
In my react-native application I have a TextInput
component. The TextInput
reads some types from the following path:
/Users/karl/Library/Caches/typescript/3.6/node_modules/@types/react-native/index.d.ts
This file has a bunch of types in including:
export type KeyboardType = 'default' | 'email-address' | 'numeric' | 'phone-pad';
I can access this file by cmd + clicking
on a prop I have added, (using vscode) to go to it's definition.
What I am wondering though is how I can reference the types in this file, so I can use them in my Flow typing definitions?
I want to be able to do something like:
// pseudocode
import type { KeyboardType } from 'react-native'
How I can go about this?
Upvotes: 3
Views: 3931
Reputation: 32522
Actually, for flow-typed
you should directly add the types from component source:
import type {
KeyboardType,
ReturnKeyType,
} from 'react-native/Libraries/Components/TextInput/TextInput';
But for typescript
first, install @types/react-native
and then get all the types from react-native
;
import type { ReturnKeyType, KeyboardType } from 'react-native';
Upvotes: 4
Reputation:
You're doing everything right, except you don't need the word type
after import
:
import { Image, StyleSheet, ReturnKeyType, KeyboardType } from "react-native";
Upvotes: 0