Open olabaloo opened 5 years ago
A workaround for this problem is to assert the type of the value returned from getApplicationNode
in the component:
getApplicationNode = () => {
return document.getElementById("root") as Element;
};
The Problem
When using react-aria-modal in combination with TypeScript compiler option
strictNullChecks
, the solution does not compile.The compile complains with the following message:
Solution
Changing
getApplicationNode?(): Node | Element;
togetApplicationNode?(): Element | null;
in the file@types\react-aria-modal\index.d.ts
seems to fix the problem.Background
In
@types\react-aria-modal\index.d.ts
thegetApplicationNode?()
return type is defined asNode | Element
. This is not correct according to MDN's getElementById documentation, which states:This error occurs when using
react-aria-modal: 3.1.0
,@types/react-aria-modal: 2.12.1
, andtypescript: 3.3.3333
.