Open CraigMacomber opened 3 days ago
This isn't wholly unexpected as parseCommandLine
returns ParsedCommandLine
which is explicitly just one tsconfig, not for use with build mode. Exposing something to be able to parse the whole thing doesn't seem too unreasonable to me. @sheetalkamat what do you think?
π Search Terms
parseCommandLine build
π Version & Regression Information
β― Playground Link
No response
π» Code
When using the typescript package programatically, the function
parseCommandLine
is exported. Implementation: https://github.com/microsoft/TypeScript/blob/main/src/compiler/commandLineParser.ts#L1999As far as I can tell, this function is public but undocumented. It seems like you should be able to give it command line arguments and have it parse them, and it usually works. However, if you give it
--build
and --forceit errors with
"Compiler option '--force' may only be used with '--build'."` which is confusing since it is used with --build.π Actual behavior
"Compiler option '--force' may only be used with '--build'."
which is confusing since it is used with --build.π Expected behavior
One of:
parseCommandLine
does not work for the--build
case in its doc comment, and have the error reported when--build
is encountered. Maybe also exposeisBuild
andparseBuildCommand
.--build
, and only emit"Compiler option '--force' may only be used with '--build'."
when --build is not provided.Additional information about the issue
I believe when TypeScript is parsing its command line inputs it does not use this function for the "build" case, based on https://github.com/microsoft/TypeScript/blob/main/src/compiler/executeCommandLine.ts#L752, which is how it works when running tsc, but not in
parseCommandLine
. In that case it usesparseBuildCommand
, which is@internal
.