parent
743540363d
commit
0a0f78f144
|
@ -1175,13 +1175,13 @@ a(href="#toc") Back to top
|
|||
<a id="04-10"></a>
|
||||
#### Style 04-10
|
||||
|
||||
.s-rule.do
|
||||
.s-rule.consider
|
||||
:marked
|
||||
**Do** create a file that imports, aggregates, and re-exports items. We call this technique a **barrel**.
|
||||
**Consider** creating a file that imports, aggregates, and re-exports items. We call this technique a **barrel**.
|
||||
|
||||
.s-rule.do
|
||||
.s-rule.consider
|
||||
:marked
|
||||
**Do** name this barrel file `index.ts`.
|
||||
**Consider** naming this barrel file `index.ts`.
|
||||
|
||||
.s-why
|
||||
:marked
|
||||
|
@ -1190,6 +1190,14 @@ a(href="#toc") Back to top
|
|||
.s-why
|
||||
:marked
|
||||
**Why?** A barrel reduces the number of imports a file may need.
|
||||
|
||||
.s-why
|
||||
:marked
|
||||
**Why?** A barrel provides a consistent pattern to import everything exported in the barrel from a folder.
|
||||
|
||||
.s-why
|
||||
:marked
|
||||
**Why?** This is consistent with a pattern from Node, which imports the index.js|ts file from a folder.
|
||||
|
||||
.s-why.s-why-last
|
||||
:marked
|
||||
|
|
Loading…
Reference in New Issue