w3c-web-usb: fix nullable types#73568
Conversation
|
🔔 @larsgk @thegecko @yume-chan — please review this PR in the next few days. Be sure to explicitly select |
c90458c to
a073eaf
Compare
Fix issues with null vs. undefined. Based on DefinitelyTyped/DefinitelyTyped#73568
Fix issues with null vs. undefined. Based on DefinitelyTyped/DefinitelyTyped#73568
RyanCavanaugh
left a comment
There was a problem hiding this comment.
The eslint changes seem unneeded - neither of those rules are violated in this PR. Please use a line-based suppression if actually needed somewhere
|
@dlech One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits. Thank you! |
There are certain properties in the WebUSB APIs that are nullable rather than optional, meaning they can only be null and never undefined. Fix the types and add a function to the test to validate this.
a073eaf to
8127560
Compare
|
@RyanCavanaugh, @yume-chan Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
|
I just dropped the configuration change commit. Since CI is passing, that tells me that I just have a local problem that was triggering the need for that. FWIW, this is the error I am seeing locally. It looks like maybe I need to wipe out Error:
/home/david/work/DefinitelyTyped/types/w3c-web-usb/index.d.ts
1:1 error Definition for rule '@typescript-eslint/no-wrapper-object-types' was not found @typescript-eslint/no-wrapper-object-types
1:1 error Definition for rule '@typescript-eslint/no-unsafe-function-type' was not found @typescript-eslint/no-unsafe-function-type
/home/david/work/DefinitelyTyped/types/w3c-web-usb/w3c-web-usb-tests.ts
1:1 error Definition for rule '@typescript-eslint/no-wrapper-object-types' was not found @typescript-eslint/no-wrapper-object-types
1:1 error Definition for rule '@typescript-eslint/no-unsafe-function-type' was not found @typescript-eslint/no-unsafe-function-type |
|
@dlech: Everything looks good here. I am ready to merge this PR (at 8127560) on your behalf whenever you think it's ready. If you'd like that to happen, please post a comment saying:
and I'll merge this PR almost instantly. Thanks for helping out! ❤️ (@larsgk, @thegecko, @yume-chan: you can do this too.) |
|
@RyanCavanaugh Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |


Please fill in this template.
pnpm test <package to test>.Select one of these and delete the others:
If changing an existing definition:
package.json.Additional context:
The first commit fixes errors that were already present when running
pnpm test w3c-web-usb. This was needed to be able to actually run tests for the main commit.The main commit fixes some incorrect types that were observed. According to the WebUSB spec (link above), some properties are nullable, meaning the value can only be
nulland neverundefined. We have also confirmed at runtime in a web browser that these properties do indeed returnnull.