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的webpack/metro主文件模块解析_Typescript_React Native_Webpack - Fatal编程技术网

带有typescript的webpack/metro主文件模块解析

带有typescript的webpack/metro主文件模块解析,typescript,react-native,webpack,Typescript,React Native,Webpack,设置 Webpack具有模块解析功能,允许您根据环境解析某些文件,如: | Button | | - index.ts | | - index.performer.ts | | - index.customer.ts // Page.ts import Button from './Button'; 在react native中也有类似的作品 您可以根据平台(换句话说,环境)导入按钮 问题: 如何告诉typescript解析这些导入, 并根据环境选择正确的文件 行为是webpac

设置

Webpack具有模块解析功能,允许您根据环境解析某些文件,如:

| Button
|   | - index.ts
|   | - index.performer.ts
|   | - index.customer.ts

// Page.ts
import Button from './Button';
在react native中也有类似的作品

您可以根据平台(换句话说,环境)导入按钮

问题:

如何告诉typescript解析这些导入, 并根据环境选择正确的文件

行为是webpack/metro将选择index.android.ts,但typescript认为我们导入了index.ts


这就是问题所在。

类似的问题,我刚刚放弃了这个想法。我目前不知道任何一个框架有这样的工作。姑息性是重新导出您认为是 index > TS 中的默认环境,所以这个文件总是存在。类似的问题,我刚刚放弃了这个想法。我目前不知道任何一个框架有这样的工作。姑息性是重新导出您认为是 index > TS 中的默认环境,因此该文件始终存在。
| Button
|   | - index.ts
|   | - index.android.ts
|   | - index.ios.ts

// App.ts
import Button from './Button';