Skip to content

feat: enhance type checking for OptionalLogger methods#41

Merged
arv merged 2 commits into
mainfrom
arv/type-check
Jun 23, 2026
Merged

feat: enhance type checking for OptionalLogger methods#41
arv merged 2 commits into
mainfrom
arv/type-check

Conversation

@arv

@arv arv commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@arv arv requested review from 0xcadams and Copilot June 23, 2026 07:51
@arv arv added this pull request to the merge queue Jun 23, 2026
Merged via the queue into main with commit 3f6371b Jun 23, 2026
6 checks passed
@arv arv deleted the arv/type-check branch June 23, 2026 07:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens TypeScript type-checking for OptionalLogger methods by adding explicit this typing so extracted/unbound calls are rejected at compile time.

Changes:

  • Adds this parameters to OptionalLogger method function types to prevent calling extracted methods without binding.
  • Updates OptionalLoggerImpl method property types to match the interface changes.
  • Adds a (currently skipped) test intended to assert the new type-checking behavior via @ts-expect-error.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/logger.ts Updates OptionalLogger / OptionalLoggerImpl method types to require an appropriate this context.
src/logger.test.ts Adds a type-checking-focused test that validates extracted-method calls fail to type-check.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/logger.ts
Comment thread src/logger.ts
Comment on lines +93 to +107
readonly debug?:
| ((this: OptionalLogger<Error, Warn, Info, Debug>, ...args: Debug) => void)
| undefined = undefined;
readonly info?:
| ((this: OptionalLogger<Error, Warn, Info, Debug>, ...args: Info) => void)
| undefined = undefined;
readonly warn?:
| ((this: OptionalLogger<Error, Warn, Info, Debug>, ...args: Warn) => void)
| undefined = undefined;
readonly error?:
| ((this: OptionalLogger<Error, Warn, Info, Debug>, ...args: Error) => void)
| undefined = undefined;
readonly flush: (
this: OptionalLogger<Error, Warn, Info, Debug>,
) => Promise<void>;
Comment thread src/logger.test.ts

@0xcadams 0xcadams left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM nice fix

@arv

arv commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

But Co-pilot is right. Let me do that.

@arv

arv commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Done in #45 and #46

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.

3 participants