TypeScript支持re-exports,模块可以导出从另一个模块导入的值:
export {ZipCodeValidator as RegExpBasedZipCodeValidator} from "./ZipCodeValidator";
它还支持通配符导出:
export * from "./StringValidator";
但是,不支持此语法(Microsoft/TypeScript#1215讨论语法,它来自ES6并且不包含此表单):
export * as StringValidator from "./StringValidator"
我之所以这样做是因为我可以将我的模块拆分成单独的文件,并使TypeScript等效于这样的声明:
module.exports = {
foo: require('./foo'),
bar: require('./bar'),
}
答案 0 :(得分:0)
import * as foo from './foo'
import * as bar from './bar'
export {foo, bar}