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

Broken (unrelated) ambient types in the user's node_modules can cause --emit-tsd builds to fail #22996

Closed
jedrichards opened this issue Nov 23, 2024 · 2 comments · Fixed by #23019
Labels
TypeScript TypeScript Generation

Comments

@jedrichards
Copy link

jedrichards commented Nov 23, 2024

The tsc invocation here seems sensitive to unrelated broken types present in the users node_modules/@types folder.

I believe TypeScript checks types in node_modules/@types, and it's not uncommon for these to be broken in some way (duplicate identifiers when multiple versions of the same package are present in a monorepo, 3rd party type incompatibilities and so on).

The issue is solved by passing the --skipLibCheck flag to tsc. Or alternatively, perhaps invoking tsc in some temporary cwd that is not the user's project, where we're not going to trigger random errors from npm dependencies.

@brendandahl brendandahl added the TypeScript TypeScript Generation label Nov 25, 2024
@brendandahl
Copy link
Collaborator

With --skipLibCheck are there any other issues that can come up from running tsc in the CWD?

@jedrichards
Copy link
Author

jedrichards commented Nov 26, 2024

@brendandahl From what I understand, --skipLibCheck is something you might want to turn on when you want to validate that everything is working also with respect to .d.ts types that might be coming in from dependencies (from node_modules/@types/...) that you want to be compatible with - for example, prior to publishing a TypeScript libray to npm or something.

So I think, it's sensible to toggle it off when we're just typechecking our own code, especially if that code is self-contained (i.e. it doesn't rely on any 3rd party ambient types itself).

With --skipLibCheck any broken types from node_modules that are actually referenced, are typed as any, but non-broken ones are still properly typed. But that may be a moot point anyway, since in this case, I do not think js_doc_file uses any 3rd party types?

It seems common practice to use the flag:

brendandahl added a commit to brendandahl/emscripten that referenced this issue Nov 26, 2024
brendandahl added a commit to brendandahl/emscripten that referenced this issue Nov 26, 2024
We don't need to validate other types when generating definitions since
they may be in bad state.

Fixes emscripten-core#22996
brendandahl added a commit that referenced this issue Dec 4, 2024
…#23019)

We don't need to validate other types when generating definitions since
they may be in bad state.

Fixes #22996
hedwigz pushed a commit to hedwigz/emscripten that referenced this issue Dec 18, 2024
…emscripten-core#23019)

We don't need to validate other types when generating definitions since
they may be in bad state.

Fixes emscripten-core#22996
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TypeScript TypeScript Generation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants