jochen-schweizer / express-prom-bundle

express middleware with standard prometheus metrics in one bundle
MIT License
310 stars 68 forks source link

Typescript definitions #32

Closed cliedeman closed 5 years ago

cliedeman commented 5 years ago

Would you be open to a PR thats adds typescript type definitions?

disjunction commented 5 years ago

don't have much experience with TS, but as long as it's not breaking anything, why not!

disjunction commented 5 years ago

@cliedeman thanks for this and also for whitelisting the files in package.json!

FYI it's now published as v5.1.1

ajilo297 commented 5 years ago

@cliedeman Thanks for the type definition. But I have an error with

'normalizePath', which lacks return-type annotation, implicitly has an 'any' return type. at this line.

export function normalizePath(
req: express.Request,
opts?: { normalizePath?: NormalizePathRegexs }
);

Is it possible to change this to

export function normalizePath(
req: express.Request,
opts?: { normalizePath?: NormalizePathRegexs }
): any;

without breaking anything?

cliedeman commented 5 years ago

@ajilo297 My bad I missed the return value.

I created #34 to fix this.

Here is the code I use to test the typedefs

Taking quick look we should be able to return string there. https://github.com/disjunction/url-value-parser/blob/master/src/UrlValueParser.js#L35

Ciaran

ajilo297 commented 5 years ago

@cliedeman Awesome. Thanks

disjunction commented 5 years ago

published as v5.1.2

cliedeman commented 5 years ago

Thanks and sorry for the churn