Microsoft/TypeScript

navigator.share is not always a function

Open

#42,809 opened on Feb 15, 2021

View on GitHub
ย (7 comments)ย (18 reactions)ย (0 assignees)TypeScriptย (48,455 stars)ย (6,726 forks)batch import
BugDomain: lib.d.tsHelp Wanted

Description

Bug 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

https://www.typescriptlang.org/play?#code/JYMwBAFAdghgbsA5jALgewE4DoDOALGDAUwEowBvAWACgw6wBjNKHNAGyKzbUQgHIAKniJhYKYHBH5CIkEVQBXYmGA4VAWwAOHdUSgoiAEz4kA3DQC+YImxwiqtekxbtO3XoOGjUEqQWVyisqqomgoGtpEuvpGJubUFkA

๐Ÿ’ป 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.

Contributor guide

navigator.share is not always a function ยท Microsoft/TypeScript#42809 | Good First Issue