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

Don't use lib dom during compilation #3257

Open
Flarna opened this issue Feb 24, 2021 · 3 comments
Open

Don't use lib dom during compilation #3257

Flarna opened this issue Feb 24, 2021 · 3 comments
Labels
api:metrics Issues and PRs related to the Metrics API api:traces Issues and PRs related to the Traces API

Comments

@Flarna
Copy link
Member

Flarna commented Feb 24, 2021

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?

@dyladan
Copy link
Member

dyladan commented Apr 9, 2021

Is there a way to only include the lib in a single file or folder? We could always manually declare types ourselves if needed.

@Flarna
Copy link
Member Author

Flarna commented Apr 9, 2021

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.

@legendecas legendecas pinned this issue Sep 15, 2022
@legendecas legendecas unpinned this issue Sep 15, 2022
@legendecas legendecas transferred this issue from open-telemetry/opentelemetry-js-api Sep 15, 2022
@legendecas legendecas added api:traces Issues and PRs related to the Traces API api:metrics Issues and PRs related to the Metrics API labels Sep 15, 2022
@SimenB
Copy link
Contributor

SimenB commented May 15, 2023

Only movement I've seen in this space is microsoft/TypeScript-DOM-lib-generator#1207, which doesn't have much movement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api:metrics Issues and PRs related to the Metrics API api:traces Issues and PRs related to the Traces API
Projects
None yet
Development

No branches or pull requests

4 participants