简体   繁体   English

使用特定模式时忽略流类型错误

[英]Ignore flowtype error when using specific pattern

I'm trying to use typescript together with flowtype in a transition period where everything is changing to typescript. 我正在尝试在所有内容都变为打字稿的过渡期内将打字稿与flowtype一起使用。 However, flowtype is giving me an error, when I try to import declarations from a typescript file in a regular js|jsx file. 但是,当我尝试从常规js | jsx文件中的打字稿文件中导入声明时,flowtype给我一个错误。 I get the usual Cannot resolve module '*.tsx . 我得到了通常的Cannot resolve module '*.tsx Is it possible to ignore this flow error globally without having to use $FlowFixMe above my import statements? 是否可以全局忽略此流错误,而不必在导入语句上方使用$ FlowFixMe?

This is giving flow errors, that I want to supress: 这是我想抑制的流错误:

import foo from 'foobar.tsx';

That is likewise an error in TypeScript. 这同样是TypeScript中的错误。 Depending on your module loader/bundler's extension resolution, use either 根据模块加载器/捆绑器的扩展分辨率,使用

import foo from 'foobar';

or 要么

import foo from 'foobar.js';

Since you are using JSX it's worth noting that 由于您使用的是JSX,因此值得注意

import foo from 'foobar.jsx';

is also incorrect. 也不正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM