@@ -18,18 +18,18 @@ export class Baz {}
1818Without a barrel, a consumer would need three import statements:
1919
2020``` ts
21- import { Foo } from ' ../demo/foo.ts ' ;
22- import { Bar } from ' ../demo/bar.ts ' ;
23- import { Baz } from ' ../demo/baz.ts ' ;
21+ import { Foo } from ' ../demo/foo' ;
22+ import { Bar } from ' ../demo/bar' ;
23+ import { Baz } from ' ../demo/baz' ;
2424```
2525
2626You can instead add a barrel ` demo/index.ts ` containing the following:
2727
2828``` ts
2929// demo/index.ts
30- export * from ' ./foo.ts ' ; // re-export all of its exports
31- export * from ' ./bar.ts ' ; // re-export all of its exports
32- export * from ' ./baz.ts ' ; // re-export all of its exports
30+ export * from ' ./foo' ; // re-export all of its exports
31+ export * from ' ./bar' ; // re-export all of its exports
32+ export * from ' ./baz' ; // re-export all of its exports
3333```
3434
3535Now the consumer can import what it needs from the barrel:
@@ -57,10 +57,10 @@ If you would rather not export `getBaz` / `setBaz` from demo you can instead put
5757
5858``` ts
5959// demo/index.ts
60- export * from ' ./foo.ts ' ; // re-export all of its exports
61- export * from ' ./bar.ts ' ; // re-export all of its exports
60+ export * from ' ./foo' ; // re-export all of its exports
61+ export * from ' ./bar' ; // re-export all of its exports
6262
63- import * as baz from ' ./baz.ts ' ; // import as a name
63+ import * as baz from ' ./baz' ; // import as a name
6464export { baz }; // export the name
6565```
6666
@@ -73,4 +73,4 @@ import { Foo, Bar, baz } from '../demo'; // demo/index.ts is implied
7373baz .getBaz ();
7474baz .setBaz ();
7575// etc. ...
76- ```
76+ ```
0 commit comments