-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
Build typescript on commit #468
Comments
Why would you want to use |
@sudo-suhas the reason would be that I only want to |
Use the pre commit hook as I mentioned above. That will do what you need. |
@sudo-suhas it would run |
|
anyway to typecheck on lint-staged? |
@sibelius I don't think TS supports that yet. Here is an example of how to do the check https://github.com/kubeapps/kubeapps/pull/700/files but it's not on staged files. |
our use case for this is that we want typescript to compile our staged files - i.e. the commit. If we run it like Would you consider reopening this issue? |
You can run
|
If you are using husky, then you can do this: // package.json
"husky": {
"hooks": {
"pre-commit": "tsc --noEmit && lint-staged"
}
} But it will check all .ts files of your project according to |
@maoxiaoke |
@khose Do you have In your ...
"devDependencies": {
"typescript": "^3.6.4"
}
... In your {
...
"include": [
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"node_modules",
"config"
]
} |
Hum, I don't have |
hi, I know this is an already closed issue, but I still ran into it. I was able to fix it though! I think the issue has nothing to do with tsconfig or the working directory. The issue is that I fixed this issue with the following config: "lint-staged": {
"*.ts": [
"prettier --parser typescript --write --no-semi",
- "tsc",
+ "bash -c tsc",
"git add"
]
},
|
@szhu you could try using a js function config, so that you can skip passing the arguments to |
Oh wow didn't see that, thanks! |
Np, you’ll of course need to pass the first argument (array of filenames) to the other commands! You can see that in the other examples. |
Anyone have a solution for running tsc type checking only on staged files and not on entire project? I looked through the thread but don't see any solution for this case. |
That's not possible since TS needs to build the whole project in order to do type checking. This is the limitation of TypeScript. You should not probably do this in the pre-commit hook. |
Wouldn't it be possible to have lint-staged call a function the user will provide (tsc in this case) during/after the |
would it be posible to run a lint-staged cmd on pre-commit, like prettier and then run a different one that do a type check before pushing?. In my case I don't care about type checking before committing. Sometimes you can do WIP commits and you don't need to to run |
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
This might be useful, I have not tried it though https://github.com/gustavopch/tsc-files
|
I'm trying to rebuild my typescript project on each commit, after prettifying the code with
prettier
:Problem is that the
tsc
command here seems to fail to see my.tsconfig.json
file, probably because the working directory oflint-staged
is set to the directory of the file that is committed.Is there a way to make this work? If I wanted to use something like
tsc --rootDir ../..
to "fix" the working directory how would I know the level of depth to go up in the directory tree for the currently staged file?The text was updated successfully, but these errors were encountered: