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

Add typings #36

Open
matthieusieben opened this issue Jun 7, 2023 · 0 comments
Open

Add typings #36

matthieusieben opened this issue Jun 7, 2023 · 0 comments
Labels
feature New functionality or improvement

Comments

@matthieusieben
Copy link

I am currently using the following to type @hapi/content. It would be nice if this module exported its own types. I d'ont have the time or resources to make a PR. Sorry about that.

// types.d.ts

declare module '@hapi/content' {
  export type MutlipartContentType = {
    mime: `multipart/${string}`
    boundary: string
  }

  export type ContentType = {
    mime: string
  }

  export function type(header: `multipart/${string}`): MutlipartContentType
  export function type(header: string): ContentType | MutlipartContentType

  export type ContentDisposition = {
    name: string
  } & { [_ in string]?: string }

  /**
   * @param header - The value of the Content-Disposition "form-data" header
   */
  export function disposition(
    header: string
  ): typeof header extends `inline${string}` | `attachment${string}` ? never : ContentDisposition
}
@matthieusieben matthieusieben added the feature New functionality or improvement label Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

1 participant