-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow tsconfig.json when input files are specified #27379
Comments
Could you provide a repro for a situation where tsconfig is ignored? |
Sure @andy-ms , but I mean, this is not even a bug. This behaviour is explicitly explained in the docs: When you do The lines of code are pretty easy to find I just can't understand why it's implemented this way. |
Probably because no one's implemented it -- could you explain what the use cases are? |
A pretty common practice is to have a pre-commit hook to compile only the staged files in your git project (It makes no sense to compile all the project). |
I have another use case for this. We have many projects that use typescript, and would like to reduce boilerplate and keep our typescript config in one place, so it can be uniformly applied across all our projects for consistency. At the moment, there isn't a way to do this, since you can't specify both a glob of files to check, and an external path to a This same goal is easily accomplished with TSLint, by using their |
related, but never considered #12958 |
I have a different use case that needs this as well. We have a pre-commit hook that does a quick type check ( Like @brapifra said here, #27379 (comment), it's written in the docs that this should be possible, but it clearly isn't. |
We have some questions for everyone in this thread Long story short, the real problem we see is that people make a
and get garbage confusing errors because e.g. their However, we're not sure what Question 1, do we:
Question 2:
Question 3:
Thoughts? |
Just my two cents:
This use case seems problematic in general, since (AFAIK) TS needs to see your whole project for some things to work (e.g. |
Question 1. I would expect that we'll "Overwrite the files setting". Question 3. If we'll treat
Question 2. IMO I think there is cases when some modules pollute global scope and it might break the compilation (because not all modules require that modules with globals even if they use them), but I believe developers should import deps explicitly (via triple-slash directives or even |
@RyanCavanaugh So, we will not be able to pass path to the custom tsconfig via |
The bug occurs when you try to pass a file to `tsc`. When passing a file to `tsc`, `tsc` will then proceed to ignore `tsconfig.json` completely. There's also no way to pass a config file, and a specific file at the same time.
Running `tsc` in a pre-commit hook has a known issue (see: microsoft/TypeScript#27379). Until this is fixed upstream pull the tsc check out as an npm script and explicitly run it
Running `tsc` in a pre-commit hook has a known issue (see: microsoft/TypeScript#27379). Until this is fixed upstream pull the tsc check out as an npm script and explicitly run it
lint-staged/lint-staged#468 check all files try fixed microsoft/TypeScript#27379 microsoft/TypeScript#49817 as an alternative https://github.com/gustavopch/tsc-files
lint-staged/lint-staged#468 check all files try fixed microsoft/TypeScript#27379 microsoft/TypeScript#49817 as an alternative https://github.com/gustavopch/tsc-files
can't use lint-staged lint-staged/lint-staged#468 check all files try fixed microsoft/TypeScript#27379 microsoft/TypeScript#49817 as an alternative https://github.com/gustavopch/tsc-files
cann't use with lint-staged lint-staged/lint-staged#468 check all files try fixed microsoft/TypeScript#27379 microsoft/TypeScript#49817 as an alternative https://github.com/gustavopch/tsc-files
cann't use with lint-staged lint-staged/lint-staged#468 check all files try fixed microsoft/TypeScript#27379 microsoft/TypeScript#49817 as an alternative https://github.com/gustavopch/tsc-files
cann't use with lint-staged lint-staged/lint-staged#468 check all files try fixed microsoft/TypeScript#27379 microsoft/TypeScript#49817 as an alternative https://github.com/gustavopch/tsc-files
cann't use with lint-staged lint-staged/lint-staged#468 check all files try fixed microsoft/TypeScript#27379 microsoft/TypeScript#49817 as an alternative https://github.com/gustavopch/tsc-files
cann't use with lint-staged lint-staged/lint-staged#468 check all files try fixed microsoft/TypeScript#27379 microsoft/TypeScript#49817 as an alternative https://github.com/gustavopch/tsc-files
cann't use with lint-staged lint-staged/lint-staged#468 check all files try fixed microsoft/TypeScript#27379 microsoft/TypeScript#49817 as an alternative https://github.com/gustavopch/tsc-files
I think it doesn't compile files individually. You just see those lines after Typescript has processed the entire codebase |
This comment was marked as off-topic.
This comment was marked as off-topic.
Same as others, this breaks my lint-staged configuration and took me hours to find out why. I understand the ambiguity of Also two less ambiguous options: I would probably do B so it would cause no regressions. Also that's the hallucinated solution that ChatGPT gives when asking why the tsconfig is not working and how to force it. |
Btw this is a cool workaround: https://github.com/gustavopch/tsc-files |
Hi everyone, I’ve encountered the same issue discussed here and wanted to share a solution I’ve been working on. I created a project called tscw-config that addresses this problem. It allows users to run
Feel free to check it out and let me know if you have any feedback or suggestions! |
I don't know why the
tsconfig.json
is ignored even when the--project
or-p
option is specified.In my opinion, the right implementation should be:
--project
or-p
option: Ignore tsconfig.jsontsconfig.json
will be ignored when input files are specified.The text was updated successfully, but these errors were encountered: