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

allow generic string as metric name #21

Merged
merged 3 commits into from
Jul 10, 2022

Conversation

noamokman
Copy link
Contributor

  • allow generic string as metric name
  • .

@@ -115,11 +115,15 @@ const innerMonitor = <Callable, Scope extends string, Method extends string>({

export const createMonitor =
<Scope extends string>({ scope, ...initOptions }: InitOptions<Scope>) =>
<Callable, Method extends string>(method: CamelCase<Method>, callable: () => Callable, options?: MonitorOptions<Callable>) =>
<Callable, Method extends string>(
method: CamelCase<Method> extends never ? string : CamelCase<Method>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extends never ? : string
mind explaning?
CamelCase didn't let you put a variable as a scope / method name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it resolves to never, so this is the workaround

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, look at the test I added, it failed before

@SharonGrossman
Copy link
Collaborator

package.json version bump

@noamokman
Copy link
Contributor Author

@SharonGrossman thanks!

@SharonGrossman SharonGrossman merged commit 39fa9e5 into main Jul 10, 2022
@SharonGrossman SharonGrossman deleted the allow-generic-string-as-metric-name branch July 10, 2022 14:25
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

Successfully merging this pull request may close these issues.

2 participants