ui5-typescript
ui5-typescript copied to clipboard
@types/openui5 - missing type information for sap/ui/Device
Tested with @types/openui5 version 1.96.0.
Thanks @marcelschork for reporting this issue.
An alternative with typing right now would be using the Device.browser
API like this:
import { browser } from "sap/ui/Device";
const isMobile = browser.mobile;
Hi Marcel, thanks for reporting. I can confirm that on Device basically nothing is defined. For the time being you can import the properties of Device, which are named exports:
import { browser } from "sap/ui/Device";
On those, everything you need should be defined.
Hi Marcel,
@akudev and I recently "massaged" the types a bit more and we aligned the generated output with the expectation of the runtime. Starting with 1.115.0
onwards we provide type definitions which allow the usage of the Device API via:
import Device from "sap/ui/Device";
const isMobile = Device.browser.mobile;
or as dynamic import:
const Device = (await import("sap/ui/Device")).default;
const isMobile = Device.browser.mobile;
As said, this matches now the behavior of the runtime and types are only available at the default export and not as named exports anymore (except for libraries - but description will follow with the next release of the types).
Stay tuned for the next types release...
We close the issue now.
Cheers