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 — Add assumeChangesOnlyAffectDirectDependencies as a option to skip checking and generating .d.ts files for files indirectly importing affected file by sheetalkamat · Pull Request #35711 · microsoft/TypeScript

Conversation

@sheetalkamat

@sheetalkamat Sheetal Nandi (sheetalkamat) commented Dec 16, 2019

Copy link
Copy Markdown
Member

Fixes #33329 by providing this flag to allow gulp-tsb like build

cc: Matt Bierner (@mjbvz)

Sorry, something went wrong.

Uh oh!

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

AntoineEsteve reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Sheetal Nandi (sheetalkamat) added 2 commits December 16, 2019 13:19
@sheetalkamat
Baselining tsc --watch output
d6b9d4a
@sheetalkamat
Add noIndirectImports as a option to skip checking and generating .d.…
6ae17e7
…ts files for files indirectly importing affected file

Fixes #33329
@sheetalkamat
Sheetal Nandi (sheetalkamat) requested review from Ryan Cavanaugh (RyanCavanaugh), Andrew Casey (amcasey), Andrew Branch (andrewbranch), Eli Barzilay (elibarzilay), Orta Therox (orta), Ron Buckton (rbuckton), Nathan Shively-Sanders (sandersn) and Wesley Wigham (weswigham) December 16, 2019 21:52
andrewbranch
Andrew Branch (andrewbranch) reviewed Dec 16, 2019
View reviewed changes
Comment thread src/compiler/commandLineParser.ts Resolved

Uh oh!

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

Comment thread src/compiler/diagnosticMessages.json Resolved

Uh oh!

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

@mjbvz

Matt Bierner (mjbvz) commented Dec 16, 2019

Copy link
Copy Markdown
Contributor

Sheetal Nandi (@sheetalkamat) Very nice. Just tested this using the test case from #33329 and confirmed that recompile time is now very similar to gulp-tsb

/cc Johannes Rieken (@jrieken)

jrieken and Bnaya reacted with laugh emoji jrieken and Bnaya reacted with hooray emoji jrieken and Bnaya reacted with rocket emoji
All reactions
  • 😄 2 reactions
  • 🎉 2 reactions
  • 🚀 2 reactions

Sorry, something went wrong.

Uh oh!

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

@sheetalkamat

Sheetal Nandi (sheetalkamat) commented Dec 18, 2019

Copy link
Copy Markdown
Member Author

Ryan Cavanaugh (@RyanCavanaugh) Daniel Rosenwasser (@DanielRosenwasser) Do you think the name of the flag is ok or otherwise please suggest something. Note that its not just check that gets disabled but also ".d.ts" emit of these indirectly importing files.

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 baselineTscWatch to master December 18, 2019 18:24
@sheetalkamat
Merge branch 'master' into noIndirectImports
1dc8544
@andrewbranch

Andrew Branch (andrewbranch) commented Dec 18, 2019

Copy link
Copy Markdown
Member

skipIndirectImportProcessing?

In an incremental build, skip type checking and .d.ts file generation for files indirectly importing changed files.

?

All reactions

Sorry, something went wrong.

Uh oh!

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

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Dec 18, 2019

Copy link
Copy Markdown
Member

assumeSemanticChangesOnlyImpactDirectDependencies

andrewbranch reacted with laugh emoji
All reactions
  • 😄 1 reaction

Sorry, something went wrong.

Uh oh!

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

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Dec 18, 2019

Copy link
Copy Markdown
Member

You left a laugh reaction, but I'm like half serious

All reactions

Sorry, something went wrong.

Uh oh!

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

@andrewbranch

Andrew Branch (andrewbranch) commented Dec 18, 2019

Copy link
Copy Markdown
Member

That’s perfect; I’m only half laughing 👍

DanielRosenwasser reacted with laugh emoji
All reactions
  • 😄 1 reaction

Sorry, something went wrong.

Uh oh!

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

@RyanCavanaugh

Ryan Cavanaugh (RyanCavanaugh) commented Dec 20, 2019

Copy link
Copy Markdown
Member
  • assumeSemanticChangesOnlyImpactDirectDependencies
  • skipIndirectImportProcessing
  • yolo
  • assumeChangesDoNotImpactIndirectDependencies
  • assumeChangesOnlyAffectDirectDependencies 👈
All reactions

Sorry, something went wrong.

Uh oh!

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

@weswigham

Wesley Wigham (weswigham) commented Dec 20, 2019

Copy link
Copy Markdown
Member

assumeApproximateDependencies?

All reactions

Sorry, something went wrong.

Uh oh!

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

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) mentioned this pull request Dec 20, 2019
Design Meeting Notes, 12/20/2019 #35807
Closed
Sheetal Nandi (sheetalkamat) added 2 commits January 2, 2020 14:07
@sheetalkamat
Rename option to assumeChangesOnlyAffectDirectDependencies
e99d202
@sheetalkamat
Merge branch 'master' into noIndirectImports
49d02f8
@sheetalkamat Sheetal Nandi (sheetalkamat) changed the title Add noIndirectImports as a option to skip checking and generating .d.ts files for files indirectly importing affected file Add assumeChangesOnlyAffectDirectDependencies as a option to skip checking and generating .d.ts files for files indirectly importing affected file Jan 2, 2020
@sheetalkamat
Sheetal Nandi (sheetalkamat) requested a review from Daniel Rosenwasser (DanielRosenwasser) January 2, 2020 22:19
DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) reviewed Jan 2, 2020
View reviewed changes
Comment thread src/compiler/diagnosticMessages.json Resolved

Uh oh!

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

@sheetalkamat
Description change as per feedback
4cab8ae
amcasey
Andrew Casey (amcasey) reviewed Jan 3, 2020
View reviewed changes
Comment thread src/compiler/builder.ts
}

forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, (state, path) => handleDtsMayChangeOf(state, path, cancellationToken, computeHash));
if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {

@amcasey Andrew Casey (amcasey) Jan 3, 2020

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To someone unfamiliar with the builder, it's not clear how adding this simple check does what it says in the description. Where are the direct dependencies handled if not in the call below? At what point is the list expanded to include indirect dependencies?

Sorry, something went wrong.

Uh oh!

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

All reactions

@sheetalkamat Sheetal Nandi (sheetalkamat) Jan 3, 2020

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getAffectedFiles handle the direct dependency and the below function handles indirect ones.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/compiler/commandLineParser.ts
affectsSemanticDiagnostics: true,
affectsEmit: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it

@amcasey Andrew Casey (amcasey) Jan 3, 2020

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this is probably a very ignorant question, but does this apply only within projects or across projects as well? Clearly we can't get everything into the name, but it might be nice to provide more details in the description (or in a a comment, if we'd prefer to keep the switch mysterious and little-used).

Sorry, something went wrong.

Uh oh!

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

All reactions

@sheetalkamat Sheetal Nandi (sheetalkamat) Jan 3, 2020

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builder is not used across projects but within single program.

Sorry, something went wrong.

Uh oh!

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

All reactions
RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) approved these changes Jan 3, 2020
View reviewed changes
@sheetalkamat
Sheetal Nandi (sheetalkamat) merged commit 18269c0 into master Jan 3, 2020
@sheetalkamat
Sheetal Nandi (sheetalkamat) deleted the noIndirectImports branch January 3, 2020 21:02
@uniqueiniquity

Ben Lichtman (uniqueiniquity) commented Jan 3, 2020 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Sheetal Nandi (@sheetalkamat) this PR added at least one test that causes long-path problems on git for windows. Could you try to shorten it?

error: unable to create file tests/baselines/reference/tscWatch/emitAndErrorUpdates/config-with---assumeChangesOnlyAffectDirectDependencies-and---declaration/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js

There is a flag for git that might resolve the issue, but it seems better to just rename the test.

All reactions

Sorry, something went wrong.

Uh oh!

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

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) mentioned this pull request Jan 4, 2020
Updating Windows contributor requirements to run Windows 10 #35991
Open
@mathias999us

mathias999us commented Feb 8, 2020

Copy link
Copy Markdown

I'm probably misunderstanding the point of assumeChangesOnlyAffectDirectDependencies, but I'm testing it on a large project on 3.8RC, and it doesn't seem to have any effect. For historical reasons, our project does not use modules, just namespaces at the file level. With the assumeChangesOnlyAffectDirectDependencies option on (and incremental), I make a test change in a file that is referenced (as far as I can tell) in a three other files. However, I see most files in the project are built, and it's still taking me 20 seconds to build our project when a small change is made.

Thanks for all your hard work on this great project. Happy to provide any other diagnostics / output that would be of help.

All reactions

Sorry, something went wrong.

Uh oh!

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

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Feb 10, 2020

Copy link
Copy Markdown
Member

Unfortunately that's as expected - codebases with global files don't have an explicit dependency graph, and every file is considered a direct dependency of a global.

All reactions

Sorry, something went wrong.

Uh oh!

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

@lensbart

Bart Lens (lensbart) commented Apr 16, 2020

Copy link
Copy Markdown

Daniel Rosenwasser (@DanielRosenwasser) we’re having the same issue as mathias999us, but I don’t understand your comment. Can you clarify what’s the difference between codebases with and without global files?

Previously we specified an array of files in the files property in tsconfig. But after getting rid of this array, the problem still persists and assumeChangesOnlyAffectDirectDependencies doesn’t seem to do anything, neither as a compiler option in tsconfig, nor as a CLI flag.

What could we be doing wrong?

Many thanks (and apologies if this is not the right place to ask)!

All reactions

Sorry, something went wrong.

Uh oh!

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

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Apr 16, 2020

Copy link
Copy Markdown
Member

If your files are all global, TypeScript assumes that they are all compose into one big ball of globals that can impact each other in arbitrary ways. Regardless of any sort of arrangement based on file order or /// <reference path="..." /> directives, globals cause non-local errors and changes in types on every file in your project, so there's no assumptions we can make based on efficiency and independent checking.

For example, imagine 3 files

// a.ts
var x: string;
// b.ts
var x: string;
// c.ts
var c: string;

Now imagine another global file comes along

// d.ts
var x: number;

That declaration of x conflicts with other declaration of x. To model that, every single global file is effectively a direct dependency of every other global file.

image

Or, as a more 3D diagram might illustrate

image

My recommendation is to move off of global code (which our team is in the process of at #35561)

yacinehmito and IPcorps reacted with laugh emoji andrewbranch, elektronik2k5, and yacinehmito reacted with heart emoji
All reactions
  • 😄 2 reactions
  • ❤️ 3 reactions

Sorry, something went wrong.

Uh oh!

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

@mathias999us

mathias999us commented Apr 17, 2020

Copy link
Copy Markdown

Daniel Rosenwasser (@DanielRosenwasser) Thanks for that straight-forward (and comical) explanation. However, our situation is still slightly different than the example you gave. We house all our code in namespaces at the file level (old-style TypeScript modules). I would think the TypeScript compiler should be able to determine that it only needs to compile other files that reference the namespace whose content is being changed.

DanielRosenwasser 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.

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Apr 17, 2020 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Namespaces are really just declarations that sit in the global scope - in theory we could do more work to say that when all files contain exactly one namespace, we can synthesize the dependency graph after type-checking and try to reuse it between compiles - but that's actually very different from the logic we use to establish dependencies between files today and would be a lot of work. My gut says that a better way forward is to migrate to modules since that's where the majority of our investment as well as the community has been going. Additionally, we've been building some tooling for ourselves to do that which you can leverage.

andrewbranch and mathias999us reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

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

@kripod

Kristóf Poduszló (kripod) commented May 26, 2020 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Great addition, thank you for the awesome work!

Is it safe to always set assumeChangesOnlyAffectDirectDependencies to true if a package is marked free of sideEffects through package.json? I became curious about this while building a modern library bundler tool.

All reactions

Sorry, something went wrong.

Uh oh!

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

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented May 26, 2020

Copy link
Copy Markdown
Member

Kristóf Poduszló (@kripod) they're not necessarily related - you can have top-level statements that cause side-effects, but don't add or remove any global declarations.

This feature is really about enabling faster iteration time by only recompiling the files that directly import a file. It relies on an assumption that given A <- B <- C, a change to A won't impact C (which is not guaranteed to be true).

kripod 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.

@github-actions github-actions Bot mentioned this pull request Aug 14, 2022
Remove span tag in title and unnecessary TOC in Ko microsoft/TypeScript-Website-Localizations#164
Merged
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 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 left review comments
@RyanCavanaugh Ryan Cavanaugh (RyanCavanaugh) RyanCavanaugh approved these changes
@orta Orta Therox (orta) Awaiting requested review from orta
@elibarzilay Eli Barzilay (elibarzilay) Awaiting requested review from elibarzilay
@sandersn Nathan Shively-Sanders (sandersn) Awaiting requested review from sandersn
@weswigham Wesley Wigham (weswigham) Awaiting requested review from weswigham
@rbuckton Ron Buckton (rbuckton) Awaiting requested review from rbuckton
+1 more reviewer
@amcasey Andrew Casey (amcasey) amcasey left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

tsc --watch --incremental recompiles are too slow for use with VS Code source

Uh oh!

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

11 participants

@sheetalkamat @mjbvz @andrewbranch @DanielRosenwasser @RyanCavanaugh @weswigham @uniqueiniquity @mathias999us @lensbart @kripod @amcasey
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.