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

refactor(resources): fix eslint warning #5383

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

chancancode
Copy link
Contributor

Which problem is this PR solving?

Fix the following eslint warning in the resources package:

/home/runner/work/opentelemetry-js/opentelemetry-js/packages/opentelemetry-resources/src/utils.ts
  17:39  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

Ref #5365

Short description of the changes

Use unknown instead.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • eslint

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

```
/home/runner/work/opentelemetry-js/opentelemetry-js/packages/opentelemetry-resources/src/utils.ts
  17:39  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
```

Ref open-telemetry#5365
@chancancode chancancode requested a review from a team as a code owner January 27, 2025 23:09
val !== null && typeof val === 'object' && typeof val.then === 'function'
val !== null &&
typeof val === 'object' &&
typeof (val as Partial<PromiseLike<R>>).then === 'function'
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding 'then' in val to the existing chain would also work (instead of doing the cast), and sometimes I prefer that for readability. However that does impose a tiny bit of additional runtime cost so I avoided it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@david-luna resolved

For context: #5350 landed a similar fix so this PR isn't strictly necessary anymore, if the only goal is to get rid of the any (which #5350 did). This is slightly more precise and matches the intention of the code better.

@chancancode chancancode mentioned this pull request Jan 27, 2025
25 tasks
Copy link

codecov bot commented Jan 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.79%. Comparing base (39e9a09) to head (2edab6f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5383   +/-   ##
=======================================
  Coverage   94.79%   94.79%           
=======================================
  Files         310      310           
  Lines        7969     7969           
  Branches     1679     1679           
=======================================
  Hits         7554     7554           
  Misses        415      415           
Files with missing lines Coverage Δ
packages/opentelemetry-resources/src/utils.ts 85.71% <100.00%> (ø)

Copy link
Contributor

@david-luna david-luna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chancancode could you please resolve the conflict? Thanks

@david-luna david-luna self-requested a review February 5, 2025 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants