neynarxyz / nodejs-sdk

Typescript SDK for Neynar APIs
https://neynar.com
MIT License
53 stars 11 forks source link

Docs: Added snippet on where/how to import type definitions from #232

Closed zacharytyhacz closed 2 weeks ago

zacharytyhacz commented 2 weeks ago

I was so bummed out when I didn't know how to import just the type definitions of objects from responses from the Neynar functions.

I didn't know it was even possible, I had to make my own type definition from scratch based on the responses and what my IDE was telling me was in 'CastAuthor' etc.

I dug a little bit and found out that you CAN in fact import the type definitions which has been super helpful.

Really wished this was explicitly shown somewhere, I imagine this will help a ton of people that want to directly use type definitions directly from neynar instead of serializing or using custom type definitions.

Added to README:

...

Type Definitions

You can directly import the type definitions from the SDK as shown below:

import { type User } from '@neynar/nodejs-sdk/build/neynar-api/v2/openapi-farcaster/models/user'
import { type CastAuthor } from '@neynar/nodejs-sdk/build/neynar-api/v2/openapi-farcaster/models/cast-author'
import { type CastWithInteractionsReactions } from '@neynar/nodejs-sdk/build/neynar-api/v2/openapi-farcaster/models/cast-with-interactions-reactions'

...