Skip to content

Include paths evaluate to no files when tsconfig.json is in a sandbox (regression in 5.5)Β #59036

Closed as not planned

Description

@alexeagle

πŸ”Ž Search Terms

symlink tsconfig includes

πŸ•— Version & Regression Information

  • This changed between versions 5.4.5 and 5.5.2

⏯ Playground Link

No response

πŸ’» Code

No response

πŸ™ Actual behavior

Under Bazel, builds are made more hermetic by creating a dedicated folder (an "execroot") and symlinking files into it.

Starting in TS 5.5, we see the following minimal reproduction:

% npm init -y
% npm install typescript@5.5.2
% echo "export const a = 1;" > index.ts
% echo "{}" > tsconfig.json
% mkdir execroot
% cd execroot
execroot % ln -s ../index.ts . 
execroot % ln -s ../tsconfig.json .
execroot % ../node_modules/.bin/tsc -p tsconfig.json --outDir .
error TS18003: No inputs were found in config file '/Users/alexeagle/repros/ts55/execroot/tsconfig.json'. 
Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["/Users/alexeagle/repros/ts55/execroot"]'.


Found 1 error.

Note that if --outDir . is removed, then this command instead succeeds and writes index.js.

This red PR to Bazel's TypeScript rules demonstrates the problem in the context of running the bazel tool: aspect-build/rules_ts#643

πŸ™‚ Expected behavior

In the prior TypeScript release this was working.

Additional information about the issue

#58042 seems like a likely explanation as it touched the resolution logic for locating files to be in the program, fyi Sheetal Nandi (@sheetalkamat)

Activity

  1. changed the title [-]Include paths evaluate to no files when tsconfig.json is (regression in 5.5)[/-] [+]Include paths evaluate to no files when tsconfig.json is in a sandbox (regression in 5.5)[/+] on Jun 26, 2024
  2. jakebailey commented on Jun 26, 2024

    @jakebailey
    Member

    Using https://www.npmjs.com/package/every-ts:

    $ every-ts bisect start
    $ every-ts bisect bad main
    $ every-ts bisect good 5.4.5
    $ every-ts bisect run sh -c 'tsc -p tsconfig.json --outDir .'
    c92bd16ac0e75834100ef57daa0083f161470509 is the first bad commit
    commit c92bd16ac0e75834100ef57daa0083f161470509
    Author: Sheetal Nandi <shkamat@microsoft.com>
    Date:   Fri Apr 26 13:14:40 2024 -0700
    
        Exclude outDir and declarationDir even if they come from extended config (#58335)

    Points to #58335, not #58042.

  3. sheetalkamat commented on Jun 26, 2024

    @sheetalkamat
    Member

    This was intentional change to exclude the outDir and declarationDir if no excludes are specified.

  4. alexeagle commented on Jun 26, 2024

    @alexeagle
    ContributorAuthor

    It seems like that PR intended to change it for the case where outDir and/or declarationDir appear in the extended tsconfig. file. Did you also instead to change the semantics for the --outDir command-line flag?

  5. sheetalkamat commented on Jun 26, 2024

    @sheetalkamat
    Member

    For all flags we normally dont care if its in config file or passed on commandLine, so thats what this change did - always exclude outDir and declaraitonDir

  6. MichaelMitchell-at commented on Jun 26, 2024

    @MichaelMitchell-at
    Contributor

    I think one would expect that these three tsconfigs would have identical behavior:

    {
       "compilerOptions": {}
    }
    {
        "compilerOptions": {
            "outDir": "."
        }
    }
    {
        "compilerOptions": {
            "outDir": "."
        },
        "exclude": []
    }

    but (2) is the only one that fails with No inputs were found in config file.

  7. sheetalkamat commented on Jun 26, 2024

    @sheetalkamat
    Member

    But they are not same:

    1. is without any outDir
    2. Redirects output to outDir and there is no exclude specified so will exclude outdir
    3. Has explicit excludes so it doesnt add any data to it.
  8. MichaelMitchell-at commented on Jun 26, 2024

    @MichaelMitchell-at
    Contributor

    I recognize the behavioral difference, but it seems like something that will be a source of confusion for users. Also I just wanted to get clarification, should this behavior only apply to tsconfig files that have been "extends"ed from, or to any tsconfig files?

  9. sheetalkamat commented on Jun 26, 2024

    @sheetalkamat
    Member

    There is no change in behavior for scenario 2 with that PR. That behavior was always there

  10. alexeagle commented on Jun 29, 2024

    @alexeagle
    ContributorAuthor

    I believe that's not correct. Scenario 2 produced .js outputs prior to your commit, and now it's an error.

    Note, the repro is even simpler than I wrote above:

    ts59036 % touch index.ts tsconfig.json
    ts59036 % npx -p typescript@5.4.5 tsc --outDir . -p .
    ts59036 % ls
    index.js	index.ts	tsconfig.json
    ts59036 % npx -p typescript@5.5.2 tsc --outDir . -p .
    error TS18003: No inputs were found in config file '/Users/alexeagle/repros/ts59036/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["/Users/alexeagle/repros/ts59036"]'.
    
    
    Found 1 error.
    
  11. sheetalkamat commented on Jul 1, 2024

    @sheetalkamat
    Member

    I believe that's not correct. Scenario 2 produced .js outputs prior to your commit, and now it's an error.

    Note, the repro is even simpler than I wrote above:

    ts59036 % touch index.ts tsconfig.json
    ts59036 % npx -p typescript@5.4.5 tsc --outDir . -p .
    ts59036 % ls
    index.js	index.ts	tsconfig.json
    ts59036 % npx -p typescript@5.5.2 tsc --outDir . -p .
    error TS18003: No inputs were found in config file '/Users/alexeagle/repros/ts59036/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["/Users/alexeagle/repros/ts59036"]'.
    
    
    Found 1 error.
    

    Thats not what i see. I believe what you ran is not scenario2 as before my change it really just looked "own config outDir" and not commandLine or extended config. Now its consistent. Wherever the outDir comes from it will be excluded if we are supposed to calculate the exclude pattern.

    C:\temp\test2>dir
     Volume in drive C is Local Disk
     Volume Serial Number is 9EF5-3A92
    
     Directory of C:\temp\test2
    
    07/01/2024  12:19 PM    <DIR>          .
    07/01/2024  12:18 PM    <DIR>          ..
    07/01/2024  12:18 PM                13 a.ts
    07/01/2024  12:19 PM    <DIR>          node_modules
    07/01/2024  12:19 PM               567 package-lock.json
    07/01/2024  12:19 PM                52 package.json
    07/01/2024  12:19 PM                41 tsconfig.json
                   4 File(s)            673 bytes
                   3 Dir(s)  595,701,358,592 bytes free
    
    C:\temp\test2>type tsconfig.json
    {
    "compilerOptions": { "outDir": "." } }
    C:\temp\test2>node node_modules\typescript\lib\tsc.js -v
    Version 5.4.5
    
    C:\temp\test2>node node_modules\typescript\lib\tsc.js --explainFiles
    error TS18003: No inputs were found in config file 'C:/temp/test2/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["."]'.
    
    
    Found 1 error.
    
  12. alexeagle commented on Jul 1, 2024

    @alexeagle
    ContributorAuthor

    I'm sorry, are you saying that you can't repro the same thing I provided above?
    Or that you're not interested in that repro because of CLI flags having been treated differently from tsconfig.json?

  13. sheetalkamat commented on Jul 3, 2024

    @sheetalkamat
    Member

    I am saying that the run you did is not same as scenario 2 described in #59036 (comment) that worked before that change, The change now handles outDir and declarationDir in same ways whether it comes from own config, command line or extended config and was intentional.

  14. RyanCavanaugh commented on Jul 12, 2024

    @RyanCavanaugh
    Member

    Alex Eagle (@alexeagle) is there any additional action needed here?

  15. alexeagle commented on Jul 12, 2024

    @alexeagle
    ContributorAuthor

    Hey Ryan Cavanaugh (@RyanCavanaugh) - I'm representing users here, rather than myself.

    In our examples I was forced to add workarounds https://github.com/aspect-build/rules_ts/pull/643/files and I expect that represents the same thing our users will be forced to do. So the required action depends on how much those folks complain about the changed semantics for when --outDir is specified as a command-line flag - I expect they'll come "upvote" this issue.

    As an example user-reported issue: aspect-build/rules_ts#644 (comment)

    To be fair, perhaps it's unusual that our Bazel integration passes that command-line flag at all. For reference, here's the spot where we do that. I could imagine we just omit this flag when the value is "." as that's a no-op. However that's not commonly the case since Bazel runs with a working directory at the root of the monorepo, we typically need --outDir=packages/foo.

  16. typescript-bot commented on Jul 29, 2024

    @typescript-bot
    Contributor

    This issue has been marked as "Question" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

  17. jthemphill commented on Dec 29, 2024

    @jthemphill

    I traveled the same path when I filed issue #60867!

    PR #58335 fixed a bug where --outDir on the command line wasn't respected. As in, passing outDir in tsconfig.json was causing a different behavior than passing --outDir on the command line! They should not have different behavior, so a bugfix is correct. I would have liked this to be noted in the release notes, though.

    I had a hard time finding out that outDir affects the exclude option, so I'm filing PR microsoft/TypeScript-Website#3292 to add a link from outDir to exclude in the TypeScript docs. (There is already a link from exclude to outDir, but I had no idea I was looking for exclude at the time.)

    Since Aspect has decided to pass an explicit value for outDir, we can make Aspect's rules_ts more robust by also passing an explicit value for exclude. That way, the Bazel rules can be masters of their own fates, and won't be relying on TypeScript's default behavior which defaults exclude to outDir and some other stuff.

  18. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions