You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Include paths evaluate to no files when tsconfig.json is in a sandbox (regression in 5.5)Β #59036
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
$ 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 commitcommit c92bd16ac0e75834100ef57daa0083f161470509Author: 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)
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?
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
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?
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.
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?
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.
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.
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.
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.
Activity
[-]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)[/+]jakebailey commentedon Jun 26, 2024
Using https://www.npmjs.com/package/every-ts:
Points to #58335, not #58042.
sheetalkamat commentedon Jun 26, 2024
This was intentional change to exclude the
outDiranddeclarationDirif no excludes are specified.alexeagle commentedon Jun 26, 2024
It seems like that PR intended to change it for the case where
outDirand/ordeclarationDirappear in theextended tsconfig. file. Did you also instead to change the semantics for the--outDircommand-line flag?sheetalkamat commentedon Jun 26, 2024
For all flags we normally dont care if its in config file or passed on commandLine, so thats what this change did - always exclude
outDiranddeclaraitonDirMichaelMitchell-at commentedon Jun 26, 2024
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.sheetalkamat commentedon Jun 26, 2024
But they are not same:
outDiroutDirand there is no exclude specified so will excludeoutdirMichaelMitchell-at commentedon Jun 26, 2024
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?sheetalkamat commentedon Jun 26, 2024
There is no change in behavior for scenario 2 with that PR. That behavior was always there
alexeagle commentedon Jun 29, 2024
I believe that's not correct. Scenario 2 produced
.jsoutputs prior to your commit, and now it's an error.Note, the repro is even simpler than I wrote above:
sheetalkamat commentedon Jul 1, 2024
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.
alexeagle commentedon Jul 1, 2024
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?
sheetalkamat commentedon Jul 3, 2024
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
outDiranddeclarationDirin same ways whether it comes from own config, command line or extended config and was intentional.RyanCavanaugh commentedon Jul 12, 2024
Alex Eagle (@alexeagle) is there any additional action needed here?
alexeagle commentedon Jul 12, 2024
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
--outDiris 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.typescript-bot commentedon Jul 29, 2024
This issue has been marked as "Question" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
jthemphill commentedon Dec 29, 2024
I traveled the same path when I filed issue #60867!
PR #58335 fixed a bug where
--outDiron the command line wasn't respected. As in, passingoutDirintsconfig.jsonwas causing a different behavior than passing--outDiron 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
outDiraffects theexcludeoption, so I'm filing PR microsoft/TypeScript-Website#3292 to add a link fromoutDirtoexcludein the TypeScript docs. (There is already a link fromexcludetooutDir, but I had no idea I was looking forexcludeat the time.)Since Aspect has decided to pass an explicit value for
outDir, we can make Aspect'srules_tsmore robust by also passing an explicit value forexclude. That way, the Bazel rules can be masters of their own fates, and won't be relying on TypeScript's default behavior which defaultsexcludetooutDirand some other stuff.--outDir srcmakes some source files invisibleΒ #60867outDirtoexcludein the tsconfig docsΒ TypeScript-Website#3292