简体   繁体   中英

Is there a way to disable Weak Type Detection introduced with Typescript Version 2.4?

With Typescript version 2.4 weak type detection was added. Now I agree this is a great feature and will help catch a whole bunch of bugs for when you are assigning a value to a type that doesn't have a single property match for the type's optional properties.

Unfortunately for a large project originally written in Javascript and then migrated to Typescript there will be cases where the weak type loophole is used.

To allow for an easy migration to TS 2.4 and then the gradual removal of all weak type offences - is anyone aware of a flag or hack to disable the weak type detection temporarily?

There is no compiler flag, but I can recommend you ts-migrate . It will transform your existing js to ts code with any where inference does not work.

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