-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: ignore missing @opentelemetry/api (#14774) #14848
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: c83f9f3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: Ben McCann <[email protected]>
benmccann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems okay to me, but we should probably have someone more knowledgeable with TypeScript weigh in
|
Given that |
I'm not sure if that will work or if that did anything. Note that you'll have to test against the types found in |
|
Thanks for the tip! I've gone ahead and gotten a solution that results in the error being gone in a local project. |
| declare module '@opentelemetry/api' { | ||
| export interface Span {} | ||
|
|
||
| export interface Tracer {} | ||
|
|
||
| export interface SpanContext {} | ||
|
|
||
| export interface PropagationAPI {} | ||
|
|
||
| export interface ContextAPI {} | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried this but I think it removes the autocomplete for users when they do have @opentelemetry/api installed since these types then override the actual package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a trade off. The alternative is that more users can't build at all unless they completely disable type-checking libraries. If there is a way to get autocomplete when it is installed without breaking dependents missing OTEL, I'm all for it.
I've created floating point airthmatic within the type system, yet this somehow is a harder problem...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should conditionally generate the stub by checking if @opentelemetry/api is installed 😆 otherwise, getting sveltejs/dts-buddy#110 merged would let us use // @ts-ignore even if it's frowned upon in that thread
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that being able to use @ts-ignore would be a better and easier solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@teemingc do you have any plans to merge the dts-buddy PR soon? If not I'd like to get this PR merged since it would fix the bug. We could look into using ts-ignore after your PR is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd need another maintainer to approve the dts-buddy PR to merge it. Even then, it seems like all the tests are failing after I've merged the main branch. I'll need to take a look at those. cc: @Rich-Harris
EDIT: we can't merge this PR as is because the stubs here will break the TypeScript autocomplete for users who do have otel installed
This PR ignores errors when
@opentelemetry/apiis not installed since it is an optional dependency. Fixes #14774.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits