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

ResponseLike in RpcRequest.ts uses DOM types #7356

Open
paulius-valiunas opened this issue Nov 13, 2024 · 0 comments
Open

ResponseLike in RpcRequest.ts uses DOM types #7356

paulius-valiunas opened this issue Nov 13, 2024 · 0 comments

Comments

@paulius-valiunas
Copy link
Contributor

As a result, I can't build a project that imports @itwin/core-common and has this in the tsconfig:

    "lib": ["ES2022"],
    "skipLibCheck": false,

The ResponseLike class has properties with types such as ResponseType, which are only available if "DOM" is included in the lib option in tsconfig. As per Typescript documentation, that option should be excluded in projects that don't run in a web browser. If skipLibCheck is enabled, the exported type simply won't be resolved correctly.

Since @itwin/core-common is supposed to be included both in web browsers and in Node.js apps, we should probably have some sort of eslint rule or config to avoid re-exporting those types. We could add "lib": ["ES2021"] to its tsconfig, but that would result in a lot of errors (30 errors in 6 files) and in most cases they're not part of the API so it's not as necessary to change anything. As a more viable solution, we could redefine some of these types locally instead of using the globally defined ones. In the long term, removing DOM types could still be beneficial as we could redefine global variables to be optional (| undefined) to have better type checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant