hapijs / hapijs/content

Add typings

Open
#36 0 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
JavaScript
Stars
7
Forks
14
PR merge metrics
No merged PRs in 30d

Description

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.

```ts
// 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
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.