简体   繁体   中英

allowSyntheticDefaultImports transpile configuration typescript babel?

In my tsconfig.json I would like to use the compilerOptions.allowSyntheticDefaultImports=true option. My understanding is that it allows import React from 'react' , but when I try this I get an error like "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?

Besides typescript I'm using meteor which uses babel

TypeScript to ignore erroring when it should, but how do you fix the React.createElement error

You can pass your code through babel that will add the synthetic import for you.

More

I would recommend against this option altogether and just use * as .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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