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

Skip .d.ts checks from referenced projects #43140

Closed
5 tasks done
vthib opened this issue Mar 8, 2021 · 4 comments
Closed
5 tasks done

Skip .d.ts checks from referenced projects #43140

vthib opened this issue Mar 8, 2021 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@vthib
Copy link

vthib commented Mar 8, 2021

Suggestion

From what i have seen, it appears that declaration files generated from a project are re-checked when compiling projects referencing it.

Here is an example:

tsconfig-a.json : include a.ts
tsconfig-b.json: include b.ts

when building tsconfig-b.json, we can see:

  • building project a => a.ts is type-checked
  • building project b => outDir/a.d.ts and b.ts is type-checked.

(I can provide a repository with this example if needed)

This is an issue because when using many projects to split a big codebase, those output files are re-checked again and again,
leading to a huge time loss.

This is evident when using the skipLibCheck. In our repository with about 900 typescript files and 15 projects:

  • without skipLibCheck: 3 minutes to run tsc -b
  • with skipLibCheck: 1 minute 15 seconds to run tsc -b

Unless i'm missing something, this shows clearly that declaration files from referenced projects are type-checked again and again, and it isn't just declaration files from node_modules which are skipped.

The issue with skipLibCheck is that it skips declaration files from the repository, and not just from node_modules or projects output directories.

Forgive me if i'm wrong, or if this has been talked about already, I have not found anything about this in my searches.

🔍 Search Terms

project references, skipLibCheck, declaration files

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

My suggestion is to skip checking declaration files when they come from a referenced project, as we already know it has been type checked.

📃 Motivating Example

This change would:

  • Improve the speed of building project references even more
  • Allow type-checking declaration files in the project without sacrificing build time
  • Fix a performance issue where a declaration file is type-checked X times (max being the number of projects) instead of once.

💻 Use Cases

Use-case is using project references to split a big codebase into chunks and improve build time, without being forced to use skipLibCheck.
I don't think there is any drawback to the change.
Workaround is using skipLibCheck, but it disables type-checking on declaration files that are inside a project.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Mar 8, 2021
@RyanCavanaugh
Copy link
Member

We've gotten the request to "Skip lib check, but don't skip my lib checks" before. Skipping referenced projects and node_modules while still checking local .d.ts files should be done concurrently with #30511.

@vthib
Copy link
Author

vthib commented Mar 8, 2021

Thank you for you quick answer.
I was talking about always skipping checks for declaration files produced by projects, even if skipLibCheck is not set, as i'm not sure i see a valid reason for not skipping them, and it does introduce a big time loss (which including type checks of node_modules does not introduce).
So imho this is not exactly the same as #30511 (which is about changing the behavior of skipLibCheck). I do see however the link between the two, and a solution for #30511 would indeed answer this ticket as well.
Just wanted to make sure this feature request was not misunderstood. If you tell me that it should be solved by fixing #30511 i will close this ticket (or you can close it directly).
Thanks for your time and your work on Typescript!

@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Mar 8, 2021

Right. What I'm saying is, if we have any feature like this, it should apply equally to node_modules and upstream project reference outputs.

@vthib
Copy link
Author

vthib commented Mar 8, 2021

I understand. I'll close this and will follow the other ticket. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants