简体   繁体   English

allowSyntheticDefaultImports可移植配置打字稿通天塔?

[英]allowSyntheticDefaultImports transpile configuration typescript babel?

In my tsconfig.json I would like to use the compilerOptions.allowSyntheticDefaultImports=true option. 在我的tsconfig.json中,我想使用CompilerOptions.allowSyntheticDefaultImports = true选项。 My understanding is that it allows import React from 'react' , but when I try this I get an error like "React.createElement is undefined" 我的理解是,它允许import React from 'react' ,但是当我尝试此操作时,出现类似 “ React.createElement is undefined”的错误。

From what I've read setting this just tells TypeScript to ignore erroring when it should, but how do you fix the React.createElement error? 从我所读过的设置来看,这只是告诉TypeScript应该在什么时候忽略错误,但是如何解决React.createElement错误?

Besides typescript I'm using meteor which uses babel 除了打字稿,我正在使用流星,它使用babel

TypeScript to ignore erroring when it should, but how do you fix the React.createElement error TypeScript应该在应有的时候忽略错误,但是如何解决React.createElement错误

You can pass your code through babel that will add the synthetic import for you. 您可以通过babel传递代码,该代码将为您添加综合导入。

More 更多

I would recommend against this option altogether and just use * as . 我建议完全反对此选项,而只需使用* as

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

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