Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Adding topics to getRandom #181

Merged
merged 3 commits into from
Jul 15, 2021
Merged

Adding topics to getRandom #181

merged 3 commits into from
Jul 15, 2021

Conversation

tanishqkancharla
Copy link
Contributor

@tanishqkancharla tanishqkancharla commented Jul 14, 2021

Overview

Yo. I'm trying to add topicIds support to the getRandom endpoint. No idea if I'm going about it right. I also keep running into this error (unrelated to the code I wrote) while building:

/src/helpers/errors.ts(24,5): semantic error TS2322:
Type 'NonEmptyArray<AnyJson> | null' is not assignable to type 'Nullable<NonEmptyArray<string>>'.
  Type 'NonEmptyArray<AnyJson>' is not assignable to type 'Nullable<NonEmptyArray<string>>'.
   Type 'AnyJson' is not assignable to type 'string'.
      Type 'null' is not assignable to type 'string'.

I'm not sure what the issue is after looking at the file referenced.

Todo

Add docs and tests.

If someone can verify I'm doing this the right way, I can add docs and tests and finish up the PR.

@tanishqkancharla tanishqkancharla requested a review from a team as a code owner July 14, 2021 02:57
@OliverJAsh
Copy link
Member

OliverJAsh commented Jul 14, 2021

Thanks, this looks good to me!

I also keep running into this error (unrelated to the code I wrote) while building:

I'm not sure what's going on there. Are you using the TS version bundled in node_modules?

image

@tanishqkancharla
Copy link
Contributor Author

I think I am, but the typescript version bundled in node_modules is 3.9, not 4.2 like in your screenshot:

Screen Shot 2021-07-14 at 6 51 57 PM

@Magellol
Copy link
Member

@moonrise-tk Have you run yarn to update any dependencies? That might solve that issue.

@tanishqkancharla
Copy link
Contributor Author

Ah shoot yall are using yarn, not npm. Works now :). I'll finish up the PR.

@tanishqkancharla
Copy link
Contributor Author

Done! I didn't add tests because I guess you can't do without the API key, but I tried it, and it seems to be working. Let me know if it looks okay! Also I updated the types for collectionIds and topicIds to be Array<string> in the README. I think they are strings: https://unsplash.com/documentation#get-a-topic.

Copy link
Member

@OliverJAsh OliverJAsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again!

@OliverJAsh OliverJAsh merged commit 23f561f into unsplash:master Jul 15, 2021
@OliverJAsh
Copy link
Member

@tanishqkancharla
Copy link
Contributor Author

I'm really confused: when I use the newest release of unsplash-js in my project, the distribution does not include the new topic ids param. When I yarn run build my fork, the dist folder does update. When I check in the src folder in the node_modules of my project, the new topicIds code shows up.

Screen Shot 2021-07-15 at 5 31 47 PM

The typing in node_modules/unsplash-js/dist/index.d.ts in my project. It does not use the new topicIds param. Incorrectly typed.

Screen Shot 2021-07-15 at 5 33 59 PM

The typing in node_modules/unsplash-js/dist/methods/photos/index.d.ts. The distributed code exports the new param. Correctly typed.

Screen Shot 2021-07-15 at 5 35 02 PM

The typing of `getRandom` in dist/index.d.ts when I run `yarn run build` on my fork. Correctly typed.

What's going on? Is there somewhere else I need to update types?

@tanishqkancharla
Copy link
Contributor Author

(Also i've tried cleaning my npm cache, uninstalling, reinstalling, everything)

@OliverJAsh
Copy link
Member

@moonrise-tk I'm sorry, we have a problem with our build tool: #167

I've just published a new version, this should work!

https://github.com/unsplash/unsplash-js/releases/tag/v7.0.15

To verify: https://unpkg.com/[email protected]/dist/index.d.ts

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants