Skip to content

.tsbuildinfo file should be created when the noEmit flag is enabled #30661

Closed

Description

@vkrol

TypeScript Version: 3.4.0-dev.20190330

Search Terms: incremental, noEmit, no emit, tsbuildinfo

Code:
https://github.com/vkrol/typescript-incremental-no-emit

{
  "compilerOptions": {
    "outDir": "./dist",
    "incremental": true,
    "noEmit": true
  }
}

Expected behavior:
.tsbuildinfo file should be created when the noEmit flag is enabled.

Actual behavior:
.tsbuildinfo file is not created when the noEmit flag is enabled.

Activity

  1. changed the title [-].tsbuildinfo file should be created when the noEmit flag is enabled.[/-] [+].tsbuildinfo file should be created when the noEmit flag is enabled[/+] on Mar 30, 2019
  2. OliverJAsh commented on Apr 1, 2019

    @OliverJAsh
    Contributor

    This would be useful so we can still benefit from fast rebuilds when using tsc for type checking only.

  3. sheetalkamat commented on Apr 1, 2019

    @sheetalkamat
    Member

    Though emitting a file (in this case .tsbuildinfo) when --noEmit is specified seems inappropriate.
    cc: Daniel Rosenwasser (@DanielRosenwasser) and Ryan Cavanaugh (@RyanCavanaugh) for their input.

  4. denis-sokolov commented on Apr 1, 2019

    @denis-sokolov

    The way I use these terms, “emit” refers to the valuable output of the application, something we’d put to stdout in unix terms. The tsbuildinfo file is a cache that is supposed to be invisible to the consumer. The fact that it happens to be a file that we happen to write to disk is rather an irrelevant implementation detail.

  5. RyanCavanaugh commented on Apr 1, 2019

    @RyanCavanaugh
    Member

    "tsc emits anything when --noEmit is specified" is a follow-up bug report to this one.

    The problem here is that incremental is on by default if composite is on, so this is an actual risky change because it's going to mean new build artifacts in unexpected places for people using --noEmit today.

    If the build info file path is specified manually, then writing it out does seem OK

  6. denis-sokolov commented on Apr 1, 2019

    @denis-sokolov

    It tsbuildinfo a build artifact in an unexpected place, though? What if we write this cache to /tmp, the Windows registry, or whatever other storage, as long as the user does not see it? (edit: to be clear, the previous sentence is a hypothetical to help identify the meaning of tsbuildinfo, not a real suggestion) It seems like the explicitly thorough solution would be to split the noEmit option into typecheckButNoBuildOutput and noTouchingMyFilesystem.

  7. vkrol commented on Apr 2, 2019

    @vkrol
    Author

    If the build info file path is specified manually, then writing it out does seem OK

    Good idea 👍

  8. fmal commented on Apr 4, 2019

    @fmal

    Ryan Cavanaugh (@RyanCavanaugh)

    If the build info file path is specified manually, then writing it out does seem OK

    i second this!

  9. META-DREAMER commented on Apr 17, 2019

    @META-DREAMER

    This would be incredibly useful in react native since the typescript code is parsed with the packager using Babel 7 so for type checking we have to use tsc --noEmit

  10. vaskevich commented on Apr 26, 2019

    @vaskevich

    I was looking into just ditching the --noEmit flag in order to use --incremental, but even though the subsequent build times decreased by half, the initial build time went up by quite a bit due to emit time.

    image

    I'm not super familiar with the implementation, but it seems like type checking via --noEmit should still be able to benefit from the signatures/dependencies stored in the build info cache file, and this would be great for use cases like speeding up type checking in CI by caching and reusing the build file periodically.

  11. zen0wu commented on Jun 1, 2019

    @zen0wu

    +1. I'm temporarily setting outDir to a phantom folder just in order to the tsconfig.buildinfo emitted to speed up the compilation!

    Context: It's a frontend project with webpack+babel so emitting js is not useful.

  12. 11 remaining items

  13. added a commit that references this issue on Dec 24, 2019
  14. liana-p commented on Mar 26, 2020

    @liana-p

    Just want to add to this, has any solution been reached for this issue? More and more people are switching to using babel to remove typescript and checking types with tsc on the side, but we then lose the advantage of incremental builds which isn't great.

  15. wincent commented on May 17, 2020

    @wincent
    Contributor

    So it seems that people who are using tsc just for type-checking (ie. with --noEmit) want to make it faster by being able to add --incremental as well.

    I'd just like to point out that you can run into this problem from the other direction too: ie. you already have "incremental": true in your tsconfig.json (for speed), and you decide you want to be able to do a typecheck alone (ie. not write any output). Discovered this because my editor does a tsc --noEmit when you ask it to do a typecheck-only run.

    Even if you wanted to forgo the speed benefits of "incremental": true for this use case, you can't turn it off temporarily because there is no --noIncremental (or analogous) flag. One workaround is to remove "incremental": true from your tsconfig.json and start passing --incremental only when you're doing an actual build and --noEmit when you just want to do a slow type check. As suggested above, setting a scratch outDir works too.

  16. InExtremaRes commented on May 17, 2020

    @InExtremaRes

    Even if you wanted to forgo the speed benefits of "incremental": true for this use case, you can't turn it off temporarily because there is no --noIncremental (or analogous) flag.

    Greg Hurrell (@wincent). There is no --noIncremental but you can pass --incremental false:

    tsc --noEmit --incremental false
    
  17. wincent commented on May 17, 2020

    @wincent
    Contributor

    Thanks Daniel Contreras (@InExtremaRes), that's easier than outDir.

  18. minedeljkovic commented on Jun 26, 2020

    @minedeljkovic

    Sheetal Nandi (@sheetalkamat) is this also fixed in #39122 ?

  19. sheetalkamat commented on Jun 26, 2020

    @sheetalkamat
    Member

    Yes

  20. OliverJAsh commented on Aug 10, 2020

    @OliverJAsh
    Contributor

    I just upgraded to TS v4 to try this out. Previously we were just using noEmit, now we're using noEmit + incremental.

    It seems that tsc is a lot slower when we run noEmit with incremental as opposed to without.

    Stats from the diagnostics flag:

    • noEmit: 15s check time, 0s emit time
    • noEmit + incremental: 15s check time, 160s emit time

    I'm assuming this is intended but does anyone understand why this is the case?

  21. sheetalkamat commented on Aug 10, 2020

    @sheetalkamat
    Member

    Oliver Joseph Ash (@OliverJAsh) Seems like declaration emit in your example takes longer. try tsc --d and you should see similar behavior. There are multiple issues tracking different declaration emit being slow and their workarounds that lookup and if something new, please create new issue with repro details.

  22. evelant commented on Aug 14, 2020

    @evelant

    Sheetal Nandi (@sheetalkamat) I also tried this out and it doesn't seem to create a tsbuildinfo file at all using Webstorm 2020.2 with noEmit incremental and tsBuildInfoFile set.

  23. vaskevich commented on Aug 23, 2020

    @vaskevich

    I wanted to propose a follow-up change to this: #40198

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions