navigator.share is not always a function
See original GitHub issueBug Report
navigator.share is undefined is many browsers, yet TypeScript reports it as “the function is always defined”
🔎 Search Terms
navigator.share share
🕗 Version & Regression Information
Version 4.1.5 & Nightly
⏯ Playground Link
💻 Code
if (navigator.share) {
console.log('The native share feature is implemented');
} else {
console.log('The native share feature is not implemented');
}
🙁 Actual behavior
TypeScript reports it as “the function is always defined”
🙂 Expected behavior
If should report navigator.share as maybe being present.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:6 (3 by maintainers)
Top Results From Across the Web
navigator.share() is not a function - Stack Overflow
share() to experiment with websharing in a react app. When I call navigator.canShare() in react, I get the following run time error: TypeError: ......
Read more >Navigator.share() - Web APIs - MDN Web Docs
An object containing data to share. Properties that are unknown to the user agent are ignored; share data is only assessed on properties...
Read more >How to share anything from your website by Web Share API
You can use this in your function or anywhere you want. But before you do that you should remember one thing that it...
Read more >"navigator.share" | Can I use... Support tables for HTML5 ...
5 Did not support share click that would trigger a fetch call ... Navigator API: share: data.text parameter. Usage % of. all users,...
Read more >Allow your mobile visitors to easier share your articles ... - Phiilu
Browsers that support the Web Share API will expose the share method on the navigator object. There is also a canShare method, but...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ran into the same issue. Discovered that using
navigator['share']
instead also works around the Typescript error, at least with my installed version of TypeScript 4.5.3.There is ton of definitions from Edge Web IDLs so I think this definition is one from Edge.