not-an-aardvark / snoowrap

A JavaScript wrapper for the reddit API
MIT License
1.01k stars 127 forks source link

SubmitLinkOptions type declaration marks subredditName as non-optional, but is autofilled in javascript source #358

Open jamesrswift opened 2 years ago

jamesrswift commented 2 years ago

https://github.com/not-an-aardvark/snoowrap/blob/498a8d5cb83181c53209a7c60de1c45b36358114/src/snoowrap.d.ts#L225

Marked without optional qualifier, however, in the javascript source, this member is autofilled to be equal to the parent object's display name:

  submitLink(options) {
    return this._r.submitLink(_objectSpread({}, options, {
      subredditName: this.display_name
    }));
  }
iMrDJAi commented 2 years ago

Nice catch! The interface SubmitLinkOptions is meant to be for snoowrap#submitLink and not Subreddit#submitLink. That means the shortcuts for the submit functions on the Subreddit class need separate interfaces. Probably it's enough to just use Omit:

submitLink (options: Omit<SubmitLinkOptions, 'subredditName'>) {
  return this._r.submitLink({...options, subredditName: this.display_name})
}