// demo/index.tsexport*from'./foo'; // re-export all of its exportsexport*from'./bar'; // re-export all of its exportsexport*from'./baz'; // re-export all of its exports
今、ユーザーは必要なものをバレルからインポートできます:
import { Foo, Bar, Baz } from'../demo'; // demo/index.ts is implied
// demo/index.tsexport*from'./foo'; // re-export all of its exportsexport*from'./bar'; // re-export all of its exportsimport*as baz from'./baz'; // import as a nameexport { baz }; // export the name
そして今、ユーザーは次のようになります:
import { Foo, Bar, baz } from'../demo'; // demo/index.ts is implied// usagebaz.getBaz();baz.setBaz();// etc. ...