From 9ac7090d676dc2a6e5688cbe2b0ec001e2a23088 Mon Sep 17 00:00:00 2001 From: Ben White Date: Mon, 9 Oct 2023 17:18:18 +0200 Subject: [PATCH] fix: Type issue with RN (#119) --- .github/workflows/ci.yml | 15 +++++++++++++++ posthog-core/src/index.ts | 2 ++ posthog-react-native/CHANGELOG.md | 4 ++++ posthog-react-native/package.json | 2 +- posthog-react-native/src/posthog-rn.ts | 2 +- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48ce3cf9..3552e529 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,3 +34,18 @@ jobs: - run: yarn compile - run: yarn lint - run: yarn prettier:check + + type-check: + timeout-minutes: 3 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: 16 + - run: | + yarn + cd examples/example-expo + yarn global add yalc + yarn + yarn tsc diff --git a/posthog-core/src/index.ts b/posthog-core/src/index.ts index a0026406..0fe39c51 100644 --- a/posthog-core/src/index.ts +++ b/posthog-core/src/index.ts @@ -36,6 +36,8 @@ class PostHogFetchNetworkError extends Error { name = 'PostHogFetchNetworkError' constructor(public error: unknown) { + // TRICKY: "cause" is a newer property but is just ignored otherwise. Cast to any to ignore the type issue. + // @ts-ignore super('Network error while fetching PostHog', error instanceof Error ? { cause: error } : {}) } } diff --git a/posthog-react-native/CHANGELOG.md b/posthog-react-native/CHANGELOG.md index 77ef31ef..7434a86f 100644 --- a/posthog-react-native/CHANGELOG.md +++ b/posthog-react-native/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.8.1 - 2023-10-09 + +1. Fixes a type generation issue + # 2.8.0 - 2023-10-06 1. Added new `const [flag, payload] = useFeatureFlagWithPayload('my-flag-name')` hook that returns the flag result and it's payload if it has one. diff --git a/posthog-react-native/package.json b/posthog-react-native/package.json index 9d9647b5..11f1710a 100644 --- a/posthog-react-native/package.json +++ b/posthog-react-native/package.json @@ -1,6 +1,6 @@ { "name": "posthog-react-native", - "version": "2.8.0", + "version": "2.8.1", "main": "lib/posthog-react-native/index.js", "files": [ "lib/" diff --git a/posthog-react-native/src/posthog-rn.ts b/posthog-react-native/src/posthog-rn.ts index 735348ca..87b5668a 100644 --- a/posthog-react-native/src/posthog-rn.ts +++ b/posthog-react-native/src/posthog-rn.ts @@ -6,7 +6,7 @@ import { PostHogFetchOptions, PostHogFetchResponse, PostHogPersistedProperty, -} from '../../posthog-core' +} from '../../posthog-core/src' import { PostHogMemoryStorage } from '../../posthog-core/src/storage-memory' import { getLegacyValues } from './legacy' import { SemiAsyncStorage } from './storage'