You're looking for default export and named exports.
in export default Something
case, you can use it with import Something from 'path'
. So you only want to export one thing. It can be used as a namespace also. It equals export { myFunction as default };
in export { Something }
case, you can use it with import { Something } from 'path'
. You can export many things with names. It increases the readability. For sure, you can also import { Something as Another} from 'path'
.
These two appoarches are not conflict. But only one default can be assigned.
// index.ts
export default function Something(){
}
export const CONST_A = 'A'
export const CONST_B = 'B'
// use.ts
import { default as Something, CONST_A, CONST_B} from './index.ts'