opentelemetry-js
opentelemetry-js copied to clipboard
Don't use lib dom during compilation
Currently tsconfig.json doesn't include a lib config. This results in automatically including dom - browser types (see https://www.typescriptlang.org/tsconfig#lib)
The only place where this is needed is for global this here
Should we aim to remove this to avoid that we use/rely on these types on other places?
Is there a way to only include the lib in a single file or folder? We could always manually declare types ourselves if needed.
I tried via /// <reference lib="dom" /> but it looks like it's available everywhere then. It even ends up in globalThis.js and globalThis.d.ts so it is even visible in consumers.
Maybe some background why I reported this. I found that removing lib dom results in following compile error in consoleLogger.ts:
This expression is not callable.
Each member of the union type '{ <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } | { <T>(this: new () => T, thisArg: T): void; <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void; }' has signatures, but none of those signatures are compatible with each other.
Reason is the Console is augmented in lib dom with by far more relaxed definitions.
Only movement I've seen in this space is https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1207, which doesn't have much movement