Skip to content

Commit

Permalink
fix: Minor typing issues for web sandbox (open-telemetry#3660)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSNev committed Mar 8, 2023
1 parent 48ecf22 commit ecb5ebe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export class FetchInstrumentation extends InstrumentationBase<
): Promise<Response> {
const self = this;
const url = web.parseUrl(
args[0] instanceof Request ? args[0].url : args[0]
args[0] instanceof Request ? args[0].url : String(args[0])
).href;

const options = args[0] instanceof Request ? args[0] : args[1] || {};
Expand Down
9 changes: 4 additions & 5 deletions packages/opentelemetry-context-zone-peer-dep/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
* limitations under the License.
*/

import { TargetWithEvents } from './types';

/**
* check if an object has addEventListener and removeEventListener functions then it will return true
* @param obj
* check if an object has addEventListener and removeEventListener functions then it will return true.
* Generally only called with a `TargetWithEvents` but may be called with an unknown / any.
* @param obj - The object to check.
*/
export function isListenerObject(obj: TargetWithEvents = {}): boolean {
export function isListenerObject(obj: any = {}): boolean {
return (
typeof obj.addEventListener === 'function' &&
typeof obj.removeEventListener === 'function'
Expand Down
5 changes: 4 additions & 1 deletion packages/opentelemetry-sdk-trace-web/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ function getUrlNormalizingAnchor(): HTMLAnchorElement {
* @param key
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function hasKey<O>(obj: O, key: keyof any): key is keyof O {
export function hasKey<O extends object>(
obj: O,
key: keyof any
): key is keyof O {
return key in obj;
}

Expand Down

0 comments on commit ecb5ebe

Please sign in to comment.