Skip to content

Commit ecb5ebe

Browse files
authored
fix: Minor typing issues for web sandbox (#3660)
1 parent 48ecf22 commit ecb5ebe

File tree

3 files changed

+9
-7
lines changed
  • experimental/packages/opentelemetry-instrumentation-fetch/src
  • packages
    • opentelemetry-context-zone-peer-dep/src
    • opentelemetry-sdk-trace-web/src

3 files changed

+9
-7
lines changed

experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ export class FetchInstrumentation extends InstrumentationBase<
301301
): Promise<Response> {
302302
const self = this;
303303
const url = web.parseUrl(
304-
args[0] instanceof Request ? args[0].url : args[0]
304+
args[0] instanceof Request ? args[0].url : String(args[0])
305305
).href;
306306

307307
const options = args[0] instanceof Request ? args[0] : args[1] || {};

packages/opentelemetry-context-zone-peer-dep/src/util.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { TargetWithEvents } from './types';
18-
1917
/**
20-
* check if an object has addEventListener and removeEventListener functions then it will return true
21-
* @param obj
18+
* check if an object has addEventListener and removeEventListener functions then it will return true.
19+
* Generally only called with a `TargetWithEvents` but may be called with an unknown / any.
20+
* @param obj - The object to check.
2221
*/
23-
export function isListenerObject(obj: TargetWithEvents = {}): boolean {
22+
export function isListenerObject(obj: any = {}): boolean {
2423
return (
2524
typeof obj.addEventListener === 'function' &&
2625
typeof obj.removeEventListener === 'function'

packages/opentelemetry-sdk-trace-web/src/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ function getUrlNormalizingAnchor(): HTMLAnchorElement {
4444
* @param key
4545
*/
4646
// eslint-disable-next-line @typescript-eslint/no-explicit-any
47-
export function hasKey<O>(obj: O, key: keyof any): key is keyof O {
47+
export function hasKey<O extends object>(
48+
obj: O,
49+
key: keyof any
50+
): key is keyof O {
4851
return key in obj;
4952
}
5053

0 commit comments

Comments
 (0)