Skip to content

Conversation

@kricsleo
Copy link
Member

resolves #695

@kricsleo kricsleo requested a review from pi0 as a code owner October 23, 2025 06:00
@43081j
Copy link
Member

43081j commented Dec 26, 2025

any chance you can catch this up with main? i left one comment but otherwise makes sense to me 👍

@codecov
Copy link

codecov bot commented Dec 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.79%. Comparing base (a52bf75) to head (e33fb46).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #696      +/-   ##
==========================================
+ Coverage   91.77%   91.79%   +0.02%     
==========================================
  Files           5        5              
  Lines         401      402       +1     
  Branches      126      127       +1     
==========================================
+ Hits          368      369       +1     
  Misses         33       33              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

kricsleo and others added 10 commits December 27, 2025 11:19
Co-authored-by: James Garbutt <43081j@users.noreply.github.com>
Co-authored-by: James Garbutt <43081j@users.noreply.github.com>
Co-authored-by: James Garbutt <43081j@users.noreply.github.com>
Co-authored-by: James Garbutt <43081j@users.noreply.github.com>
Co-authored-by: James Garbutt <43081j@users.noreply.github.com>
Co-authored-by: James Garbutt <43081j@users.noreply.github.com>
Co-authored-by: James Garbutt <43081j@users.noreply.github.com>
Co-authored-by: James Garbutt <43081j@users.noreply.github.com>
Co-authored-by: James Garbutt <43081j@users.noreply.github.com>
const DRIVER_NAME = "null";

export default defineDriver<void>(() => {
const driver: DriverFactory<void, never> = defineDriver(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Both type parameters are meant to be never here. They're used to define the type of an optional property rather than a function return, so can't really be void.

Copy link
Member Author

@kricsleo kricsleo Dec 27, 2025

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Gah because of the factory type 😭

Can you try undefined? Either way it isn't void since this is the type of the options property and parameter, which would never be void.

Copy link
Member

Choose a reason for hiding this comment

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

No worries I'll figure it out when I'm back at a laptop and get back to you 👍

As it would be good to get this right. Sorry for the lengthy back and forth 😅

Copy link
Member

Choose a reason for hiding this comment

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

i think im leaning towards using undefined:

export type DriverFactory<OptionsT, InstanceT> = (
  ...args: undefined extends OptionsT ? [] : [opts: OptionsT]
) => Driver<OptionsT, InstanceT>;

by doing this, DriverFactory<undefined, T> has no args, which is more correct than what we have right now in main.

Copy link
Member Author

@kricsleo kricsleo Dec 27, 2025

Choose a reason for hiding this comment

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

This seems overwhelming... While it brings more accurate type-safety, it makes the source code less straightforward. We are just "hacking through TypeScript"—is it really worth it? 🤔 (Compared to DriverFactory<void, never>)

Copy link
Member

Choose a reason for hiding this comment

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

happy to leave it as void for sake of getting this over the line. however, i'd still like to explain:

the current type is "hacky" (in main).

Driver<Options, Instance> is basically using those type params for these two properties:

export interface Driver<OptionsT = any, InstanceT = any> {
  // ...
  options?: OptionsT;
  getInstance?: () => InstanceT;
  // ...
}

by setting it as void, we're basically saying options?: void - which doesn't make any sense.

it makes some sense in the factory, as (opts: void) => Driver basically means opts can be set or not, as it won't be used.

but that too is incorrect. the null driver has no arguments, no options. it should be () => Driver, never taking any arguments.

this is why it should ideally be never (options?: never) and () => Driver.

but it is void in main right now so, whatever works. will leave @pi0 to review/merge

Copy link
Member Author

Choose a reason for hiding this comment

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

Totally agree! I'm 100% passionate about achieving full type-safety, just like you. ❤️
But TypeScript itself isn't ideal for handling situations like this. It's a weakness of the type system, and if we have to do weird stuff just to work around TypeScript itself, I'll step back and reconsider whether it's worth it.
Glad to discuss—I learned quite a lot 👍

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.

Missing declarations in dist

3 participants