Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export types in feed #128

Closed
gustavkj opened this issue Sep 23, 2020 · 2 comments · Fixed by #136
Closed

Export types in feed #128

gustavkj opened this issue Sep 23, 2020 · 2 comments · Fixed by #136

Comments

@gustavkj
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Right now, only the Feed class is exported as a type. It would be nice if the types used for the parameters of different methods and the constructor were exported to.

Describe the solution you'd like
Export the following types: Author, Extension, FeedOptions, and Item.

Describe alternatives you've considered
In the meantime, I'm getting the type from the typing of the parameters. Which I do not think is as nice, though:

import { Feed } from 'feed';

type Item = Parameters<Feed['addItem']>[0];

It's also possible to get the type by importing from the typings directory, but it do not think this is an intended feature (right?):

import { Item } from 'feed/lib/typings';

Additional context

For reference, feed.d.ts looks like this as of 4.2.1:

import { Author, Extension, FeedOptions, Item } from "./typings";
export declare class Feed {
    options: FeedOptions;
    items: Item[];
    categories: string[];
    contributors: Author[];
    extensions: Extension[];
    constructor(options: FeedOptions);
    addItem: (item: Item) => number;
    addCategory: (category: string) => number;
    addContributor: (contributor: Author) => number;
    addExtension: (extension: Extension) => number;
    atom1: () => string;
    rss2: () => string;
    json1: () => string;
}
@jpmonette
Copy link
Owner

@gustavkj Good catch. You can open a PR!

@gustavkj
Copy link
Contributor Author

gustavkj commented Dec 6, 2020

@jpmonette Thanks! Sure, I've opened a PR now.

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

Successfully merging a pull request may close this issue.

2 participants