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

[Feature Request]: Add generic type support for format function #170

Open
SamuelTrew opened this issue May 5, 2022 · 0 comments
Open

[Feature Request]: Add generic type support for format function #170

SamuelTrew opened this issue May 5, 2022 · 0 comments

Comments

@SamuelTrew
Copy link

The vision

Currently when using the format function, the opts are typed as any which I think is unneeded.

It could instead be like:

export type TransformFunction<T> = (info: TransformableInfo, opts?: T) => TransformableInfo | boolean;

export function format<T>(transform: TransformFunction<T>): FormatWrap;

So as to keep full type support

Use case

interface Info {
   x?: string
   y: number
}

const doSmth = format<Info>((info, opts) => {
   if (opts.x)
      info.timestamp = x
   return info
})

Additional information

No response

🔎 Search Terms

type, types

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