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

LogFnAsError type missing from src/index.d.ts #20

Closed
maxmilton opened this issue Oct 25, 2022 · 3 comments · Fixed by #21
Closed

LogFnAsError type missing from src/index.d.ts #20

maxmilton opened this issue Oct 25, 2022 · 3 comments · Fixed by #21

Comments

@maxmilton
Copy link
Contributor

Describe the bug

After 78334b3 the types in https://github.com/maraisr/diary/blob/a723e0b203321faa6a95195c9991c2cf74c67427/src/index.d.ts are broken. Specifically, a type definition for LogFnAsError is now missing.

This means that any use of customLogger.error(...) and customLogger.fatal(...) in a typescript project doesn't work as expected.

To reproduce

import { diary } from 'diary';

const customLogger = diary('');

customLogger.error(new Error('test'));

Typescript can't see any type definition for LogFnAsError and treats it as any. When using @typescript-eslint/eslint-plugin in a project, a lint error for the rule @typescript-eslint/no-unsafe-call is emitted for customLogger.error.

Expected behavior

customLogger.error(...) and customLogger.fatal(...) are typed correctly.

@maxmilton
Copy link
Contributor Author

Created a fix PR in #21.

I also suggest adding linting to this project which would catch bugs like this.

@maraisr
Copy link
Owner

maraisr commented Oct 25, 2022

Yeah ouch... bad moment! Sorry about this. Ill get this out asap.

In terms of testing, yeah think I better — this hasn't been the first time. Thanks for jumping on it.

@maraisr
Copy link
Owner

maraisr commented Oct 25, 2022

I think with this commit (707d687) we should now have tests for our types as well.

Thanks for the highlight.

also v0.4.3 has the fix applied.

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 a pull request may close this issue.

2 participants