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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Types for Typescript #3

Open
WickedSik opened this issue May 7, 2019 · 1 comment
Open

No Types for Typescript #3

WickedSik opened this issue May 7, 2019 · 1 comment

Comments

@WickedSik
Copy link

WickedSik commented May 7, 2019

Hi! I realise this is a fairly old project, but still. I decided to add a typescript definition file 馃棥

declare module 'wallhaven-api' {
    type SearchCategory = 'general' | 'anime' | 'people'
    type SearchCategoryUC = 'General' | 'Anime' | 'People'
    type SearchSorting = 'relevance' | 'random' | 'date_added' | 'views' | 'favorites'

    type SearchOptions = {
        categories?: SearchCategory[]
        page?: number
        sorting?: SearchSorting
        nsfw?: boolean
        sketchy?: boolean
    }

    type Tag = {
        id: number
        text: string
    }

    type SearchResultItem = {
        id: number
        width: number
        height: number
        thumb: string
    }

    type SearchResult = {
        end: boolean
        totalPages: number
        images: SearchResultItem[]
    }

    type DetailResult = {
        fullImage: string
        tags: Tag[]
        category: SearchCategoryUC
        size: string
        views: number
        width: number
        height: number
        colors: string[]
    }

    export default class Wallhaven {
        search(keyword: string, options?: SearchOptions): Promise<SearchResult>
        details(id: number): Promise<DetailResult>
    }
}
@WickedSik
Copy link
Author

Also, the package name is wallhaven-api not wallhaven like it shows in the README.md

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

No branches or pull requests

1 participant