Closed aacanakin closed 2 years ago
Hey! Could you share a reproducible code example of the error? That would make it much easier to solve the issue.
Hi. I was using with nestjs but it doesn't work without it either. The following steps will give the error with "typescript": "^3.6.3";
Use this tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2017",
"sourceMap": true,
"inlineSources": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true
},
"exclude": ["node_modules", "dist"]
}
Install & run ts-node
Run
import PostHog from 'posthog-node'
const client = new PostHog('test-key')
That's it. You'll see the error
It also doesn't work with the "typescript": "4.2.3"
as well. See https://codesandbox.io/s/icy-monad-fz8ke?file=/src/index.ts
The entire type definitions file seem off, for example groupIdentify
should have a callback
as the last param. Also the default export should probably be top level and not inside a declaration.
How was this generated? Can we generate a new index.d.ts?
Had the same error. Posthog instance during setup told me to import
import PostHog from 'posthog-node'
but docs say it's
import { PostHog } from 'posthog-node'
what also seems to work for me :-)
Hey @matthiasnannt , could you point me to where you were told to do the former?
We recently updated docs to say the latter, will update the remaining place as well 😅 . The type definitions were sorted out in version 2.0
@neilkakkar I installed posthog on my server using the instructions for Hobby. It seems because it was pulling the latest release ( 1.38.1 ) that in this version the text wasn't already changed. But gladly you changed it yesterday so it will be fine in the next release 💪
Perfect, thanks!
I'm using
"typescript": "^3.6.3"
with the followingtsconfig.json
When I try to create a new instance of
PostHog
it gives the following error;When I try to log
PostHog
, it isundefined