Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过Typescript为Flow导入React本机类型?_Typescript_React Native_Flowtype_Typechecking_Flow Typed - Fatal编程技术网

如何通过Typescript为Flow导入React本机类型?

如何通过Typescript为Flow导入React本机类型?,typescript,react-native,flowtype,typechecking,flow-typed,Typescript,React Native,Flowtype,Typechecking,Flow Typed,在react原生应用程序中,我有一个TextInput组件。TextInput从以下路径读取某些类型: /Users/karl/Library/Caches/typescript/3.6/node_modules/@types/react-native/index.d.ts 此文件中有一系列类型,包括: export type KeyboardType = 'default' | 'email-address' | 'numeric' | 'phone-pad'; 我可以通过cmd+单击我添

在react原生应用程序中,我有一个
TextInput
组件。
TextInput
从以下路径读取某些类型:

/Users/karl/Library/Caches/typescript/3.6/node_modules/@types/react-native/index.d.ts
此文件中有一系列类型,包括:

export type KeyboardType = 'default' | 'email-address' | 'numeric' | 'phone-pad';
我可以通过
cmd+单击我添加的道具上的
(使用vscode)来访问该文件,以转到其定义

但我想知道的是,如何引用此文件中的类型,以便在流类型定义中使用它们

我希望能够做到以下几点:

//伪代码
从“react native”导入类型{KeyboardType}

我该怎么做呢?

你做的一切都很好,只是你不需要在
导入后键入
这个词:

import { Image, StyleSheet, ReturnKeyType, KeyboardType } from "react-native";

实际上,对于
flow-typed
,您应该直接从组件源添加类型:

导入类型{
键盘式,
返回键类型,
}来自“react native/Libraries/Components/TextInput/TextInput”;
但是对于
typescript
首先,安装
@types/react native
,然后从
react native
获取所有类型

从'react native'导入{ReturnKeyType,KeyboardType};

Wow。今天真的是星期一。谢谢,我现在真的得到了这个
流(推断错误)
。但是打字绝对不错。有什么想法吗<代码>无法导入“KeyboardType”,因为“react native”中没有“KeyboardType”导出。Flow(InferError)
希望您了解语义差异。如果没有,研究它们实际上我有相同的问题,并为
flow-typed
typescript
两者都留下答案。我对你的精彩帖子投了一票。