Skip to content Skip to sidebar Skip to footer

Frequent Issue With Typescript And Preferring Import Over Require

Whenever possible, I try to use import over require but in some circumstances this breaks type checking. What is the correct way to handle this issue? Is it possible to cast an imp

Solution 1:

Unfortunately this is an issue with the typings of one of your dependencies, convict. Looking at the @types/convict source:

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/convict/index.d.ts#L122

They export the definitions using export = ..., which according to the Typescript handbook:

https://www.typescriptlang.org/docs/handbook/modules.html (see the "export =and import = require()" heading)

breaks import * from ... imports. So, you're kinda stuck on this one.

Post a Comment for "Frequent Issue With Typescript And Preferring Import Over Require"