unsplash-js: `createApi` errors when TypeScript `dom` `lib` is not included
Hello π
I am integrating with unsplash for a project. While I was successful I found the following problem:
Steps to Reproduce
Use createApi
in Typescript projects.
Observed Behaviour

In order to use Typescript I ended up doing:
// @ts-ignore
const unsplash = createApi({
accessKey: functions.config().unsplash.access_key,
fetch,
});
Expected Behaviour
createApi
code should be valid with Typescript codebase if following documentation instructions.
Technical Notes
"unsplash-js": "^7.0.4"
"typescript": "^3.8.0"
I also tried with typescript v4, yielding same result.
Thank you, let me know if I can provide more info.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (8 by maintainers)
Commits related to this issue
- Reduced version of issue https://github.com/unsplash/unsplash-js/issues/166 — committed to cabello/unsplash-demo by cabello 3 years ago
i found a solution that using cross-fetch, will solve the typings issue for fetch type from
createApi
interface.I just pushed a fix. With v7.0.6 you should be able to do this:
This is only necessary if youβre not using the
dom
lib
.https://github.com/unsplash/unsplash-js/compare/v7.0.5...v7.0.6