(parent?: string)
| 2 | * @internal Util used for exporting opposing platform utils and warning the user if they are trying to access them. |
| 3 | */ |
| 4 | export function platformCheck(parent?: string) { |
| 5 | if (__DEV__) { |
| 6 | return new Proxy( |
| 7 | {}, |
| 8 | { |
| 9 | get(_, prop) { |
| 10 | const propPretty = [parent, prop.toString()].join('.'); |
| 11 | const hintPlatformCheck = __ANDROID__ ? '__IOS__' : '__ANDROID__'; |
| 12 | |
| 13 | // prettier-ignore |
| 14 | const errorMsg = [ |
| 15 | `Trying to access "${propPretty}" without checking platform first.`, |
| 16 | `Hint: Use "${hintPlatformCheck}" to check platform before accessing "${propPretty}".` |
| 17 | ].join('\n'); |
| 18 | |
| 19 | throw new Error(errorMsg); |
| 20 | }, |
| 21 | }, |
| 22 | ); |
| 23 | } |
| 24 | |
| 25 | return undefined; |
| 26 | } |
no outgoing calls
no test coverage detected