I have this TypeScript node module that imports some base errors ( errors1
and errors2
) and define some module specific errors3
:
// in errors3.ts
import errors1 from './errors1'
import errors2 from './errors2'
const errors3 = {
...
}
export default ? // <-- want to merge and export all errors here
Is there a way to combine all 3 error objects into one default export without explicit merging these objects into one manually (ie via Object.assign
, lodash
, etc?
You can use a barrel to export them all and then import them under a namespace.
https://basarat.gitbooks.io/typescript/docs/tips/barrel.html
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.