diff --git a/packages/core/src/Platform/detection/Angular.ts b/packages/core/src/Platform/detection/Angular.ts index ef70551265a..b0bd50b4bd4 100644 --- a/packages/core/src/Platform/detection/Angular.ts +++ b/packages/core/src/Platform/detection/Angular.ts @@ -1,12 +1,19 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { processExists, windowExists } from './helpers'; +import { documentExists, processExists, windowExists } from './helpers'; // Tested with @angular/core 16.0.0 export function angularWebDetect() { - return windowExists() && typeof window['ng'] !== 'undefined'; + const angularVersionSetInDocument = Boolean( + documentExists() && document.querySelector('[ng-version]') + ); + const angularContentSetInWindow = Boolean( + // @ts-ignore + windowExists() && typeof window['ng'] !== 'undefined' + ); + return angularVersionSetInDocument || angularContentSetInWindow; } export function angularSSRDetect() { diff --git a/packages/core/src/Platform/detection/Expo.ts b/packages/core/src/Platform/detection/Expo.ts index f3cc6f894c2..3294cf72b86 100644 --- a/packages/core/src/Platform/detection/Expo.ts +++ b/packages/core/src/Platform/detection/Expo.ts @@ -6,5 +6,6 @@ import { globalExists } from './helpers'; // Tested with expo 48 / react-native 0.71.3 export function expoDetect() { + // @ts-ignore return globalExists() && typeof global['expo'] !== 'undefined'; } diff --git a/packages/core/src/Platform/detection/Next.ts b/packages/core/src/Platform/detection/Next.ts index db96e46fa1f..45cdb08d356 100644 --- a/packages/core/src/Platform/detection/Next.ts +++ b/packages/core/src/Platform/detection/Next.ts @@ -6,6 +6,7 @@ import { globalExists, keyPrefixMatch, windowExists } from './helpers'; // Tested with next 13.4 / react 18.2 export function nextWebDetect() { + // @ts-ignore return windowExists() && window['next'] && typeof window['next'] === 'object'; } diff --git a/packages/core/src/Platform/detection/Nuxt.ts b/packages/core/src/Platform/detection/Nuxt.ts index 6264df94576..2341c9ac418 100644 --- a/packages/core/src/Platform/detection/Nuxt.ts +++ b/packages/core/src/Platform/detection/Nuxt.ts @@ -8,10 +8,12 @@ import { globalExists, windowExists } from './helpers'; export function nuxtWebDetect() { return ( windowExists() && + // @ts-ignore (window['__NUXT__'] !== undefined || window['$nuxt'] !== undefined) ); } export function nuxtSSRDetect() { + // @ts-ignore return globalExists() && typeof global['__NUXT_PATHS__'] !== 'undefined'; } diff --git a/packages/core/src/Platform/detection/React.ts b/packages/core/src/Platform/detection/React.ts index 76770a43b94..d0245b5d0d6 100644 --- a/packages/core/src/Platform/detection/React.ts +++ b/packages/core/src/Platform/detection/React.ts @@ -6,11 +6,11 @@ import { documentExists, processExists, windowExists } from './helpers'; // Tested with react 18.2 - built using Vite export function reactWebDetect() { - const elementKeyPrefixedWithReact = k => { - return k.startsWith('_react') || k.startsWith('__react'); + const elementKeyPrefixedWithReact = key => { + return key.startsWith('_react') || key.startsWith('__react'); }; - const elementIsReactEnabled = e => { - return Object.keys(e).find(elementKeyPrefixedWithReact); + const elementIsReactEnabled = element => { + return Object.keys(element).find(elementKeyPrefixedWithReact); }; const allElementsWithId = () => Array.from(document.querySelectorAll('[id]')); diff --git a/packages/core/src/Platform/detection/helpers.ts b/packages/core/src/Platform/detection/helpers.ts index 9b94e9f6f5d..9f4bcd46a85 100644 --- a/packages/core/src/Platform/detection/helpers.ts +++ b/packages/core/src/Platform/detection/helpers.ts @@ -21,6 +21,6 @@ export const processExists = () => { return typeof process !== 'undefined'; }; -export const keyPrefixMatch = (object, prefix) => { +export const keyPrefixMatch = (object: object, prefix: string) => { return !!Object.keys(object).find(key => key.startsWith(prefix)); };