Skip to content

Commit f3e4319

Browse files
authored
Merge branch 'main' into add-casing-option
2 parents c69004a + f12fbf6 commit f3e4319

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

docs/guide/index.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,38 @@ It is highly recommended to use version tags when importing libraries in Deno, e
9090

9191
- https://cdn.jsdelivr.net/npm/@faker-js/faker
9292

93+
### TypeScript Support
94+
95+
Since version `v6+` there is native TypeScript support.
96+
97+
In order to have faker working properly, you need to check if these `compilerOptions` are set correctly in your `tsconfig` file:
98+
99+
```json
100+
{
101+
"compilerOptions": {
102+
"esModuleInterop": true,
103+
"moduleResolution": "Node"
104+
}
105+
}
106+
```
107+
108+
And then simply import it like everything else:
109+
110+
```ts
111+
import { faker } from '@faker-js/faker';
112+
```
113+
114+
If you want for whatever reason the versions prior to `v6`,
115+
you can use `@types/faker` and rebind the declarations to the `@faker-js/faker` package with a `faker.d.ts` file in your e.g. src folder.
116+
117+
```ts
118+
// faker.d.ts
119+
declare module '@faker-js/faker' {
120+
import faker from 'faker';
121+
export default faker;
122+
}
123+
```
124+
93125
## Community
94126

95127
If you have questions or need help, reach out to the community via [Discord](https://chat.fakerjs.dev) and [GitHub Discussions](https://github.com/faker-js/faker/discussions).

0 commit comments

Comments
 (0)