-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
For editing experience, use source instead of .d.ts files from project references #32028
Conversation
I'm pretty excited about this. Editing experience is the only thing stopping me from using project references. Here are some edge cases that might need to be handled:
|
…o to source generated position
…ect path so that module symbol is correctly resolved
I have a question. Is this a thing for composite projects? If so, I think it's possible for your editor to say that you've reached the max instantiation depth, but when building, it'll build fine. Especially if the editor is looking at source files and compiler is looking at The editor would have to "go deeper" to resolve types, while the compiler would not. It would also break my current workaround for avoiding the max instantiation depth, If whatever I just said isn't relevant at all.. Just ignore me =x |
@Andarist When creating program if file to be included in program is ".d.ts" from project reference output, we include its input file. We know the mapping because composite projects need to list all files in the program so we have list of input and outputfiles mapping. |
So this still requires generating |
@sheetalkamat I've opened an issue to report a failure in error underlining: This started happening after the switch to using source files as per this PR. I have captured some logs, although there is no 'Err' line as far as I can tell. But I the offending files are listed in the logs so that may help. Let me know where to mail them. |
@sheetalkamat , we have been depending on this feature for a few months now and all is very nice and fast, thanks again. It seems like we have forgotten to update the wiki about Project References, it says that is work is still work in progress and that we need to check in .d.ts files. |
I'm not sure that's a good idea, because types from source are different than types from declarations, and they are not compatible in various ways. See here for a non-exhaustive list of issues: #35822 Something that could happen is, a new user is happy-go-lucky writing code, and it all works perfectly (because the editor says so). Then later they go and try to publish their code as a library (with declaration files) and it all breaks. It's a very bad experience (believe me from experience!). |
@trusktr this is a perfectly good idea for the large number of companies writing in-house-only code. Ideally, we don't want to work with We have found this implementation a huge help. |
@NoelAbrahams I can see how that can be helpful if all sources are consumed directly (yay, class-factory mixins work in this case). Using source files directly may lead to other issues, f.e.: #35744. The downside of this is that if any dependencies were compiled with different settings than the consumer project, then they may fail to be compiled in the consumer project. In your case, it may be fine, as I assume all your in-house projects all use the exact same tsconfig configuration. It's just something people should be aware of, and unless those issues have been fixed, then in the general case the change of this PR isn't necessarily a final solution. |
@sheetalkamat Wait a second, based on #40431 (comment) by @RyanCavanaugh, this PR compiles to If so, I think that can be the solution for #35744 if it isn't already. |
As mentioned in PR description this PR includes source files from the referenced project instead of generated .d.ts file. We do not generate in memory d.ts files. |
This comment has been minimized.
This comment has been minimized.
@dko-slapdash you posted the same question on three different issues/PRs (here, #39267 (comment), #34677 (comment)) within the course of an hour, before anyone had a chance to respond. That makes it incredibly difficult for us, and for future users who might have similar questions, to keep track of the conversation. I’m going to mark these off-topic, except for the one here, to avoid confusion. |
Do we still need |
Hi! I have a question about monorepo+project reference settings. The example I have the folder structure below:
These two projects are configured to use project references. My question is: Do I need to add I worry about if TypeScript does not resolve Can @sheetalkamat help? Thanks! |
As long as you don’t have |
Thanks, but I still have a question, what about the following case?
In this case, even if TypeScript can resolve |
Yes, I think that should work. The reference to |
It's just hypothetical. |
Instead of using
.d.ts
files from project references, use their original source files to give better editing experience.I have played with this on our own compiler sources (eg. adding methods to public api of compiler and getting it reflected in services without having to build
.d.ts
file and also tried sample module scenario to see same behavior.I would like to get the feel of the experience before actually working on remaining to dos
Things yet to look into:
disableSourceOfProjectReferenceRedirect