TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

navigator.share should be an optional attribute

Open ghost opened this issue 4 years ago • 0 comments

navigator.share should be an optional attribute of Navigator because a significant number of browsers still don't support it (CanIUse), but it seems to be defined as always defined on the navigator interface. So, the following code:

//...
          <Tooltip
            title={
              navigator.share ? "Share" : "Your device doesn't support sharing"
            }
          >
//...

which is perfectly fine raises the following error:

This condition will always return true since the function is always defined. Did you mean to call it instead?  TS2774

ghost avatar Nov 24 '20 11:11 ghost