mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00

BREAKING CHANGES: `Application.orientation` is no longer a function. Migration: Remove `()` from the `Application.orientation()` call: ```diff import { Application } from "@nativescript/core"; -console.log(Application.orientation()); +console.log(Application.orientation); ``` `Application.systemAppearance` is no longer a function. Migration: Remove `()` from the `Application.systemAppearance()` call: ```diff import { Application } from "@nativescript/core"; -console.log(Application.systemAppearance()); +console.log(Application.systemAppearance); ```
27 lines
700 B
TypeScript
27 lines
700 B
TypeScript
/**
|
|
* @internal Util used for exporting opposing platform utils and warning the user if they are trying to access them.
|
|
*/
|
|
export function platformCheck(parent?: string) {
|
|
if (__DEV__) {
|
|
return new Proxy(
|
|
{},
|
|
{
|
|
get(_, prop) {
|
|
const propPretty = [parent, prop.toString()].join('.');
|
|
const hintPlatformCheck = global.isAndroid ? 'global.isIOS' : 'global.isAndroid';
|
|
|
|
// prettier-ignore
|
|
const errorMsg = [
|
|
`Trying to access "${propPretty}" without checking platform first.`,
|
|
`Hint: Use "${hintPlatformCheck}" to check platform before accessing "${propPretty}".`
|
|
].join('\n');
|
|
|
|
throw new Error(errorMsg);
|
|
},
|
|
}
|
|
);
|
|
}
|
|
|
|
return undefined;
|
|
}
|