GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — For editing experience, use source instead of .d.ts files from project references by sheetalkamat · Pull Request #32028 · microsoft/TypeScript

Conversation

@sheetalkamat

@sheetalkamat Sheetal Nandi (sheetalkamat) commented Jun 21, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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:

  • errors in the project -> Skip type checking (so error reporting) on sources of project reference redirect
  • compile on save -> do not emit files that are sources of project reference redirects,
  • compile on save -> add error if compileOnSave is enabled but referenced projects don't have compileOnSave - Created Handle CompileOnSave on projects that contain project references. #33270
  • Fixing tests
  • Implications on memory and what can be done for exploding project size -> Add compile option to disable including sources of project reference redirect - option is disableSourceOfProjectReferenceRedirect

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

SlurpTheo, augbog, ryall, ASDFGerte, and Zzzen reacted with thumbs up emoji bajtos, calebmer, agentcooper, lemonmade, minheq, earthlyreason, vilicvane, zoltanbedi, sebald, ixcviw7bw, and 9 more reacted with heart emoji
All reactions
  • 👍 5 reactions
  • ❤️ 19 reactions
Sheetal Nandi (sheetalkamat) added 2 commits June 21, 2019 09:07
@sheetalkamat
Add test to verify when source changes
d0282b7
@sheetalkamat
Use source files instead of .d.ts files from project references
0adab89
@sheetalkamat Sheetal Nandi (sheetalkamat) changed the title [WIP] References prototype source file [WIP] For editing experience, use source instead of .d.ts files from project references Jun 21, 2019
sheetalkamat
Sheetal Nandi (sheetalkamat) commented Jun 21, 2019
View reviewed changes
Comment thread src/server/project.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Sheetal Nandi (sheetalkamat) added 2 commits June 21, 2019 13:54
@sheetalkamat
Log the config of the project
c97be16
@sheetalkamat
Check only for .d.ts files
746b01e
@microsoft Microsoft (microsoft) deleted a comment from TypeScript Bot (typescript-bot) Jun 21, 2019
@microsoft Microsoft (microsoft) deleted a comment from TypeScript Bot (typescript-bot) Jun 21, 2019
@microsoft Microsoft (microsoft) deleted a comment from TypeScript Bot (typescript-bot) Jun 21, 2019
@microsoft Microsoft (microsoft) deleted a comment from TypeScript Bot (typescript-bot) Jun 21, 2019
Sheetal Nandi (sheetalkamat) added 2 commits June 21, 2019 14:24
@sheetalkamat
Check for language serivice enabled when including source files
ecf8751
@sheetalkamat
Fix tests
1810288
@ajafff

Klaus Meinhardt (ajafff) commented Jun 23, 2019

Copy link
Copy Markdown
Contributor

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:

  • Does this work with different compilerOptions in the referenced project (strictNullChecks, noImplicitAny, moduleResolution, paths, ...)?
  • Will autocomplete show //@internal symbols from the referenced project because they are not yet stripped out?
  • Assignability might be different from batch compilation when types of private properties are removed.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sheetalkamat Sheetal Nandi (sheetalkamat) mentioned this pull request Jun 25, 2019
[WIP] Open bigger set of configured projects when opening composite project for operations that operate over multiple projects like rename #28261
Closed
2 of 4 tasks
Sheetal Nandi (sheetalkamat) added 5 commits June 25, 2019 15:16
@sheetalkamat
Watch generated file if it doesnt exist when trying to translate it t…
f472868
…o to source generated position
@sheetalkamat
Add sourceOf project reference redirect to filesByName list for redir…
012ecda
…ect path so that module symbol is correctly resolved
@sheetalkamat
More tests
2f30add
@sheetalkamat
Create original project when location is in source of project referen…
da9260c
…ce redirect
@sheetalkamat
Fix more tests
75bd3cd
@sheetalkamat
Sheetal Nandi (sheetalkamat) changed the base branch from master to noDtsWhenNotUsingProjectReferences June 27, 2019 20:14
@microsoft Microsoft (microsoft) deleted a comment from TypeScript Bot (typescript-bot) Jun 27, 2019
@microsoft Microsoft (microsoft) deleted a comment from TypeScript Bot (typescript-bot) Jun 27, 2019
@AnyhowStep

AnyhowStep commented Jun 27, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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 .d.ts files.

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,
#29511 (comment)


If whatever I just said isn't relevant at all.. Just ignore me =x

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sheetalkamat
Sheetal Nandi (sheetalkamat) changed the base branch from noDtsWhenNotUsingProjectReferences to master June 27, 2019 21:02
Sheetal Nandi (sheetalkamat) added 6 commits June 28, 2019 12:42
@sheetalkamat
Merge branch 'master' into referencesPrototypeSourceFile
96a8c86
@sheetalkamat
Verify the scenarios when d.ts directory of dependency doesnt exist
f72af3b
@sheetalkamat
Merge branch 'master' into referencesPrototypeSourceFile
4d13f53
@sheetalkamat
Fix incorrectly exported type
f9e4b91
@sheetalkamat
Refactoring
f7ea0ba
@sheetalkamat
Refactor tests so its easy to edit and reason about them
b5737fc
@Andarist

Mateusz Burzyński (Andarist) commented Nov 28, 2019

Copy link
Copy Markdown
Contributor

So this still requires generating .d.ts files on the disk?

colinhacks reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@NoelAbrahams

Noel Abrahams (NoelAbrahams) commented Dec 9, 2019

Copy link
Copy Markdown

Sheetal Nandi (@sheetalkamat) I've opened an issue to report a failure in error underlining:
#35587

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@VincentBailly

VincentBailly commented Feb 7, 2020

Copy link
Copy Markdown
Member

Sheetal Nandi (@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sheetalkamat Sheetal Nandi (sheetalkamat) mentioned this pull request Feb 10, 2020
Intellisense does not pickup Typescript 3 references #26913
Closed
@bajtos Miroslav Bajtoš (bajtos) mentioned this pull request Apr 20, 2020
feat: enable TypeScript project references loopbackio/loopback-next#5155
Merged
3 of 7 tasks
@elitvinchuk Egor Litvinchuk (elitvinchuk) mentioned this pull request Jun 5, 2020
Import autocompletion with project references and yarn workspaces doesn't work #38955
Closed
@valerybugakov Valery Bugakov (valerybugakov) mentioned this pull request Sep 8, 2020
Project-references type check with --noEmit fails without built files #40431
Closed
@trusktr

Joe Pea (trusktr) commented Sep 21, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Instead of using .d.ts files from project references, use their original source files to give better editing experience.

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!).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trusktr Joe Pea (trusktr) mentioned this pull request Sep 21, 2020
Support for all type features in declaration files. #35822
Open
5 tasks done
@NoelAbrahams

Noel Abrahams (NoelAbrahams) commented Sep 22, 2020

Copy link
Copy Markdown

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.

Joe Pea (@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 .d.ts files at all.

We have found this implementation a huge help.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gluxon Brandon Cheng (gluxon) mentioned this pull request Oct 6, 2020
Reuse Module Resolutions Within Project References During Initial Program Creation #40964
Closed
@trusktr Joe Pea (trusktr) mentioned this pull request Nov 3, 2020
"types" field in package.json pointing to a .ts file in node_modules results in the file being compiled and type checked #35744
Open
@trusktr

Joe Pea (trusktr) commented Nov 3, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Noel Abrahams (@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trusktr

Joe Pea (trusktr) commented Nov 3, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Sheetal Nandi (@sheetalkamat) Wait a second, based on #40431 (comment) by Ryan Cavanaugh (@RyanCavanaugh), this PR compiles to .d.ts files in memory, then relies on those virtual declaration files?

If so, I think that can be the solution for #35744 if it isn't already.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sheetalkamat

Sheetal Nandi (sheetalkamat) commented Nov 3, 2020

Copy link
Copy Markdown
Member Author

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.

Bnaya reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dko-slapdash

This comment has been minimized.

Sign in to view
@andrewbranch

Andrew Branch (andrewbranch) commented Nov 24, 2020

Copy link
Copy Markdown
Member

Dimitri (@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.

HolgerJeromin reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@shrinktofit

stf (shrinktofit) commented Dec 12, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Do we still need composite: true to be set?

cadesalaberry, anbraten, miluoshi, ryall, and Treycos reacted with eyes emoji
All reactions
  • 👀 5 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markboyall Mark Boyall (markboyall) mentioned this pull request Mar 25, 2021
Intellisense cannot find referenced projects in VS, even after successful build #43375
Open
@Jack-Works

Jack Works (Jack-Works) commented Nov 8, 2021

Copy link
Copy Markdown
Contributor

Hi! I have a question about monorepo+project reference settings.

The example I have the folder structure below:

/packages/main
    - tsconfig.json
    - app.ts
    - node_modules/@project/utils (symlink to /packages/utils)
/packages/utils
    - tsconfig.json

These two projects are configured to use project references. main/tsconfig.json references ../utils.

My question is: Do I need to add "paths": { "@project/utils": "../utils" } in main/tsconfig.json to speed-up the compilation?

I worry about if TypeScript does not resolve @project/utils to its real position, it will treat node_modules/@project/utils as a normal .d.ts reference instead of another TS project and lose the benefit of incremental compiling. If TypeScript knows @project/utils is a symlink and gets its real position and found it is a project reference, it would be great.

Can Sheetal Nandi (@sheetalkamat) help? Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andrewbranch

Andrew Branch (andrewbranch) commented Nov 8, 2021

Copy link
Copy Markdown
Member

As long as you don’t have preserveSymlinks on, we should realize the path through node_modules is a symlink and the paths entry is not necessary. You do need references though. My convention is to put the relative path to the realpath in references.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Jack-Works

Jack Works (Jack-Works) commented Nov 9, 2021

Copy link
Copy Markdown
Contributor

As long as you don’t have preserveSymlinks on, we should realize the path through node_modules is a symlink and the paths entry is not necessary. You do need references though. My convention is to put the relative path to the realpath in references.

Thanks, but I still have a question, what about the following case?

/packages/main
    - tsconfig.json ("reference": [{ "path": "../utils/src" }])
    - app.ts
    - node_modules/@project/utils (symlink to /packages/utils)
/packages/utils
    - package.json ("main": "./dist", "types": "./dist")
    - src/tsconfig.json ("outDir": "../dist")

In this case, even if TypeScript can resolve node_modules/@project/utils to it's real position /packages/utils, there is no /packages/utils/tsconfig.json. If it goes through the package.json, it will find the type definition at /packages/utils/dist so it still compiles. But can TypeScript know /packages/utils/dist actually generated by project /packages/utils/src/tsconfig.json and keep that track?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andrewbranch

Andrew Branch (andrewbranch) commented Nov 9, 2021

Copy link
Copy Markdown
Member

Yes, I think that should work. The reference to /packages/utils/src/tsconfig.json gets analyzed first so there’s up-front knowledge of its input and output files. Is something not working as you expect or is this just hypothetical?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Jack-Works

Jack Works (Jack-Works) commented Nov 9, 2021

Copy link
Copy Markdown
Contributor

Yes, I think that should work. The reference to /packages/utils/src/tsconfig.json gets analyzed first so there’s up-front knowledge of its input and output files. Is something not working as you expect or is this just hypothetical?

It's just hypothetical. tsc -b runs slow so I'm trying to figure out why. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sandersn Nathan Shively-Sanders (sandersn) mentioned this pull request Nov 13, 2021
tsc -b incorrectly succeeds when there is a problem introduced by a transitive dependency #46153
Closed
@Hujianboo Hujianboo (Hujianboo) mentioned this pull request Jul 16, 2022
why can the vscode recognize the source path when the exports field in not include the src wixplosives/sample-monorepo#501
Closed
@FunkMonkey FunkMonkey mentioned this pull request Jul 24, 2023
TSServer forgets module type declarations, when using project references #55135
Closed
@hanna-cirilla Hanna Dennhardt (hanna-cirilla) mentioned this pull request Jan 17, 2024
Add support for typescript "Build-Free Editing with Project References" sveltejs/language-tools#2262
Closed
@harsssh Kentaro Mizuki (harsssh) mentioned this pull request Nov 21, 2024
Hono のクライアントの補完を高速化 smatsuodev/scrap#19
Merged
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) DanielRosenwasser left review comments
@andrewbranch Andrew Branch (andrewbranch) andrewbranch approved these changes
@sandersn Nathan Shively-Sanders (sandersn) Awaiting requested review from sandersn
@orta Orta Therox (orta) Awaiting requested review from orta
@rbuckton Ron Buckton (rbuckton) Awaiting requested review from rbuckton
@RyanCavanaugh Ryan Cavanaugh (RyanCavanaugh) Awaiting requested review from RyanCavanaugh
@weswigham Wesley Wigham (weswigham) Awaiting requested review from weswigham

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@sheetalkamat Sheetal Nandi (sheetalkamat)

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

20 participants

@sheetalkamat @ajafff @AnyhowStep @typescript-bot @weswigham @MLoughry @OliverJAsh @Andarist @kiprasmel @vilicvane @kenotron @jquense @osdiab @NoelAbrahams @VincentBailly @trusktr @dko-slapdash @andrewbranch @shrinktofit @Jack-Works
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.