-
Notifications
You must be signed in to change notification settings - Fork 440
navigator.vibrate is typed as always being defined, but is undefined in Safari #1486
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
Comments
Yeah, I agree, this is probably the right call (having made this exact mistake myself also) |
https://github.com/microsoft/TypeScript-DOM-lib-generator#why-is-my-fancy-api-still-not-available-here |
Yeah, I'd like to have some policy rather than doing special treatment to a specific API. |
Hah, yeah, you're both not wrong there - should probably not do it |
Oh I mean, I'm open to this but I'd like to modify the policy so that things can be consistent for other APIs too. That said, not sure how the impact would be. |
Yeah, my suggestion was to make it optional in the emitter code (where we handle the number of implementations anyway).
This would probably make quite a few APIs optional with some breakings... Some good, some bad (depending on the target audience of the customer code) |
Yeah - while I don't think this is a massively used API, I'm willing to bet that systemically making a bunch of fns optional because it's only two is probably going to /feel/ like too much of a breaking change Hard to say without someone showing a .d.ts diff though |
I think our longstanding policy of marking things as fully present once they're in the relevant spec plus two major browsers is a sensible one, Safari's eccentricities notwithstanding. I realize Safari isn't exactly niche, but "a browser that exists doesn't support a spec'd, otherwise-available API" is not a road that goes to a good place. |
I've been bitten by that before as well (with |
Perhaps https://github.com/amilajack/eslint-plugin-compat could be an alternative. |
window.requestIdleCallback(() => {});
const shouldVibrate = true;
if (shouldVibrate) {
navigator.vibrate();
} |
The
navigator.vibrate
API is currently always defined. However, according to the navigator.vibrate MDN docs, this is currently not supported in Safari:I'm proposing to update the
Navigator
interface to:The text was updated successfully, but these errors were encountered: