I am running a react application . The code below does not work because of the following error message:
import =
is not supported by @babel/plugin-transform-typescript Please consider usingimport <moduleName> from '<moduleName>';
alongside Typescript's --allowSyntheticDefaultImports option.
apiTypes.d.ts
declare module ModuleA {
declare module ModuleB {
export interface ModuleABInterface {
}
}
}
token.ts
import ModuleABInterface = ModuleA.ModuleB.ModuleABInterface
let test: ModuleABInterface
What would be the correct solution to import from nested modules?
It's impossible to nest ES6 modules.TypeScript namespaces (that were originally called "modules") can be nested, but should be avoided . And yes, it's impossible to import from them - you can only import the namespace object itself, using normal ES6 import
declarations (not the deprecated import =
syntax), then access their properties.
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.