Skip to content

Commit e3d26cc

Browse files
authored
Merge pull request basarat#286 from trentrand/patch-1
Fix error in barrel: An import path cannot end with a '.ts' extension.
2 parents 2ec0e4b + 0fae6bf commit e3d26cc

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

docs/tips/barrel.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ export class Baz {}
1818
Without 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

2626
You 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

3535
Now 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
6464
export { baz }; // export the name
6565
```
6666

@@ -73,4 +73,4 @@ import { Foo, Bar, baz } from '../demo'; // demo/index.ts is implied
7373
baz.getBaz();
7474
baz.setBaz();
7575
// etc. ...
76-
```
76+
```

0 commit comments

Comments
 (0)