Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing return types and promises not awaited #961

Closed
thehme opened this issue Oct 2, 2023 · 5 comments
Closed

Missing return types and promises not awaited #961

thehme opened this issue Oct 2, 2023 · 5 comments

Comments

@thehme
Copy link

thehme commented Oct 2, 2023

I have added this package to my ts project and seeing these errors on compile:

node_modules/@segment/analytics-node/src/app/analytics-node.ts(97,11): error TS7010: '_dispatch', which lacks return-type annotation, implicitly has an 'any' return type.
node_modules/@segment/analytics-node/src/lib/abort.ts(63,40): error TS7011: Function expression, which lacks return-type annotation, implicitly has an 'any[] | readonly [AbortSignal | AbortSignal, Timeout]' return type.
node_modules/@segment/analytics-node/src/plugins/segmentio/publisher.ts(178,39): error TS2339: Property 'message' does not exist on type '{ success: true; } | { success: false; message: string; }'.
  Property 'message' does not exist on type '{ success: true; }'.

I can try to fix these errors, which lead to errors about promises not being awaited in packages/node/src/app/analytics-node.ts. I think I have fixed these errors too, so would like to post a PR and get any feedback necessary. This is blocking us from using the package to start tracking server side events.

@silesky
Copy link
Contributor

silesky commented Oct 2, 2023

Thanks @thehme for taking out an issue.

These errors do not show up for us per our CI, we are using TS 4.x. I assume you are using a more recent version of Typescript.

Can you set "skipLibCheck: true" in your tsconfig?

While we want to make things as compat as possible, being forwards compatible with all versions of typescript is not always possible, and it's not a goal of this lib.

@thehme
Copy link
Author

thehme commented Oct 3, 2023

@silesky we are using TS 4.8.4. Can you confirm up to what version you expect the package to work?

Atm I am stuck with the test suite failing because after awaiting the promises in packages/node/src/app/analytics-node.ts, a couple tests are failing.

As for using skipLibCheck: true, I tried this before and still got the same errors.

EDIT: I posted a PR for this fix at #963

@silesky
Copy link
Contributor

silesky commented Oct 3, 2023

Hey @thehme,

As for using skipLibCheck: true, I tried this before and still got the same errors.

Hmmm... that shouldn't be the case -- getting any build errors like this from node_modules is a sign that something is up with your environment. Can you put a sample repo on github?

@thehme
Copy link
Author

thehme commented Oct 4, 2023

I am working on a sample repo.

@thehme
Copy link
Author

thehme commented Oct 5, 2023

@silesky thanks for your advice through this issue. I worked on setting up the sample repo and found the issue through that process.

My IDE (VS Code v1.82.2) imported types as follows in the non-working project:

import {
  IdentifyParams,
  PageParams,
  TrackParams
} from "@segment/analytics-node/src/app/types";

When I created a clean repository, the types were imported differently:

import {
  IdentifyParams,
  PageParams,
  TrackParams
} from "@segment/analytics-node";

Without the sub-directories, the compilation errors went away. The errors were due to how the types were being imported.

@thehme thehme closed this as completed Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants