From 8b5edaa1897e5844acbb16686aed54355fdbcdd1 Mon Sep 17 00:00:00 2001 From: Philippe Serhal Date: Thu, 7 Oct 2021 18:55:30 -0400 Subject: [PATCH] docs(readme): add note about TypeScript --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 9d602e93..5e53aa15 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,22 @@ jsonFetch('http://www.test.com/products/1234', { }); ``` +### TypeScript + +This library comes with built-in TypeScript type declarations. + +Due to complexities in dealing with isomorphic-fetch - which uses whatwg-fetch in browsers and node-fetch +in node.js, which are subtly different - these type declarations only work if you include the `DOM` built-in +TypeScript lib in your `tsconfig.json`. For example: +```json +{ + "lib": ["DOM", "ES2020"] +} +``` +This happens implicitly if you don't set a `lib`. + +This may be fixed in the future. + ### Retry Behavior By default, jsonFetch doesn't retry requests. However, you may opt in to jsonFetch's very flexible retry behavior, provided by the excellent [`promise-retry`](https://github.com/IndigoUnited/node-promise-retry) library. Here's a quick example: