Skip to content

Commit 00674f1

Browse files
committed
Added fragment
1 parent 9c747f0 commit 00674f1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

book-content/fragments.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,3 +1600,23 @@ By now you should feel comfortable with both CommonJS (CJS) and ECMAScript Modul
16001600
Remember, the JavaScript ecosystem is constantly evolving, and what's considered best practice today might change tomorrow. Stay connected with the community, keep learning, and don't be afraid to experiment.
16011601
16021602
Should you encounter any stumbling blocks, don't hesitate to connect on the Total TypeScript Discord! The community there is always eager to help and share their experiences with publishing TypeScript applications and libraries.
1603+
1604+
<!-- -->
1605+
1606+
### Importing Inside `declare module`
1607+
1608+
There's an interesting edge case you can run into when using `declare module`. What if you want to keep the file you're working in a script, but import some types to use inside the `declare module` block?
1609+
1610+
You won't be able to `import` at the top of the file, because that will turn the file into a module. But you can use `import` inside the `declare module` block:
1611+
1612+
```typescript
1613+
// inside express.d.ts
1614+
1615+
declare module "express" {
1616+
import { Request } from "express";
1617+
1618+
export interface MyType {
1619+
hello: string;
1620+
}
1621+
}
1622+
```

0 commit comments

Comments
 (0)