aboutsummaryrefslogtreecommitdiff
path: root/docs/guide
diff options
context:
space:
mode:
authorchilam <[email protected]>2022-05-15 19:30:43 +0800
committerGitHub <[email protected]>2022-05-15 11:30:43 +0000
commitf12fbf67f91188ccbe62884e7de6ffddfe19ff7e (patch)
treec544477aad16a895ccb3e71e8dc2d7e1e8c8ead2 /docs/guide
parentfa0a3d1dc41a6f385141af13354a7f182a62385f (diff)
downloadfaker-f12fbf67f91188ccbe62884e7de6ffddfe19ff7e.tar.xz
faker-f12fbf67f91188ccbe62884e7de6ffddfe19ff7e.zip
docs(docs/guide): Add typescript support in the guide (#947)
Diffstat (limited to 'docs/guide')
-rw-r--r--docs/guide/index.md32
1 files changed, 32 insertions, 0 deletions
diff --git a/docs/guide/index.md b/docs/guide/index.md
index 18bd257c..f83966b7 100644
--- a/docs/guide/index.md
+++ b/docs/guide/index.md
@@ -90,6 +90,38 @@ It is highly recommended to use version tags when importing libraries in Deno, e
- https://cdn.jsdelivr.net/npm/@faker-js/faker
+### TypeScript Support
+
+Since version `v6+` there is native TypeScript support.
+
+In order to have faker working properly, you need to check if these `compilerOptions` are set correctly in your `tsconfig` file:
+
+```json
+{
+ "compilerOptions": {
+ "esModuleInterop": true,
+ "moduleResolution": "Node"
+ }
+}
+```
+
+And then simply import it like everything else:
+
+```ts
+import { faker } from '@faker-js/faker';
+```
+
+If you want for whatever reason the versions prior to `v6`,
+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.
+
+```ts
+// faker.d.ts
+declare module '@faker-js/faker' {
+ import faker from 'faker';
+ export default faker;
+}
+```
+
## Community
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).