-
Notifications
You must be signed in to change notification settings - Fork 834
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
@opentelemetry/otlp-exporter-base
TS error in Node environment
#3580
Comments
I'm surprised this hasn't come up before. I don't think there is any way for us to bundle the types for the browser-specific files. I'm wondering how our compiler passes since I don't see the "DOM" lib included in any tsconfig. Am I missing some obvious configuration that allows us to compile? Where is it referencing those types from? |
We've had this issue in Jest as well. If some dependency, somewhere in the monorepo, has a |
How did you solve it? I'm shocked this hasn't come up before since there are browser types in other places as well |
In our case it was |
@jschuttler no real update. I tried a bit today to strip the One possible solution would be to publish our own package that exports a typed global object and use it like |
I have this problem and found microsoft/TypeScript#36146 (comment) So I've added
as BlobPropertyBag was my problem. I guess that's in the same vein as #3580 (comment) |
Hi, I've had a similar issue in a project and we came with a couple of ways to avoid this error
IMHO having sources for both platforms (node/browser) is very challenging regarding types. Sooner or later you will reference them and you'll get type errors in one platform or the other.
If if got it right TypeScript v4.5 allows to specify the types explicitly as a dependency https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#supporting-lib-from-node_modules. This may help us to avoid this issue since types will be installed and pinned to a version. The possible drawback is that we may land in another type of issues like the one we had with express open-telemetry/opentelemetry-js-contrib#1787 Also we cannot forget that the problem can happen both ways. A project for web platform that compilations fails because of missing node types and then we will also try to strip node types from the sources.
would that package then contain a mix of browser and node types? We can think for now of adding these types into the package itself. The type I'm wondering if node/browser code needs to be in the same package. I guess this was already discussed so it would be good to have a like to the discussion if there is one. Sorry, I think I'm adding more questions instead contributing to a solution. |
See: open-telemetry/opentelemetry-js/issues/3580#issuecomment-1701157270
See: open-telemetry/opentelemetry-js/issues/3580#issuecomment-1701157270
See: open-telemetry/opentelemetry-js/issues/3580#issuecomment-1701157270
See: open-telemetry/opentelemetry-js/issues/3580#issuecomment-1701157270
See: open-telemetry/opentelemetry-js/issues/3580#issuecomment-1701157270
See: open-telemetry/opentelemetry-js/issues/3580#issuecomment-1701157270
What happened?
Steps to Reproduce
Import
@opentelemetry/exporter-trace-otlp-http@0.35.1
withoutdom
types availableExpected Result
No TypeScript error
Actual Result
Additional Details
Regressed in #3208
OpenTelemetry Setup Code
package.json
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: